summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/CMakeLists.txt1
-rw-r--r--tests/auto/cmake/CMakeLists.txt15
-rw-r--r--tests/auto/cmake/mockplugins/.cmake.conf2
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp2
-rw-r--r--tests/auto/cmake/test_android_aar/CMakeLists.txt54
-rw-r--r--tests/auto/cmake/test_android_aar/main.cpp4
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/.cmake.conf2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt1
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt1
-rw-r--r--tests/auto/cmake/test_interface/widget_test/main.cpp2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake2
-rw-r--r--tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt2
-rw-r--r--tests/auto/cmake/test_static_resources/.cmake.conf2
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp1
-rw-r--r--tests/auto/corelib/global/CMakeLists.txt5
-rw-r--r--tests/auto/corelib/global/q20/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/global/qcompare/tst_qcompare.cpp16
-rw-r--r--tests/auto/corelib/global/qcomparehelpers/CMakeLists.txt7
-rw-r--r--tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp63
-rw-r--r--tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.h6
-rw-r--r--tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp42
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp17
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp2
-rw-r--r--tests/auto/corelib/global/qlibraryinfo/CMakeLists.txt24
-rw-r--r--tests/auto/corelib/global/qlibraryinfo/empty.qt.conf0
-rw-r--r--tests/auto/corelib/global/qlibraryinfo/list.qt.conf2
-rw-r--r--tests/auto/corelib/global/qlibraryinfo/merge.qt.conf5
-rw-r--r--tests/auto/corelib/global/qlibraryinfo/partial.qt.conf2
-rw-r--r--tests/auto/corelib/global/qlibraryinfo/tst_qlibraryinfo.cpp103
-rw-r--r--tests/auto/corelib/global/qxp/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/io/CMakeLists.txt8
-rw-r--r--tests/auto/corelib/io/largefile/tst_largefile.cpp8
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp4
-rw-r--r--tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp106
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp9
-rw-r--r--tests/auto/corelib/io/qfileselector/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+vxworks/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+vxworks/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+vxworks/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp2
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp10
-rw-r--r--tests/auto/corelib/io/qfloat16format/CMakeLists.txt23
-rw-r--r--tests/auto/corelib/io/qfloat16format/tst_qfloat16format.cpp157
-rw-r--r--tests/auto/corelib/io/qprocess/crasher.h2
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp6
-rw-r--r--tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp3
-rwxr-xr-xtests/auto/corelib/io/qresourceengine/generateResources.sh2
-rw-r--r--tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp2
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp1
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp47
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp4
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp8
-rw-r--r--tests/auto/corelib/ipc/qsharedmemory/tst_qsharedmemory.cpp4
-rw-r--r--tests/auto/corelib/itemmodels/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp21
-rw-r--r--tests/auto/corelib/itemmodels/qabstractproxymodel/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp33
-rw-r--r--tests/auto/corelib/kernel/qchronotimer/tst_qchronotimer.cpp50
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp2
-rw-r--r--tests/auto/corelib/kernel/qelapsedtimer/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp22
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp12
-rw-r--r--tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp53
-rw-r--r--tests/auto/corelib/kernel/qjniobject/testdata/src/org/qtproject/qt/android/testdata/QtJniObjectTestClass.java14
-rw-r--r--tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp39
-rw-r--r--tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp14
-rw-r--r--tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp2
-rw-r--r--tests/auto/corelib/kernel/qpointer/CMakeLists.txt1
-rw-r--r--tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp44
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp5
-rw-r--r--tests/auto/corelib/platform/windows/qcomobject/tst_qcomobject.cpp3
-rw-r--r--tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp6
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp2
-rw-r--r--tests/auto/corelib/plugin/quuid/test/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/plugin/quuid/tst_quuid.cpp225
-rw-r--r--tests/auto/corelib/serialization/CMakeLists.txt5
-rw-r--r--tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp28
-rw-r--r--tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp15
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp37
-rw-r--r--tests/auto/corelib/text/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/text/qanystringview/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp83
-rw-r--r--tests/auto/corelib/text/qbytearrayview/CMakeLists.txt7
-rw-r--r--tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp8
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp2
-rw-r--r--tests/auto/corelib/text/qregularexpression/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp16
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp32
-rw-r--r--tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp167
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp29
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp2
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp2
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp2
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp2
-rw-r--r--tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp4
-rw-r--r--tests/auto/corelib/text/qstringview/CMakeLists.txt7
-rw-r--r--tests/auto/corelib/text/qstringview/tst_qstringview.cpp26
-rw-r--r--tests/auto/corelib/thread/qfuture/tst_qfuture.cpp6
-rw-r--r--tests/auto/corelib/thread/qresultstore/CMakeLists.txt1
-rw-r--r--tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp33
-rw-r--r--tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp98
-rw-r--r--tests/auto/corelib/tools/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp111
-rw-r--r--tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp28
-rw-r--r--tests/auto/corelib/tools/qsize/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/tools/qsize/tst_qsize.cpp37
-rw-r--r--tests/auto/corelib/tools/qsizef/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/tools/qsizef/tst_qsizef.cpp96
-rw-r--r--tests/auto/corelib/tools/qspan/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/tools/qspan/tst_qspan.cpp67
-rw-r--r--tests/auto/gui/image/CMakeLists.txt5
-rw-r--r--tests/auto/gui/image/qicon/CMakeLists.txt5
-rw-r--r--tests/auto/gui/image/qicon/plugin/CMakeLists.txt20
-rw-r--r--tests/auto/gui/image/qicon/plugin/main.cpp73
-rw-r--r--tests/auto/gui/image/qicon/plugin/plugin.json3
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.cpp29
-rw-r--r--tests/auto/gui/image/qimage/images/VideoHD.iccbin0 -> 786 bytes
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp191
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp22
-rw-r--r--tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt3
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp5
-rw-r--r--tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp2
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.iccbin0 -> 13300 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp96
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp24
-rw-r--r--tests/auto/gui/platform/qx11info/tst_qx11info.cpp35
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp55
-rw-r--r--tests/auto/gui/text/qfontdatabase/CMakeLists.txt2
-rw-r--r--tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttfbin0 -> 5664 bytes
-rw-r--r--tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttfbin0 -> 5280 bytes
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp135
-rw-r--r--tests/auto/gui/text/qfontmetrics/CMakeLists.txt4
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp44
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp109
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/example.md4
-rw-r--r--tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp15
-rw-r--r--tests/auto/network/access/CMakeLists.txt4
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp2
-rw-r--r--tests/auto/network/access/qformdatabuilder/CMakeLists.txt34
-rw-r--r--tests/auto/network/access/qformdatabuilder/document.docxbin0 -> 10548 bytes
-rw-r--r--tests/auto/network/access/qformdatabuilder/image1.jpgbin0 -> 518 bytes
-rw-r--r--tests/auto/network/access/qformdatabuilder/rfc3252.txt1
-rw-r--r--tests/auto/network/access/qformdatabuilder/sheet.xlsxbin0 -> 8534 bytes
-rw-r--r--tests/auto/network/access/qformdatabuilder/tst_qformdatabuilder.cpp456
-rw-r--r--tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp3
-rw-r--r--tests/auto/network/access/qnetworkcookiejar/testdata/publicsuffix/public_suffix_list.dafsabin52422 -> 53629 bytes
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp10
-rw-r--r--tests/auto/network/access/qnetworkreply_local/CMakeLists.txt9
-rw-r--r--tests/auto/network/access/qnetworkreply_local/minihttpserver.h246
-rw-r--r--tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp177
-rw-r--r--tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp2
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp8
-rw-r--r--tests/auto/other/android_deployment_settings/CMakeLists.txt2
-rw-r--r--tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp7
-rw-r--r--tests/auto/shared/resources/testfont_linemetrics.otfbin0 -> 65540 bytes
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp12
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp103
-rw-r--r--tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp22
-rw-r--r--tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp2
-rw-r--r--tests/auto/testlib/selftests/eventloop/CMakeLists.txt2
-rw-r--r--tests/auto/testlib/selftests/failcleanup/CMakeLists.txt2
-rw-r--r--tests/auto/testlib/selftests/failcleanuptestcase/CMakeLists.txt2
-rw-r--r--tests/auto/testlib/selftests/skipblacklisted/CMakeLists.txt2
-rw-r--r--tests/auto/testlib/selftests/skipcleanuptestcase/CMakeLists.txt2
-rw-r--r--tests/auto/testlib/selftests/subtest/tst_subtest.cpp2
-rw-r--r--tests/auto/testlib/selftests/warnings/tst_warnings.cpp2
-rw-r--r--tests/auto/tools/macdeployqt/tst_macdeployqt.cpp3
-rw-r--r--tests/auto/tools/moc/CMakeLists.txt2
-rw-r--r--tests/auto/tools/moc/allmocs_baseline_in.json81
-rw-r--r--tests/auto/tools/moc/enum_inc.h2
-rw-r--r--tests/auto/tools/moc/forwarddeclaredparam.h2
-rw-r--r--tests/auto/tools/moc/single_function_keyword.h6
-rw-r--r--tests/auto/tools/moc/subdir/extradefines.h2
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp11
-rw-r--r--tests/auto/tools/qdbuscpp2xml/CMakeLists.txt1
-rw-r--r--tests/auto/tools/qdbusxml2cpp/CMakeLists.txt2
-rw-r--r--tests/auto/tools/qmake/testdata/conflicting_targets/main.cpp2
-rw-r--r--tests/auto/tools/qmake/testdata/findDeps/needed.cpp2
-rw-r--r--tests/auto/tools/qmake/testdata/findMocs/digitseparated.h2
-rw-r--r--tests/auto/tools/qmake/testdata/include_pwd/anotherheader.h2
-rw-r--r--tests/auto/tools/qmake/testdata/include_pwd/main.cpp2
-rw-r--r--tests/auto/tools/qmake/testdata/include_pwd/somedirectory/someheader.h2
-rw-r--r--tests/auto/tools/qmake/testdata/quotedfilenames/include folder/header.h2
-rw-r--r--tests/auto/tools/qmake/testdata/windows_resources/main.cpp2
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp5
-rw-r--r--tests/auto/tools/qt_cmake_create/testdata/cpp_project/main.cpp2
-rw-r--r--tests/auto/tools/qt_cmake_create/testdata/qml_project/main.cpp2
-rw-r--r--tests/auto/tools/qt_cmake_create/testdata/qrc_project/main.cpp2
-rw-r--r--tests/auto/tools/qt_cmake_create/testdata/ui_project/main.cpp2
-rw-r--r--tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.cpp3
-rw-r--r--tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.h2
-rw-r--r--tests/auto/tools/qt_cmake_create/tst_qt_cmake_create.cpp5
-rw-r--r--tests/auto/tools/rcc/data/.gitattributes2
-rw-r--r--tests/auto/tools/rcc/data/deduplication/deduplication.expected157
-rw-r--r--tests/auto/tools/rcc/data/deduplication/deduplication.qrc10
-rw-r--r--tests/auto/tools/rcc/data/deduplication/files/a.txt1
-rw-r--r--tests/auto/tools/rcc/data/deduplication/files/b.txt1
-rw-r--r--tests/auto/tools/rcc/data/deduplication/files/c_with_a_content.txt1
-rw-r--r--tests/auto/tools/rcc/data/legal/legal.qrc10
-rw-r--r--tests/auto/tools/rcc/data/legal/rcc_legal.cpp101
-rw-r--r--tests/auto/tools/rcc/tst_rcc.cpp9
-rw-r--r--tests/auto/tools/uic/baseline/Widget.ui2
-rw-r--r--tests/auto/tools/uic/baseline/Widget.ui.h5
-rw-r--r--tests/auto/tools/uic/baseline/qtbug126265.ui51
-rw-r--r--tests/auto/tools/uic/baseline/qtbug126265.ui.h57
-rw-r--r--tests/auto/wasm/selenium/CMakeLists.txt2
-rw-r--r--tests/auto/wasm/selenium/qwasmwindow.py57
-rw-r--r--tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp43
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp19
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp85
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp14
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp111
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp3
-rw-r--r--tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp217
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp31
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp3
-rw-r--r--tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp12
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp51
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp68
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp2
-rw-r--r--tests/auto/xml/CMakeLists.txt2
-rw-r--r--tests/baseline/painting/tst_baseline_painting.cpp13
-rw-r--r--tests/baseline/shared/baselineprotocol.cpp13
-rw-r--r--tests/baseline/shared/baselineprotocol.h3
-rw-r--r--tests/baseline/shared/qbaselinetest.cpp27
-rw-r--r--tests/baseline/shared/qbaselinetest.h5
-rw-r--r--tests/baseline/stylesheet/tst_baseline_stylesheet.cpp13
-rw-r--r--tests/baseline/text/tst_baseline_text.cpp13
-rw-r--r--tests/baseline/widgets/tst_baseline_widgets.cpp13
-rw-r--r--tests/benchmarks/corelib/io/qdir/CMakeLists.txt2
-rw-r--r--tests/benchmarks/corelib/itemmodels/CMakeLists.txt2
-rw-r--r--tests/benchmarks/network/access/qdecompresshelper/main.cpp3
-rw-r--r--tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp6
-rw-r--r--tests/manual/CMakeLists.txt1
-rw-r--r--tests/manual/android_content_uri/CMakeLists.txt2
-rw-r--r--tests/manual/assets/CMakeLists.txt4
-rw-r--r--tests/manual/assets/assets.pro3
-rw-r--r--tests/manual/assets/downloader/CMakeLists.txt15
-rw-r--r--tests/manual/assets/downloader/downloader.pro5
-rw-r--r--tests/manual/assets/downloader/main.cpp48
-rw-r--r--tests/manual/dialogs/wizardpanel.cpp2
-rw-r--r--tests/manual/examples/corelib/permissions/android/AndroidManifest.xml3
-rw-r--r--tests/manual/examples/widgets/richtext/textedit/example.html4
-rw-r--r--tests/manual/examples/widgets/richtext/textedit/example.md4
-rw-r--r--tests/manual/examples/widgets/scroller/CMakeLists.txt2
-rw-r--r--tests/manual/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt2
-rw-r--r--tests/manual/highdpi/CMakeLists.txt2
-rw-r--r--tests/manual/highdpi/dprgadget/CMakeLists.txt2
-rw-r--r--tests/manual/highdpi/kitchensink/CMakeLists.txt2
-rw-r--r--tests/manual/highdpi/pixelgadget/CMakeLists.txt2
-rw-r--r--tests/manual/highdpi/screengadget/CMakeLists.txt2
-rw-r--r--tests/manual/inputdevices/CMakeLists.txt2
-rw-r--r--tests/manual/manual.pro1
-rw-r--r--tests/manual/permissions/android/AndroidManifest.xml3
-rw-r--r--tests/manual/qtabbar/tabbarform.cpp2
-rw-r--r--tests/manual/qtabbar/tabbarform.h2
-rw-r--r--tests/manual/rhi/hdr/CMakeLists.txt2
-rw-r--r--tests/manual/rhi/imguirenderer/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/a11y/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/a11y/basic_widgets/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/clipboard/mainwindow.cpp6
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/network/echo_client_mainthread/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/network/echo_client_secondarythread/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/network/echo_server/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/network/sockify_sockets_auto/CMakeLists.txt2
-rw-r--r--tests/manual/wasm/qstdweb/CMakeLists.txt3
-rw-r--r--tests/manual/xembed/CMakeLists.txt2
-rw-r--r--tests/manual/xembed/gtk-container/CMakeLists.txt2
-rwxr-xr-xtests/testserver/echo/echo.sh2
283 files changed, 5142 insertions, 756 deletions
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
index 1297db9b8a..8bb038ffaf 100644
--- a/tests/auto/CMakeLists.txt
+++ b/tests/auto/CMakeLists.txt
@@ -66,6 +66,7 @@ if(QT_BUILD_WASM_BATCHED_TESTS)
add_subdirectory(corelib/io/qbuffer)
add_subdirectory(corelib/io/qabstractfileengine)
add_subdirectory(corelib/io/qsettings)
+ add_subdirectory(corelib/io/qstorageinfo)
add_subdirectory(corelib/io/qstandardpaths)
add_subdirectory(corelib/io/qfileselector)
add_subdirectory(corelib/io/qfile)
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index b159de7c9c..86db954086 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -146,6 +146,21 @@ if(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS AND NOT NO_GUI)
"-DTEST_ESCAPING_VALUE_ARG=${escaping_value}"
"-DTEST_SPACES_VALUE_ARG=${spaces_value}"
)
+
+ #Run test_android_aar only if the host is Unix and zipinfo is available
+ find_program(ZIPINFO_EXECUTABLE zipinfo)
+ if(CMAKE_HOST_UNIX AND ZIPINFO_EXECUTABLE)
+ _qt_internal_test_expect_pass(test_android_aar
+ BUILD_OPTIONS
+ ${multi_abi_vars}
+ --build-target verify_aar
+ )
+ else()
+ message(WARNING
+ "Skipping test_android_aar CMake build test because \
+ the host is not Unix or zipinfo is not found")
+ endif()
+
return()
endif()
diff --git a/tests/auto/cmake/mockplugins/.cmake.conf b/tests/auto/cmake/mockplugins/.cmake.conf
index 10bc1fd407..6d83b084f7 100644
--- a/tests/auto/cmake/mockplugins/.cmake.conf
+++ b/tests/auto/cmake/mockplugins/.cmake.conf
@@ -1 +1 @@
-set(QT_REPO_MODULE_VERSION "6.8.0")
+set(QT_REPO_MODULE_VERSION "6.9.0")
diff --git a/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp
index 2ee817d80a..a2994c10e3 100644
--- a/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp
+++ b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qmock1plugin.h"
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp
index 5b3280e884..8e10797997 100644
--- a/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp
+++ b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qmock2plugin.h"
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp
index b38f854e4b..53090472e0 100644
--- a/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp
+++ b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qmock3plugin.h"
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp
index 5deaf7f43f..f2a904182d 100644
--- a/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp
+++ b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qmock4plugin.h"
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp
index c5b4620516..92ea47690f 100644
--- a/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp
+++ b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qmock5plugin.h"
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp
index 4a0329c68a..9dd9e02f2a 100644
--- a/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp
+++ b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qmock6plugin.h"
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/test_android_aar/CMakeLists.txt b/tests/auto/cmake/test_android_aar/CMakeLists.txt
new file mode 100644
index 0000000000..88cd5abf23
--- /dev/null
+++ b/tests/auto/cmake/test_android_aar/CMakeLists.txt
@@ -0,0 +1,54 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_android_aar)
+
+find_package(Qt6 COMPONENTS Core Gui REQUIRED)
+
+qt6_add_executable(test_aar main.cpp)
+
+# To support opening the project in QtCreator
+if($CACHE{QT_USE_TARGET_ANDROID_BUILD_DIR})
+ set(TARGET_ANDROID_BUILD_DIR ${CMAKE_BINARY_DIR}/android-build-test_aar)
+else()
+ set(TARGET_ANDROID_BUILD_DIR ${CMAKE_BINARY_DIR}/android-build)
+endif()
+
+# Add common libs for available ABIs that should be present in the aar package in a list
+unset(aar_content_filepaths_to_verify)
+foreach(abi IN LISTS QT_ANDROID_ABIS)
+ list(APPEND aar_content_filepaths_to_verify "jni/${abi}/libQt6Core_${abi}.so")
+ list(APPEND aar_content_filepaths_to_verify "jni/${abi}/libQt6Gui_${abi}.so")
+ list(APPEND aar_content_filepaths_to_verify
+ "jni/${abi}/libplugins_platforms_qtforandroid_${abi}.so")
+ list(APPEND aar_content_filepaths_to_verify "jni/${abi}/libtest_aar_${abi}.so")
+endforeach()
+
+# Add a few ABI independent file that should be present in the aar package in a list
+list(APPEND aar_content_filepaths_to_verify "libs/Qt6Android.jar")
+list(APPEND aar_content_filepaths_to_verify "res/xml/qtprovider_paths.xml")
+list(APPEND aar_content_filepaths_to_verify "AndroidManifest.xml")
+list(JOIN aar_content_filepaths_to_verify "|" grep_pattern)
+
+# The overall number of lines we should expect to be filtered by grep regex
+list(LENGTH aar_content_filepaths_to_verify expected_file_count)
+
+set(zipinfo_command "zipinfo -1 ${TARGET_ANDROID_BUILD_DIR}/test_aar.aar")
+
+# Runs zipinfo on the aar package, greps and outputs the number of matching lines
+# and finally compares the expected number of lines with the output
+add_custom_target(verify_aar
+ bash -c "${zipinfo_command} \
+ | grep -Ecx '${grep_pattern}' \
+ | grep -xq ${expected_file_count} \
+ || { echo 'Error: The aar package is missing at least one file.'; exit 1; };"
+ COMMENT "Verifying aar package content"
+ VERBATIM
+)
+
+# Build aar package before verification
+add_dependencies(verify_aar aar)
+
+target_link_libraries(test_aar PRIVATE Qt::Core Qt::Gui)
diff --git a/tests/auto/cmake/test_android_aar/main.cpp b/tests/auto/cmake/test_android_aar/main.cpp
new file mode 100644
index 0000000000..90df9ee937
--- /dev/null
+++ b/tests/auto/cmake/test_android_aar/main.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+int main(int, char *[]) { return 0; }
diff --git a/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
index 10bc1fd407..6d83b084f7 100644
--- a/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
+++ b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
@@ -1 +1 @@
-set(QT_REPO_MODULE_VERSION "6.8.0")
+set(QT_REPO_MODULE_VERSION "6.9.0")
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt
index 0e446dd108..f1cc6906f8 100644
--- a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt
@@ -3,7 +3,6 @@
qt_internal_add_module(TestAutogeneratingCppExports
NO_UNITY_BUILD
- GENERATE_CPP_EXPORTS
SOURCES
module_api.h
module_api.cpp
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt
index 8473979c70..87a83bd013 100644
--- a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt
@@ -3,7 +3,6 @@
qt_internal_add_module(TestAutogeneratingCppExportsCustomName
NO_UNITY_BUILD
- GENERATE_CPP_EXPORTS
CPP_EXPORT_HEADER_BASE_NAME
"customname_exports"
SOURCES
diff --git a/tests/auto/cmake/test_interface/widget_test/main.cpp b/tests/auto/cmake/test_interface/widget_test/main.cpp
index e6a8ab5fe9..0a47f43d84 100644
--- a/tests/auto/cmake/test_interface/widget_test/main.cpp
+++ b/tests/auto/cmake/test_interface/widget_test/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QString>
#include <QWidget>
diff --git a/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake b/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake
index 4ca8fab119..5388816c07 100644
--- a/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake
+++ b/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake
@@ -1,4 +1,6 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
function(check_parameters file_path)
file(READ ${file_path} file_content)
foreach(compile_option IN ITEMS "-DDEFINE_CMDLINE_SIGNAL" "-DMY_OPTION")
diff --git a/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt
index 0a40a948c6..1696eae261 100644
--- a/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt
+++ b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(sample LANGUAGES CXX)
diff --git a/tests/auto/cmake/test_static_resources/.cmake.conf b/tests/auto/cmake/test_static_resources/.cmake.conf
index 10bc1fd407..6d83b084f7 100644
--- a/tests/auto/cmake/test_static_resources/.cmake.conf
+++ b/tests/auto/cmake/test_static_resources/.cmake.conf
@@ -1 +1 @@
-set(QT_REPO_MODULE_VERSION "6.8.0")
+set(QT_REPO_MODULE_VERSION "6.9.0")
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index 03755fa7ab..3ebec35f12 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -7,6 +7,7 @@
#include <QAnimationGroup>
#include <QSequentialAnimationGroup>
#include <QtCore/qpropertyanimation.h>
+#include <QtCore/qtimer.h>
#include <QtCore/qvariantanimation.h>
#include <private/qabstractanimation_p.h>
#include <QtGui/qpointingdevice.h>
diff --git a/tests/auto/corelib/global/CMakeLists.txt b/tests/auto/corelib/global/CMakeLists.txt
index 7970116672..2b26c494d0 100644
--- a/tests/auto/corelib/global/CMakeLists.txt
+++ b/tests/auto/corelib/global/CMakeLists.txt
@@ -4,7 +4,9 @@
if(NOT INTEGRITY)
add_subdirectory(qcompare)
endif()
+if(NOT WASM) # QTBUG-121822
add_subdirectory(qcomparehelpers)
+endif()
add_subdirectory(qflags)
add_subdirectory(q_func_info)
add_subdirectory(qgetputenv)
@@ -16,6 +18,9 @@ if(NOT INTEGRITY)
add_subdirectory(qnativeinterface)
endif()
add_subdirectory(qrandomgenerator)
+if (QT_FEATURE_settings)
+ add_subdirectory(qlibraryinfo)
+endif()
add_subdirectory(qlogging)
add_subdirectory(qtendian)
add_subdirectory(qglobalstatic)
diff --git a/tests/auto/corelib/global/q20/CMakeLists.txt b/tests/auto/corelib/global/q20/CMakeLists.txt
index bd28f8b999..141f94d9f7 100644
--- a/tests/auto/corelib/global/q20/CMakeLists.txt
+++ b/tests/auto/corelib/global/q20/CMakeLists.txt
@@ -1 +1,3 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(memory)
diff --git a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp
index e36429e62b..556c8212b3 100644
--- a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp
+++ b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp
@@ -785,9 +785,10 @@ void tst_QCompare::compareThreeWay()
static_assert(noexcept(qCompareThreeWay(std::declval<TestEnum>(), std::declval<TestEnum>())));
// pointers
- static_assert(noexcept(qCompareThreeWay(std::declval<StringWrapper *>(),
- std::declval<StringWrapper *>())));
- static_assert(noexcept(qCompareThreeWay(std::declval<StringWrapper *>(), nullptr)));
+ using StringWrapperPtr = Qt::totally_ordered_wrapper<StringWrapper *>;
+ static_assert(noexcept(qCompareThreeWay(std::declval<StringWrapperPtr>(),
+ std::declval<StringWrapperPtr>())));
+ static_assert(noexcept(qCompareThreeWay(std::declval<StringWrapperPtr>(), nullptr)));
// Test some actual comparison results
@@ -832,8 +833,17 @@ void tst_QCompare::compareThreeWay()
// pointers
std::array<int, 2> arr{1, 0};
+#if QT_DEPRECATED_SINCE(6, 8)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QCOMPARE_EQ(qCompareThreeWay(&arr[1], &arr[0]), Qt::strong_ordering::greater);
QCOMPARE_EQ(qCompareThreeWay(arr.data(), &arr[0]), Qt::strong_ordering::equivalent);
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
+ const auto a0 = Qt::totally_ordered_wrapper(&arr[0]);
+ const auto a1 = Qt::totally_ordered_wrapper(&arr[1]);
+ QCOMPARE_EQ(qCompareThreeWay(a1, a0), Qt::strong_ordering::greater);
+ QCOMPARE_EQ(qCompareThreeWay(arr.data(), a0), Qt::strong_ordering::equivalent);
}
QTEST_MAIN(tst_QCompare)
diff --git a/tests/auto/corelib/global/qcomparehelpers/CMakeLists.txt b/tests/auto/corelib/global/qcomparehelpers/CMakeLists.txt
index 31d8bff0a5..6b584dc7ca 100644
--- a/tests/auto/corelib/global/qcomparehelpers/CMakeLists.txt
+++ b/tests/auto/corelib/global/qcomparehelpers/CMakeLists.txt
@@ -11,6 +11,10 @@ qt_internal_add_test(tst_qcomparehelpers
SOURCES
tst_qcomparehelpers.h tst_qcomparehelpers.cpp tst_qcomparehelpers1.cpp
wrappertypes.h
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
LIBRARIES
Qt::TestPrivate
)
@@ -22,7 +26,10 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.20" AND NOT MACOS AND NOT VXWORKS AND
SOURCES
tst_qcomparehelpers.h tst_qcomparehelpers.cpp tst_qcomparehelpers1.cpp
wrappertypes.h
+ NO_BATCH # QTBUG-121815
DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
tst_QCompareHelpers=tst_QCompareHelpersCpp23
LIBRARIES
Qt::TestPrivate
diff --git a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp
index f140c23ed0..a49504db8b 100644
--- a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp
+++ b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp
@@ -4,6 +4,8 @@
#include "tst_qcomparehelpers.h"
#include "wrappertypes.h"
+#include <QtCore/qscopeguard.h>
+
#if defined(__STDCPP_FLOAT16_T__) && __has_include(<stdfloat>)
#include <stdfloat>
#endif
@@ -109,32 +111,12 @@ void tst_QCompareHelpers::compareStringData()
void tst_QCompareHelpers::comparisonCompiles()
{
QTestPrivate::testAllComparisonOperatorsCompile<IntWrapper>();
- if (QTest::currentTestFailed())
- return;
-
QTestPrivate::testAllComparisonOperatorsCompile<IntWrapper, int>();
- if (QTest::currentTestFailed())
- return;
-
QTestPrivate::testAllComparisonOperatorsCompile<DoubleWrapper>();
- if (QTest::currentTestFailed())
- return;
-
QTestPrivate::testAllComparisonOperatorsCompile<DoubleWrapper, double>();
- if (QTest::currentTestFailed())
- return;
-
QTestPrivate::testAllComparisonOperatorsCompile<DoubleWrapper, IntWrapper>();
- if (QTest::currentTestFailed())
- return;
-
QTestPrivate::testAllComparisonOperatorsCompile<StringWrapper<QString>>();
- if (QTest::currentTestFailed())
- return;
-
QTestPrivate::testAllComparisonOperatorsCompile<StringWrapper<QString>, QAnyStringView>();
- if (QTest::currentTestFailed())
- return;
}
void tst_QCompareHelpers::compare_IntWrapper_data()
@@ -498,11 +480,14 @@ enum class TestEnum : quint8 {
void tst_QCompareHelpers::builtinOrder()
{
#define TEST_BUILTIN(Left, Right) \
- testOrderForTypes<Left, Right>(); \
- if (QTest::currentTestFailed()) { \
- qDebug("Failed Qt::compareThreeWay() test for builtin types " #Left " and " #Right); \
- return; \
- }
+ do { \
+ auto printOnFailure = qScopeGuard([] { \
+ qDebug("Failed Qt::compareThreeWay() test for builtin types %s and %s", \
+ #Left, #Right); \
+ }); \
+ testOrderForTypes<Left, Right>(); \
+ printOnFailure.dismiss(); \
+ } while (false);
// some combinations
TEST_BUILTIN(char, char)
@@ -581,20 +566,46 @@ void tst_QCompareHelpers::builtinOrder()
Qt::strong_ordering::equivalent);
std::array<int, 2> arr{1, 0};
+#if QT_DEPRECATED_SINCE(6, 8)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QCOMPARE_EQ(Qt::compareThreeWay(&arr[0], &arr[1]), Qt::strong_ordering::less);
QCOMPARE_EQ(Qt::compareThreeWay(arr.data(), &arr[0]), Qt::strong_ordering::equivalent);
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
class Base {};
class Derived : public Base {};
auto b = std::make_unique<Base>();
auto d = std::make_unique<Derived>();
+#if QT_DEPRECATED_SINCE(6, 8)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QCOMPARE_NE(Qt::compareThreeWay(b.get(), d.get()), Qt::strong_ordering::equivalent);
QCOMPARE_EQ(Qt::compareThreeWay(b.get(), nullptr), Qt::strong_ordering::greater);
QCOMPARE_EQ(Qt::compareThreeWay(nullptr, d.get()), Qt::strong_ordering::less);
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
+
+ // Check Qt::totally_ordered_wrapper
+ auto a0 = Qt::totally_ordered_wrapper(&arr[0]);
+ auto a1 = Qt::totally_ordered_wrapper(&arr[1]);
+ QCOMPARE_EQ(Qt::compareThreeWay(a0, a1), Qt::strong_ordering::less);
+ QCOMPARE_EQ(Qt::compareThreeWay(arr.data(), a0), Qt::strong_ordering::equivalent);
+
+ auto bWrapper = Qt::totally_ordered_wrapper(b.get());
+ auto dWrapper = Qt::totally_ordered_wrapper(d.get());
+ QCOMPARE_NE(Qt::compareThreeWay(bWrapper, dWrapper), Qt::strong_ordering::equivalent);
+ QCOMPARE_NE(Qt::compareThreeWay(bWrapper, d.get()), Qt::strong_ordering::equivalent);
+ QCOMPARE_NE(Qt::compareThreeWay(b.get(), dWrapper), Qt::strong_ordering::equivalent);
+ QCOMPARE_EQ(Qt::compareThreeWay(bWrapper, nullptr), Qt::strong_ordering::greater);
+ QCOMPARE_EQ(Qt::compareThreeWay(nullptr, dWrapper), Qt::strong_ordering::less);
+ dWrapper.reset(nullptr);
+ QCOMPARE_EQ(Qt::compareThreeWay(nullptr, dWrapper), Qt::strong_ordering::equivalent);
#undef TEST_BUILTIN
}
QTEST_MAIN(tst_QCompareHelpers)
-#include "tst_qcomparehelpers.moc"
+#include "moc_tst_qcomparehelpers.cpp"
diff --git a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.h b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.h
index 16398b0978..89d8a26947 100644
--- a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.h
+++ b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.h
@@ -9,6 +9,10 @@
#include <QtTest/qtest.h>
#include <QtTest/private/qcomparisontesthelper_p.h>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
class tst_QCompareHelpers : public QObject
{
Q_OBJECT
@@ -58,6 +62,8 @@ private Q_SLOTS:
// Add new test cases to tst_qcomparehelpers1.cpp, because minGW already
// complains about a too large tst_qcomparehelpers.cpp.obj object file
void compareWithAttributes();
+
+ void totallyOrderedWrapperBasics();
};
#endif // TST_QCOMPAREHELPERS_H
diff --git a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp
index a3b8200a63..33967f314c 100644
--- a/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp
+++ b/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers1.cpp
@@ -4,23 +4,26 @@
#include "tst_qcomparehelpers.h"
#define DECLARE_TYPE(Name, Type, RetType, Constexpr, Suffix) \
-class Deprecated ## Name \
+class Templated ## Name \
{ \
public: \
- Constexpr Deprecated ## Name () {} \
+ Constexpr Templated ## Name () {} \
\
private: \
+ template <typename X> \
friend Constexpr bool \
- comparesEqual(const Deprecated ## Name &lhs, int rhs) noexcept; \
+ comparesEqual(const Templated ## Name &lhs, X rhs) noexcept; \
+ template <typename X> \
friend Constexpr RetType \
- compareThreeWay(const Deprecated ## Name &lhs, int rhs) noexcept; \
- Q_DECLARE_ ## Type ## _ORDERED ## Suffix (Deprecated ## Name, int, \
- Q_DECL_DEPRECATED_X("This op is deprecated")) \
+ compareThreeWay(const Templated ## Name &lhs, X rhs) noexcept; \
+ Q_DECLARE_ ## Type ## _ORDERED ## Suffix (Templated ## Name, X, template <typename X>) \
}; \
\
-Constexpr bool comparesEqual(const Deprecated ## Name &lhs, int rhs) noexcept \
+template <typename X> \
+Constexpr bool comparesEqual(const Templated ## Name &lhs, X rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \
-Constexpr RetType compareThreeWay(const Deprecated ## Name &lhs, int rhs) noexcept \
+template <typename X> \
+Constexpr RetType compareThreeWay(const Templated ## Name &lhs, X rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return RetType::equivalent; }
DECLARE_TYPE(PartialConst, PARTIALLY, Qt::partial_ordering, constexpr, _LITERAL_TYPE)
@@ -34,10 +37,6 @@ DECLARE_TYPE(Strong, STRONGLY, Qt::strong_ordering, , )
void tst_QCompareHelpers::compareWithAttributes()
{
- // All these comparisons would trigger deprecation warnings.
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
#define COMPARE(ClassName) \
do { \
ClassName c; \
@@ -46,14 +45,19 @@ QT_WARNING_DISABLE_DEPRECATED
QCOMPARE_GE(0, c); \
} while (false)
- COMPARE(DeprecatedPartialConst);
- COMPARE(DeprecatedPartial);
- COMPARE(DeprecatedWeakConst);
- COMPARE(DeprecatedWeak);
- COMPARE(DeprecatedStrongConst);
- COMPARE(DeprecatedStrong);
+ COMPARE(TemplatedPartialConst);
+ COMPARE(TemplatedPartial);
+ COMPARE(TemplatedWeakConst);
+ COMPARE(TemplatedWeak);
+ COMPARE(TemplatedStrongConst);
+ COMPARE(TemplatedStrong);
#undef COMPARE
+}
-QT_WARNING_POP
+void tst_QCompareHelpers::totallyOrderedWrapperBasics()
+{
+ Qt::totally_ordered_wrapper<int*> pi; // partially-formed
+ pi = nullptr;
+ QCOMPARE_EQ(pi.get(), nullptr);
}
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
index 7acf8c2cf6..5f1ff67316 100644
--- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
+++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
@@ -155,6 +155,7 @@ void tst_qfloat16::ordering_data()
row(2.0f, -inf);
row(-2.0f, nan);
row(-inf, -2.0f);
+
// testing with values outside qfloat16 range
row(0.0f, 13e5f);
// generateRow(inf, 13e5f); // fails qfloat16 vs qfloat16 and qfloat16 vs int (QTBUG-118193)
@@ -187,11 +188,21 @@ void tst_qfloat16::ordering()
#undef CHECK_FP
+ auto check_int = [=](auto rhs) {
+ // check that we're in range before converting, otherwise
+ // [conv.fpint]/1 says it would be UB
+ using RHS = decltype(rhs);
+ if (right > double(std::numeric_limits<RHS>::max()))
+ return;
+ if (auto min = std::numeric_limits<RHS>::min(); min != 0 && right < double(min))
+ return;
+ rhs = RHS(right);
+ const auto expectedRes = Qt::compareThreeWay(left, rhs);
+ QTestPrivate::testAllComparisonOperators(lhs, rhs, expectedRes);
+ };
#define CHECK_INT(RHS) \
do { \
- const auto rhs = static_cast<RHS>(right); \
- const auto expectedRes = Qt::compareThreeWay(left, rhs); \
- QTestPrivate::testAllComparisonOperators(lhs, rhs, expectedRes); \
+ check_int(static_cast<RHS>(0)); \
POSTCHECK("qfloat16 vs " #RHS " comparison failed") \
} while (false) \
/* END */
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 1a19048bbe..3fc91e4f59 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -261,7 +261,7 @@ void tst_QGlobal::qtry()
void tst_QGlobal::checkptr()
{
- int i;
+ int i = 0;
QCOMPARE(q_check_ptr(&i), &i);
const char *c = "hello";
diff --git a/tests/auto/corelib/global/qlibraryinfo/CMakeLists.txt b/tests/auto/corelib/global/qlibraryinfo/CMakeLists.txt
new file mode 100644
index 0000000000..d72e871967
--- /dev/null
+++ b/tests/auto/corelib/global/qlibraryinfo/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qlibraryinfo LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+
+qt_internal_add_test(tst_qlibraryinfo SOURCES tst_qlibraryinfo.cpp
+ LIBRARIES
+ Qt::CorePrivate
+
+)
+
+qt_add_resources(tst_qlibraryinfo "qtconffiles"
+ PREFIX "/"
+ FILES
+ empty.qt.conf
+ partial.qt.conf
+ list.qt.conf
+ merge.qt.conf
+)
diff --git a/tests/auto/corelib/global/qlibraryinfo/empty.qt.conf b/tests/auto/corelib/global/qlibraryinfo/empty.qt.conf
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/global/qlibraryinfo/empty.qt.conf
diff --git a/tests/auto/corelib/global/qlibraryinfo/list.qt.conf b/tests/auto/corelib/global/qlibraryinfo/list.qt.conf
new file mode 100644
index 0000000000..9271b414ca
--- /dev/null
+++ b/tests/auto/corelib/global/qlibraryinfo/list.qt.conf
@@ -0,0 +1,2 @@
+[Paths]
+Documentation = "/path/to/mydoc","/path/to/anotherdoc","relativePath"
diff --git a/tests/auto/corelib/global/qlibraryinfo/merge.qt.conf b/tests/auto/corelib/global/qlibraryinfo/merge.qt.conf
new file mode 100644
index 0000000000..a687dc4d71
--- /dev/null
+++ b/tests/auto/corelib/global/qlibraryinfo/merge.qt.conf
@@ -0,0 +1,5 @@
+[Paths]
+QmlImports = "/path/to/myqml"
+
+[Config]
+MergeQtConf=true
diff --git a/tests/auto/corelib/global/qlibraryinfo/partial.qt.conf b/tests/auto/corelib/global/qlibraryinfo/partial.qt.conf
new file mode 100644
index 0000000000..bba214c2a6
--- /dev/null
+++ b/tests/auto/corelib/global/qlibraryinfo/partial.qt.conf
@@ -0,0 +1,2 @@
+[Paths]
+QmlImports = "/path/to/myqml"
diff --git a/tests/auto/corelib/global/qlibraryinfo/tst_qlibraryinfo.cpp b/tests/auto/corelib/global/qlibraryinfo/tst_qlibraryinfo.cpp
new file mode 100644
index 0000000000..b7d79c05f5
--- /dev/null
+++ b/tests/auto/corelib/global/qlibraryinfo/tst_qlibraryinfo.cpp
@@ -0,0 +1,103 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
+#include <QtCore/qlibraryinfo.h>
+#include <QtCore/qscopeguard.h>
+#include <QtCore/private/qlibraryinfo_p.h>
+
+
+class tst_QLibraryInfo : public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void cleanup();
+ void path_data();
+ void path();
+ void paths();
+ void merge();
+};
+
+void tst_QLibraryInfo::initTestCase()
+{
+#if !QT_CONFIG(settings)
+ QSKIP("QSettings support is required for the test to run.");
+#endif
+}
+
+void tst_QLibraryInfo::cleanup()
+{
+ QLibraryInfoPrivate::setQtconfManualPath(nullptr);
+ QLibraryInfoPrivate::reload();
+}
+
+void tst_QLibraryInfo::path_data()
+{
+ QTest::addColumn<QString>("qtConfPath");
+ QTest::addColumn<QLibraryInfo::LibraryPath>("path");
+ QTest::addColumn<QString>("expected");
+
+ // TODO: deal with bundle on macOs?
+ QString baseDir = QCoreApplication::applicationDirPath();
+
+ // empty means we fall-back to default entries
+ QTest::addRow("empty_qmlimports") << ":/empty.qt.conf" << QLibraryInfo::QmlImportsPath << (baseDir + "/qml");
+ QTest::addRow("empty_Data") << ":/empty.qt.conf" << QLibraryInfo::DataPath << baseDir;
+
+ // partial override; use given entry if provided, otherwise default
+ QTest::addRow("partial_qmlimports") << ":/partial.qt.conf" << QLibraryInfo::QmlImportsPath << "/path/to/myqml";
+ QTest::addRow("partial_Data") << ":/partial.qt.conf" << QLibraryInfo::DataPath << baseDir;
+}
+
+void tst_QLibraryInfo::path()
+{
+ QFETCH(QString, qtConfPath);
+ QFETCH(QLibraryInfo::LibraryPath, path);
+ QFETCH(QString, expected);
+
+ QLibraryInfoPrivate::setQtconfManualPath(&qtConfPath);
+ QLibraryInfoPrivate::reload();
+ QString value = QLibraryInfo::path(path);
+ QCOMPARE(value, expected);
+
+ // check consistency with paths
+ auto values = QLibraryInfo::paths(path);
+ QVERIFY(!values.isEmpty());
+ QCOMPARE(values.first(), expected);
+}
+
+void tst_QLibraryInfo::paths()
+{
+ QString qtConfPath(u":/list.qt.conf");
+ QLibraryInfoPrivate::setQtconfManualPath(&qtConfPath);
+ QLibraryInfoPrivate::reload();
+
+ QList<QString> values = QLibraryInfo::paths(QLibraryInfo::DocumentationPath);
+ QCOMPARE(values.length(), 3);
+ QCOMPARE(values[0], "/path/to/mydoc");
+ QCOMPARE(values[1], "/path/to/anotherdoc");
+ QString baseDir = QCoreApplication::applicationDirPath();
+ QCOMPARE(values[2], baseDir + "/relativePath");
+}
+
+void tst_QLibraryInfo::merge()
+{
+ QString qtConfPath(u":/merge.qt.conf");
+ QLibraryInfoPrivate::setQtconfManualPath(&qtConfPath);
+ QLibraryInfoPrivate::reload();
+
+ QString baseDir = QCoreApplication::applicationDirPath();
+ QString docPath = QLibraryInfo::path(QLibraryInfo::DocumentationPath);
+ // we can't know where exactly the doc path points, but it should not point to ${baseDir}/doc,
+ // which would be the behavior without merge_qt_conf
+ QCOMPARE_NE(docPath, baseDir + "/doc");
+
+ QList<QString> values = QLibraryInfo::paths(QLibraryInfo::QmlImportsPath);
+ QCOMPARE(values.size(), 2); // custom entry + Qt default entry
+ QCOMPARE(values[0], "/path/to/myqml");
+}
+
+QTEST_GUILESS_MAIN(tst_QLibraryInfo)
+
+#include "tst_qlibraryinfo.moc"
diff --git a/tests/auto/corelib/global/qxp/CMakeLists.txt b/tests/auto/corelib/global/qxp/CMakeLists.txt
index 2178f446db..8292462d17 100644
--- a/tests/auto/corelib/global/qxp/CMakeLists.txt
+++ b/tests/auto/corelib/global/qxp/CMakeLists.txt
@@ -1,2 +1,4 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(function_ref)
add_subdirectory(is_virtual_base_of)
diff --git a/tests/auto/corelib/io/CMakeLists.txt b/tests/auto/corelib/io/CMakeLists.txt
index 7fdf4b52b0..1e66aa8956 100644
--- a/tests/auto/corelib/io/CMakeLists.txt
+++ b/tests/auto/corelib/io/CMakeLists.txt
@@ -25,7 +25,7 @@ add_subdirectory(qloggingcategory)
add_subdirectory(qnodebug)
add_subdirectory(qsavefile)
add_subdirectory(qstandardpaths)
-if(NOT QNX)
+if(NOT QNX AND NOT VXWORKS)
add_subdirectory(qstorageinfo)
endif()
add_subdirectory(qtemporarydir)
@@ -68,3 +68,9 @@ endif()
if(QT_FEATURE_private_tests)
add_subdirectory(qzip)
endif()
+if(NOT (MACOS AND "$ENV{QT_BUILD_ENVIRONMENT}" STREQUAL "ci"))
+ # On macOS the new features require at least macOS 13.3,
+ # but we also run the tests on older OS versions.
+ # So just skip macOS on CI for now.
+ add_subdirectory(qfloat16format)
+endif()
diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp
index 6fa3569c4f..f5af3bde63 100644
--- a/tests/auto/corelib/io/largefile/tst_largefile.cpp
+++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp
@@ -46,6 +46,10 @@ public:
// This means that files are limited to 2 GB − 1 bytes.
// Limit max size to 256MB
maxSizeBits = 28; // 256 MiB
+ #elif defined(Q_OS_VXWORKS)
+ // VxWorks doesn't support sparse files, also, default /tmp directory is a RAM-disk which
+ // limits its capacity.
+ maxSizeBits = 28; // 256 MiB
#elif defined (Q_OS_WASM)
maxSizeBits = 28; // 256 MiB
#elif defined(QT_LARGEFILE_SUPPORT)
@@ -494,6 +498,7 @@ void tst_LargeFile::mapFile()
// 32-bit: limited to 44-bit offsets (when sizeof(off_t) == 8)
//Windows: memory-mapping beyond EOF is not allowed
//wasm: as for linux
+//VxWorks: memory-mapping beyond EOF is not allowed
void tst_LargeFile::mapOffsetOverflow()
{
enum {
@@ -506,6 +511,9 @@ void tst_LargeFile::mapOffsetOverflow()
#elif (defined(Q_OS_LINUX) || defined(Q_OS_ANDROID)) && (Q_PROCESSOR_WORDSIZE == 4)
Succeeds = true,
MaxOffset = sizeof(QT_OFF_T) > 4 ? 43 : 30
+#elif defined(Q_OS_VXWORKS)
+ Succeeds = false,
+ MaxOffset = 8 * sizeof(QT_OFF_T) - 1
#else
Succeeds = true,
MaxOffset = 8 * sizeof(QT_OFF_T) - 1
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index b19f158746..7b05a88e81 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -438,7 +438,7 @@ void tst_QDir::mkdirOnSymlink()
// create our structure:
dir.mkpath("two/three");
- ::symlink("two/three", "symlink");
+ QCOMPARE(::symlink("two/three", "symlink"), 0);
// try it:
QString path = "symlink/../four/five";
@@ -2285,6 +2285,8 @@ void tst_QDir::equalityOperator_data()
QString pathinroot("/system/..");
#elif defined(Q_OS_HAIKU)
QString pathinroot("/boot/..");
+#elif defined(Q_OS_VXWORKS)
+ QString pathinroot("/tmp/..");
#else
QString pathinroot("/usr/..");
#endif
diff --git a/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp b/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp
index bb4e1b30d2..e2ac1858da 100644
--- a/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp
+++ b/tests/auto/corelib/io/qdirlisting/tst_qdirlisting.cpp
@@ -85,9 +85,12 @@ private slots:
void uncPaths();
#endif
#ifndef Q_OS_WIN
- void hiddenDirs_hiddenFiles();
+ void hiddenFiles();
+ void hiddenDirs();
#endif
+ void withStdAlgorithms();
+
private:
QSharedPointer<QTemporaryDir> m_dataDir;
};
@@ -173,10 +176,10 @@ void tst_QDirListing::initTestCase()
createFile("hiddenDirs_hiddenFiles/normalDirectory/.hiddenFile");
createFile("hiddenDirs_hiddenFiles/.hiddenDirectory/normalFile");
createFile("hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenFile");
- createDirectory("hiddenDirs_hiddenFiles/normalDirectory/normalDirectory");
- createDirectory("hiddenDirs_hiddenFiles/normalDirectory/.hiddenDirectory");
- createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/normalDirectory");
- createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenDirectory");
+ createDirectory("hiddenDirs_hiddenFiles/normalDirectory/subdir");
+ createDirectory("hiddenDirs_hiddenFiles/normalDirectory/.hidden-subdir");
+ createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/subdir");
+ createDirectory("hiddenDirs_hiddenFiles/.hiddenDirectory/.hidden-subdir");
#endif
}
@@ -571,40 +574,77 @@ void tst_QDirListing::uncPaths()
// In Unix it is easy to create hidden files, but in Windows it requires
// a special call since hidden files need to be "marked" while in Unix
// anything starting by a '.' is a hidden file.
-// For that reason this test is not run in Windows.
-void tst_QDirListing::hiddenDirs_hiddenFiles()
+// For that reason these two tests aren't run on Windows.
+
+void tst_QDirListing::hiddenFiles()
{
- // Only files
- {
- int matches = 0;
- int failures = 0;
- constexpr auto filters = QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot;
- for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters,
- ItFlag::Recursive)) {
- ++matches;
- if (dirEntry.isDir())
- ++failures; // search was only supposed to find files
- }
- QCOMPARE(matches, 6);
- QCOMPARE(failures, 0);
+ QStringList expected = {
+ "hiddenDirs_hiddenFiles/normalFile"_L1,
+ "hiddenDirs_hiddenFiles/.hiddenFile"_L1,
+ "hiddenDirs_hiddenFiles/normalDirectory/normalFile"_L1,
+ "hiddenDirs_hiddenFiles/normalDirectory/.hiddenFile"_L1,
+ "hiddenDirs_hiddenFiles/.hiddenDirectory/normalFile"_L1,
+ "hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenFile"_L1,
+ };
+ expected.sort();
+
+ constexpr auto filters = QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot;
+ QStringList list;
+ list.reserve(expected.size());
+ for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters,
+ ItFlag::Recursive)) {
+ QVERIFY(dirEntry.isFile());
+ list.emplace_back(dirEntry.filePath());
}
- // Only directories
- {
- int matches = 0;
- int failures = 0;
- constexpr auto filters = QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot;
- for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters,
- ItFlag::Recursive)) {
- ++matches;
- if (!dirEntry.isDir())
- ++failures; // search was only supposed to find files
- }
- QCOMPARE(matches, 6);
- QCOMPARE(failures, 0);
+
+ list.sort();
+
+ QCOMPARE_EQ(list, expected);
+}
+
+void tst_QDirListing::hiddenDirs()
+{
+ QStringList expected = {
+ "hiddenDirs_hiddenFiles/normalDirectory"_L1,
+ "hiddenDirs_hiddenFiles/normalDirectory/subdir"_L1,
+ "hiddenDirs_hiddenFiles/normalDirectory/.hidden-subdir"_L1,
+ "hiddenDirs_hiddenFiles/.hiddenDirectory"_L1,
+ "hiddenDirs_hiddenFiles/.hiddenDirectory/subdir"_L1,
+ "hiddenDirs_hiddenFiles/.hiddenDirectory/.hidden-subdir"_L1,
+ };
+ expected.sort();
+
+ constexpr auto filters = QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot;
+ QStringList list;
+ list.reserve(expected.size());
+ for (const auto &dirEntry : QDirListing(u"hiddenDirs_hiddenFiles"_s, filters,
+ ItFlag::Recursive)) {
+ QVERIFY(dirEntry.isDir());
+ list.emplace_back(dirEntry.filePath());
}
+ list.sort();
+
+ QCOMPARE_EQ(list, expected);
}
+
#endif // Q_OS_WIN
+void tst_QDirListing::withStdAlgorithms()
+{
+ QDirListing dirList(u"entrylist"_s, QDir::AllEntries | QDir::NoDotAndDotDot, ItFlag::Recursive);
+
+ std::for_each(dirList.cbegin(), dirList.cend(), [](const auto &dirEntry) {
+ QVERIFY(dirEntry.absoluteFilePath().contains("entrylist"));
+ });
+
+ const auto fileName = "dummy"_L1;
+ auto it = std::find_if(dirList.cbegin(), dirList.cend(), [fileName](const auto &dirEntry) {
+ return dirEntry.fileName() == fileName;
+ });
+ QVERIFY(it != dirList.cend());
+ QCOMPARE(it->fileName(), fileName);
+}
+
QTEST_MAIN(tst_QDirListing)
#include "tst_qdirlisting.moc"
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index f7d531f61f..563e4c2a83 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -1217,9 +1217,16 @@ void tst_QFileInfo::setFileTimes()
QCOMPARE(file.write(data), data.size());
QCOMPARE(file.size(), data.size());
- const QDateTime before = QDateTime::currentDateTimeUtc().addMSecs(-5000);
+ QDateTime before = QDateTime::currentDateTimeUtc().addMSecs(-5000);
+
QVERIFY(file.setFileTime(before, QFile::FileModificationTime));
const QDateTime mtime = file.fileTime(QFile::FileModificationTime).toUTC();
+ if (mtime.time().msec() == 0)
+ {
+ const QTime beforeTime = before.time();
+ const QTime beforeTimeWithMSCutOff{beforeTime.hour(), beforeTime.minute(), beforeTime.second(), 0};
+ before.setTime(beforeTimeWithMSCutOff);
+ }
QCOMPARE(mtime, before);
}
diff --git a/tests/auto/corelib/io/qfileselector/CMakeLists.txt b/tests/auto/corelib/io/qfileselector/CMakeLists.txt
index c27c4f4f96..aafdddb595 100644
--- a/tests/auto/corelib/io/qfileselector/CMakeLists.txt
+++ b/tests/auto/corelib/io/qfileselector/CMakeLists.txt
@@ -47,8 +47,11 @@ set(qfileselector_resource_files
"platforms/+unix/+haiku/test"
"platforms/+unix/+linux/test"
"platforms/+unix/+qnx/test"
+ "platforms/+unix/+vxworks/test"
"platforms/+unix/test"
"platforms/+unix/test3"
+ "platforms/+vxworks/test"
+ "platforms/+vxworks/test2"
"platforms/+wince/test"
"platforms/+wince/test2"
"platforms/+windows/+wince/test"
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+vxworks/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+vxworks/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+vxworks/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test2 b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+vxworks/test2
diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
index 626166c8b8..82c9d5ef37 100644
--- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
+++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
@@ -61,7 +61,7 @@ void tst_QFileSelector::basicTest_data()
QString expectedPlatform2File(""); //Only the last selector
QString expectedPlatform3File; // Only the first selector (the family)
#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WASM) && \
- !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU) && !defined(Q_OS_QNX)
+ !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU) && !defined(Q_OS_QNX) && !defined(Q_OS_VXWORKS)
/* We are only aware of specific unixes, and do not have test files for any of the others.
However those unixes can get a selector added from the result of a uname call, so this will
lead to a case where we don't have that file so we can't expect the concatenation of platform
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index a5b0087f9c..184eef3f15 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -26,14 +26,18 @@
using namespace std::chrono_literals;
#if defined(Q_OS_QNX)
-// Longer polling times on QNX, otherwise the tests fail on the CI
+constexpr bool isQNX = true;
+#else
+constexpr bool isQNX = false;
+#endif
+
+#if defined(Q_OS_QNX) || defined(Q_OS_VXWORKS)
+// Longer polling times on QNX and VxWorks, otherwise the tests fail on the CI
constexpr auto nativeEngineTimeout = 1s;
constexpr auto pollingEngineTimeout = 1s;
-constexpr bool isQNX = true;
#else
constexpr auto nativeEngineTimeout = 0ms;
constexpr auto pollingEngineTimeout = 20ms;
-constexpr bool isQNX = false;
#endif
/* All tests need to run in temporary directories not used
diff --git a/tests/auto/corelib/io/qfloat16format/CMakeLists.txt b/tests/auto/corelib/io/qfloat16format/CMakeLists.txt
new file mode 100644
index 0000000000..88c47d8de3
--- /dev/null
+++ b/tests/auto/corelib/io/qfloat16format/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfloat16format LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+set(CMAKE_OSX_DEPLOYMENT_TARGET 13.3)
+
+qt_internal_add_test(tst_qfloat16format
+ SOURCES
+ tst_qfloat16format.cpp
+)
+
+if(NOT VXWORKS)
+ set_target_properties(tst_qfloat16format
+ PROPERTIES
+ CXX_STANDARD 20
+ CXX_STANDARD_REQUIRED OFF
+ )
+endif()
diff --git a/tests/auto/corelib/io/qfloat16format/tst_qfloat16format.cpp b/tests/auto/corelib/io/qfloat16format/tst_qfloat16format.cpp
new file mode 100644
index 0000000000..ea07b327af
--- /dev/null
+++ b/tests/auto/corelib/io/qfloat16format/tst_qfloat16format.cpp
@@ -0,0 +1,157 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
+
+#include <QtCore/qcompilerdetection.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qfloat16format.h>
+#include <QtCore/qstring.h>
+
+using namespace Qt::StringLiterals;
+
+class tst_QFloat16Format : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void formatCompileTime();
+ void format_data();
+ void format();
+ void formatMultiArg();
+};
+
+void tst_QFloat16Format::initTestCase()
+{
+#ifndef QT_SUPPORTS_STD_FORMAT
+ QSKIP("This test requires std::format support!");
+#endif
+}
+
+void tst_QFloat16Format::formatCompileTime()
+{
+#ifdef QT_SUPPORTS_STD_FORMAT
+ // Starting from __cpp_lib_format == 202106L,
+ // std::format requires the format string to be evaluated at compile-time,
+ // so check it here.
+
+ const qfloat16 val{1.234f};
+ std::locale loc{"C"};
+
+ // char
+ std::string buffer;
+ std::format_to(std::back_inserter(buffer), "{}", val);
+ std::format_to(std::back_inserter(buffer), "{:*>15.7f}", val);
+ std::format_to(std::back_inserter(buffer), "{:*^+#15.7g}", val);
+ std::format_to(std::back_inserter(buffer), "{:*<-#15.7A}", val);
+ std::format_to(std::back_inserter(buffer), "{:*^ 15.7e}", val);
+ std::format_to(std::back_inserter(buffer), loc, "{:*^10.3Lf}", val);
+ std::format_to(std::back_inserter(buffer), loc, "{:*< 10.7LE}", val);
+
+ // wchar_t
+ std::wstring wbuffer;
+ std::format_to(std::back_inserter(wbuffer), L"{}", val);
+ std::format_to(std::back_inserter(wbuffer), L"{:*>15.7f}", val);
+ std::format_to(std::back_inserter(wbuffer), L"{:*^+#15.7g}", val);
+ std::format_to(std::back_inserter(wbuffer), L"{:*<-#15.7A}", val);
+ std::format_to(std::back_inserter(wbuffer), L"{:*^ 15.7e}", val);
+ std::format_to(std::back_inserter(wbuffer), loc, L"{:*^10.3Lf}", val);
+ std::format_to(std::back_inserter(wbuffer), loc, L"{:*< 10.7LE}", val);
+#endif // QT_SUPPORTS_STD_FORMAT
+}
+
+void tst_QFloat16Format::format_data()
+{
+#ifdef QT_SUPPORTS_STD_FORMAT
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<qfloat16>("value");
+ QTest::addColumn<std::locale>("locale");
+ QTest::addColumn<QString>("expectedString");
+
+ auto row = [](const QString &format, qfloat16 val, const QString &expected,
+ const std::locale &loc = std::locale::classic())
+ {
+ QTest::addRow("%s:%s", loc.name().c_str(), qPrintable(format))
+ << format << val << loc << expected;
+ };
+
+ row(u"{}"_s, qfloat16(1.f), u"1"_s);
+ row(u"{:#}"_s, qfloat16(1.f), u"1."_s);
+ row(u"{:f}"_s, qfloat16(1.f), u"1.000000"_s);
+ row(u"{:*>10.2a}"_s, qfloat16(-1.23f), u"**-1.3bp+0"_s);
+
+ try {
+ // check if this locale is a) valid and b) works as expected
+#if defined(Q_CC_MSVC)
+ std::locale loc("de-DE");
+#else
+ std::locale loc("de_DE");
+#endif
+ if (std::format(loc, "{:L}", 1.25) == "1,25") {
+ row(u"{:+Lf}"_s, qfloat16(1.f), u"+1,000000"_s, loc);
+ row(u"{:*^10.3LF}"_s, qfloat16(-0.1234f), u"**-0,123**"_s, loc);
+ row(u"{:*^#10.4Lg}"_s, qfloat16(-1.f), u"**-1,000**"_s, loc);
+ row(u"{:*<14.3LE}"_s, qfloat16(-0.1234f), u"-1,234E-01****"_s, loc);
+ }
+ } catch (const std::runtime_error &) {
+ // locale doesn't exist (std::locale constructor threw)
+ }
+#endif // QT_SUPPORTS_STD_FORMAT
+}
+
+void tst_QFloat16Format::format()
+{
+#ifdef QT_SUPPORTS_STD_FORMAT
+ QFETCH(const QString, format);
+ QFETCH(const qfloat16, value);
+ QFETCH(const std::locale, locale);
+ QFETCH(const QString, expectedString);
+
+ // char
+ {
+ std::string buffer;
+ const auto formatStr = format.toStdString();
+ std::vformat_to(std::back_inserter(buffer), locale, formatStr,
+ std::make_format_args(value));
+ const QString actualString = QString::fromStdString(buffer);
+ QCOMPARE_EQ(actualString, expectedString);
+ }
+
+ // wchar_t
+ {
+ std::wstring buffer;
+ const auto formatStr = format.toStdWString();
+ std::vformat_to(std::back_inserter(buffer), locale, formatStr,
+ std::make_wformat_args(value));
+ const QString actualString = QString::fromStdWString(buffer);
+ QCOMPARE_EQ(actualString, expectedString);
+ }
+#endif // QT_SUPPORTS_STD_FORMAT
+}
+
+void tst_QFloat16Format::formatMultiArg()
+{
+#ifdef QT_SUPPORTS_STD_FORMAT
+ const qfloat16 v1{-0.1234f};
+ const qfloat16 v2{5.67f};
+
+ const QString expectedString = u"**+5.67**_*****-1.234E-01"_s;
+ // char
+ {
+ std::string buffer;
+ std::format_to(std::back_inserter(buffer), "{1:*^+9.2f}_{0:*>15.3E}", v1, v2);
+ QCOMPARE_EQ(QString::fromStdString(buffer), expectedString);
+ }
+
+ // wchar_t
+ {
+ std::wstring buffer;
+ std::format_to(std::back_inserter(buffer), L"{1:*^+9.2f}_{0:*>15.3E}", v1, v2);
+ QCOMPARE_EQ(QString::fromStdWString(buffer), expectedString);
+ }
+#endif // QT_SUPPORTS_STD_FORMAT
+}
+
+QTEST_MAIN(tst_QFloat16Format)
+#include "tst_qfloat16format.moc"
diff --git a/tests/auto/corelib/io/qprocess/crasher.h b/tests/auto/corelib/io/qprocess/crasher.h
index 7d55bf980f..f1ca82a86b 100644
--- a/tests/auto/corelib/io/qprocess/crasher.h
+++ b/tests/auto/corelib/io/qprocess/crasher.h
@@ -45,6 +45,8 @@ void crash()
{
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
__ud2();
+#elif defined(_MSC_VER) && defined(_M_ARM64)
+ __debugbreak();
#elif __has_builtin(__builtin_trap)
__builtin_trap();
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 5f35732979..316c388bc8 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1715,7 +1715,7 @@ void tst_QProcess::raiseInChildProcessModifier()
sa.sa_flags = SA_RESETHAND;
sa.sa_handler = [](int) {
static const char msg[] = "SIGUSR1 handler was run";
- write(STDERR_FILENO, msg, strlen(msg));
+ (void)write(STDERR_FILENO, msg, strlen(msg));
raise(SIGUSR1); // re-raise
};
sigaction(SIGUSR1, &sa, nullptr);
@@ -1897,8 +1897,8 @@ void tst_QProcess::unixProcessParametersAndChildModifier()
process.setChildProcessModifier([=, &vforkControl] {
const char *pgidmsg = "PGID mismatch. ";
if (getpgrp() != oldpgid)
- write(pipes[1], pgidmsg, strlen(pgidmsg));
- write(pipes[1], message, strlen(message));
+ (void)write(pipes[1], pgidmsg, strlen(pgidmsg));
+ (void)write(pipes[1], message, strlen(message));
vforkControl.storeRelaxed(1);
});
auto flags = QProcess::UnixProcessFlag::CloseFileDescriptors |
diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
index 6a2a3daaa2..560d4196b2 100644
--- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
+++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
@@ -257,6 +257,9 @@ void tst_QProcessEnvironment::caseSensitivity()
void tst_QProcessEnvironment::systemEnvironment()
{
+#ifdef Q_OS_VXWORKS
+ QSKIP("VxWorks do not have PATH environment variable");
+#endif
static const char envname[] = "THIS_ENVIRONMENT_VARIABLE_HOPEFULLY_DOESNT_EXIST";
QByteArray path = qgetenv("PATH");
QByteArray nonexistant = qgetenv(envname);
diff --git a/tests/auto/corelib/io/qresourceengine/generateResources.sh b/tests/auto/corelib/io/qresourceengine/generateResources.sh
index 18d1e0b80f..ab05f1c35a 100755
--- a/tests/auto/corelib/io/qresourceengine/generateResources.sh
+++ b/tests/auto/corelib/io/qresourceengine/generateResources.sh
@@ -1,6 +1,6 @@
+#!/bin/sh
# Copyright (C) 2016 Intel Corporation.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#!/bin/sh
count=`awk '/ZERO_FILE_LEN/ { print $3 }' tst_qresourceengine.cpp`
dd if=/dev/zero of=zero.txt bs=1 count=$count
rcc --binary -o uncompressed.rcc --no-compress compressed.qrc
diff --git a/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp b/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp
index 39a3a1e012..c7b0fe7ea1 100644
--- a/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp
+++ b/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
class PluginClass : public QObject
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index f0dab35f81..00a8cc4d72 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -201,7 +201,6 @@ void tst_QResourceEngine::checkStructure_data()
<< (QStringList()
#if defined(BUILTIN_TESTDATA)
<< "parentdir.txt"
- << "runtime_resource.rcc"
#endif
<< "search_file.txt"
#if defined(BUILTIN_TESTDATA)
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
index 5242988fd1..f96cd48900 100644
--- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
+++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
@@ -24,6 +24,8 @@
# include "../../../../../src/corelib/io/qstorageinfo_linux_p.h"
#endif
+using namespace Qt::StringLiterals;
+
class tst_QStorageInfo : public QObject
{
Q_OBJECT
@@ -137,8 +139,10 @@ void tst_QStorageInfo::root()
QVERIFY(storage.isReady());
QCOMPARE(storage.rootPath(), QDir::rootPath());
QVERIFY(storage.isRoot());
+#ifndef Q_OS_WASM
QVERIFY(!storage.device().isEmpty());
QVERIFY(!storage.fileSystemType().isEmpty());
+#endif
#ifndef Q_OS_HAIKU
QCOMPARE_GE(storage.bytesTotal(), 0);
QCOMPARE_GE(storage.bytesFree(), 0);
@@ -149,6 +153,9 @@ void tst_QStorageInfo::root()
void tst_QStorageInfo::currentStorage()
{
QString appPath = QCoreApplication::applicationFilePath();
+ if (appPath.isEmpty())
+ QSKIP("No applicationFilePath(), cannot test");
+
QStorageInfo storage(appPath);
QVERIFY(storage.isValid());
QVERIFY(storage.isReady());
@@ -308,7 +315,10 @@ void tst_QStorageInfo::freeSpaceUpdate()
QCOMPARE(free, storage2.bytesFree());
storage2.refresh();
QCOMPARE(storage1, storage2);
+
+#ifndef Q_OS_WASM
QCOMPARE_NE(free, storage2.bytesFree());
+#endif
}
#if defined(Q_OS_LINUX) && defined(QT_BUILD_INTERNAL)
@@ -319,64 +329,64 @@ void tst_QStorageInfo::testParseMountInfo_data()
QTest::newRow("tmpfs")
<< "17 25 0:18 / /dev rw,nosuid,relatime shared:2 - tmpfs tmpfs rw,seclabel,mode=755\n"_ba
- << MountInfo{"/dev", "tmpfs", "tmpfs", "", makedev(0, 18)};
+ << MountInfo{"/dev", "tmpfs", "tmpfs", "", makedev(0, 18), 17};
QTest::newRow("proc")
<< "23 66 0:21 / /proc rw,nosuid,nodev,noexec,relatime shared:12 - proc proc rw\n"_ba
- << MountInfo{"/proc", "proc", "proc", "", makedev(0, 21)};
+ << MountInfo{"/proc", "proc", "proc", "", makedev(0, 21), 23};
// E.g. on Android
QTest::newRow("rootfs")
<< "618 618 0:1 / / ro,relatime master:1 - rootfs rootfs ro,seclabel\n"_ba
- << MountInfo{"/", "rootfs", "rootfs", "", makedev(0, 1)};
+ << MountInfo{"/", "rootfs", "rootfs", "", makedev(0, 1), 618};
QTest::newRow("ext4")
<< "47 66 8:3 / /home rw,relatime shared:50 - ext4 /dev/sda3 rw,stripe=32736\n"_ba
- << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3)};
+ << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3), 47};
QTest::newRow("empty-optional-field")
<< "23 25 0:22 / /apex rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,seclabel,mode=755\n"_ba
- << MountInfo{"/apex", "tmpfs", "tmpfs", "", makedev(0, 22)};
+ << MountInfo{"/apex", "tmpfs", "tmpfs", "", makedev(0, 22), 23};
QTest::newRow("one-optional-field")
<< "47 66 8:3 / /home rw,relatime shared:50 - ext4 /dev/sda3 rw,stripe=32736\n"_ba
- << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3)};
+ << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3), 47};
QTest::newRow("multiple-optional-fields")
<< "47 66 8:3 / /home rw,relatime shared:142 master:111 - ext4 /dev/sda3 rw,stripe=32736\n"_ba
- << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3)};
+ << MountInfo{"/home", "ext4", "/dev/sda3", "", makedev(8, 3), 47};
QTest::newRow("mountdir-with-utf8")
<< "129 66 8:51 / /mnt/lab\xC3\xA9l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba
- << MountInfo{"/mnt/labél", "ext4", "/dev/sdd3", "", makedev(8, 51)};
+ << MountInfo{"/mnt/labél", "ext4", "/dev/sdd3", "", makedev(8, 51), 129};
QTest::newRow("mountdir-with-space")
<< "129 66 8:51 / /mnt/labe\\040l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba
- << MountInfo{"/mnt/labe l", "ext4", "/dev/sdd3", "", makedev(8, 51)};
+ << MountInfo{"/mnt/labe l", "ext4", "/dev/sdd3", "", makedev(8, 51), 129};
QTest::newRow("mountdir-with-tab")
<< "129 66 8:51 / /mnt/labe\\011l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba
- << MountInfo{"/mnt/labe\tl", "ext4", "/dev/sdd3", "", makedev(8, 51)};
+ << MountInfo{"/mnt/labe\tl", "ext4", "/dev/sdd3", "", makedev(8, 51), 129};
QTest::newRow("mountdir-with-backslash")
<< "129 66 8:51 / /mnt/labe\\134l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba
- << MountInfo{"/mnt/labe\\l", "ext4", "/dev/sdd3", "", makedev(8, 51)};
+ << MountInfo{"/mnt/labe\\l", "ext4", "/dev/sdd3", "", makedev(8, 51), 129};
QTest::newRow("mountdir-with-newline")
<< "129 66 8:51 / /mnt/labe\\012l rw,relatime shared:234 - ext4 /dev/sdd3 rw\n"_ba
- << MountInfo{"/mnt/labe\nl", "ext4", "/dev/sdd3", "", makedev(8, 51)};
+ << MountInfo{"/mnt/labe\nl", "ext4", "/dev/sdd3", "", makedev(8, 51), 129};
QTest::newRow("btrfs-subvol")
<< "775 503 0:49 /foo/bar / rw,relatime shared:142 master:111 - btrfs "
"/dev/mapper/vg0-stuff rw,ssd,discard,space_cache,subvolid=272,subvol=/foo/bar\n"_ba
- << MountInfo{"/", "btrfs", "/dev/mapper/vg0-stuff", "/foo/bar", makedev(0, 49)};
+ << MountInfo{"/", "btrfs", "/dev/mapper/vg0-stuff", "/foo/bar", makedev(0, 49), 775};
QTest::newRow("bind-mount")
<< "59 47 8:17 /rpmbuild /home/user/rpmbuild rw,relatime shared:48 - ext4 /dev/sdb1 rw\n"_ba
- << MountInfo{"/home/user/rpmbuild", "ext4", "/dev/sdb1", "/rpmbuild", makedev(8, 17)};
+ << MountInfo{"/home/user/rpmbuild", "ext4", "/dev/sdb1", "/rpmbuild", makedev(8, 17), 59};
QTest::newRow("space-dash-space")
<< "47 66 8:3 / /home\\040-\\040dir rw,relatime shared:50 - ext4 /dev/sda3 rw,stripe=32736\n"_ba
- << MountInfo{"/home - dir", "ext4", "/dev/sda3", "", makedev(8, 3)};
+ << MountInfo{"/home - dir", "ext4", "/dev/sda3", "", makedev(8, 3), 47};
QTest::newRow("btrfs-mount-bind-file")
<< "1799 1778 0:49 "
@@ -385,7 +395,7 @@ void tst_QStorageInfo::testParseMountInfo_data()
"rw,ssd,discard,space_cache,subvolid=1773,subvol=/var_lib_docker\n"_ba
<< MountInfo{"/etc/resolv.conf", "btrfs", "/dev/mapper/vg0-stuff",
"/var_lib_docker/containers/81fde0fec3dd3d99765c3f7fd9cf1ab121b6ffcfd05d5d7ff434db933fe9d795/resolv.conf",
- makedev(0, 49)};
+ makedev(0, 49), 1799};
QTest::newRow("very-long-line-QTBUG-77059")
<< "727 26 0:52 / "
@@ -402,13 +412,13 @@ void tst_QStorageInfo::testParseMountInfo_data()
"workdir=/var/lib/docker/overlay2/f3fbad5eedef71145f00729f0826ea8c44defcfec8c92c58aee0aa2c5ea3fa3a/work,"
"index=off,xino=off\n"_ba
<< MountInfo{"/var/lib/docker/overlay2/f3fbad5eedef71145f00729f0826ea8c44defcfec8c92c58aee0aa2c5ea3fa3a/merged",
- "overlay", "overlay", "", makedev(0, 52)};
+ "overlay", "overlay", "", makedev(0, 52), 727};
QTest::newRow("sshfs-src-device-not-start-with-slash")
<< "128 92 0:64 / /mnt-point rw,nosuid,nodev,relatime shared:234 - "
"fuse.sshfs admin@192.168.1.2:/storage/emulated/0 rw,user_id=1000,group_id=1000\n"_ba
<< MountInfo{"/mnt-point", "fuse.sshfs",
- "admin@192.168.1.2:/storage/emulated/0", "", makedev(0, 64)};
+ "admin@192.168.1.2:/storage/emulated/0", "", makedev(0, 64), 128};
}
void tst_QStorageInfo::testParseMountInfo()
@@ -424,6 +434,7 @@ void tst_QStorageInfo::testParseMountInfo()
QCOMPARE(a.device, expected.device);
QCOMPARE(a.fsRoot, expected.fsRoot);
QCOMPARE(a.stDev, expected.stDev);
+ QCOMPARE(a.mntid, expected.mntid);
}
void tst_QStorageInfo::testParseMountInfo_filtered_data()
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index 579e6d5511..1419f06f86 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -592,7 +592,9 @@ void tst_QTemporaryFile::rename()
void tst_QTemporaryFile::renameFdLeak()
{
#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID)
- const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA("CMakeLists.txt"));
+ QTemporaryFile file;
+ QVERIFY(file.open());
+ const QByteArray sourceFile = QFile::encodeName(file.fileName());
QVERIFY(!sourceFile.isEmpty());
// Test this on Unix only
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index bd454fb695..2024968435 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -3776,13 +3776,13 @@ void tst_QUrl::setComponents_data()
<< PrettyDecoded << QString() << "foo:/path";
QTest::newRow("host-empty") << QUrl("foo://example.com/path")
<< int(Host) << "" << Tolerant << true
- << PrettyDecoded << QString() << "foo:///path";
+ << PrettyDecoded << "" << "foo:///path";
QTest::newRow("authority-null") << QUrl("foo://example.com/path")
<< int(Authority) << QString() << Tolerant << true
<< PrettyDecoded << QString() << "foo:/path";
QTest::newRow("authority-empty") << QUrl("foo://example.com/path")
<< int(Authority) << "" << Tolerant << true
- << PrettyDecoded << QString() << "foo:///path";
+ << PrettyDecoded << "" << "foo:///path";
QTest::newRow("query-null") << QUrl("http://example.com/?q=foo")
<< int(Query) << QString() << Tolerant << true
<< PrettyDecoded << QString() << "http://example.com/";
@@ -3840,10 +3840,10 @@ void tst_QUrl::setComponents_data()
<< PrettyDecoded << QString() << QString();
QTest::newRow("invalid-authority-1") << QUrl("http://example.com")
<< int(Authority) << "-not-valid-" << Tolerant << false
- << PrettyDecoded << QString() << QString();
+ << PrettyDecoded << "" << QString();
QTest::newRow("invalid-authority-2") << QUrl("http://example.com")
<< int(Authority) << "%31%30.%30.%30.%31" << Strict << false
- << PrettyDecoded << QString() << QString();
+ << PrettyDecoded << "" << QString();
QTest::newRow("invalid-path-0") << QUrl("http://example.com")
<< int(Path) << "{}" << Strict << false
diff --git a/tests/auto/corelib/ipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/corelib/ipc/qsharedmemory/tst_qsharedmemory.cpp
index 73578a3bab..5bd74da532 100644
--- a/tests/auto/corelib/ipc/qsharedmemory/tst_qsharedmemory.cpp
+++ b/tests/auto/corelib/ipc/qsharedmemory/tst_qsharedmemory.cpp
@@ -583,8 +583,8 @@ void tst_QSharedMemory::attachBeforeCreate()
*/
void tst_QSharedMemory::useTooMuchMemory()
{
- if (QSysInfo::productType() == QLatin1String("Debian")
- || QSysInfo::productType() == QLatin1String("debian"))
+ if (QSysInfo::kernelType() == QLatin1String("linux")
+ && QSysInfo::currentCpuArchitecture() == QLatin1String("arm64"))
QSKIP("This test is unstable: QTBUG-119321");
#ifdef Q_OS_LINUX
diff --git a/tests/auto/corelib/itemmodels/CMakeLists.txt b/tests/auto/corelib/itemmodels/CMakeLists.txt
index c0cd04df12..a8aa743887 100644
--- a/tests/auto/corelib/itemmodels/CMakeLists.txt
+++ b/tests/auto/corelib/itemmodels/CMakeLists.txt
@@ -5,7 +5,9 @@ add_subdirectory(qstringlistmodel)
if(TARGET Qt::Gui)
add_subdirectory(qabstractitemmodel)
if(QT_FEATURE_proxymodel)
+ if (NOT WASM) # QTBUG-121822
add_subdirectory(qabstractproxymodel)
+ endif()
add_subdirectory(qconcatenatetablesproxymodel)
add_subdirectory(qidentityproxymodel)
add_subdirectory(qsortfilterproxymodel_recursive)
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 6b1e4ce9ba..c48b79b260 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -993,9 +993,9 @@ void tst_QAbstractItemModel::complexChangesWithPersistent()
void tst_QAbstractItemModel::modelIndexComparisons()
{
- QTestPrivate::testEqualityOperatorsCompile<QModelIndex>();
- QTestPrivate::testEqualityOperatorsCompile<QPersistentModelIndex>();
- QTestPrivate::testEqualityOperatorsCompile<QPersistentModelIndex, QModelIndex>();
+ QTestPrivate::testAllComparisonOperatorsCompile<QModelIndex>();
+ QTestPrivate::testAllComparisonOperatorsCompile<QPersistentModelIndex>();
+ QTestPrivate::testAllComparisonOperatorsCompile<QPersistentModelIndex, QModelIndex>();
QtTestModel model(3, 3);
@@ -1003,13 +1003,28 @@ void tst_QAbstractItemModel::modelIndexComparisons()
QModelIndex mi22 = model.index(2, 2);
QPersistentModelIndex pmi11 = mi11;
QPersistentModelIndex pmi22 = mi22;
+ QPersistentModelIndex pmiU;
QT_TEST_EQUALITY_OPS(mi11, mi11, true);
QT_TEST_EQUALITY_OPS(mi11, mi22, false);
+ QT_TEST_ALL_COMPARISON_OPS(mi11, mi11, Qt::strong_ordering::equal);
+ QT_TEST_ALL_COMPARISON_OPS(mi11, mi22, Qt::strong_ordering::less);
+ QT_TEST_ALL_COMPARISON_OPS(mi22, mi11, Qt::strong_ordering::greater);
QT_TEST_EQUALITY_OPS(pmi11, pmi11, true);
QT_TEST_EQUALITY_OPS(pmi11, pmi22, false);
QT_TEST_EQUALITY_OPS(pmi11, mi11, true);
QT_TEST_EQUALITY_OPS(pmi11, mi22, false);
+
+ QT_TEST_ALL_COMPARISON_OPS(pmi11, pmi11, Qt::strong_ordering::equal);
+ QT_TEST_ALL_COMPARISON_OPS(pmi11, pmi22, Qt::strong_ordering::less);
+ // Disengaged QPMIs are sorted randomly (based on address of their Private)
+ // So all we can check here is QPMIs with d == nullptr, which should reliably
+ // come before any others.
+ QT_TEST_ALL_COMPARISON_OPS(pmiU, pmiU, Qt::strong_ordering::equal);
+ QT_TEST_ALL_COMPARISON_OPS(pmi11, pmiU, Qt::strong_ordering::greater);
+ QT_TEST_ALL_COMPARISON_OPS(pmi11, mi11, Qt::strong_ordering::equal);
+ QT_TEST_ALL_COMPARISON_OPS(pmi11, mi22, Qt::strong_ordering::less);
+ QT_TEST_ALL_COMPARISON_OPS(pmiU, mi11, Qt::strong_ordering::less);
}
void tst_QAbstractItemModel::testMoveSameParentDown_data()
diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/CMakeLists.txt b/tests/auto/corelib/itemmodels/qabstractproxymodel/CMakeLists.txt
index 8799814324..ea90d1dd79 100644
--- a/tests/auto/corelib/itemmodels/qabstractproxymodel/CMakeLists.txt
+++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/CMakeLists.txt
@@ -14,6 +14,10 @@ endif()
qt_internal_add_test(tst_qabstractproxymodel
SOURCES
tst_qabstractproxymodel.cpp
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
LIBRARIES
Qt::Gui
Qt::TestPrivate
diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
index 62512889fd..73a81f56ab 100644
--- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
@@ -3,10 +3,17 @@
#include <QTest>
#include <QtTest/private/qpropertytesthelper_p.h>
+
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
#include <qabstractproxymodel.h>
#include <QItemSelection>
#include <qstandarditemmodel.h>
+#include <QtCore/qscopeguard.h>
+
class tst_QAbstractProxyModel : public QObject
{
Q_OBJECT
@@ -610,28 +617,30 @@ void tst_QAbstractProxyModel::sourceModelBinding()
SubQAbstractProxyModel proxy;
QStandardItemModel model1;
QStandardItemModel model2;
+ const char *lhs;
+ const char *rhs;
+
+ auto printOnFailure = qScopeGuard([&] {
+ qDebug("Failed %s - %s test", lhs, rhs);
+ });
+ lhs = "model";
+ rhs = "model";
QTestPrivate::testReadWritePropertyBasics<SubQAbstractProxyModel, QAbstractItemModel *>(
proxy, &model1, &model2, "sourceModel");
- if (QTest::currentTestFailed()) {
- qDebug("Failed model - model test");
- return;
- }
proxy.setSourceModel(&model2);
+ lhs = "model";
+ rhs = "nullptr";
QTestPrivate::testReadWritePropertyBasics<SubQAbstractProxyModel, QAbstractItemModel *>(
proxy, &model1, nullptr, "sourceModel");
- if (QTest::currentTestFailed()) {
- qDebug("Failed model - nullptr test");
- return;
- }
proxy.setSourceModel(&model1);
+ lhs = "nullptr";
+ rhs = "model";
QTestPrivate::testReadWritePropertyBasics<SubQAbstractProxyModel, QAbstractItemModel *>(
proxy, nullptr, &model2, "sourceModel");
- if (QTest::currentTestFailed()) {
- qDebug("Failed nullptr - model test");
- return;
- }
+
+ printOnFailure.dismiss();
}
QTEST_MAIN(tst_QAbstractProxyModel)
diff --git a/tests/auto/corelib/kernel/qchronotimer/tst_qchronotimer.cpp b/tests/auto/corelib/kernel/qchronotimer/tst_qchronotimer.cpp
index 62c402ae24..4711853c88 100644
--- a/tests/auto/corelib/kernel/qchronotimer/tst_qchronotimer.cpp
+++ b/tests/auto/corelib/kernel/qchronotimer/tst_qchronotimer.cpp
@@ -20,6 +20,10 @@
#include <qelapsedtimer.h>
#include <qproperty.h>
+#if defined(Q_OS_WIN32)
+#include <qt_windows.h>
+#endif
+
#if defined Q_OS_UNIX
#include <unistd.h>
#endif
@@ -57,6 +61,7 @@ private slots:
void recurringTimer();
void deleteLaterOnQChronoTimer(); // long name, don't want to shadow QObject::deleteLater()
void moveToThread();
+ void newTimerFiresTooSoon();
void restartedTimerFiresTooSoon();
void timerFiresOnlyOncePerProcessEvents_data();
void timerFiresOnlyOncePerProcessEvents();
@@ -619,6 +624,51 @@ void tst_QChronoTimer::moveToThread()
QVERIFY((ti3.id() & 0xffffff) != (timer1.id() & 0xffffff));
}
+class TimerListener : public QObject
+{
+ Q_OBJECT
+public:
+ void timerEvent(QTimerEvent *) override
+ {
+ m_timerElapsed = true;
+ }
+
+ bool m_timerElapsed = false;
+};
+
+void tst_QChronoTimer::newTimerFiresTooSoon()
+{
+#ifndef Q_OS_WIN32
+ QSKIP("Only relevant on Windows");
+#else
+ // Arrange - Create timer and make sure it ticked
+ {
+ QTest::qWait(0 /*ms*/); // Clean up event queue from previous tests
+
+ TimerListener listener;
+ const int timerId = listener.startTimer(50ms, Qt::CoarseTimer);
+ QThread::sleep(100ms);
+
+ // Force WM_TIMER events on Windows event queue
+ MSG msg{};
+ PeekMessage(&msg, nullptr, WM_TIMER, WM_TIMER, PM_NOREMOVE);
+
+ listener.killTimer(timerId);
+ }
+
+ // Act - Create new timer with long interval and make sure it does not immediately tick
+ TimerListener listener;
+ const int timerId = listener.startTimer(60s, Qt::CoarseTimer);
+
+ QTest::qWait(0 /*ms*/); // Process event queue - Should not call timerEvent
+ listener.killTimer(timerId);
+
+ // Assert
+ QEXPECT_FAIL("", "QTBUG-124496 - QObject::timerEvent may be called before the timer elapsed", Continue);
+ QVERIFY(!listener.m_timerElapsed);
+#endif
+}
+
class RestartedTimerFiresTooSoonObject : public QObject
{
Q_OBJECT
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index 8f8ab33e64..5dc445d44f 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -1065,7 +1065,7 @@ static void createQObjectOnDestruction()
// QThread) after the last QObject has been destroyed (especially after
// QCoreApplication has).
-#if !defined(QT_QGUIAPPLICATIONTEST) && !defined(Q_OS_WIN)
+#if !defined(QT_QGUIAPPLICATIONTEST) && !defined(Q_OS_WIN) && !defined(Q_OS_VXWORKS)
// QCoreApplicationData's global static destructor has run and cleaned up
// the QAdoptedThread.
if (theMainThreadIsSet())
diff --git a/tests/auto/corelib/kernel/qelapsedtimer/CMakeLists.txt b/tests/auto/corelib/kernel/qelapsedtimer/CMakeLists.txt
index 9a40a2f905..eccde38df2 100644
--- a/tests/auto/corelib/kernel/qelapsedtimer/CMakeLists.txt
+++ b/tests/auto/corelib/kernel/qelapsedtimer/CMakeLists.txt
@@ -14,4 +14,6 @@ endif()
qt_internal_add_test(tst_qelapsedtimer
SOURCES
tst_qelapsedtimer.cpp
+ LIBRARIES
+ Qt::TestPrivate
)
diff --git a/tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp b/tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp
index 7623fd2e43..7a2b12b2eb 100644
--- a/tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp
+++ b/tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp
@@ -5,6 +5,7 @@
#include <QtCore/QString>
#include <QtCore/QElapsedTimer>
#include <QTest>
+#include <QtTest/private/qcomparisontesthelper_p.h>
#include <QTimer>
static const int minResolution = 100; // the minimum resolution for the tests
@@ -22,6 +23,7 @@ class tst_QElapsedTimer : public QObject
Q_OBJECT
private Q_SLOTS:
+ void compareCompiles();
void statics();
void validity();
void basics();
@@ -29,6 +31,11 @@ private Q_SLOTS:
void msecsTo();
};
+void tst_QElapsedTimer::compareCompiles()
+{
+ QTestPrivate::testAllComparisonOperatorsCompile<QElapsedTimer>();
+}
+
void tst_QElapsedTimer::statics()
{
// these have been required since Qt 6.6
@@ -77,6 +84,7 @@ void tst_QElapsedTimer::basics()
QVERIFY(!(t1 < t1));
QCOMPARE(t1.msecsTo(t1), qint64(0));
QCOMPARE(t1.secsTo(t1), qint64(0));
+ QT_TEST_ALL_COMPARISON_OPS(t1, t1, Qt::strong_ordering::equal);
quint64 value1 = t1.msecsSinceReference();
qDebug() << "value1:" << value1 << "t1:" << t1;
@@ -141,10 +149,16 @@ void tst_QElapsedTimer::msecsTo()
QTest::qSleep(minResolution);
QElapsedTimer t2;
t2.start();
-
- QVERIFY(t1 != t2);
- QVERIFY(!(t1 == t2));
- QVERIFY(t1 < t2);
+ QTest::qSleep(minResolution);
+ QElapsedTimer t3;
+ t3.start();
+
+ QT_TEST_EQUALITY_OPS(t1, t2, false);
+ QT_TEST_EQUALITY_OPS(QElapsedTimer(), QElapsedTimer(), true);
+ QT_TEST_EQUALITY_OPS(QElapsedTimer(), t2, false);
+ QT_TEST_ALL_COMPARISON_OPS(t1, t2, Qt::strong_ordering::less);
+ QT_TEST_ALL_COMPARISON_OPS(t3, t2, Qt::strong_ordering::greater);
+ QT_TEST_ALL_COMPARISON_OPS(t3, QElapsedTimer(), Qt::strong_ordering::greater);
auto diff = t1.msecsTo(t2);
QVERIFY2(diff > 0, QString("difference t1 and t2 is %1").arg(diff).toLatin1());
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt b/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt
index 1f9cfb9449..a18bdab429 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt
+++ b/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt
@@ -19,6 +19,9 @@ endif()
foreach(test ${test_names})
qt_internal_add_test(${test}
NO_BATCH
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
SOURCES
tst_qeventdispatcher.cpp
)
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index 285d080960..a61f398366 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -20,6 +20,10 @@ static bool glibDisabled = []() {
#include <chrono>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
using namespace std::chrono_literals;
static constexpr auto PreciseTimerInterval = 10ms;
@@ -230,8 +234,6 @@ void tst_QEventDispatcher::registerTimer()
{
TimerManager timers(eventDispatcher, this);
timers.registerAll();
- if (QTest::currentTestFailed())
- return;
// check that all 3 are present in the eventDispatcher's registeredTimer() list
QCOMPARE(timers.registeredTimers().size(), 3);
@@ -267,8 +269,6 @@ void tst_QEventDispatcher::registerTimer()
QCOMPARE(timerIdFromEvent, timers.preciseTimerId());
// now unregister it and make sure it's gone
timers.unregister(Qt::TimerId(timers.preciseTimerId()));
- if (QTest::currentTestFailed())
- return;
QCOMPARE(timers.registeredTimers().size(), 2);
QVERIFY(!timers.foundPrecise());
QVERIFY(timers.foundCoarse());
@@ -291,8 +291,6 @@ void tst_QEventDispatcher::registerTimer()
QCOMPARE(timerIdFromEvent, timers.coarseTimerId());
// now unregister it and make sure it's gone
timers.unregister(Qt::TimerId(timers.coarseTimerId()));
- if (QTest::currentTestFailed())
- return;
QCOMPARE(timers.registeredTimers().size(), 1);
QVERIFY(!timers.foundPrecise());
QVERIFY(!timers.foundCoarse());
@@ -300,8 +298,6 @@ void tst_QEventDispatcher::registerTimer()
// not going to wait for the VeryCoarseTimer, would take too long, just unregister it
timers.unregisterAll();
- if (QTest::currentTestFailed())
- return;
QVERIFY(timers.registeredTimers().isEmpty());
}
diff --git a/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp b/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp
index b7b1f95b39..2f895b7b9e 100644
--- a/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp
+++ b/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp
@@ -17,6 +17,7 @@ public:
private slots:
void construct();
+ void invalidArraysAreEmpty();
void size();
void operators();
};
@@ -81,6 +82,7 @@ VERIFY_RETURN_FOR_TYPE(QJniArray<List>, QJniArray<List>);
void tst_QJniArray::construct()
{
+ // explicit
{
QStringList strings;
for (int i = 0; i < 10000; ++i)
@@ -89,19 +91,66 @@ void tst_QJniArray::construct()
QCOMPARE(list.size(), 10000);
}
{
- QJniArray<jint> list{1, 2, 3};
+ QJniArray bytes = QJniArrayBase::fromContainer(QByteArray("abc"));
+ static_assert(std::is_same_v<decltype(bytes)::value_type, jbyte>);
+ QCOMPARE(bytes.size(), 3);
+ }
+ {
+ QJniArray list{1, 2, 3};
+ static_assert(std::is_same_v<decltype(list), QJniArray<int>>);
QCOMPARE(list.size(), 3);
+ list = {4, 5};
+ QCOMPARE(list.size(), 2);
}
{
QJniArray<jint> list(QList<int>{1, 2, 3});
QCOMPARE(list.size(), 3);
}
+ // CTAD with deduction guide
+ {
+ QJniArray list(QList<int>{1, 2, 3});
+ QCOMPARE(list.size(), 3);
+ }
+ {
+ QJniArray bytes(QByteArray("abc"));
+ static_assert(std::is_same_v<decltype(bytes)::value_type, jbyte>);
+ QCOMPARE(bytes.size(), 3);
+ }
+ {
+ QStringList strings{"a", "b", "c"};
+ QJniArray list(strings);
+ QCOMPARE(list.size(), 3);
+ }
{
QJniArray<jint> list{QList<int>{1, 2, 3}};
QCOMPARE(list.size(), 3);
}
}
+void tst_QJniArray::invalidArraysAreEmpty()
+{
+ QJniArray<jchar> invalid;
+ QVERIFY(!invalid.isValid());
+ QCOMPARE(invalid.object(), nullptr);
+ QVERIFY(invalid.isEmpty());
+
+ QCOMPARE(invalid.begin(), invalid.end());
+ QCOMPARE(invalid.rbegin(), invalid.rend());
+
+ QList<jchar> data;
+ // safe to iterate
+ for (const auto &e : invalid)
+ data.emplace_back(e);
+ QVERIFY(data.empty());
+
+ // safe to convert
+ data = invalid.toContainer();
+ QVERIFY(data.empty());
+
+ // unsafe to access
+ // auto element = invalid.at(0);
+}
+
void tst_QJniArray::size()
{
QJniArray<jint> array;
@@ -110,7 +159,7 @@ void tst_QJniArray::size()
QList<int> intList;
intList.resize(10);
- auto intArray = QJniArrayBase::fromContainer(intList);
+ auto intArray = QJniArray(intList);
QCOMPARE(intArray.size(), 10);
}
diff --git a/tests/auto/corelib/kernel/qjniobject/testdata/src/org/qtproject/qt/android/testdata/QtJniObjectTestClass.java b/tests/auto/corelib/kernel/qjniobject/testdata/src/org/qtproject/qt/android/testdata/QtJniObjectTestClass.java
index 07a94d1cac..eb86a18034 100644
--- a/tests/auto/corelib/kernel/qjniobject/testdata/src/org/qtproject/qt/android/testdata/QtJniObjectTestClass.java
+++ b/tests/auto/corelib/kernel/qjniobject/testdata/src/org/qtproject/qt/android/testdata/QtJniObjectTestClass.java
@@ -43,6 +43,8 @@ public class QtJniObjectTestClass
static char S_CHAR_VAR;
static String S_STRING_OBJECT_VAR;
+ static char[] S_CHAR_ARRAY = A_STRING_OBJECT.toCharArray();
+
// --------------------------------------------------------------------------------------------
public static void staticVoidMethod() { return; }
public static void staticVoidMethodWithArgs(int a, boolean b, char c) { return; }
@@ -199,6 +201,18 @@ public class QtJniObjectTestClass
{ return staticReverseCharArray(array); }
// --------------------------------------------------------------------------------------------
+ public static char[] getStaticCharArray()
+ { return S_CHAR_ARRAY; }
+ public static void mutateStaticCharArray(char [] values)
+ {
+ for (int i = 0; i < values.length; ++i) {
+ S_CHAR_ARRAY[i] = values[i];
+ }
+ }
+ public static void replaceStaticCharArray(char[] array)
+ { S_CHAR_ARRAY = array; }
+
+ // --------------------------------------------------------------------------------------------
public static short[] staticShortArrayMethod() { short[] array = { 3, 2, 1 }; return array; }
public short[] shortArrayMethod() { return staticShortArrayMethod(); }
public static short[] staticReverseShortArray(short[] array)
diff --git a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
index 64b464e002..1da70b7127 100644
--- a/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
+++ b/tests/auto/corelib/kernel/qjniobject/tst_qjniobject.cpp
@@ -116,6 +116,7 @@ private slots:
void isClassAvailable();
void fromLocalRef();
void largeObjectArray();
+ void arrayLifetime();
void callback_data();
void callback();
@@ -1627,7 +1628,7 @@ void tst_QJniObject::templateApiCheck()
QCOMPARE(array.size(), 3);
QCOMPARE(array.toContainer(), "abc");
- QJniArray<jbyte> newArray = QJniArrayBase::fromContainer(QByteArray{"cba"});
+ QJniArray newArray = QJniArray(QByteArray{"cba"});
QVERIFY(newArray.isValid());
const auto reverse = testClass.callMethod<jbyte[]>("reverseByteArray", newArray);
QVERIFY(reverse.isValid());
@@ -1884,6 +1885,42 @@ void tst_QJniObject::largeObjectArray()
}
}
+void tst_QJniObject::arrayLifetime()
+{
+ const auto stringData = A_STRING_OBJECT();
+
+ QJniArray oldChars = TestClass::callStaticMethod<jchar[]>("getStaticCharArray");
+ QVERIFY(oldChars.isValid());
+ QCOMPARE(oldChars.size(), stringData.size());
+ QCOMPARE(QChar(oldChars.toContainer().at(0)), stringData.at(0));
+
+ QJniArray<jchar> newChars{'a', 'b', 'c'};
+ // replace the first three characters in the array
+ TestClass::callStaticMethod<void>("mutateStaticCharArray", newChars);
+ // the old jcharArray is still valid and the size is unchanged
+ QVERIFY(oldChars.isValid());
+ QCOMPARE(oldChars.size(), A_STRING_OBJECT().size());
+ QCOMPARE(oldChars.toContainer().at(0), jchar('a'));
+
+ // get a second reference to the Java array
+ QJniArray updatedChars = TestClass::getStaticField<jchar[]>("S_CHAR_ARRAY");
+ // the two QJniArrays reference the same jobject
+ QCOMPARE(updatedChars.size(), oldChars.size());
+ QCOMPARE(updatedChars, oldChars);
+
+ // replace the Java array; the old jcharArray is still valid and unchanged
+ TestClass::callStaticMethod<void>("replaceStaticCharArray", newChars);
+ // the old jcharArray is still valid and unchanged
+ QVERIFY(oldChars.isValid());
+ QCOMPARE(oldChars.size(), stringData.size());
+ QCOMPARE(oldChars, updatedChars);
+
+ // we get the same object that we set
+ updatedChars = TestClass::getStaticField<jchar[]>("S_CHAR_ARRAY");
+ QCOMPARE(updatedChars, newChars);
+ QCOMPARE_NE(updatedChars, oldChars);
+}
+
enum class CallbackParameterType
{
Object,
diff --git a/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp b/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp
index bf582041f3..cb9c7022b1 100644
--- a/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp
+++ b/tests/auto/corelib/kernel/qjnitypes/tst_qjnitypes.cpp
@@ -63,7 +63,6 @@ Q_DECLARE_JNI_CLASS(JavaType, "org/qtproject/qt/JavaType");
static_assert(QtJniTypes::Traits<QtJniTypes::JavaType>::signature() == "Lorg/qtproject/qt/JavaType;");
static_assert(QtJniTypes::Traits<QtJniTypes::JavaType[]>::signature() == "[Lorg/qtproject/qt/JavaType;");
-Q_DECLARE_JNI_CLASS(String, "java/lang/String");
static_assert(QtJniTypes::Traits<jstring>::className() == "java/lang/String");
static_assert(QtJniTypes::Traits<QtJniTypes::String>::className() == "java/lang/String");
static_assert(QtJniTypes::Traits<QtJniTypes::String>::signature() == "Ljava/lang/String;");
@@ -72,6 +71,19 @@ static_assert(QtJniTypes::Traits<QtJniTypes::String[]>::signature() == "[Ljava/l
Q_DECLARE_JNI_CLASS(QtTextToSpeech, "org/qtproject/qt/android/speech/QtTextToSpeech")
static_assert(QtJniTypes::Traits<QtJniTypes::QtTextToSpeech>::className() == "org/qtproject/qt/android/speech/QtTextToSpeech");
+// declaring two types Size in different packages
+Q_DECLARE_JNI_CLASS(android, util, Size)
+// inline namespaces, so this works
+static_assert(QtJniTypes::Traits<QtJniTypes::Size>::className() == "android/util/Size");
+
+Q_DECLARE_JNI_CLASS(org, qtproject, Size)
+// this would now be ambiguous
+// static_assert(QtJniTypes::Traits<QtJniTypes::Size>::className() == "android/util/Size");
+
+// but client code can be explicit
+static_assert(QtJniTypes::Traits<QtJniTypes::android::util::Size>::className() == "android/util/Size");
+static_assert(QtJniTypes::Traits<QtJniTypes::org::qtproject::Size>::className() == "org/qtproject/Size");
+
static_assert(QtJniTypes::fieldSignature<jint>() == "I");
static_assert(QtJniTypes::fieldSignature<jint[]>() == "[I");
static_assert(QtJniTypes::fieldSignature<jint>() != "X");
diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
index e67bab7da4..3bf6211a53 100644
--- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
+++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
@@ -335,7 +335,7 @@ void tst_QMetaProperty::conversion()
void tst_QMetaProperty::enumsFlags()
{
// QTBUG-83689, verify that enumerations and flags can be assigned from int,
- // which is important for Qt Designer.
+ // which is important for Qt Widgets Designer.
EnumFlagsTester t;
auto mo = t.metaObject();
diff --git a/tests/auto/corelib/kernel/qpointer/CMakeLists.txt b/tests/auto/corelib/kernel/qpointer/CMakeLists.txt
index b1570b8cef..0b2c4b7e45 100644
--- a/tests/auto/corelib/kernel/qpointer/CMakeLists.txt
+++ b/tests/auto/corelib/kernel/qpointer/CMakeLists.txt
@@ -20,6 +20,7 @@ qt_internal_add_test(tst_qpointer
tst_qpointer.cpp
LIBRARIES
Qt::Gui
+ Qt::TestPrivate
)
## Scopes:
diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
index 7365fee819..b88f1b5b0f 100644
--- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
+++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
+#include <QtTest/private/qcomparisontesthelper_p.h>
#include <QRunnable>
#include <QThreadPool>
@@ -23,6 +24,7 @@ private slots:
void conversion();
void destructor();
void assignment_operators();
+ void compareCompiles();
void equality_operators();
void swap();
void isNull();
@@ -203,12 +205,21 @@ void tst_QPointer::assignment_operators()
delete object;
}
+void tst_QPointer::compareCompiles()
+{
+ QTestPrivate::testEqualityOperatorsCompile<QPointer<QObject>>();
+ QTestPrivate::testEqualityOperatorsCompile<QPointer<QObject>, QObject*>();
+ QTestPrivate::testEqualityOperatorsCompile<QPointer<QObject>, QWidget*>();
+ QTestPrivate::testEqualityOperatorsCompile<QPointer<QObject>, QPointer<QWidget>>();
+ QTestPrivate::testEqualityOperatorsCompile<QPointer<QObject>, std::nullptr_t>();
+}
+
void tst_QPointer::equality_operators()
{
QPointer<QObject> p1;
QPointer<QObject> p2;
- QVERIFY(p1 == p2);
+ QT_TEST_EQUALITY_OPS(p1, p2, true);
QObject *object = nullptr;
#ifndef QT_NO_WIDGETS
@@ -216,16 +227,15 @@ void tst_QPointer::equality_operators()
#endif
p1 = object;
- QVERIFY(p1 == p2);
- QVERIFY(p1 == object);
+ QT_TEST_EQUALITY_OPS(p1, p2, true);
+ QT_TEST_EQUALITY_OPS(p1, object, true);
p2 = object;
- QVERIFY(p2 == p1);
- QVERIFY(p2 == object);
-
+ QT_TEST_EQUALITY_OPS(p2, p1, true);
+ QT_TEST_EQUALITY_OPS(p2, object, true);
p1 = this;
- QVERIFY(p1 != p2);
+ QT_TEST_EQUALITY_OPS(p1, p2, false);
p2 = p1;
- QVERIFY(p1 == p2);
+ QT_TEST_EQUALITY_OPS(p1, p2, true);
// compare to zero
p1 = nullptr;
@@ -233,19 +243,13 @@ void tst_QPointer::equality_operators()
QVERIFY(0 == p1);
QVERIFY(p2 != 0);
QVERIFY(0 != p2);
- QVERIFY(p1 == nullptr);
- QVERIFY(nullptr == p1);
- QVERIFY(p2 != nullptr);
- QVERIFY(nullptr != p2);
- QVERIFY(p1 == object);
- QVERIFY(object == p1);
- QVERIFY(p2 != object);
- QVERIFY(object != p2);
+ QT_TEST_EQUALITY_OPS(p1, nullptr, true);
+ QT_TEST_EQUALITY_OPS(p2, nullptr, false);
+ QT_TEST_EQUALITY_OPS(p1, object, true);
+ QT_TEST_EQUALITY_OPS(p2, object, false);
#ifndef QT_NO_WIDGETS
- QVERIFY(p1 == widget);
- QVERIFY(widget == p1);
- QVERIFY(p2 != widget);
- QVERIFY(widget != p2);
+ QT_TEST_EQUALITY_OPS(p1, widget, true);
+ QT_TEST_EQUALITY_OPS(p2, widget, false);
#endif
}
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 23d41cafb2..d79e0e82f8 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -5,6 +5,8 @@
#include <qvariant.h>
+#include <QtCore/qttypetraits.h>
+
// don't assume <type_traits>
template <typename T, typename U>
constexpr inline bool my_is_same_v = false;
@@ -544,6 +546,9 @@ void tst_QVariant::isNull()
var3 = QVariant(QMetaType::fromType<QString>());
QVERIFY( var3.isNull() );
+ var3.setValue(QString());
+ QVERIFY( !var3.isNull() );
+
QVariant var4( 0 );
QVERIFY( !var4.isNull() );
diff --git a/tests/auto/corelib/platform/windows/qcomobject/tst_qcomobject.cpp b/tests/auto/corelib/platform/windows/qcomobject/tst_qcomobject.cpp
index 5ad961ee66..3c609238fc 100644
--- a/tests/auto/corelib/platform/windows/qcomobject/tst_qcomobject.cpp
+++ b/tests/auto/corelib/platform/windows/qcomobject/tst_qcomobject.cpp
@@ -69,6 +69,7 @@ struct QComObjectTraits<IDirect>
};
} // namespace QtPrivate
+QT_END_NAMESPACE
class tst_QComObject : public QObject
{
@@ -263,6 +264,4 @@ void tst_QComObject::Release_decrementsReferenceCountByOne()
QTEST_MAIN(tst_QComObject)
# include "tst_qcomobject.moc"
-QT_END_NAMESPACE
-
#endif // Q_OS_WIN
diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
index 3d3cb8330d..9443ba9e5c 100644
--- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
+++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
@@ -49,7 +49,7 @@ void tst_QPlugin::initTestCase()
void tst_QPlugin::loadDebugPlugin()
{
- const auto fileNames = dir.entryList(QStringList() << "*debug*", QDir::Files);
+ const auto fileNames = dir.entryList(QStringList() << "*debugplugin*", QDir::Files);
if (fileNames.isEmpty())
QSKIP("No debug plugins found - skipping test");
@@ -82,7 +82,7 @@ void tst_QPlugin::loadDebugPlugin()
void tst_QPlugin::loadReleasePlugin()
{
- const auto fileNames = dir.entryList(QStringList() << "*release*", QDir::Files);
+ const auto fileNames = dir.entryList(QStringList() << "*releaseplugin*", QDir::Files);
if (fileNames.isEmpty())
QSKIP("No release plugins found - skipping test");
@@ -180,7 +180,7 @@ void tst_QPlugin::scanInvalidPlugin()
#if defined(Q_OS_MACOS) && defined(Q_PROCESSOR_ARM)
QSKIP("This test crashes on ARM macOS");
#endif
- const auto fileNames = dir.entryList({"*invalid*"}, QDir::Files);
+ const auto fileNames = dir.entryList({"*invalidplugin*"}, QDir::Files);
QString invalidPluginName;
if (fileNames.isEmpty())
QSKIP("No invalid plugin found - skipping test");
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
index 6cb69fc46d..daf922b42c 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
set_directory_properties(PROPERTIES
_qt_good_targets ""
_qt_stub_targets ""
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp b/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp
index 24bac391fb..eed7228a29 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp
@@ -1 +1,3 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
void dummy() {}
diff --git a/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt b/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt
index 1e1e820b14..ec6c1979f7 100644
--- a/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/quuid/test/CMakeLists.txt
@@ -9,6 +9,8 @@ qt_internal_add_test(tst_quuid
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"
SOURCES
../tst_quuid.cpp
+ LIBRARIES
+ Qt::TestPrivate
)
## Scopes:
diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
index c5ce490b61..6d149c08db 100644
--- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
+++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
@@ -3,6 +3,8 @@
#include <QTest>
+#include <QtTest/private/qcomparisontesthelper_p.h>
+
#if QT_CONFIG(process)
#include <QProcess>
#endif
@@ -17,6 +19,7 @@ class tst_QUuid : public QObject
private slots:
void initTestCase();
+ void compareCompiles();
void fromChar();
void toString();
void fromString_data();
@@ -33,6 +36,8 @@ private slots:
void equal();
void notEqual();
void cpp11();
+ void ordering_data();
+ void ordering();
// Only in Qt > 3.2.x
void generate();
@@ -89,20 +94,28 @@ void tst_QUuid::initTestCase()
uuidD = QUuid(0x21f7f8de, 0x8051, 0x5b89, 0x86, 0x80, 0x01, 0x95, 0xef, 0x79, 0x8b, 0x6a);
}
-void tst_QUuid::fromChar()
+void tst_QUuid::compareCompiles()
{
- QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
- QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
- QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"));
- QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5"));
- QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c"));
- QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34"));
- QCOMPARE(QUuid(), QUuid("fc69b59e-cc34-"));
- QCOMPARE(QUuid(), QUuid("fc69b59e-cc34"));
- QCOMPARE(QUuid(), QUuid("cc34"));
- QCOMPARE(QUuid(), QUuid(nullptr));
+ QTestPrivate::testAllComparisonOperatorsCompile<QUuid>();
+#if defined(Q_OS_WIN)
+ QTestPrivate::testEqualityOperatorsCompile<QUuid, GUID>();
+#endif
+}
- QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+void tst_QUuid::fromChar()
+{
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"), true);
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"), true);
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"), true);
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5"), true);
+ QT_TEST_EQUALITY_OPS(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c"), true);
+ QT_TEST_EQUALITY_OPS(QUuid(), QUuid("{fc69b59e-cc34"), true);
+ QT_TEST_EQUALITY_OPS(QUuid(), QUuid("fc69b59e-cc34-"), true);
+ QT_TEST_EQUALITY_OPS(QUuid(), QUuid("fc69b59e-cc34"), true);
+ QT_TEST_EQUALITY_OPS(QUuid(), QUuid("cc34"), true);
+ QT_TEST_EQUALITY_OPS(QUuid(), QUuid(nullptr), true);
+
+ QT_TEST_EQUALITY_OPS(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")), true);
}
void tst_QUuid::toString()
@@ -162,21 +175,21 @@ void tst_QUuid::fromString()
const auto inputL1 = input.toLatin1();
const auto inputU8 = input.toUtf8();
- QCOMPARE(expected, QUuid(input));
- QCOMPARE(expected, QUuid(inputU8));
- QCOMPARE(expected, QUuid(inputL1));
+ QT_TEST_EQUALITY_OPS(expected, QUuid(input), true);
+ QT_TEST_EQUALITY_OPS(expected, QUuid(inputU8), true);
+ QT_TEST_EQUALITY_OPS(expected, QUuid(inputL1), true);
- QCOMPARE(expected, QUuid::fromString(input));
+ QT_TEST_EQUALITY_OPS(expected, QUuid::fromString(input), true);
// for QLatin1String, construct one whose data() is not NUL-terminated:
const auto longerInputL1 = inputL1 + '5'; // the '5' makes the premature end check incorrectly succeed
const auto inputL1S = QLatin1String(longerInputL1.data(), inputL1.size());
- QCOMPARE(expected, QUuid::fromString(inputL1S));
+ QT_TEST_EQUALITY_OPS(expected, QUuid::fromString(inputL1S), true);
// for QUtf8StringView, too:
const auto longerInputU8 = inputU8 + '5'; // the '5' makes the premature end check incorrectly succeed
const auto inputU8S = QUtf8StringView(longerInputU8.data(), inputU8.size());
- QCOMPARE(expected, QUuid::fromString(inputU8S));
+ QT_TEST_EQUALITY_OPS(expected, QUuid::fromString(inputU8S), true);
}
void tst_QUuid::toByteArray()
@@ -196,27 +209,30 @@ void tst_QUuid::toByteArray()
void tst_QUuid::fromByteArray()
{
- QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
- QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
- QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
- QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
- QCOMPARE(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c")));
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")), true);
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")), true);
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")), true);
+ QT_TEST_EQUALITY_OPS(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5")), true);
+ QT_TEST_EQUALITY_OPS(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c")), true);
- QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+ QT_TEST_EQUALITY_OPS(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")), true);
}
void tst_QUuid::toRfc4122()
{
QCOMPARE(uuidA.toRfc4122(), QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5"));
-
QCOMPARE(uuidB.toRfc4122(), QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b"));
}
void tst_QUuid::fromRfc4122()
{
- QCOMPARE(uuidA, QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")));
+ QT_TEST_EQUALITY_OPS(
+ uuidA,
+ QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")), true);
- QCOMPARE(uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")));
+ QT_TEST_EQUALITY_OPS(
+ uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")),
+ true);
}
void tst_QUuid::id128()
@@ -234,15 +250,15 @@ void tst_QUuid::id128()
0xba, 0x47, 0xec, 0x7e, 0x99, 0x03, 0x9a, 0x7b,
} };
- QCOMPARE(QUuid(bytesA), uuidA);
- QCOMPARE(QUuid(bytesB), uuidB);
+ QT_TEST_EQUALITY_OPS(QUuid(bytesA), uuidA, true);
+ QT_TEST_EQUALITY_OPS(QUuid(bytesB), uuidB, true);
QVERIFY(memcmp(uuidA.toBytes().data, bytesA.data, sizeof(QUuid::Id128Bytes)) == 0);
QVERIFY(memcmp(uuidB.toBytes().data, bytesB.data, sizeof(QUuid::Id128Bytes)) == 0);
QUuid::Id128Bytes leBytesA = {};
for (int i = 0; i < 16; i++)
leBytesA.data[15 - i] = bytesA.data[i];
- QCOMPARE(QUuid(leBytesA, QSysInfo::LittleEndian), uuidA);
+ QT_TEST_EQUALITY_OPS(QUuid(leBytesA, QSysInfo::LittleEndian), uuidA, true);
QVERIFY(memcmp(uuidA.toBytes(QSysInfo::LittleEndian).data, leBytesA.data, sizeof(leBytesA)) == 0);
// check the new q{To,From}{Big,Little}Endian() overloads
@@ -271,16 +287,16 @@ void tst_QUuid::uint128()
constexpr QUuid uuid = QUuid::fromUInt128(be);
static_assert(uuid.toUInt128() == be, "Round-trip through QUuid failed");
- QCOMPARE(uuid, uuidA);
+ QT_TEST_EQUALITY_OPS(uuid, uuidA, true);
QCOMPARE(uuid.toUInt128(), be);
quint128 le = qFromBigEndian(be);
QCOMPARE(uuid.toUInt128(QSysInfo::LittleEndian), le);
- QCOMPARE(QUuid::fromUInt128(le, QSysInfo::LittleEndian), uuidA);
+ QT_TEST_EQUALITY_OPS(QUuid::fromUInt128(le, QSysInfo::LittleEndian), uuidA, true);
QUuid::Id128Bytes bytes = { .data128 = { qToBigEndian(u) } };
QUuid uuid2(bytes);
- QCOMPARE(uuid2, uuid);
+ QT_TEST_EQUALITY_OPS(uuid2, uuid, true);
// verify that toBytes() and toUInt128() provide bytewise similar result
constexpr quint128 val = uuid.toUInt128();
@@ -294,11 +310,11 @@ void tst_QUuid::uint128()
void tst_QUuid::createUuidV3OrV5()
{
//"www.widgets.com" is also from RFC4122
- QCOMPARE(uuidC, QUuid::createUuidV3(uuidNS, QByteArray("www.widgets.com")));
- QCOMPARE(uuidC, QUuid::createUuidV3(uuidNS, QString("www.widgets.com")));
+ QT_TEST_EQUALITY_OPS(uuidC, QUuid::createUuidV3(uuidNS, QByteArray("www.widgets.com")), true);
+ QT_TEST_EQUALITY_OPS(uuidC, QUuid::createUuidV3(uuidNS, QString("www.widgets.com")), true);
- QCOMPARE(uuidD, QUuid::createUuidV5(uuidNS, QByteArray("www.widgets.com")));
- QCOMPARE(uuidD, QUuid::createUuidV5(uuidNS, QString("www.widgets.com")));
+ QT_TEST_EQUALITY_OPS(uuidD, QUuid::createUuidV5(uuidNS, QByteArray("www.widgets.com")), true);
+ QT_TEST_EQUALITY_OPS(uuidD, QUuid::createUuidV5(uuidNS, QString("www.widgets.com")), true);
}
void tst_QUuid::check_QDataStream()
@@ -314,7 +330,7 @@ void tst_QUuid::check_QDataStream()
QDataStream in(&ar,QIODevice::ReadOnly);
in.setByteOrder(QDataStream::BigEndian);
in >> tmp;
- QCOMPARE(uuidA, tmp);
+ QT_TEST_EQUALITY_OPS(uuidA, tmp, true);
}
{
QDataStream out(&ar,QIODevice::WriteOnly);
@@ -325,7 +341,7 @@ void tst_QUuid::check_QDataStream()
QDataStream in(&ar,QIODevice::ReadOnly);
in.setByteOrder(QDataStream::LittleEndian);
in >> tmp;
- QCOMPARE(uuidA, tmp);
+ QT_TEST_EQUALITY_OPS(uuidA, tmp, true);
}
}
@@ -340,14 +356,14 @@ void tst_QUuid::isNull()
void tst_QUuid::equal()
{
- QVERIFY( !(uuidA == uuidB) );
+ QT_TEST_EQUALITY_OPS(uuidA, uuidB, false);
QUuid copy(uuidA);
- QCOMPARE(uuidA, copy);
+ QT_TEST_EQUALITY_OPS(uuidA, copy, true);
QUuid assigned;
assigned = uuidA;
- QCOMPARE(uuidA, assigned);
+ QT_TEST_EQUALITY_OPS(uuidA, assigned, true);
}
@@ -368,6 +384,123 @@ void tst_QUuid::cpp11() {
#endif
}
+constexpr QUuid make_minimal(QUuid::Variant variant)
+{
+ using V = QUuid::Variant;
+ switch (variant) {
+ case V::VarUnknown: // special case
+ return {};
+ case V::NCS: // special case: null would be NCS, but is treated as Unknown
+ return {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ case V::DCE: // special case: DCE should be 0b100, but is 0b10
+ return {0, 0, 0, 0b1000'0000, 0, 0, 0, 0, 0, 0, 0};
+ case V::Microsoft:
+ case V::Reserved:
+ return {0, 0, 0, uchar(variant << 5), 0, 0, 0, 0, 0, 0, 0};
+ }
+}
+
+void tst_QUuid::ordering_data()
+{
+ QTest::addColumn<QUuid>("lhs");
+ QTest::addColumn<QUuid>("rhs");
+ QTest::addColumn<Qt::strong_ordering>("expected");
+
+ // QUuid is sorted by variant() first, then the dataN fields, in order
+ // Exhaustive testing is pointless, so pick some strategic values
+
+ constexpr QUuid null = make_minimal(QUuid::Variant::VarUnknown);
+ QCOMPARE(null.variant(), QUuid::Variant::VarUnknown);
+
+ constexpr QUuid minNCS = make_minimal(QUuid::Variant::NCS);
+ QCOMPARE(minNCS.variant(), QUuid::Variant::NCS);
+
+ constexpr QUuid ncs000_0000_0001 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ QCOMPARE(ncs000_0000_0001, minNCS);
+ constexpr QUuid ncs000_0000_0010 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0};
+ constexpr QUuid ncs000_0000_0100 = {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};
+ constexpr QUuid ncs000_0000_1000 = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0};
+
+ constexpr QUuid ncs000_0001_0000 = {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
+ constexpr QUuid ncs000_0010_0000 = {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
+ constexpr QUuid ncs000_0100_0000 = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0};
+ constexpr QUuid ncs000_1000_0000 = {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
+
+ constexpr QUuid ncs001_0000_0000 = {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
+ constexpr QUuid ncs010_0000_0000 = {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ constexpr QUuid ncs100_0000_0000 = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+ constexpr QUuid minDCE = make_minimal(QUuid::Variant::DCE);
+ QCOMPARE(minDCE.variant(), QUuid::Variant::DCE);
+
+ constexpr QUuid minMS = make_minimal(QUuid::Variant::Microsoft);
+ QCOMPARE(minMS.variant(), QUuid::Variant::Microsoft);
+
+ constexpr QUuid minR = make_minimal(QUuid::Variant::Reserved);
+ QCOMPARE(minR.variant(), QUuid::Variant::Reserved);
+
+ constexpr QUuid ones = {0xFFFF'FFFFU, 0xFFFFu, 0xFFFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu};
+ QCOMPARE(ones.variant(), QUuid::Variant::Reserved);
+
+#define ROW(l, r, c) \
+ QTest::addRow("%s<>%s", #l, #r) << l << r << Qt::strong_ordering:: c \
+ /* end */
+#define EQUAL(x) ROW(x, x, equal)
+ EQUAL(null);
+ EQUAL(minNCS);
+ EQUAL(minDCE);
+ EQUAL(minMS);
+ EQUAL(minR);
+ EQUAL(ones);
+#undef EQUAL
+#define AFTER_NULL(x) ROW(null, x, less)
+ AFTER_NULL(minNCS);
+ AFTER_NULL(minDCE);
+ AFTER_NULL(minMS);
+ AFTER_NULL(minR);
+ AFTER_NULL(ones);
+#undef AFTER_NULL
+#define AFTER_NCS(x) ROW(minNCS, x, less)
+ AFTER_NCS(ncs000_0000_0010);
+ AFTER_NCS(ncs000_0000_0100);
+ AFTER_NCS(ncs000_0000_1000);
+ AFTER_NCS(ncs000_0001_0000);
+ AFTER_NCS(ncs000_0010_0000);
+ AFTER_NCS(ncs000_0100_0000);
+ AFTER_NCS(ncs000_1000_0000);
+ AFTER_NCS(ncs001_0000_0000);
+ AFTER_NCS(ncs010_0000_0000);
+ AFTER_NCS(ncs100_0000_0000);
+ ROW(ncs100_0000_0000, minDCE, less);
+ AFTER_NCS(minDCE);
+ AFTER_NCS(minMS);
+ AFTER_NCS(minR);
+ AFTER_NCS(ones);
+#undef AFTER_NCS
+#define AFTER_DCE(x) ROW(minDCE, x, less)
+ AFTER_DCE(minMS);
+ AFTER_DCE(minR);
+ AFTER_DCE(ones);
+#undef AFTER_DCE
+#define AFTER_MS(x) ROW(minMS, x, less)
+ AFTER_MS(minR);
+ AFTER_MS(ones);
+#undef AFTER_MS
+#define AFTER_R(x) ROW(minR, x, less)
+ AFTER_R(ones);
+#undef AFTER_R
+#undef ROW
+}
+
+void tst_QUuid::ordering()
+{
+ QFETCH(const QUuid, lhs);
+ QFETCH(const QUuid, rhs);
+ QFETCH(const Qt::strong_ordering, expected);
+
+ QT_TEST_ALL_COMPARISON_OPS(lhs, rhs, expected);
+}
+
void tst_QUuid::generate()
{
QUuid shouldnt_be_null_uuidA = QUuid::createUuid();
@@ -384,10 +517,12 @@ void tst_QUuid::less()
QVERIFY( uuidB <= uuidA);
QVERIFY(!(uuidA < uuidB) );
QVERIFY(!(uuidA <= uuidB));
+ QT_TEST_ALL_COMPARISON_OPS(uuidB, uuidA, Qt::strong_ordering::less);
QUuid null_uuid;
QVERIFY(null_uuid < uuidA); // Null uuid is always less than a valid one
QVERIFY(null_uuid <= uuidA);
+ QT_TEST_ALL_COMPARISON_OPS(null_uuid, uuidA, Qt::strong_ordering::less);
QVERIFY(null_uuid <= null_uuid);
QVERIFY(uuidA <= uuidA);
@@ -400,6 +535,7 @@ void tst_QUuid::more()
QVERIFY( uuidA >= uuidB);
QVERIFY(!(uuidB > uuidA));
QVERIFY(!(uuidB >= uuidA));
+ QT_TEST_ALL_COMPARISON_OPS(uuidA, uuidB, Qt::strong_ordering::greater);
QUuid null_uuid;
QVERIFY(!(null_uuid > uuidA)); // Null uuid is always less than a valid one
@@ -407,6 +543,7 @@ void tst_QUuid::more()
QVERIFY(null_uuid >= null_uuid);
QVERIFY(uuidA >= uuidA);
+ QT_TEST_ALL_COMPARISON_OPS(uuidA, uuidA, Qt::strong_ordering::equal);
}
@@ -512,7 +649,7 @@ void tst_QUuid::qvariant()
QUuid uuid2 = v.value<QUuid>();
QVERIFY(!uuid2.isNull());
- QCOMPARE(uuid, uuid2);
+ QT_TEST_EQUALITY_OPS(uuid, uuid2, true);
}
void tst_QUuid::qvariant_conversion()
@@ -544,7 +681,7 @@ void tst_QUuid::qvariant_conversion()
QVariant sv = QVariant::fromValue(uuid.toByteArray());
QCOMPARE(sv.metaType(), QMetaType(QMetaType::QByteArray));
QVERIFY(sv.canConvert<QUuid>());
- QCOMPARE(sv.value<QUuid>(), uuid);
+ QT_TEST_EQUALITY_OPS(sv.value<QUuid>(), uuid, true);
}
}
diff --git a/tests/auto/corelib/serialization/CMakeLists.txt b/tests/auto/corelib/serialization/CMakeLists.txt
index 45965114cc..96959ec8f0 100644
--- a/tests/auto/corelib/serialization/CMakeLists.txt
+++ b/tests/auto/corelib/serialization/CMakeLists.txt
@@ -2,10 +2,15 @@
# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(json)
+if (NOT WASM) # QTBUG-121822
add_subdirectory(qcborstreamreader)
+endif()
if(QT_FEATURE_cborstreamwriter)
+ if (NOT WASM) # QTBUG-121822
add_subdirectory(qcborstreamwriter)
+ endif()
endif()
+# also (but not only!) QTBUG-121822:
if(NOT WASM)
add_subdirectory(qcborvalue)
endif()
diff --git a/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt b/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt
index 29a935977b..af6aaf3eab 100644
--- a/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt
+++ b/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt
@@ -17,6 +17,10 @@ qt_internal_add_test(tst_qcborstreamreader
INCLUDE_DIRECTORIES
../../../../../src/3rdparty/tinycbor/src
../../../../../src/3rdparty/tinycbor/tests
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
LIBRARIES
Qt::CorePrivate
)
diff --git a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
index 63cfbce75f..05e3c7bc23 100644
--- a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
+++ b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
@@ -5,6 +5,10 @@
#include <QTest>
#include <QBuffer>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
class tst_QCborStreamReader : public QObject
{
Q_OBJECT
@@ -627,8 +631,6 @@ void tst_QCborStreamReader::strings_data()
void tst_QCborStreamReader::strings()
{
fixed();
- if (QTest::currentTestFailed())
- return;
// Extra string checks:
// We'll compare the reads using readString() and readByteArray()
@@ -814,9 +816,6 @@ void tst_QCborStreamReader::arrays()
removeIndicators(expected);
checkContainer(1, '\x81' + data, '[' + expected + ']');
- if (QTest::currentTestFailed())
- return;
-
checkContainer(2, '\x82' + data + data, '[' + expected + ", " + expected + ']');
}
@@ -828,19 +827,11 @@ void tst_QCborStreamReader::maps()
// int keys
checkContainer(1, "\xa1\1" + data, "{1: " + expected + '}');
- if (QTest::currentTestFailed())
- return;
-
checkContainer(2, "\xa2\1" + data + '\x20' + data,
"{1: " + expected + ", -1: " + expected + '}');
- if (QTest::currentTestFailed())
- return;
// string keys
checkContainer(1, "\xa1\x65Hello" + data, "{\"Hello\": " + expected + '}');
- if (QTest::currentTestFailed())
- return;
-
checkContainer(2, "\xa2\x65World" + data + "\x65Hello" + data,
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
}
@@ -852,9 +843,6 @@ void tst_QCborStreamReader::undefLengthArrays()
removeIndicators(expected);
checkContainer(-1, '\x9f' + data + '\xff', '[' + expected + ']');
- if (QTest::currentTestFailed())
- return;
-
checkContainer(-2, '\x9f' + data + data + '\xff', '[' + expected + ", " + expected + ']');
}
@@ -866,19 +854,11 @@ void tst_QCborStreamReader::undefLengthMaps()
// int keys
checkContainer(-1, "\xbf\1" + data + '\xff', "{1: " + expected + '}');
- if (QTest::currentTestFailed())
- return;
-
checkContainer(-2, "\xbf\1" + data + '\x20' + data + '\xff',
"{1: " + expected + ", -1: " + expected + '}');
- if (QTest::currentTestFailed())
- return;
// string keys
checkContainer(-1, "\xbf\x65Hello" + data + '\xff', "{\"Hello\": " + expected + '}');
- if (QTest::currentTestFailed())
- return;
-
checkContainer(-2, "\xbf\x65World" + data + "\x65Hello" + data + '\xff',
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
}
diff --git a/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt b/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt
index c1a9a87677..7b2428e027 100644
--- a/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt
+++ b/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt
@@ -16,4 +16,8 @@ qt_internal_add_test(tst_qcborstreamwriter
tst_qcborstreamwriter.cpp
INCLUDE_DIRECTORIES
../../../../../src/3rdparty/tinycbor/tests
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
)
diff --git a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp
index 45e241ef5c..a0ce4a93a6 100644
--- a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp
+++ b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp
@@ -5,6 +5,10 @@
#include <QCborStreamWriter>
#include <QBuffer>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
class tst_QCborStreamWriter : public QObject
{
Q_OBJECT
@@ -247,18 +251,10 @@ void tst_QCborStreamWriter::arrays()
QFETCH(QByteArray, output);
compare(make_list(input), "\x81" + output);
- if (QTest::currentTestFailed())
- return;
-
compare(make_list(input, input), "\x82" + output + output);
- if (QTest::currentTestFailed())
- return;
// nested lists
compare(make_list(make_list(input)), "\x81\x81" + output);
- if (QTest::currentTestFailed())
- return;
-
compare(make_list(make_list(input), make_list(input)), "\x82\x81" + output + "\x81" + output);
}
@@ -268,9 +264,6 @@ void tst_QCborStreamWriter::maps()
QFETCH(QByteArray, output);
compare(make_map({{1, input}}), "\xa1\1" + output);
- if (QTest::currentTestFailed())
- return;
-
compare(make_map({{1, input}, {input, 24}}), "\xa2\1" + output + output + "\x18\x18");
}
diff --git a/tests/auto/corelib/serialization/qcborvalue/CMakeLists.txt b/tests/auto/corelib/serialization/qcborvalue/CMakeLists.txt
index 4b72396489..089677aacb 100644
--- a/tests/auto/corelib/serialization/qcborvalue/CMakeLists.txt
+++ b/tests/auto/corelib/serialization/qcborvalue/CMakeLists.txt
@@ -17,6 +17,10 @@ qt_internal_add_test(tst_qcborvalue
INCLUDE_DIRECTORIES
../../../../../src/3rdparty/tinycbor/src
../../../../../src/3rdparty/tinycbor/tests/parser
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
LIBRARIES
Qt::CorePrivate
Qt::TestPrivate
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index e480b033e1..04d90bcf9d 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -14,6 +14,10 @@
#include <QtEndian>
#include <QTimeZone>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
Q_DECLARE_METATYPE(QCborKnownTags)
Q_DECLARE_METATYPE(QCborValue)
Q_DECLARE_METATYPE(QCborValue::EncodingOptions)
@@ -1348,8 +1352,6 @@ void tst_QCborValue::arrayValueRef()
};
iteratorCheck(a.begin());
- if (QTest::currentTestFailed())
- return;
iteratorCheck(a.constBegin());
}
@@ -1412,8 +1414,6 @@ void tst_QCborValue::mapValueRef()
};
iteratorCheck(m.begin());
- if (QTest::currentTestFailed())
- return;
iteratorCheck(m.constBegin());
}
@@ -2410,53 +2410,29 @@ void fromCbor_common(void (*doCheck)(const QCborValue &, const QByteArray &))
QFETCH(QByteArray, result);
doCheck(v, result);
- if (QTest::currentTestFailed())
- return;
// in an array
doCheck(QCborArray{v}, "\x81" + result);
- if (QTest::currentTestFailed())
- return;
-
doCheck(QCborArray{v, v}, "\x82" + result + result);
- if (QTest::currentTestFailed())
- return;
// in a map
doCheck(QCborMap{{1, v}}, "\xa1\1" + result);
- if (QTest::currentTestFailed())
- return;
// undefined-length arrays and maps
doCheck(QCborArray{v}, "\x9f" + result + "\xff");
- if (QTest::currentTestFailed())
- return;
doCheck(QCborArray{v, v}, "\x9f" + result + result + "\xff");
- if (QTest::currentTestFailed())
- return;
doCheck(QCborMap{{1, v}}, "\xbf\1" + result + "\xff");
- if (QTest::currentTestFailed())
- return;
// tagged
QCborValue t(QCborKnownTags::Signature, v);
doCheck(t, "\xd9\xd9\xf7" + result);
- if (QTest::currentTestFailed())
- return;
// in an array
doCheck(QCborArray{t}, "\x81\xd9\xd9\xf7" + result);
- if (QTest::currentTestFailed())
- return;
-
doCheck(QCborArray{t, t}, "\x82\xd9\xd9\xf7" + result + "\xd9\xd9\xf7" + result);
- if (QTest::currentTestFailed())
- return;
// in a map
doCheck(QCborMap{{1, t}}, "\xa1\1\xd9\xd9\xf7" + result);
- if (QTest::currentTestFailed())
- return;
}
void tst_QCborValue::fromCbor()
@@ -3116,14 +3092,9 @@ void tst_QCborValue::cborValueRefMutatingMapIntKey()
};
// accessing a negative index causes it to become a map
executeTest(-1);
- if (QTest::currentTestFailed())
- return;
// if the index is bigger than 0x10000, the array becomes a map
executeTest(0x10000);
- if (QTest::currentTestFailed())
- return;
-
if (type != QCborValue::Array)
executeTest(5);
}
diff --git a/tests/auto/corelib/text/CMakeLists.txt b/tests/auto/corelib/text/CMakeLists.txt
index 099f0e7eef..bee0c5cf44 100644
--- a/tests/auto/corelib/text/CMakeLists.txt
+++ b/tests/auto/corelib/text/CMakeLists.txt
@@ -1,7 +1,9 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if (NOT WASM) # QTBUG-121822
add_subdirectory(qanystringview)
+endif()
add_subdirectory(qbytearray)
add_subdirectory(qbytearray_large)
add_subdirectory(qbytearrayapisymmetry)
@@ -13,7 +15,9 @@ add_subdirectory(qchar)
add_subdirectory(qcollator)
add_subdirectory(qlatin1stringmatcher)
add_subdirectory(qlatin1stringview)
+if (NOT WASM) # QTBUG-121822
add_subdirectory(qregularexpression)
+endif()
add_subdirectory(qstring)
add_subdirectory(qstring_no_cast_from_bytearray)
add_subdirectory(qstringapisymmetry)
diff --git a/tests/auto/corelib/text/qanystringview/CMakeLists.txt b/tests/auto/corelib/text/qanystringview/CMakeLists.txt
index 96837dadf6..894115d1c2 100644
--- a/tests/auto/corelib/text/qanystringview/CMakeLists.txt
+++ b/tests/auto/corelib/text/qanystringview/CMakeLists.txt
@@ -14,6 +14,10 @@ endif()
qt_internal_add_test(tst_qanystringview
SOURCES
tst_qanystringview.cpp
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
LIBRARIES
Qt::CorePrivate
Qt::TestPrivate
diff --git a/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp b/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp
index 0eaadb870c..51ea3025ab 100644
--- a/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp
+++ b/tests/auto/corelib/text/qanystringview/tst_qanystringview.cpp
@@ -28,6 +28,10 @@
#include <deque>
#include <list>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
#ifdef __cpp_char8_t
# define ONLY_IF_CHAR_8_T(expr) expr
#else
@@ -356,6 +360,25 @@ private Q_SLOTS:
fromLiteral(u8"Hello, World!"); // char[] in <= C++17, char8_t[] in >= C++20
}
+ void fromChar() const { fromCharacter('\xE4', 1); }
+ void fromUChar() const { fromCharacter(static_cast<unsigned char>('\xE4'), 1); }
+ void fromSChar() const { fromCharacter(static_cast<signed char>('\xE4'), 1); }
+ void fromChar16T() const { fromCharacter(u'ä', 1); }
+ void fromUShort() const { fromCharacter(ushort(0xE4), 1); }
+ void fromChar32T() const {
+ fromCharacter(U'ä', 1);
+ fromCharacter(U'\x1F0A0', 2); // U+1F0A0: PLAYING CARD BACK
+ }
+ void fromWCharT() const {
+ ONLY_WIN(fromCharacter(L'ä', 1)); // should work on Unix, too (char32_t does)
+ }
+ void fromQChar() const { fromCharacter(QChar(u'ä'), 1); }
+ void fromQLatin1Char() const { fromCharacter(QLatin1Char('\xE4'), 1); }
+ void fromQCharSpecialCharacter() const {
+ fromCharacter(QChar::ReplacementCharacter, 1);
+ fromCharacter(QChar::LastValidCodePoint, 1);
+ }
+
void fromChar16TStar() const { fromLiteral(u"Hello, World!"); }
void fromWCharTStar() const { ONLY_WIN(fromLiteral(L"Hello, World!")); }
@@ -393,6 +416,8 @@ private:
template <typename Char>
void fromLiteral(const Char *arg) const;
template <typename Char>
+ void fromCharacter(Char arg, qsizetype expectedSize) const;
+ template <typename Char>
void fromRange() const;
template <typename Char, typename Container>
void fromContainer() const;
@@ -636,20 +661,10 @@ void tst_QAnyStringView::fromQStringOrByteArray() const
QVERIFY(!QAnyStringView(empty).isNull());
conversion_tests(QStringOrByteArray(Strings::oneChar));
- if (QTest::currentTestFailed())
- return;
conversion_tests(QStringOrByteArray(Strings::twoChars));
- if (QTest::currentTestFailed())
- return;
conversion_tests(QStringOrByteArray(Strings::threeChars));
- if (QTest::currentTestFailed())
- return;
conversion_tests(QStringOrByteArray(Strings::regularString));
- if (QTest::currentTestFailed())
- return;
conversion_tests(QStringOrByteArray(Strings::regularLongString));
- if (QTest::currentTestFailed())
- return;
conversion_tests(QStringOrByteArray(Strings::stringWithNulls, Strings::stringWithNullsLength));
}
@@ -673,6 +688,44 @@ void tst_QAnyStringView::fromLiteral(const Char *arg) const
conversion_tests(arg);
}
+template<typename Char>
+void tst_QAnyStringView::fromCharacter(Char arg, qsizetype expectedSize) const
+{
+ // Need to re-create a new QASV(arg) each time, QASV(Char).data() dangles
+ // after the end of the Full Expression:
+
+ static_assert(noexcept(QAnyStringView(arg)),
+ "If this fails, we may be creating a temporary QString/QByteArray");
+
+ QCOMPARE(QAnyStringView(arg).size(), expectedSize);
+
+ // QCOMPARE(QAnyStringView(arg), arg); // not all pairs compile, so do it manually:
+
+ // Check implicit conversion:
+ const QChar chars[] = {
+ [](QAnyStringView v) { return v.front(); }(arg),
+ [](QAnyStringView v) { return v.back(); }(arg),
+ };
+
+ switch (expectedSize) {
+ case 1:
+ if constexpr (std::is_same_v<Char, signed char>) // QChar doesn't have a ctor for this
+ QCOMPARE(chars[0], QChar(uchar(arg)));
+ else
+ QCOMPARE(chars[0], QChar(arg));
+ break;
+ case 2:
+ QCOMPARE_EQ(QAnyStringView(arg), QStringView::fromArray(chars));
+ if constexpr (std::is_convertible_v<Char, char32_t>)
+ QCOMPARE_EQ(QAnyStringView(arg), QStringView(QChar::fromUcs4(arg)));
+ break;
+ default:
+ QFAIL("Don't know how to compare this type to QAnyStringView");
+ }
+
+ // conversion_tests() would produce dangling references
+}
+
template <typename Char>
void tst_QAnyStringView::fromRange() const
{
@@ -697,18 +750,10 @@ void tst_QAnyStringView::fromRange() const
doTest(reinterpret_cast<const Char *>(std::begin(Strings::regularString)),
reinterpret_cast<const Char *>(std::end(Strings::regularString)));
- if (QTest::currentTestFailed())
- return;
-
doTest(reinterpret_cast<const Char *>(std::begin(Strings::regularLongString)),
reinterpret_cast<const Char *>(std::end(Strings::regularLongString)));
- if (QTest::currentTestFailed())
- return;
-
doTest(reinterpret_cast<const Char *>(std::begin(Strings::stringWithNulls)),
reinterpret_cast<const Char *>(std::end(Strings::stringWithNulls)));
- if (QTest::currentTestFailed())
- return;
}
template <typename Char, typename Container>
@@ -723,8 +768,6 @@ void tst_QAnyStringView::fromContainer() const
std::copy(s.begin(), s.end(), std::back_inserter(c));
conversion_tests(std::move(c));
- if (QTest::currentTestFailed())
- return;
// repeat with nulls
c = {};
diff --git a/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt b/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt
index c78a81c7bd..8922ae2267 100644
--- a/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt
+++ b/tests/auto/corelib/text/qbytearrayview/CMakeLists.txt
@@ -15,3 +15,10 @@ qt_internal_add_test(tst_qbytearrayview
SOURCES
tst_qbytearrayview.cpp
)
+
+if(QT_FEATURE_sanitize_undefined)
+ qt_internal_extend_target(tst_qbytearrayview
+ DEFINES
+ QT_SANITIZE_UNDEFINED # GCC (in)famously doesn't provide a predefined macro for this
+ )
+endif()
diff --git a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
index 894f0430dd..702e1840da 100644
--- a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
+++ b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
@@ -262,10 +262,9 @@ void tst_QByteArrayView::constExpr() const
static_assert(!bv2.empty());
static_assert(bv2.size() == 5);
}
-#if !defined(Q_CC_GNU) || defined(Q_CC_CLANG)
+#if !defined(Q_CC_GNU_ONLY) || !defined(QT_SANITIZE_UNDEFINED)
// Below checks are disabled because of a compilation issue with GCC and
// -fsanitize=undefined. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962.
- // Note: Q_CC_GNU is also defined for Clang, so we need to check that too.
{
static constexpr char hello[] = "Hello";
constexpr QByteArrayView bv(hello);
@@ -307,6 +306,9 @@ void tst_QByteArrayView::constExpr() const
static_assert(bv.back() == 'o');
static_assert(bv.last() == 'o');
+ constexpr auto bv2 = QByteArrayView::fromArray(hello);
+ QCOMPARE_EQ(bv, bv2);
+
constexpr std::string_view sv = bv;
static_assert(bv.size() == sv.size());
#ifdef AMBIGUOUS_CALL // QTBUG-108805
@@ -416,7 +418,7 @@ void tst_QByteArrayView::fromArray() const
{
static constexpr char hello[] = "Hello\0abc\0\0.";
- constexpr QByteArrayView bv = QByteArrayView::fromArray(hello);
+ const QByteArrayView bv = QByteArrayView::fromArray(hello);
QCOMPARE(bv.size(), 13);
QVERIFY(!bv.empty());
QVERIFY(!bv.isEmpty());
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index c9668cd4d4..eb2d73b9b2 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -4178,6 +4178,8 @@ void tst_QLocale::mySystemLocale()
qDebug("\n\t%s", qPrintable(QLocale::system().uiLanguages().join(u"\n\t")));
});
QCOMPARE(QLocale::system().uiLanguages(), uiLanguages);
+ QCOMPARE(QLocale::system().uiLanguages(QLocale::TagSeparator::Underscore),
+ uiLanguages.replaceInStrings(u"-", u"_"));
reporter.dismiss();
}
diff --git a/tests/auto/corelib/text/qregularexpression/CMakeLists.txt b/tests/auto/corelib/text/qregularexpression/CMakeLists.txt
index a7a7fe298f..2c67a16184 100644
--- a/tests/auto/corelib/text/qregularexpression/CMakeLists.txt
+++ b/tests/auto/corelib/text/qregularexpression/CMakeLists.txt
@@ -14,6 +14,10 @@ endif()
qt_internal_add_test(tst_qregularexpression
SOURCES
tst_qregularexpression.cpp
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
LIBRARIES
Qt::TestPrivate
)
diff --git a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp
index d0ce414095..53a6d83d50 100644
--- a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp
@@ -16,6 +16,10 @@
#include <iostream>
#include <optional>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
Q_DECLARE_METATYPE(QRegularExpression::PatternOptions)
Q_DECLARE_METATYPE(QRegularExpression::MatchType)
Q_DECLARE_METATYPE(QRegularExpression::MatchOptions)
@@ -292,11 +296,7 @@ void consistencyCheck(const QRegularExpressionMatchIterator &iterator)
QRegularExpressionMatch peeked = i.peekNext();
QRegularExpressionMatch match = i.next();
consistencyCheck(peeked);
- if (QTest::currentTestFailed())
- return;
consistencyCheck(match);
- if (QTest::currentTestFailed())
- return;
QVERIFY(match.isValid());
QVERIFY(match.hasMatch() || match.hasPartialMatch());
QCOMPARE(i.regularExpression(), match.regularExpression());
@@ -544,8 +544,6 @@ void tst_QRegularExpression::moveSemanticsMatch()
QCOMPARE(match2.capturedStart(), 3);
QCOMPARE(match2.capturedEnd(), 7);
consistencyCheck(match2);
- if (QTest::currentTestFailed())
- return;
QRegularExpressionMatch match3 = re.match("test1");
QCOMPARE(match3.hasMatch(), true);
@@ -558,8 +556,6 @@ void tst_QRegularExpression::moveSemanticsMatch()
QCOMPARE(match1.capturedStart(), 0);
QCOMPARE(match1.capturedEnd(), 4);
consistencyCheck(match1);
- if (QTest::currentTestFailed())
- return;
// here match3 is in the moved-from state, so destructor call for moved-from
// object is also checked
@@ -578,8 +574,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator()
QVERIFY(it2.hasNext());
QT_TEST_EQUALITY_OPS(it2.regularExpression(), re, true);
consistencyCheck(it2);
- if (QTest::currentTestFailed())
- return;
QRegularExpression re2("test");
QRegularExpressionMatchIterator it3 = re2.globalMatch("123test456");
@@ -593,8 +587,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator()
QVERIFY(it1.hasNext());
QT_TEST_EQUALITY_OPS(it1.regularExpression(), re2, true);
consistencyCheck(it1);
- if (QTest::currentTestFailed())
- return;
// here it3 is in the moved-from state, so destructor call for moved-from
// object is also checked
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index d56a9ebd20..92ea5b013d 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -6647,9 +6647,41 @@ void tst_QString::arg()
// number overloads
QCOMPARE( s4.arg(0), QLatin1String("[0]") );
QCOMPARE( s4.arg(-1), QLatin1String("[-1]") );
+ QCOMPARE( s4.arg(0U), QLatin1String("[0]"));
+ QCOMPARE( s4.arg(qint8(-128)), QLatin1String("[-128]")); // signed char
+ QCOMPARE( s4.arg(quint8(255)), QLatin1String("[255]")); // unsigned char
+ QCOMPARE( s4.arg(short(-4200)), QLatin1String("[-4200]"));
+ QCOMPARE( s4.arg(ushort(42000)), QLatin1String("[42000]"));
QCOMPARE( s4.arg(4294967295UL), QLatin1String("[4294967295]") ); // ULONG_MAX 32
QCOMPARE( s4.arg(Q_INT64_C(9223372036854775807)), // LLONG_MAX
QLatin1String("[9223372036854775807]") );
+ QCOMPARE( s4.arg(Q_UINT64_C(9223372036854775808)), // LLONG_MAX + 1
+ QLatin1String("[9223372036854775808]") );
+
+ // FP overloads
+ QCOMPARE(s4.arg(2.25), QLatin1String("[2.25]"));
+ QCOMPARE(s4.arg(3.75f), QLatin1String("[3.75]"));
+#if !QFLOAT16_IS_NATIVE // QTBUG-126055
+ QCOMPARE(s4.arg(qfloat16{4.125f}), QLatin1String("[4.125]"));
+#endif
+
+ // char-ish overloads
+ QCOMPARE(s4.arg('\xE4'), QStringView(u"[ä]"));
+ QEXPECT_FAIL("", "QTBUG-125588", Continue);
+ QCOMPARE(s4.arg(u'ø'), QStringView(u"[ø]"));
+#ifdef Q_OS_WIN
+ QCOMPARE(QLatin1String("[%1]").arg(L'ø'), QStringView(u"[ø]"));
+#endif
+ QEXPECT_FAIL("", "QTBUG-126054", Continue);
+ QCOMPARE(s4.arg(L'ø'), QStringView(u"[ø]"));
+#ifndef __cpp_char8_t
+#ifndef QT_NO_CAST_FROM_ASCII
+ QCOMPARE(QLatin1String("[%1]").arg(u8'a'), QLatin1String("[a]"));
+#endif
+#else
+ QEXPECT_FAIL("", "QTBUG-126053", Continue);
+#endif
+ QCOMPARE(s4.arg(u8'a'), QLatin1String("[a]"));
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: , foo");
QCOMPARE(QString().arg(foo), QString());
diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
index 35a734cf02..06ef1aede0 100644
--- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -545,6 +545,93 @@ private Q_SLOTS:
void endsWith_QLatin1String_QLatin1Char() { endsWith_impl<QLatin1String, QLatin1Char>(); }
private:
+ void arg1_data(bool argHasVariableLength = true) const;
+ template <typename Format, typename Argument> void arg1_impl() const;
+
+private Q_SLOTS:
+ // let Formats = {QString, QStringView, QLatin1String}
+ // let Arguments = Formats ∪ {QByteArray, const char*, const char8_t*. const char16_t*, std::u16string, char, QChar, QLatin1Char, char16_t}
+ // test Formats × Arguments:
+ void arg1_QString_QString_data() { arg1_data(); }
+ void arg1_QString_QString() { arg1_impl<QString, QString>(); }
+ void arg1_QString_QStringView_data() { arg1_data(); }
+ void arg1_QString_QStringView() { arg1_impl<QString, QStringView>(); }
+ void arg1_QString_QLatin1StringView_data() { arg1_data(); }
+ void arg1_QString_QLatin1StringView() { arg1_impl<QString, QLatin1StringView>(); }
+ void arg1_QString_QByteArray_data() { arg1_data(); }
+ void arg1_QString_QByteArray() { arg1_impl<QString, QByteArray>(); }
+ void arg1_QString_const_char_star_data() { arg1_data(); }
+ void arg1_QString_const_char_star() { arg1_impl<QString, const char*>(); }
+ void arg1_QString_const_char8_t_star_data() { arg1_data(); }
+ void arg1_QString_const_char8_t_star() { IF_CHAR8T((arg1_impl<QString, const char8_t*>())); }
+ void arg1_QString_const_char16_t_star_data() { arg1_data(); }
+ void arg1_QString_const_char16_t_star() { arg1_impl<QString, const char16_t*>(); }
+ void arg1_QString_stdu16string_data() { arg1_data(); }
+ void arg1_QString_stdu16string() { arg1_impl<QString, std::u16string>(); }
+ void arg1_QString_char_data() { arg1_data(false); }
+ void arg1_QString_char() { arg1_impl<QString, char>(); }
+ void arg1_QString_QChar_data() { arg1_data(false); }
+ void arg1_QString_QChar() { arg1_impl<QString, QChar>(); }
+ void arg1_QString_QLatin1Char_data() { arg1_data(false); }
+ void arg1_QString_QLatin1Char() { arg1_impl<QString, QLatin1Char>(); }
+ void arg1_QString_char16_t_data() { arg1_data(false); }
+ void arg1_QString_char16_t() {
+ QEXPECT_FAIL("%1/a", "QTBUG-125588", Continue);
+ QEXPECT_FAIL("%1/ä", "QTBUG-125588", Continue);
+ arg1_impl<QString, char16_t>();
+ }
+
+ void arg1_QStringView_QString_data() { arg1_data(); }
+ void arg1_QStringView_QString() { arg1_impl<QStringView, QString>(); }
+ void arg1_QStringView_QStringView_data() { arg1_data(); }
+ void arg1_QStringView_QStringView() { arg1_impl<QStringView, QStringView>(); }
+ void arg1_QStringView_QLatin1StringView_data() { arg1_data(); }
+ void arg1_QStringView_QLatin1StringView() { arg1_impl<QStringView, QLatin1StringView>(); }
+ void arg1_QStringView_QByteArray_data() { arg1_data(); }
+ void arg1_QStringView_QByteArray() { arg1_impl<QStringView, QByteArray>(); }
+ void arg1_QStringView_const_char_star_data() { arg1_data(); }
+ void arg1_QStringView_const_char_star() { arg1_impl<QStringView, const char*>(); }
+ void arg1_QStringView_const_char8_t_star_data() { arg1_data(); }
+ void arg1_QStringView_const_char8_t_star() { IF_CHAR8T((arg1_impl<QStringView, const char8_t*>())); }
+ void arg1_QStringView_const_char16_t_star_data() { arg1_data(); }
+ void arg1_QStringView_const_char16_t_star() { arg1_impl<QStringView, const char16_t*>(); }
+ void arg1_QStringView_stdu16string_data() { arg1_data(); }
+ void arg1_QStringView_stdu16string() { arg1_impl<QStringView, std::u16string>(); }
+ void arg1_QStringView_char_data() { arg1_data(false); }
+ void arg1_QStringView_char() { arg1_impl<QStringView, char>(); }
+ void arg1_QStringView_QChar_data() { arg1_data(false); }
+ void arg1_QStringView_QChar() { arg1_impl<QStringView, QChar>(); }
+ void arg1_QStringView_QLatin1Char_data() { arg1_data(false); }
+ void arg1_QStringView_QLatin1Char() { arg1_impl<QStringView, QLatin1Char>(); }
+ void arg1_QStringView_char16_t_data() { arg1_data(false); }
+ void arg1_QStringView_char16_t() { arg1_impl<QStringView, char16_t>(); }
+
+ void arg1_QLatin1StringView_QString_data() { arg1_data(); }
+ void arg1_QLatin1StringView_QString() { arg1_impl<QLatin1StringView, QString>(); }
+ void arg1_QLatin1StringView_QStringView_data() { arg1_data(); }
+ void arg1_QLatin1StringView_QStringView() { arg1_impl<QLatin1StringView, QStringView>(); }
+ void arg1_QLatin1StringView_QLatin1StringView_data() { arg1_data(); }
+ void arg1_QLatin1StringView_QLatin1StringView() { arg1_impl<QLatin1StringView, QLatin1StringView>(); }
+ void arg1_QLatin1StringView_QByteArray_data() { arg1_data(); }
+ void arg1_QLatin1StringView_QByteArray() { arg1_impl<QLatin1StringView, QByteArray>(); }
+ void arg1_QLatin1StringView_const_char_star_data() { arg1_data(); }
+ void arg1_QLatin1StringView_const_char_star() { arg1_impl<QLatin1StringView, const char*>(); }
+ void arg1_QLatin1StringView_const_char8_t_star_data() { arg1_data(); }
+ void arg1_QLatin1StringView_const_char8_t_star() { IF_CHAR8T((arg1_impl<QLatin1StringView, const char8_t*>())); }
+ void arg1_QLatin1StringView_const_char16_t_star_data() { arg1_data(); }
+ void arg1_QLatin1StringView_const_char16_t_star() { arg1_impl<QLatin1StringView, const char16_t*>(); }
+ void arg1_QLatin1StringView_stdu16string_data() { arg1_data(); }
+ void arg1_QLatin1StringView_stdu16string() { arg1_impl<QLatin1StringView, std::u16string>(); }
+ void arg1_QLatin1StringView_char_data() { arg1_data(false); }
+ void arg1_QLatin1StringView_char() { arg1_impl<QLatin1StringView, char>(); }
+ void arg1_QLatin1StringView_QChar_data() { arg1_data(false); }
+ void arg1_QLatin1StringView_QChar() { arg1_impl<QLatin1StringView, QChar>(); }
+ void arg1_QLatin1StringView_QLatin1Char_data() { arg1_data(false); }
+ void arg1_QLatin1StringView_QLatin1Char() { arg1_impl<QLatin1StringView, QLatin1Char>(); }
+ void arg1_QLatin1StringView_char16_t_data() { arg1_data(false); }
+ void arg1_QLatin1StringView_char16_t() { arg1_impl<QLatin1StringView, char16_t>(); }
+
+private:
void split_data(bool rhsHasVariableLength = true);
template <typename Haystack, typename Needle> void split_impl() const;
@@ -1112,6 +1199,10 @@ auto overload_s_v(QStringView s) { return s; }
auto overload_sr_v(QString &&s) { return std::move(s); }
auto overload_sr_v(QStringView s) { return s; }
+Q_WEAK_OVERLOAD
+auto overload_s_bav(const QString &s) { return s; }
+auto overload_s_bav(QByteArrayView s) { return s; }
+
} // unnamed namespace
template<typename T>
@@ -1174,6 +1265,15 @@ void tst_QStringApiSymmetry::overload()
overload_sr_v(CT());
}
}
+
+ if constexpr (std::is_convertible_v<T, QString> || std::is_convertible_v<T, QByteArrayView>) {
+ overload_s_bav(t);
+ overload_s_bav(ct);
+ if constexpr (!std::is_array_v<T>) {
+ overload_s_bav(T());
+ overload_s_bav(CT());
+ }
+ }
QT_WARNING_POP
}
@@ -1290,6 +1390,7 @@ template <class Str> Str make(QStringView sf, QLatin1String l1, const QByteArra
[[maybe_unused]] const QByteArray &u8) \
/*end*/
MAKE(QChar) { return sv.isEmpty() ? QChar() : sv.at(0); }
+MAKE(char) { return sv.isEmpty() ? char() : char(sv.at(0).unicode()); }
MAKE(char16_t) { return sv.isEmpty() ? char16_t() : char16_t{sv.at(0).unicode()}; }
MAKE(QLatin1Char) { return l1.isEmpty() ? QLatin1Char('\0') : l1.at(0); }
MAKE(QString) { return sv.toString(); }
@@ -1298,6 +1399,9 @@ MAKE(QLatin1String) { return l1; }
MAKE(QByteArray) { return u8; }
MAKE(QByteArrayView) { return u8; }
MAKE(const char *) { return u8.data(); }
+#ifdef __cpp_char8_t
+MAKE(const char8_t *) { return q_has_char8_t::QUtf8StringView(u8).data(); }
+#endif
MAKE(const char16_t *) { return sv.utf16(); } // assumes `sv` doesn't represent a substring
MAKE(std::u16string) { return sv.toString().toStdU16String(); }
MAKE(QUtf8StringView) { return u8; }
@@ -1926,6 +2030,69 @@ void tst_QStringApiSymmetry::endsWith_impl() const
QCOMPARE_EQ(haystack.endsWith(needle, Qt::CaseInsensitive), resultCIS);
}
+void tst_QStringApiSymmetry::arg1_data(bool argHasVariableLength) const
+{
+ QTest::addColumn<QString>("formatU16");
+ QTest::addColumn<QString>("argumentU16");
+ QTest::addColumn<QString>("expected");
+
+ const char *null = nullptr;
+ const char *empty = "";
+
+ auto row = [](const char *fmt, const char *arg, const char *res) {
+ auto protect = [](const char *s) { return s ? *s ? s : "<empty>" : "<null>"; };
+ QTest::addRow("%s/%s", protect(fmt), protect(arg))
+ << QString::fromUtf8(fmt) << QString::fromUtf8(arg) << QString::fromUtf8(res);
+ };
+
+ for (auto fmt : {null, empty}) {
+ if (argHasVariableLength) {
+ for (auto arg : {null, empty})
+ row(fmt, arg, "");
+ }
+ for (auto arg : {"a", "ä"})
+ row(fmt, arg, "");
+ if (argHasVariableLength) {
+ for (auto arg : {"äá", "Øåß"})
+ row(fmt, arg, "");
+ }
+ }
+
+ for (auto fmt : {"%1"}) {
+ if (argHasVariableLength) {
+ for (auto arg : {null, empty})
+ row(fmt, arg, arg);
+ }
+ for (auto arg : {"a", "ä"})
+ row(fmt, arg, arg);
+ if (argHasVariableLength) {
+ for (auto arg : {"äá", "Øåß"})
+ row(fmt, arg, arg);
+ }
+ }
+}
+
+template <typename Format, typename Argument>
+void tst_QStringApiSymmetry::arg1_impl() const
+{
+ QFETCH(const QString, formatU16);
+ QFETCH(const QString, argumentU16);
+ QFETCH(const QString, expected);
+
+ const auto formatL1Pinned = formatU16.toLatin1();
+ const auto formatL1 = QLatin1StringView{formatL1Pinned};
+ const auto formatU8 = formatU16.toUtf8();
+
+ const auto argumentL1Pinned = argumentU16.toLatin1();
+ const auto argumentL1= QLatin1StringView{argumentL1Pinned};
+ const auto argumentU8 = argumentU16.toUtf8();
+
+ const auto format = make<Format>(formatU16, formatL1, formatU8);
+ const auto argument = make<Argument>(argumentU16, argumentL1, argumentU8);
+
+ QCOMPARE(format.arg(argument), expected);
+}
+
void tst_QStringApiSymmetry::split_data(bool rhsHasVariableLength)
{
QTest::addColumn<QStringView>("haystackU16");
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 59362d010a..7931363b4b 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -377,6 +377,8 @@ void runScenario()
char chararray[3] = { 'H', 'i', '\0' };
const char constchararray[3] = { 'H', 'i', '\0' };
char achar = 'a';
+ char embedded_NULs[16] = { 'H', 'i' };
+ const char const_embedded_NULs[16] = { 'H', 'i' };
CHECK(P, bytearray, bytearray);
CHECK(P, QByteArray(bytearray), bytearray);
@@ -400,6 +402,33 @@ void runScenario()
CHECK(P, bytearray, achar);
CHECK(Q, bytearray, constchararray);
CHECK(Q, bytearray, achar);
+ CHECK(Q, bytearray, embedded_NULs);
+ CHECK(Q, bytearray, const_embedded_NULs);
+
+ CHECK(Q, baview, bytearray);
+ CHECK(Q, baview, charstar);
+ CHECK(Q, baview, chararray);
+ CHECK(Q, baview, constchararray);
+ CHECK(Q, baview, achar);
+ CHECK(Q, baview, embedded_NULs);
+ CHECK(Q, baview, const_embedded_NULs);
+
+ // Check QString/QByteArray consistency when appending const char[] with embedded NULs:
+ {
+ const QByteArray ba = baview Q embedded_NULs;
+ QEXPECT_FAIL("", "QTBUG-117321", Continue);
+ QCOMPARE(ba.size(), baview.size() + q20::ssize(embedded_NULs) - 1);
+
+#ifndef QT_NO_CAST_FROM_ASCII
+ const auto l1s = QLatin1StringView{baview}; // l1string != baview
+
+ const QString s = l1s Q embedded_NULs;
+ QCOMPARE(s.size(), l1s.size() + q20::ssize(embedded_NULs) - 1);
+
+ QEXPECT_FAIL("", "QTBUG-117321", Continue);
+ QCOMPARE(s, ba);
+#endif
+ }
//CHECK(Q, charstar, charstar); // BUILTIN <-> BUILTIN cat't be overloaded
//CHECK(Q, charstar, chararray);
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp
index 394372c398..e8365f500b 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp
@@ -15,6 +15,8 @@
#include <QtCore/QStringBuilder>
#include <QtTest/QTest>
+#include <QtCore/q20iterator.h>
+
#define LITERAL "some literal"
namespace {
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp
index dc590304f5..1aaee114a3 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp
@@ -16,6 +16,8 @@
#include <QtCore/QStringBuilder>
#include <QtTest/QTest>
+#include <QtCore/q20iterator.h>
+
#define LITERAL "some literal"
namespace {
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp
index 3222b52713..aaa14a5d1a 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp
@@ -15,6 +15,8 @@
#include <QtCore/QStringBuilder>
#include <QtTest/QTest>
+#include <QtCore/q20iterator.h>
+
#define LITERAL "some literal"
namespace {
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp
index 442c5275d2..319708fd4b 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp
@@ -16,6 +16,8 @@
#include <QtCore/QStringBuilder>
#include <QtTest/QTest>
+#include <QtCore/q20iterator.h>
+
#define LITERAL "some literal"
namespace {
diff --git a/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp b/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp
index ed3f91ac94..342c343a42 100644
--- a/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp
+++ b/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp
@@ -257,7 +257,7 @@ void tst_QStringConverter::invalidConverter()
QVERIFY(!encoder.hasError());
char buffer[100];
char *position = encoder.appendToBuffer(buffer, u"Even more");
- QCOMPARE(position, buffer);
+ QCOMPARE(position - buffer, 0);
QVERIFY(encoder.hasError());
}
@@ -283,7 +283,7 @@ void tst_QStringConverter::invalidConverter()
QVERIFY(!decoder.hasError());
char16_t buffer[100];
char16_t *position = decoder.appendToBuffer(buffer, "Even more");
- QCOMPARE(position, buffer);
+ QCOMPARE(position - buffer, 0);
QVERIFY(decoder.hasError());
}
}
diff --git a/tests/auto/corelib/text/qstringview/CMakeLists.txt b/tests/auto/corelib/text/qstringview/CMakeLists.txt
index ba5f540838..b541cdd0ed 100644
--- a/tests/auto/corelib/text/qstringview/CMakeLists.txt
+++ b/tests/auto/corelib/text/qstringview/CMakeLists.txt
@@ -18,5 +18,12 @@ qt_internal_add_test(tst_qstringview
Qt::CorePrivate
)
+if(QT_FEATURE_sanitize_undefined)
+ qt_internal_extend_target(tst_qstringview
+ DEFINES
+ QT_SANITIZE_UNDEFINED # GCC (in)famously doesn't provide a predefined macro for this
+ )
+endif()
+
## Scopes:
#####################################################################
diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
index df3ef94371..3f87ffc9fc 100644
--- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
+++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
@@ -359,6 +359,30 @@ void tst_QStringView::constExpr() const
static_assert(sv3.isEmpty());
static_assert(sv3.size() == 0);
}
+#if !defined(Q_CC_GNU_ONLY) || !defined(QT_SANITIZE_UNDEFINED)
+ // Below checks are disabled because of a compilation issue with GCC and
+ // -fsanitize=undefined. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962.
+ {
+ static constexpr char16_t hello[] = u"Hello";
+ constexpr QStringView sv(hello);
+ static_assert(sv.size() == 5);
+ static_assert(!sv.empty());
+ static_assert(!sv.isEmpty());
+ static_assert(!sv.isNull());
+ static_assert(*sv.utf16() == 'H');
+ static_assert(sv[0] == QLatin1Char('H'));
+ static_assert(sv.at(0) == QLatin1Char('H'));
+ static_assert(sv.front() == QLatin1Char('H'));
+ static_assert(sv.first() == QLatin1Char('H'));
+ static_assert(sv[4] == QLatin1Char('o'));
+ static_assert(sv.at(4) == QLatin1Char('o'));
+ static_assert(sv.back() == QLatin1Char('o'));
+ static_assert(sv.last() == QLatin1Char('o'));
+
+ constexpr auto sv2 = QStringView::fromArray(hello);
+ QCOMPARE_EQ(sv, sv2.chopped(1));
+ }
+#endif // -fsanitize=undefined
}
void tst_QStringView::basics() const
@@ -430,7 +454,7 @@ void tst_QStringView::fromArray() const
{
static constexpr char16_t hello[] = u"Hello\0abc\0\0.";
- constexpr QStringView sv = QStringView::fromArray(hello);
+ const QStringView sv = QStringView::fromArray(hello);
QCOMPARE(sv.size(), 13);
QVERIFY(!sv.empty());
QVERIFY(!sv.isEmpty());
diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
index 4cb29c514a..8a6ac6a61d 100644
--- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
+++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
@@ -4632,6 +4632,9 @@ void testWhenAllDifferentTypes()
void tst_QFuture::whenAllDifferentTypes()
{
+#ifdef Q_OS_VXWORKS
+ QSKIP("std::variant implementation on VxWorks 24.03 is broken and doesn't work with duplicated types");
+#endif
using Futures = std::variant<QFuture<int>, QFuture<int>, QFuture<void>>;
testWhenAllDifferentTypes<QList<Futures>>();
if (QTest::currentTestFailed())
@@ -4841,6 +4844,9 @@ void tst_QFuture::whenAnyIteratorsWithFailed()
void tst_QFuture::whenAnyDifferentTypes()
{
+#ifdef Q_OS_VXWORKS
+ QSKIP("std::variant implementation on VxWorks 24.03 is broken and doesn't work with duplicated types");
+#endif
QPromise<int> pInt1;
QPromise<int> pInt2;
QPromise<void> pVoid;
diff --git a/tests/auto/corelib/thread/qresultstore/CMakeLists.txt b/tests/auto/corelib/thread/qresultstore/CMakeLists.txt
index 0f9d8d9e52..5abfc14ac6 100644
--- a/tests/auto/corelib/thread/qresultstore/CMakeLists.txt
+++ b/tests/auto/corelib/thread/qresultstore/CMakeLists.txt
@@ -16,4 +16,5 @@ qt_internal_add_test(tst_qresultstore
tst_qresultstore.cpp
LIBRARIES
Qt::CorePrivate
+ Qt::TestPrivate
)
diff --git a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp
index 265b2cd1f6..722184a72a 100644
--- a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp
+++ b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
-
+#include <QtTest/private/qcomparisontesthelper_p.h>
#include <qresultstore.h>
using namespace QtPrivate;
@@ -23,6 +23,7 @@ class tst_QtConcurrentResultStore : public QObject
public slots:
void init();
private slots:
+ void compareCompiles();
void construction();
void iterators();
void addResult();
@@ -52,6 +53,11 @@ void tst_QtConcurrentResultStore::init()
vec1 = QList<int> { 4, 5 };
}
+void tst_QtConcurrentResultStore::compareCompiles()
+{
+ QTestPrivate::testEqualityOperatorsCompile<ResultIteratorBase>();
+}
+
void tst_QtConcurrentResultStore::construction()
{
ResultStoreBase store;
@@ -74,17 +80,20 @@ void tst_QtConcurrentResultStore::iterators()
storebase.addResult(1, &int1); // ResultStoreBase does not take ownership, only ResultStore<> does.
ResultIteratorBase it = storebase.begin();
QCOMPARE(it.resultIndex(), 0);
- QCOMPARE(it, storebase.begin());
+ QT_TEST_EQUALITY_OPS(it, storebase.begin(), true);
QVERIFY(it != storebase.end());
++it;
QCOMPARE(it.resultIndex(), 1);
QVERIFY(it != storebase.begin());
QVERIFY(it != storebase.end());
+ QT_TEST_EQUALITY_OPS(it, storebase.begin(), false);
+ QT_TEST_EQUALITY_OPS(it, storebase.end(), false);
++it;
QVERIFY(it != storebase.begin());
QCOMPARE(it, storebase.end());
+ QT_TEST_EQUALITY_OPS(it, storebase.end(), true);
}
}
@@ -147,8 +156,8 @@ void tst_QtConcurrentResultStore::addResults()
store.addResults(-1, &vec1);
ResultIteratorBase it = store.begin();
QCOMPARE(it.resultIndex(), 0);
- QCOMPARE(it, store.begin());
- QVERIFY(it != store.end());
+ QT_TEST_EQUALITY_OPS(it, store.begin(), true);
+ QT_TEST_EQUALITY_OPS(it, store.end(), false);
++it;
QCOMPARE(it.resultIndex(), 1);
@@ -162,7 +171,7 @@ void tst_QtConcurrentResultStore::addResults()
QCOMPARE(it.resultIndex(), 3);
++it;
- QCOMPARE(it, store.end());
+ QT_TEST_EQUALITY_OPS(it, store.end(), true);
QList<int> empty;
const auto countBefore = store.count();
@@ -184,22 +193,22 @@ void tst_QtConcurrentResultStore::resultIndex()
ResultIteratorBase it = store.begin();
QCOMPARE(it.resultIndex(), 0);
- QVERIFY(it == store.begin());
- QVERIFY(it != store.end());
+ QT_TEST_EQUALITY_OPS(it, store.begin(), true);
+ QT_TEST_EQUALITY_OPS(it, store.end(), false);
++it;
QCOMPARE(it.resultIndex(), 1);
- QVERIFY(it != store.begin());
- QVERIFY(it != store.end());
+ QT_TEST_EQUALITY_OPS(it, store.begin(), false);
+ QT_TEST_EQUALITY_OPS(it, store.end(), false);
++it;
QCOMPARE(it.resultIndex(), 2);
- QVERIFY(it != store.end());
+ QT_TEST_EQUALITY_OPS(it, store.end(), false);
++it;
QCOMPARE(it.resultIndex(), 3);
- QVERIFY(it != store.end());
+ QT_TEST_EQUALITY_OPS(it, store.end(), false);
++it;
- QVERIFY(it == store.end());
+ QT_TEST_EQUALITY_OPS(it, store.end(), true);
QCOMPARE(store.resultAt(0).value<int>(), int0);
QCOMPARE(store.resultAt(1).value<int>(), vec0[0]);
diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
index d2e8f63f24..e71f32a3ca 100644
--- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
@@ -7,6 +7,7 @@
#include <private/qcomparisontesthelper_p.h>
#include <qlocale.h>
+#include <qscopeguard.h>
#if defined(Q_OS_WIN)
#include <QOperatingSystemVersion>
@@ -16,6 +17,8 @@
# define USING_WIN_TZ
#endif
+using namespace Qt::StringLiterals;
+
class tst_QTimeZone : public QObject
{
Q_OBJECT
@@ -38,6 +41,8 @@ private Q_SLOTS:
void availableTimeZoneIds();
void utcOffsetId_data();
void utcOffsetId();
+ void aliasMatches_data();
+ void aliasMatches();
void specificTransition_data();
void specificTransition();
void transitionEachZone_data();
@@ -558,9 +563,12 @@ void tst_QTimeZone::isTimeZoneIdAvailable()
const QList<QByteArray> available = QTimeZone::availableTimeZoneIds();
for (const QByteArray &id : available) {
QVERIFY2(QTimeZone::isTimeZoneIdAvailable(id), id);
- QVERIFY2(QTimeZone(id).isValid(), id);
- QCOMPARE(QTimeZone(id).id(), id);
+ const QTimeZone zone(id);
+ QVERIFY2(zone.isValid(), id);
+ QVERIFY2(zone.aliasMatches(id), zone.id() + " != " + id);
}
+ // availableTimeZoneIds() doesn't list all possible offset IDs, but
+ // isTimeZoneIdAvailable() should accept them.
for (qint32 offset = QTimeZone::MinUtcOffsetSecs;
offset <= QTimeZone::MinUtcOffsetSecs; ++offset) {
const QByteArray id = QTimeZone(offset).id();
@@ -700,6 +708,58 @@ void tst_QTimeZone::utcOffsetId()
}
}
+void tst_QTimeZone::aliasMatches_data()
+{
+ QTest::addColumn<QByteArray>("iana");
+ QTest::addColumn<QByteArray>("alias");
+
+ QTest::newRow("Montreal=Toronto") << "America/Toronto"_ba << "America/Montreal"_ba;
+ QTest::newRow("Asmera=Asmara") << "Africa/Asmara"_ba << "Africa/Asmera"_ba;
+ QTest::newRow("Argentina/Catamarca")
+ << "America/Argentina/Catamarca"_ba << "America/Catamarca"_ba;
+ QTest::newRow("Godthab=Nuuk") << "America/Nuuk"_ba << "America/Godthab"_ba;
+ QTest::newRow("Indiana/Indianapolis")
+ << "America/Indiana/Indianapolis"_ba << "America/Indianapolis"_ba;
+ QTest::newRow("Kentucky/Louisville")
+ << "America/Kentucky/Louisville"_ba << "America/Louisville"_ba;
+ QTest::newRow("Calcutta=Kolkata") << "Asia/Kolkata"_ba << "Asia/Calcutta"_ba;
+ QTest::newRow("Katmandu=Kathmandu") << "Asia/Kathmandu"_ba << "Asia/Katmandu"_ba;
+ QTest::newRow("Rangoon=Yangon") << "Asia/Yangon"_ba << "Asia/Rangoon"_ba;
+ QTest::newRow("Saigon=Ho_Chi_Minh") << "Asia/Ho_Chi_Minh"_ba << "Asia/Saigon"_ba;
+ QTest::newRow("Faeroe=Faroe") << "Atlantic/Faroe"_ba << "Atlantic/Faeroe"_ba;
+ QTest::newRow("Currie=Hobart") << "Australia/Hobart"_ba << "Australia/Currie"_ba;
+ QTest::newRow("Kiev=Kyiv") << "Europe/Kyiv"_ba << "Europe/Kiev"_ba;
+ QTest::newRow("Uzhgorod=Kyiv") << "Europe/Kyiv"_ba << "Europe/Uzhgorod"_ba;
+ QTest::newRow("Zaporozhye=Kyiv") << "Europe/Kyiv"_ba << "Europe/Zaporozhye"_ba;
+ QTest::newRow("Fiji=Fiji") << "Pacific/Fiji"_ba << "Pacific/Fiji"_ba;
+ QTest::newRow("Enderbury=Enderbury") << "Pacific/Enderbury"_ba << "Pacific/Enderbury"_ba;
+}
+
+void tst_QTimeZone::aliasMatches()
+{
+ QFETCH(const QByteArray, iana);
+ QFETCH(const QByteArray, alias);
+ const QTimeZone zone(iana);
+ const QTimeZone peer(alias);
+ if (!zone.isValid())
+ QSKIP("Backend doesn't support IANA ID");
+
+ auto report = qScopeGuard([zone, peer]() {
+ const QByteArray zid = zone.id(), pid = peer.id();
+ qDebug("Using %s and %s", zid.constData(), pid.constData());
+ });
+ QVERIFY2(peer.isValid(), "Construction should have fallen back on IANA ID");
+ QVERIFY(zone.aliasMatches(zone.id()));
+ QVERIFY(zone.aliasMatches(iana));
+ QVERIFY(peer.aliasMatches(peer.id()));
+ QVERIFY(peer.aliasMatches(alias));
+ QVERIFY(zone.aliasMatches(peer.id()));
+ QVERIFY(zone.aliasMatches(alias));
+ QVERIFY(peer.aliasMatches(zone.id()));
+ QVERIFY(peer.aliasMatches(iana));
+ report.dismiss();
+}
+
void tst_QTimeZone::specificTransition_data()
{
QTest::addColumn<QByteArray>("zone");
@@ -924,7 +984,7 @@ void tst_QTimeZone::stressTest()
for (const QByteArray &id : idList) {
QTimeZone testZone = QTimeZone(id);
QCOMPARE(testZone.isValid(), true);
- QCOMPARE(testZone.id(), id);
+ QVERIFY2(testZone.aliasMatches(id), testZone.id() + " != " + id);
QDateTime testDate = QDateTime(QDate(2015, 1, 1), QTime(0, 0), UTC);
testZone.territory();
testZone.comment();
@@ -972,7 +1032,7 @@ void tst_QTimeZone::windowsId()
Current Windows zones for "Central Standard Time":
Region IANA Id(s)
Default "America/Chicago"
- Canada "America/Winnipeg America/Rainy_River America/Rankin_Inlet America/Resolute"
+ Canada "America/Winnipeg America/Rankin_Inlet America/Resolute"
Mexico "America/Matamoros"
USA "America/Chicago America/Indiana/Knox America/Indiana/Tell_City America/Menominee"
"America/North_Dakota/Beulah America/North_Dakota/Center"
@@ -1004,8 +1064,8 @@ void tst_QTimeZone::windowsId()
"America/Chicago", "America/Indiana/Knox", "America/Indiana/Tell_City",
"America/Matamoros", "America/Menominee", "America/North_Dakota/Beulah",
"America/North_Dakota/Center", "America/North_Dakota/New_Salem",
- "America/Ojinaga", "America/Rainy_River", "America/Rankin_Inlet",
- "America/Resolute", "America/Winnipeg", "CST6CDT"
+ "America/Ojinaga", "America/Rankin_Inlet", "America/Resolute",
+ "America/Winnipeg", "CST6CDT"
};
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time"), list);
}
@@ -1018,7 +1078,7 @@ void tst_QTimeZone::windowsId()
{
// Check valid country returns list in preference order
const QList<QByteArray> list = {
- "America/Winnipeg", "America/Rainy_River", "America/Rankin_Inlet", "America/Resolute"
+ "America/Winnipeg", "America/Rankin_Inlet", "America/Resolute"
};
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Canada), list);
}
@@ -1280,7 +1340,7 @@ void tst_QTimeZone::utcTest()
void tst_QTimeZone::icuTest()
{
-#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(icu)
+#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(icu) && !defined(Q_OS_UNIX)
// Known datetimes
qint64 std = QDateTime(QDate(2012, 1, 1), QTime(0, 0), QTimeZone::UTC).toMSecsSinceEpoch();
qint64 dst = QDateTime(QDate(2012, 6, 1), QTime(0, 0), QTimeZone::UTC).toMSecsSinceEpoch();
@@ -1323,7 +1383,7 @@ void tst_QTimeZone::icuTest()
if (QTest::currentTestFailed())
return;
testEpochTranPrivate(QIcuTimeZonePrivate("America/Toronto"));
-#endif // icu
+#endif // ICU not on Unix
}
void tst_QTimeZone::tzTest()
@@ -1527,7 +1587,7 @@ void tst_QTimeZone::tzTest()
QDateTime dt(QDate(2016, 3, 28), QTime(0, 0), UTC);
QCOMPARE(tzBarnaul.data(dt.toMSecsSinceEpoch()).abbreviation, QString("+07"));
}
-#endif // QT_BUILD_INTERNAL && Q_OS_UNIX && !Q_OS_DARWIN
+#endif // QT_BUILD_INTERNAL && Q_OS_UNIX && !Q_OS_DARWIN && !Q_OS_ANDROID
}
void tst_QTimeZone::macTest()
@@ -1685,6 +1745,8 @@ void tst_QTimeZone::localeSpecificDisplayName()
QVERIFY(zone.isValid());
const QString localeName = zone.displayName(timeType, QTimeZone::LongName, locale);
+ if (localeName.isEmpty()) // Backend doesn't know how to localize this zone's name
+ QEXPECT_FAIL("", "QTBUG-115158 zone name localization unknown", Continue);
QCOMPARE(localeName, expectedName);
}
@@ -1857,18 +1919,10 @@ void tst_QTimeZone::stdCompatibility()
QFETCH(const std::chrono::time_zone *, timeZone);
QByteArrayView zoneName = QByteArrayView(timeZone->name());
QTimeZone tz = QTimeZone::fromStdTimeZonePtr(timeZone);
- if (tz.isValid()) {
- QCOMPARE(tz.id(), zoneName);
- } else {
- // QTBUG-102187: a few timezones reported by tzdb might not be
- // recognized by QTimeZone. This happens for instance on Windows, where
- // tzdb is using ICU, whose database does not match QTimeZone's.
- const bool isKnownUnknown =
- !zoneName.contains('/')
- || zoneName == "Antarctica/Troll"
- || zoneName.startsWith("SystemV/");
- QVERIFY(isKnownUnknown);
- }
+ if (tz.isValid())
+ QVERIFY2(tz.aliasMatches(zoneName), tz.id().constData());
+ else
+ QVERIFY(!QTimeZone::isTimeZoneIdAvailable(zoneName.toByteArray()));
#else
QSKIP("This test requires C++20's <chrono>.");
#endif
diff --git a/tests/auto/corelib/tools/CMakeLists.txt b/tests/auto/corelib/tools/CMakeLists.txt
index 5cca2e2df6..5d4d4e9998 100644
--- a/tests/auto/corelib/tools/CMakeLists.txt
+++ b/tests/auto/corelib/tools/CMakeLists.txt
@@ -47,7 +47,9 @@ add_subdirectory(qset)
add_subdirectory(qsharedpointer)
add_subdirectory(qsize)
add_subdirectory(qsizef)
+if (NOT WASM) # QTBUG-121822
add_subdirectory(qspan)
+endif()
add_subdirectory(qstl)
add_subdirectory(quniquehandle)
add_subdirectory(qvarlengtharray)
diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
index f52a368aa9..4281d93179 100644
--- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
+++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
@@ -375,6 +375,13 @@ void tst_QBitArray::operator_andeq_data()
<< QStringToQBitArray(QString());
}
+#define COMPARE_BITARRAY_EQ(actual, expected) do { \
+ QT_TEST_EQUALITY_OPS(actual, expected, true); \
+ QCOMPARE(actual.count(), expected.count()); \
+ QCOMPARE(actual.count(true), expected.count(true)); \
+ QCOMPARE(actual.count(false), expected.count(false)); \
+ } while (false)
+
void tst_QBitArray::operator_andeq()
{
QFETCH(QBitArray, input1);
@@ -383,32 +390,32 @@ void tst_QBitArray::operator_andeq()
QBitArray result = input1;
result &= input2;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1;
result &= std::move(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1;
result &= detached(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is commutative
result = input2;
result &= input1;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2;
result &= std::move(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2;
result &= detached(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is idempotent
result &= result;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result &= std::move(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result &= detached(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
}
void tst_QBitArray::operator_and()
@@ -418,27 +425,27 @@ void tst_QBitArray::operator_and()
QFETCH(QBitArray, res);
QBitArray result = input1 & input2;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1 & QBitArray(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1 & detached(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is commutative
result = input2 & input1;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2 & QBitArray(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2 & detached(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is idempotent
result = result & result;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = result & QBitArray(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = result & detached(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
}
void tst_QBitArray::operator_oreq_data()
@@ -489,32 +496,32 @@ void tst_QBitArray::operator_oreq()
QBitArray result = input1;
result |= input2;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1;
result |= QBitArray(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1;
result |= detached(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is commutative
result = input2;
result |= input1;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2;
result |= QBitArray(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2;
result |= detached(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is idempotent
result |= result;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result |= QBitArray(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result |= detached(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
}
void tst_QBitArray::operator_or()
@@ -524,27 +531,27 @@ void tst_QBitArray::operator_or()
QFETCH(QBitArray, res);
QBitArray result = input1 | input2;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1 | QBitArray(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1 | detached(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is commutative
result = input2 | input1;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2 | QBitArray(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2 | detached(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is idempotent
result = result | result;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = result | QBitArray(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = result | detached(result);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
}
void tst_QBitArray::operator_xoreq_data()
@@ -593,24 +600,24 @@ void tst_QBitArray::operator_xoreq()
QBitArray result = input1;
result ^= input2;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1;
result ^= QBitArray(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1;
result ^= detached(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is commutative
result = input2;
result ^= input1;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2;
result ^= QBitArray(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2;
result ^= detached(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// XORing with oneself is nilpotent
result = input1;
@@ -651,19 +658,19 @@ void tst_QBitArray::operator_xor()
QFETCH(QBitArray, res);
QBitArray result = input1 ^ input2;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1 ^ QBitArray(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input1 ^ detached(input2);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// operation is commutative
result = input2 ^ input1;
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2 ^ QBitArray(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
result = input2 ^ detached(input1);
- QT_TEST_EQUALITY_OPS(result, res, true);
+ COMPARE_BITARRAY_EQ(result, res);
// XORing with oneself is nilpotent
result = input1 ^ input1;
@@ -734,7 +741,7 @@ void tst_QBitArray::operator_neg()
input = ~input;
- QT_TEST_EQUALITY_OPS(input, res, true);
+ COMPARE_BITARRAY_EQ(input, res);
QT_TEST_EQUALITY_OPS(~~input, res, true); // performs two in-place negations
}
@@ -795,9 +802,9 @@ void tst_QBitArray::datastream()
QCOMPARE(array1.count(true), onBits);
QCOMPARE(array1.count(false), numBits - onBits);
- QT_TEST_EQUALITY_OPS(array1, bits, true);
- QT_TEST_EQUALITY_OPS(array2, bits, true);
- QT_TEST_EQUALITY_OPS(array3, bits, true);
+ COMPARE_BITARRAY_EQ(array1, bits);
+ COMPARE_BITARRAY_EQ(array2, bits);
+ COMPARE_BITARRAY_EQ(array3, bits);
}
void tst_QBitArray::invertOnNull() const
diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
index c08afd67c4..47e0ead270 100644
--- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
+++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
@@ -20,6 +20,8 @@ private slots:
void repeated_result();
void intermediary_result_data();
void intermediary_result();
+ void static_hash_data() { intermediary_result_data(); }
+ void static_hash();
void sha1();
void sha3_data();
void sha3();
@@ -29,9 +31,9 @@ private slots:
void blake2();
void files_data();
void files();
- void hashLength_data();
+ void hashLength_data() { all_methods(true); }
void hashLength();
- void addDataAcceptsNullByteArrayView_data() { hashLength_data(); }
+ void addDataAcceptsNullByteArrayView_data() { all_methods(false); }
void addDataAcceptsNullByteArrayView();
void move();
void swap();
@@ -40,6 +42,7 @@ private slots:
void moreThan4GiBOfData();
void keccakBufferOverflow();
private:
+ void all_methods(bool includingNumAlgorithms) const;
void ensureLargeData();
std::vector<char> large;
};
@@ -197,6 +200,20 @@ void tst_QCryptographicHash::intermediary_result()
hash.reset();
}
+void tst_QCryptographicHash::static_hash()
+{
+ QFETCH(const int, algo);
+ QFETCH(const QByteArray, first);
+ QFETCH(const QByteArray, hash_first);
+
+ const auto _algo = QCryptographicHash::Algorithm(algo);
+
+ QCOMPARE(QCryptographicHash::hash(first, _algo), hash_first);
+
+ std::byte buffer[1024];
+ QCOMPARE(QCryptographicHash::hashInto(buffer, first, _algo), hash_first);
+}
+
void tst_QCryptographicHash::sha1()
{
@@ -474,12 +491,14 @@ void tst_QCryptographicHash::files()
}
}
-void tst_QCryptographicHash::hashLength_data()
+void tst_QCryptographicHash::all_methods(bool inclNumAlgos) const
{
QTest::addColumn<QCryptographicHash::Algorithm>("algorithm");
auto metaEnum = QMetaEnum::fromType<QCryptographicHash::Algorithm>();
for (int i = 0, value = metaEnum.value(i); value != -1; value = metaEnum.value(++i)) {
auto algorithm = QCryptographicHash::Algorithm(value);
+ if (!inclNumAlgos && algorithm == QCryptographicHash::Algorithm::NumAlgorithms)
+ continue;
QTest::addRow("%s", metaEnum.key(i)) << algorithm;
}
}
@@ -495,6 +514,9 @@ void tst_QCryptographicHash::hashLength()
expectedSize = 0;
} else {
expectedSize = QCryptographicHash::hash("test", algorithm).size();
+
+ std::byte buffer[1024];
+ QCOMPARE(QCryptographicHash::hashInto(buffer, "foo", algorithm).size(), expectedSize);
}
QCOMPARE(QCryptographicHash::hashLength(algorithm), expectedSize);
}
diff --git a/tests/auto/corelib/tools/qsize/CMakeLists.txt b/tests/auto/corelib/tools/qsize/CMakeLists.txt
index 91de696ddd..4a4c96b52c 100644
--- a/tests/auto/corelib/tools/qsize/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qsize/CMakeLists.txt
@@ -14,4 +14,6 @@ endif()
qt_internal_add_test(tst_qsize
SOURCES
tst_qsize.cpp
+ LIBRARIES
+ Qt::TestPrivate
)
diff --git a/tests/auto/corelib/tools/qsize/tst_qsize.cpp b/tests/auto/corelib/tools/qsize/tst_qsize.cpp
index c9699c5e76..d379275dd8 100644
--- a/tests/auto/corelib/tools/qsize/tst_qsize.cpp
+++ b/tests/auto/corelib/tools/qsize/tst_qsize.cpp
@@ -24,6 +24,7 @@ CHECK(const &&);
#undef CHECK
#include <QTest>
+#include <QtTest/private/qcomparisontesthelper_p.h>
#include <qsize.h>
#include <array>
@@ -34,6 +35,10 @@ class tst_QSize : public QObject
{
Q_OBJECT
private slots:
+ void compareCompiles();
+ void compare_data();
+ void compare();
+
void getSetCheck();
void scale();
@@ -55,6 +60,38 @@ private slots:
void structuredBinding();
};
+void tst_QSize::compareCompiles()
+{
+ QTestPrivate::testEqualityOperatorsCompile<QSize>();
+}
+
+void tst_QSize::compare_data()
+{
+ QTest::addColumn<QSize>("lhs");
+ QTest::addColumn<QSize>("rhs");
+ QTest::addColumn<bool>("result");
+
+ auto row = [](QSize lhs, QSize rhs, bool res) {
+ QTest::addRow("(%d, %d) vs (%d, %d)", lhs.width(), lhs.height(), rhs.width(), rhs.height())
+ << lhs << rhs << res;
+ };
+
+ row(QSize(0, 0), QSize(0, 0), true);
+ row(QSize(1, 0), QSize(0, 1), false);
+ row(QSize(-1, -1), QSize(-1, -1), true);
+ row(QSize(-1, -1), QSize(1, 1), false);
+ row(QSize(INT_MIN, INT_MAX), QSize(INT_MAX, INT_MIN), false);
+}
+
+void tst_QSize::compare()
+{
+ QFETCH(QSize, lhs);
+ QFETCH(QSize, rhs);
+ QFETCH(bool, result);
+
+ QT_TEST_EQUALITY_OPS(lhs, rhs, result);
+}
+
// Testing get/set functions
void tst_QSize::getSetCheck()
{
diff --git a/tests/auto/corelib/tools/qsizef/CMakeLists.txt b/tests/auto/corelib/tools/qsizef/CMakeLists.txt
index 9adaafe2ea..d8a1c7f46e 100644
--- a/tests/auto/corelib/tools/qsizef/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qsizef/CMakeLists.txt
@@ -14,4 +14,6 @@ endif()
qt_internal_add_test(tst_qsizef
SOURCES
tst_qsizef.cpp
+ LIBRARIES
+ Qt::TestPrivate
)
diff --git a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp
index ee33fa13b6..bb087e89de 100644
--- a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp
+++ b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp
@@ -24,17 +24,30 @@ CHECK(const &&);
#undef CHECK
#include <QTest>
+#include <QtTest/private/qcomparisontesthelper_p.h>
#include <qsize.h>
Q_DECLARE_METATYPE(QMarginsF)
+static constexpr qreal qreal_min = std::numeric_limits<qreal>::min();
+
class tst_QSizeF : public QObject
{
Q_OBJECT
private slots:
+ void compareCompiles();
+ void compare_data();
+ void compare();
+
+ void fuzzyCompare_data();
+ void fuzzyCompare();
+
void isNull_data();
void isNull();
+ void fuzzyIsNull_data();
+ void fuzzyIsNull();
+
void scale();
void expandedTo();
@@ -52,6 +65,61 @@ private slots:
void structuredBinding();
};
+void tst_QSizeF::compareCompiles()
+{
+ QTestPrivate::testEqualityOperatorsCompile<QSizeF>();
+ QTestPrivate::testEqualityOperatorsCompile<QSizeF, QSize>();
+}
+
+void tst_QSizeF::compare_data()
+{
+ QTest::addColumn<QSizeF>("lhs");
+ QTest::addColumn<QSizeF>("rhs");
+ QTest::addColumn<bool>("result");
+ QTest::addColumn<bool>("mixedResult");
+
+ auto row = [&](QSizeF lhs, QSizeF rhs, bool res, bool mixedRes) {
+ QString str;
+ QDebug dbg(&str);
+ dbg.nospace() << "(" << lhs.width() << ", " << lhs.height() << ") vs "
+ << "(" << rhs.width() << ", " << rhs.height() << ")";
+ QTest::addRow("%s", str.toLatin1().constData()) << lhs << rhs << res << mixedRes;
+ };
+
+ row(QSizeF(0.0, 0.0), QSizeF(0.0, 0.0), true, true);
+ row(QSizeF(1.0, 2.0), QSizeF(1.0, 2.0), true, true);
+ row(QSizeF(1.0, -1.0), QSizeF(-1.0, 1.0), false, false);
+ row(QSizeF(0.1, 1.1), QSizeF(0.1, 1.1), true, false);
+ row(QSizeF(qreal_min, 0.0), QSizeF(0.0, -qreal_min), true, true);
+}
+
+void tst_QSizeF::compare()
+{
+ QFETCH(QSizeF, lhs);
+ QFETCH(QSizeF, rhs);
+ QFETCH(bool, result);
+ QFETCH(bool, mixedResult);
+
+ QT_TEST_EQUALITY_OPS(lhs, rhs, result);
+
+ const QSize rhsFixed = rhs.toSize();
+ QT_TEST_EQUALITY_OPS(lhs, rhsFixed, mixedResult);
+}
+
+void tst_QSizeF::fuzzyCompare_data()
+{
+ compare_data();
+}
+
+void tst_QSizeF::fuzzyCompare()
+{
+ QFETCH(QSizeF, lhs);
+ QFETCH(QSizeF, rhs);
+ QFETCH(bool, result);
+
+ QCOMPARE_EQ(qFuzzyCompare(lhs, rhs), result);
+}
+
void tst_QSizeF::isNull_data()
{
QTest::addColumn<qreal>("width");
@@ -66,6 +134,7 @@ void tst_QSizeF::isNull_data()
QTest::newRow("0, -0.1") << qreal(0) << qreal(-0.1) << false;
QTest::newRow("0.1, 0") << qreal(0.1) << qreal(0) << false;
QTest::newRow("0, 0.1") << qreal(0) << qreal(0.1) << false;
+ QTest::newRow("qreal_min, -qreal_min") << qreal_min << -qreal_min << false;
}
void tst_QSizeF::isNull()
@@ -80,6 +149,33 @@ void tst_QSizeF::isNull()
QCOMPARE(size.isNull(), isNull);
}
+void tst_QSizeF::fuzzyIsNull_data()
+{
+ QTest::addColumn<qreal>("width");
+ QTest::addColumn<qreal>("height");
+ QTest::addColumn<bool>("fuzzyNull");
+
+ QTest::newRow("0, 0") << qreal(0.0) << qreal(0.0) << true;
+ QTest::newRow("-0, -0") << qreal(-0.0) << qreal(-0.0) << true;
+ QTest::newRow("0, -0") << qreal(0) << qreal(-0.0) << true;
+ QTest::newRow("-0, 0") << qreal(-0.0) << qreal(0) << true;
+ QTest::newRow("-0.1, 0") << qreal(-0.1) << qreal(0) << false;
+ QTest::newRow("0, -0.1") << qreal(0) << qreal(-0.1) << false;
+ QTest::newRow("0.1, 0") << qreal(0.1) << qreal(0) << false;
+ QTest::newRow("0, 0.1") << qreal(0) << qreal(0.1) << false;
+ QTest::newRow("qreal_min, -qreal_min") << qreal_min << -qreal_min << true;
+}
+
+void tst_QSizeF::fuzzyIsNull()
+{
+ QFETCH(qreal, width);
+ QFETCH(qreal, height);
+ QFETCH(bool, fuzzyNull);
+
+ QSizeF size(width, height);
+ QCOMPARE(qFuzzyIsNull(size), fuzzyNull);
+}
+
void tst_QSizeF::scale() {
QSizeF t1(10.4, 12.8);
t1.scale(60.6, 60.6, Qt::IgnoreAspectRatio);
diff --git a/tests/auto/corelib/tools/qspan/CMakeLists.txt b/tests/auto/corelib/tools/qspan/CMakeLists.txt
index 595d19dc43..b4517640a0 100644
--- a/tests/auto/corelib/tools/qspan/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qspan/CMakeLists.txt
@@ -10,4 +10,8 @@ endif()
qt_internal_add_test(tst_qspan
SOURCES
tst_qspan.cpp
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
)
diff --git a/tests/auto/corelib/tools/qspan/tst_qspan.cpp b/tests/auto/corelib/tools/qspan/tst_qspan.cpp
index 91d2ecf739..95c60ee953 100644
--- a/tests/auto/corelib/tools/qspan/tst_qspan.cpp
+++ b/tests/auto/corelib/tools/qspan/tst_qspan.cpp
@@ -6,6 +6,10 @@
#include <QList>
#include <QTest>
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
#include <algorithm>
#include <array>
#ifdef __cpp_lib_span
@@ -141,31 +145,27 @@ private:
void from_variable_size_container_impl(C &&c) const;
};
-#define RETURN_IF_FAILED() \
- do { if (QTest::currentTestFailed()) return; } while (false)
+template <typename T>
+const void *as_const_void(T *p) noexcept { return static_cast<const void *>(p); }
void tst_QSpan::onlyZeroExtentSpansHaveDefaultCtors() const
{
static_assert(std::is_nothrow_default_constructible_v<QSpan<int, 0>>);
static_assert(std::is_nothrow_default_constructible_v<QSpan<const int, 0>>);
static_assert(std::is_nothrow_default_constructible_v<QSpan<int>>);
- static_assert(std::is_nothrow_default_constructible_v<QSpan<const int, 0>>);
+ static_assert(std::is_nothrow_default_constructible_v<QSpan<const int>>);
QSpan<int, 0> si;
check_null_span(si);
- RETURN_IF_FAILED();
QSpan<const int, 0> sci;
check_null_span(sci);
- RETURN_IF_FAILED();
QSpan<int> sdi;
check_null_span(sdi);
- RETURN_IF_FAILED();
QSpan<const int> sdci;
check_null_span(sdci);
- RETURN_IF_FAILED();
static_assert(!std::is_default_constructible_v<QSpan<int, 1>>);
static_assert(!std::is_default_constructible_v<QSpan<const int, 42>>);
@@ -173,26 +173,22 @@ void tst_QSpan::onlyZeroExtentSpansHaveDefaultCtors() const
void tst_QSpan::zeroExtentSpansMaintainADataPointer() const
{
- int i;
+ int i = 0;
QSpan<int, 0> si{&i, 0};
QCOMPARE(si.data(), &i);
check_empty_span_incl_subspans(si);
- RETURN_IF_FAILED();
QSpan<const int, 0> sci{&i, 0};
QCOMPARE(sci.data(), &i);
check_empty_span_incl_subspans(sci);
- RETURN_IF_FAILED();
QSpan<int, 0> sdi{&i, 0};
QCOMPARE(sdi.data(), &i);
check_empty_span_incl_subspans(sdi);
- RETURN_IF_FAILED();
QSpan<const int, 0> sdci{&i, 0};
QCOMPARE(sdci.data(), &i);
check_empty_span_incl_subspans(sdci);
- RETURN_IF_FAILED();
}
template <typename T, std::size_t N>
@@ -230,18 +226,14 @@ void tst_QSpan::check_nonempty_span(QSpan<T, N> s, qsizetype expectedSize) const
// don't run into Mandates: Offset >= Extent
if constexpr (N > 0) { // incl. N == std::dynamic_extent
check_empty_span_incl_subspans(s.template subspan<1>());
- RETURN_IF_FAILED();
}
check_empty_span_incl_subspans(s.subspan(1));
- RETURN_IF_FAILED();
} else {
// don't run into Mandates: Offset >= Extent
if constexpr (N > 1) { // incl. N == std::dynamic_extent
check_nonempty_span(s.template subspan<1>(), expectedSize - 1);
- RETURN_IF_FAILED();
}
check_nonempty_span(s.subspan(1), expectedSize - 1);
- RETURN_IF_FAILED();
}
}
@@ -263,55 +255,46 @@ template <typename T, std::size_t N>
void tst_QSpan::check_empty_span_incl_subspans(QSpan<T, N> s) const
{
check_empty_span(s);
- RETURN_IF_FAILED();
{
const auto fi = s.template first<0>();
check_empty_span(fi);
- RETURN_IF_FAILED();
QCOMPARE_EQ(fi.data(), s.data());
}
{
const auto la = s.template last<0>();
check_empty_span(la);
- RETURN_IF_FAILED();
QCOMPARE_EQ(la.data(), s.data());
}
{
const auto ss = s.template subspan<0>();
check_empty_span(ss);
- RETURN_IF_FAILED();
QCOMPARE_EQ(ss.data(), s.data());
}
{
const auto ss = s.template subspan<0, 0>();
check_empty_span(ss);
- RETURN_IF_FAILED();
QCOMPARE_EQ(ss.data(), s.data());
}
{
const auto fi = s.first(0);
check_empty_span(fi);
- RETURN_IF_FAILED();
QCOMPARE_EQ(fi.data(), s.data());
}
{
const auto la = s.last(0);
check_empty_span(la);
- RETURN_IF_FAILED();
QCOMPARE_EQ(la.data(), s.data());
}
{
const auto ss = s.subspan(0);
check_empty_span(ss);
- RETURN_IF_FAILED();
QCOMPARE_EQ(ss.data(), s.data());
}
{
const auto ss = s.subspan(0, 0);
check_empty_span(ss);
- RETURN_IF_FAILED();
QCOMPARE_EQ(ss.data(), s.data());
}
}
@@ -334,6 +317,8 @@ void tst_QSpan::from_container_impl(C &&c) const
const auto c_data = QSpanPrivate::adl_data(c);
using V = std::remove_reference_t<QSpanPrivate::range_reference_t<C>>;
+ constexpr auto ExpectedBytesExtent
+ = ExpectedExtent == q20::dynamic_extent ? q20::dynamic_extent : ExpectedExtent * sizeof(V);
{
QSpan si = c; // CTAD
static_assert(std::is_same_v<decltype(si), QSpan<V, ExpectedExtent>>);
@@ -342,7 +327,20 @@ void tst_QSpan::from_container_impl(C &&c) const
QCOMPARE_EQ(si.data(), c_data);
check_nonempty_span(si, c_size);
- RETURN_IF_FAILED();
+
+ auto bi = as_bytes(si);
+ static_assert(std::is_same_v<decltype(bi), QSpan<const std::byte, ExpectedBytesExtent>>);
+ QCOMPARE_EQ(bi.size(), si.size_bytes());
+ QCOMPARE_EQ(as_const_void(bi.data()),
+ as_const_void(si.data()));
+
+ if constexpr (!std::is_const_v<V>) { // e.g. std::initializer_list<int>
+ auto wbi = as_writable_bytes(si);
+ static_assert(std::is_same_v<decltype(wbi), QSpan<std::byte, ExpectedBytesExtent>>);
+ QCOMPARE_EQ(wbi.size(), si.size_bytes());
+ QCOMPARE_EQ(as_const_void(wbi.data()),
+ as_const_void(si.data()));
+ }
QSpan<const int> sci = c;
@@ -350,7 +348,12 @@ void tst_QSpan::from_container_impl(C &&c) const
QCOMPARE_EQ(sci.data(), c_data);
check_nonempty_span(sci, c_size);
- RETURN_IF_FAILED();
+
+ auto bci = as_bytes(sci);
+ static_assert(std::is_same_v<decltype(bci), QSpan<const std::byte>>);
+ QCOMPARE_EQ(bci.size(), sci.size_bytes());
+ QCOMPARE_EQ(as_const_void(bci.data()),
+ as_const_void(sci.data()));
}
{
QSpan sci = std::as_const(c); // CTAD
@@ -360,7 +363,12 @@ void tst_QSpan::from_container_impl(C &&c) const
QCOMPARE_EQ(sci.data(), c_data);
check_nonempty_span(sci, c_size);
- RETURN_IF_FAILED();
+
+ auto bci = as_bytes(sci);
+ static_assert(std::is_same_v<decltype(bci), QSpan<const std::byte, ExpectedBytesExtent>>);
+ QCOMPARE_EQ(bci.size(), sci.size_bytes());
+ QCOMPARE_EQ(as_const_void(bci.data()),
+ as_const_void(sci.data()));
}
}
@@ -395,7 +403,6 @@ void tst_QSpan::fromStdInitializerList() const
QCOMPARE_EQ(sci.data(), il.begin());
check_nonempty_span(sci, 4);
- RETURN_IF_FAILED();
}
void tst_QSpan::fromZeroSizeStdArray() const
@@ -444,7 +451,5 @@ void tst_QSpan::fromInitList() const
l2({4, 5, 6});
}
-#undef RETURN_IF_FAILED
-
QTEST_APPLESS_MAIN(tst_QSpan);
#include "tst_qspan.moc"
diff --git a/tests/auto/gui/image/CMakeLists.txt b/tests/auto/gui/image/CMakeLists.txt
index 3535d5f01e..c7fc6f07d3 100644
--- a/tests/auto/gui/image/CMakeLists.txt
+++ b/tests/auto/gui/image/CMakeLists.txt
@@ -23,7 +23,4 @@ if(QT_FEATURE_private_tests)
add_subdirectory(qpixmapcache)
endif()
-# QTBUG-87669
-if(NOT ANDROID)
- add_subdirectory(qicon)
-endif()
+add_subdirectory(qicon)
diff --git a/tests/auto/gui/image/qicon/CMakeLists.txt b/tests/auto/gui/image/qicon/CMakeLists.txt
index c693c559cc..93f75741c0 100644
--- a/tests/auto/gui/image/qicon/CMakeLists.txt
+++ b/tests/auto/gui/image/qicon/CMakeLists.txt
@@ -37,11 +37,14 @@ file(GLOB_RECURSE test_data_glob
*.svgz)
list(APPEND test_data ${test_data_glob})
+add_subdirectory(plugin)
+
qt_internal_add_test(tst_qicon
SOURCES
tst_qicon.cpp
LIBRARIES
Qt::Gui
+ TestIconPlugin
TESTDATA ${test_data}
)
@@ -105,3 +108,5 @@ qt_internal_extend_target(tst_qicon CONDITION TARGET Qt::Widgets
LIBRARIES
Qt::Widgets
)
+
+add_dependencies(tst_qicon TestIconPlugin)
diff --git a/tests/auto/gui/image/qicon/plugin/CMakeLists.txt b/tests/auto/gui/image/qicon/plugin/CMakeLists.txt
new file mode 100644
index 0000000000..cae49b2df1
--- /dev/null
+++ b/tests/auto/gui/image/qicon/plugin/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## TestIconEngine Plugin:
+#####################################################################
+
+qt_internal_add_plugin(TestIconPlugin
+ STATIC
+ OUTPUT_NAME qtesticonplugin
+ OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
+ SKIP_INSTALL
+ PLUGIN_TYPE iconengines
+ DEFAULT_IF TRUE
+ SOURCES
+ main.cpp
+ LIBRARIES
+ Qt::Core
+ Qt::Gui
+)
diff --git a/tests/auto/gui/image/qicon/plugin/main.cpp b/tests/auto/gui/image/qicon/plugin/main.cpp
new file mode 100644
index 0000000000..58d9807142
--- /dev/null
+++ b/tests/auto/gui/image/qicon/plugin/main.cpp
@@ -0,0 +1,73 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qiconengineplugin.h>
+#include <qiconengine.h>
+
+QT_BEGIN_NAMESPACE
+
+class TestIconPlugin : public QIconEnginePlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QIconEngineFactoryInterface" FILE "plugin.json")
+
+public:
+ QIconEngine *create(const QString &icon) override;
+};
+
+class TestIconEngine : public QIconEngine
+{
+public:
+ TestIconEngine(const QString &icon)
+ : m_iconName(QIcon::themeName() + "/" + icon)
+ {
+ }
+
+ ~TestIconEngine()
+ {}
+
+ QIconEngine *clone() const override
+ {
+ return new TestIconEngine(m_iconName);
+ }
+
+ QString key() const override
+ {
+ return QStringLiteral("TestIconEngine");
+ }
+
+ QString iconName() override
+ {
+ return m_iconName;
+ }
+
+ bool isNull() override
+ {
+ return m_iconName.isNull();
+ }
+
+ QList<QSize> availableSizes(QIcon::Mode, QIcon::State) override
+ {
+ return {{16, 16}, {48, 48}, {64, 64}};
+ }
+
+ void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override
+ {
+ Q_UNUSED(painter);
+ Q_UNUSED(rect);
+ Q_UNUSED(mode);
+ Q_UNUSED(state);
+ }
+
+private:
+ const QString m_iconName;
+};
+
+QIconEngine *TestIconPlugin::create(const QString &icon)
+{
+ return new TestIconEngine(icon);
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/tests/auto/gui/image/qicon/plugin/plugin.json b/tests/auto/gui/image/qicon/plugin/plugin.json
new file mode 100644
index 0000000000..96b59aa79e
--- /dev/null
+++ b/tests/auto/gui/image/qicon/plugin/plugin.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "plugintheme", "SpecialTheme" ]
+}
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp
index 99b4a0589e..d95ee66fb6 100644
--- a/tests/auto/gui/image/qicon/tst_qicon.cpp
+++ b/tests/auto/gui/image/qicon/tst_qicon.cpp
@@ -48,6 +48,9 @@ private slots:
#endif
void task223279_inconsistentAddFile();
+ void themeFromPlugin_data();
+ void themeFromPlugin();
+
private:
bool haveImageFormat(QByteArray const&);
@@ -872,6 +875,32 @@ void tst_QIcon::task223279_inconsistentAddFile()
QCOMPARE(pm1.size(), pm2.size());
}
+Q_IMPORT_PLUGIN(TestIconPlugin)
+
+void tst_QIcon::themeFromPlugin_data()
+{
+ QTest::addColumn<QString>("themeName");
+
+ QTest::addRow("plugintheme") << "plugintheme";
+ QTest::addRow("specialtheme") << "specialTheme"; // deliberately not matching case
+}
+
+void tst_QIcon::themeFromPlugin()
+{
+ QFETCH(const QString, themeName);
+ auto restoreTheme = qScopeGuard([oldTheme = QIcon::themeName()]{
+ QIcon::setThemeName(oldTheme);
+ });
+
+ QIcon icon = QIcon::fromTheme("icon1");
+ QVERIFY(icon.isNull());
+
+ QIcon::setThemeName(themeName);
+
+ icon = QIcon::fromTheme("icon1");
+ QVERIFY(!icon.isNull());
+ QCOMPARE(icon.name(), themeName + "/icon1");
+}
QTEST_MAIN(tst_QIcon)
#include "tst_qicon.moc"
diff --git a/tests/auto/gui/image/qimage/images/VideoHD.icc b/tests/auto/gui/image/qimage/images/VideoHD.icc
new file mode 100644
index 0000000000..b96eb68136
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/VideoHD.icc
Binary files differ
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 3e3d0a49bc..8086ffcc28 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <qpainter.h>
+#include <private/qcmyk_p.h>
#include <private/qimage_p.h>
#include <private/qdrawhelper_p.h>
@@ -110,6 +111,8 @@ private slots:
void smoothScaleFormats();
void smoothScaleNoConversion_data();
void smoothScaleNoConversion();
+ void smoothScale_CMYK_data();
+ void smoothScale_CMYK();
void transformed_data();
void transformed();
@@ -173,6 +176,10 @@ private slots:
void colorSpaceRgbConversion();
void colorSpaceCmykConversion_data();
void colorSpaceCmykConversion();
+ void colorSpaceFromGrayConversion_data();
+ void colorSpaceFromGrayConversion();
+ void colorSpaceToGrayConversion_data();
+ void colorSpaceToGrayConversion();
void deepCopyWhenPaintingActive();
void scaled_QTBUG19157();
@@ -2091,6 +2098,76 @@ void tst_QImage::smoothScaleNoConversion()
QVERIFY(img.hasAlphaChannel());
}
+void tst_QImage::smoothScale_CMYK_data()
+{
+ QTest::addColumn<int>("size");
+
+ const int sizes[] = { 2, 3, 4, 6, 7, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128 };
+ for (int size : sizes)
+ QTest::addRow("%d x %d", size, size) << size;
+}
+
+void tst_QImage::smoothScale_CMYK()
+{
+ QFETCH(int, size);
+ QImage img(size, size, QImage::Format_CMYK8888);
+ QCmyk32 expected(31, 63, 127, 127);
+ img.fill(expected.toUint());
+
+ auto getCmykPixel = [](const QImage &image, int x, int y) {
+ Q_ASSERT(image.format() == QImage::Format_CMYK8888);
+ const uint *line = reinterpret_cast<const uint *>(image.scanLine(y));
+ const uint pixel = line[x];
+ return QCmyk32::fromCmyk32(pixel);
+ };
+
+ // scale x down, y down
+ QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QCmyk32 pixel = getCmykPixel(scaled, 0, 0);
+ QCOMPARE(pixel, expected);
+
+ // scale x down, y up
+ scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ pixel = getCmykPixel(scaled, 0, y);
+ QCOMPARE(pixel, expected);
+ }
+
+ // scale x up, y down
+ scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, 0);
+ QCOMPARE(pixel, expected);
+ }
+
+ // scale x up
+ scaled = img.scaled(QSize(size, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, y);
+ QCOMPARE(pixel, expected);
+ }
+ }
+
+ // scale y up
+ scaled = img.scaled(QSize(size * 2, size), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, y);
+ QCOMPARE(pixel, expected);
+ }
+ }
+
+ // scale x up, y up
+ scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, y);
+ QCOMPARE(pixel, expected);
+ }
+ }
+}
+
static int count(const QImage &img, int x, int y, int dx, int dy, QRgb pixel)
{
int i = 0;
@@ -3387,6 +3464,120 @@ void tst_QImage::colorSpaceCmykConversion()
}
}
+void tst_QImage::colorSpaceFromGrayConversion_data()
+{
+ QTest::addColumn<QImage::Format>("fromFormat");
+ QTest::addColumn<QColorSpace>("fromCS");
+ QTest::addColumn<QColorSpace>("toCS");
+
+ QImage::Format formats[] = {
+ QImage::Format_Grayscale8,
+ QImage::Format_Grayscale16,
+ };
+
+ QList<QColorSpace> colorSpaces = {
+ QColorSpace::SRgbLinear,
+ QColorSpace::DisplayP3,
+ QColorSpace(QPointF(0.31271, 0.32902), QColorSpace::TransferFunction::SRgb),
+ QColorSpace(QPointF(0.30, 0.33), QColorSpace::TransferFunction::Linear)
+ };
+ std::string names[] = {
+ "sRgbLinear",
+ "displayP3",
+ "graySRgb",
+ "grayOther",
+ "videoHD(A2B)"
+ };
+
+ QFile iccProfile(m_prefix + "VideoHD.icc");
+ iccProfile.open(QIODevice::ReadOnly);
+ colorSpaces.append(QColorSpace::fromIccProfile(iccProfile.readAll()));
+
+ for (auto fromFormat : formats) {
+ for (int from = 0; from < 5; ++from) {
+ for (int to = 0; to < 4; ++to) {
+ QTest::addRow("%s: %s -> %s", formatToString(fromFormat).data(), names[from].c_str(), names[to].c_str())
+ << fromFormat << colorSpaces[from] << colorSpaces[to];
+ }
+ }
+ }
+}
+
+void tst_QImage::colorSpaceFromGrayConversion()
+{
+ QFETCH(QImage::Format, fromFormat);
+ QFETCH(QColorSpace, fromCS);
+ QFETCH(QColorSpace, toCS);
+
+ QImage image(16, 16, fromFormat);
+ image.setColorSpace(fromCS);
+ QVERIFY(image.colorSpace().isValid());
+
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ image.setPixel(j, i, qRgb((i + j) * 8, (i + j) * 8, (i + j) * 8));
+ }
+ }
+ QImage imageConverted = image.convertedToColorSpace(toCS);
+ QCOMPARE(imageConverted.format(), fromFormat);
+ QCOMPARE(imageConverted.size(), image.size());
+ int gray = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newGray = qGray(imageConverted.pixel(x, 3));
+ QCOMPARE_GE(newGray, gray);
+ gray = newGray;
+ }
+}
+
+void tst_QImage::colorSpaceToGrayConversion_data()
+{
+ QTest::addColumn<QImage::Format>("fromFormat");
+
+ QImage::Format formats[] = {
+ QImage::Format_RGB32,
+ QImage::Format_ARGB32,
+ QImage::Format_ARGB32_Premultiplied,
+ QImage::Format_RGBX64,
+ QImage::Format_RGBA64,
+ QImage::Format_RGBA64_Premultiplied,
+ QImage::Format_RGBX32FPx4,
+ QImage::Format_RGBA32FPx4,
+ QImage::Format_RGBA32FPx4_Premultiplied,
+ QImage::Format_Grayscale8,
+ QImage::Format_Grayscale16,
+ };
+
+ for (auto fromFormat : formats)
+ QTest::addRow("%s -> Gray", formatToString(fromFormat).data()) << fromFormat;
+}
+
+void tst_QImage::colorSpaceToGrayConversion()
+{
+ QFETCH(QImage::Format, fromFormat);
+
+ QImage image(16, 16, fromFormat);
+ image.setColorSpace(QColorSpace::DisplayP3);
+ QVERIFY(image.colorSpace().isValid());
+
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ image.setPixel(j, i, qRgb((i + j) * 8, (i + j) * 8, (i + j) * 8));
+ }
+ }
+
+ QColorSpace grayColorSpace(QPointF(0.31271, 0.32902), QColorSpace::TransferFunction::SRgb);
+
+ QImage imageConverted = image.convertedToColorSpace(grayColorSpace);
+ QVERIFY(imageConverted.format() == QImage::Format_Grayscale8 || imageConverted.format() == QImage::Format_Grayscale16);
+ QCOMPARE(imageConverted.size(), image.size());
+ int gray = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newGray = qGray(imageConverted.pixel(x, 11));
+ QCOMPARE_GE(newGray, gray);
+ gray = newGray;
+ }
+}
+
void tst_QImage::deepCopyWhenPaintingActive()
{
QImage image(64, 64, QImage::Format_ARGB32_Premultiplied);
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 8ef0b6272a..4ba3ae11de 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -117,8 +117,7 @@ protected:
bool createFiles(QFileSystemModel *model, const QString &test_path,
const QStringList &initial_files, int existingFileCount = 0,
const QStringList &initial_dirs = QStringList());
- QModelIndex prepareTestModelRoot(QFileSystemModel *model, const QString &test_path,
- QSignalSpy **spy2 = nullptr, QSignalSpy **spy3 = nullptr);
+ QModelIndex prepareTestModelRoot(QFileSystemModel *model, const QString &test_path);
private:
QString flatDirTestPath;
@@ -382,17 +381,12 @@ bool tst_QFileSystemModel::createFiles(QFileSystemModel *model, const QString &t
return true;
}
-QModelIndex tst_QFileSystemModel::prepareTestModelRoot(QFileSystemModel *model, const QString &test_path,
- QSignalSpy **spy2, QSignalSpy **spy3)
+QModelIndex tst_QFileSystemModel::prepareTestModelRoot(QFileSystemModel *model,
+ const QString &test_path)
{
if (model->rowCount(model->index(test_path)) != 0)
return QModelIndex();
- if (spy2)
- *spy2 = new QSignalSpy(model, &QFileSystemModel::rowsInserted);
- if (spy3)
- *spy3 = new QSignalSpy(model, &QFileSystemModel::rowsAboutToBeInserted);
-
QStringList files = { "b", "d", "f", "h", "j", ".a", ".c", ".e", ".g" };
if (!createFiles(model, test_path, files))
@@ -412,16 +406,16 @@ QModelIndex tst_QFileSystemModel::prepareTestModelRoot(QFileSystemModel *model,
void tst_QFileSystemModel::rowCount()
{
- QSignalSpy *spy2 = nullptr;
- QSignalSpy *spy3 = nullptr;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
QAbstractItemModelTester tester(model.get());
+ QSignalSpy rowsInsertedSpy(model.get(), &QFileSystemModel::rowsInserted);
+ QSignalSpy rowsAboutToBeInsertedSpy(model.get(), &QFileSystemModel::rowsAboutToBeInserted);
tester.setUseFetchMore(false);
- QModelIndex root = prepareTestModelRoot(model.data(), flatDirTestPath, &spy2, &spy3);
+ QModelIndex root = prepareTestModelRoot(model.data(), flatDirTestPath);
QVERIFY(root.isValid());
- QVERIFY(spy2 && spy2->size() > 0);
- QVERIFY(spy3 && spy3->size() > 0);
+ QCOMPARE_GT(rowsInsertedSpy.size(), 0);
+ QCOMPARE_GT(rowsAboutToBeInsertedSpy.size(), 0);
}
void tst_QFileSystemModel::rowsInserted_data()
diff --git a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
index 62299f77df..3313575403 100644
--- a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
@@ -21,6 +21,9 @@ foreach(test ${test_names})
NO_BATCH
SOURCES
../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index a9e2c5f882..227fd77e1a 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -1509,6 +1509,7 @@ void tst_QWindow::touchCancelWithTouchToMouse()
void tst_QWindow::touchInterruptedByPopup()
{
InputTestWindow window;
+ window.setObjectName("main");
window.setTitle(QLatin1String(QTest::currentTestFunction()));
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
@@ -1529,6 +1530,7 @@ void tst_QWindow::touchInterruptedByPopup()
// Launch a popup window
InputTestWindow popup;
+ window.setObjectName("popup");
popup.setFlags(Qt::Popup);
popup.setModality(Qt::WindowModal);
popup.resize(m_testWindowSize / 2);
@@ -1551,9 +1553,6 @@ void tst_QWindow::touchInterruptedByPopup()
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
QCoreApplication::processEvents();
QTRY_COMPARE(window.touchReleasedCount, 0);
-
- // Due to temporary fix for QTBUG-37371: the original window should receive a TouchCancel
- QTRY_COMPARE(window.touchEventType, QEvent::TouchCancel);
}
void tst_QWindow::orientation()
diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index 38ecaa7e44..e761f8cb3c 100644
--- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -2343,7 +2343,7 @@ void tst_QMatrixNxN::rotate4x4()
ROTATE4(2.0f, 3.0f, 0.0f, 1.0f, p1x, p1y, p1z, p1w);
p1x /= p1w;
p1y /= p1w;
- p1z /= p1w;
+ Q_UNUSED(p1z);
QVector3D v1(2.0f, 3.0f, -4.0f);
QVector3D v2 = m1.map(v1);
diff --git a/tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.icc b/tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.icc
new file mode 100644
index 0000000000..e0ceaa12f8
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index 7505d463ed..e23b3d21a1 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -7,6 +7,7 @@
#include <qcolorspace.h>
#include <qimage.h>
#include <qimagereader.h>
+#include <qrgbafloat.h>
#include <private/qcolorspace_p.h>
@@ -71,6 +72,9 @@ private slots:
void setWhitePoint();
void grayColorSpace();
void grayColorSpaceEffectivelySRgb();
+
+ void scaleAlphaValue();
+ void hdrColorSpaces();
};
tst_QColorSpace::tst_QColorSpace()
@@ -121,6 +125,15 @@ void tst_QColorSpace::namedColorSpaces_data()
QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb << true
<< QColorSpace::Primaries::ProPhotoRgb
<< QColorSpace::TransferFunction::ProPhotoRgb;
+ QTest::newRow("BT.2020") << QColorSpace::Bt2020 << true
+ << QColorSpace::Primaries::Bt2020
+ << QColorSpace::TransferFunction::Bt2020;
+ QTest::newRow("BT.2100 PQ") << QColorSpace::Bt2100Pq << true
+ << QColorSpace::Primaries::Bt2020
+ << QColorSpace::TransferFunction::St2084;
+ QTest::newRow("BT.2100 HLG") << QColorSpace::Bt2100Hlg << true
+ << QColorSpace::Primaries::Bt2020
+ << QColorSpace::TransferFunction::Hlg;
QTest::newRow("0") << QColorSpace::NamedColorSpace(0)
<< false
<< QColorSpace::Primaries::Custom
@@ -223,6 +236,11 @@ void tst_QColorSpace::fromIccProfile_data()
<< QColorSpace::TransferFunction::Custom
<< QColorSpace::TransformModel::ElementListProcessing
<< QColorSpace::ColorModel::Cmyk << QString("uCMY");
+ // BT.2100 PQ profile
+ QTest::newRow("BT.2100 PQ") << prefix + "Rec. ITU-R BT.2100 PQ.icc" << QColorSpace::Bt2100Pq
+ << QColorSpace::TransferFunction::St2084
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Rgb << QString("Rec. ITU-R BT.2100 PQ");
}
void tst_QColorSpace::fromIccProfile()
@@ -252,6 +270,15 @@ void tst_QColorSpace::fromIccProfile()
QCOMPARE(iccProfile, iccProfile2);
QColorSpace fileColorSpace2 = QColorSpace::fromIccProfile(iccProfile2);
QCOMPARE(fileColorSpace2, fileColorSpace);
+
+ // Change description to force generation of new icc profile data.
+ fileColorSpace2.setDescription("Hello my QTest description");
+ iccProfile2 = fileColorSpace2.iccProfile();
+ QCOMPARE_NE(iccProfile, iccProfile2);
+ fileColorSpace2 = QColorSpace::fromIccProfile(iccProfile2);
+ QVERIFY(fileColorSpace2.isValid());
+ // Note, we do not currently compare description in color space equality
+ QCOMPARE(fileColorSpace2, fileColorSpace);
}
void tst_QColorSpace::imageConversion_data()
@@ -1030,5 +1057,74 @@ void tst_QColorSpace::grayColorSpaceEffectivelySRgb()
QCOMPARE(rgbImage1, rgbImage2);
}
+void tst_QColorSpace::scaleAlphaValue()
+{
+ QImage image(1, 1, QImage::Format_ARGB32);
+ image.setPixel(0, 0, qRgba(255, 255, 255, 125));
+ image.setColorSpace(QColorSpace::SRgb);
+ image.convertToColorSpace(QColorSpace::SRgbLinear, QImage::Format_RGBA64);
+ QCOMPARE(reinterpret_cast<const QRgba64 *>(image.constBits())->alpha(), 257 * 125);
+}
+
+void tst_QColorSpace::hdrColorSpaces()
+{
+ QColorSpace bt2020linear(QColorSpace::Primaries::Bt2020, QColorSpace::TransferFunction::Linear);
+ QColorTransform pqToLinear = QColorSpace(QColorSpace::Bt2100Pq).transformationToColorSpace(bt2020linear);
+ QColorTransform hlgToLinear = QColorSpace(QColorSpace::Bt2100Hlg).transformationToColorSpace(bt2020linear);
+
+ QColor maxWhite = QColor::fromRgbF(1.0f, 1.0f, 1.0f);
+ QColor hlgWhite = QColor::fromRgbF(0.5f, 0.5f, 0.5f);
+ QCOMPARE(hlgToLinear.map(maxWhite).redF(), 12.f);
+ QCOMPARE(hlgToLinear.map(maxWhite).greenF(), 12.f);
+ QCOMPARE(hlgToLinear.map(maxWhite).blueF(), 12.f);
+ QCOMPARE(hlgToLinear.map(hlgWhite).redF(), 1.f);
+ QCOMPARE(hlgToLinear.map(hlgWhite).greenF(), 1.f);
+ QCOMPARE(hlgToLinear.map(hlgWhite).blueF(), 1.f);
+ QCOMPARE(pqToLinear.map(maxWhite).redF(), 64.f);
+ QCOMPARE(pqToLinear.map(maxWhite).greenF(), 64.f);
+ QCOMPARE(pqToLinear.map(maxWhite).blueF(), 64.f);
+
+ {
+ QImage image(1, 1, QImage::Format_RGBA32FPx4);
+ image.setPixel(0, 0, qRgba(255, 255, 255, 255));
+ image.setColorSpace(QColorSpace::Bt2100Pq);
+ QImage image2 = image.convertedToColorSpace(bt2020linear);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 64.f);
+ image.setColorSpace(QColorSpace::Bt2100Hlg);
+ image2 = image.convertedToColorSpace(bt2020linear);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 12.f);
+ }
+ {
+ QImage image(1, 1, QImage::Format_RGBA32FPx4_Premultiplied);
+ image.setPixel(0, 0, qRgba(255, 255, 255, 255));
+ image.setColorSpace(QColorSpace::Bt2100Pq);
+ QImage image2 = image.convertedToColorSpace(bt2020linear);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 64.f);
+ image.setColorSpace(QColorSpace::Bt2100Hlg);
+ image2 = image.convertedToColorSpace(bt2020linear);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 12.f);
+ }
+ {
+ QImage image(1, 1, QImage::Format_ARGB32);
+ image.setPixel(0, 0, qRgba(255, 255, 255, 255));
+ image.setColorSpace(QColorSpace::Bt2100Pq);
+ QImage image2 = image.convertedToColorSpace(bt2020linear, QImage::Format_RGBA32FPx4);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 64.f);
+ image.setColorSpace(QColorSpace::Bt2100Hlg);
+ image2 = image.convertedToColorSpace(bt2020linear, QImage::Format_RGBA32FPx4);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 12.f);
+ }
+ {
+ QImage image(1, 1, QImage::Format_ARGB32_Premultiplied);
+ image.setPixel(0, 0, qRgba(255, 255, 255, 255));
+ image.setColorSpace(QColorSpace::Bt2100Pq);
+ QImage image2 = image.convertedToColorSpace(bt2020linear, QImage::Format_RGBA32FPx4);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 64.f);
+ image.setColorSpace(QColorSpace::Bt2100Hlg);
+ image2 = image.convertedToColorSpace(bt2020linear, QImage::Format_RGBA32FPx4);
+ QCOMPARE(image2.pixelColor(0, 0).redF(), 12.f);
+ }
+}
+
QTEST_MAIN(tst_QColorSpace)
#include "tst_qcolorspace.moc"
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index 3d60e62fc1..934725844a 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -138,12 +138,15 @@ void tst_QRegion::rects()
QRegion region(rect);
QVERIFY(region.isEmpty());
QCOMPARE(region.begin(), region.end());
+ QVERIFY(region.rects().isEmpty());
}
{
QRect rect(10, -20, 30, 40);
QRegion region(rect);
QCOMPARE(region.end(), region.begin() + 1);
QCOMPARE(*region.begin(), rect);
+ QCOMPARE(region.rects().size(), 1);
+ QCOMPARE(region.rects()[0], rect);
}
{
QRect r(QPoint(10, 10), QPoint(40, 40));
@@ -190,6 +193,7 @@ void tst_QRegion::setRects()
QCOMPARE(region, QRegion());
QCOMPARE(region.begin(), region.end());
QVERIFY(!region.boundingRect().isValid());
+ QVERIFY(region.rects().isEmpty());
}
{
QRegion region;
@@ -197,12 +201,15 @@ void tst_QRegion::setRects()
region.setRects(&rect, 1);
QCOMPARE(region.begin(), region.end());
QVERIFY(!region.boundingRect().isValid());
+ QVERIFY(region.rects().isEmpty());
}
{
QRegion region;
QRect rect(10, -20, 30, 40);
region.setRects(&rect, 1);
QCOMPARE(region.end(), region.begin() + 1);
+ QCOMPARE(region.rects().size(), 1);
+ QCOMPARE(region.rects()[0], rect);
QCOMPARE(*region.begin(), rect);
}
}
@@ -316,10 +323,12 @@ void tst_QRegion::emptyPolygonRegion()
QRegion r(pa);
QTEST(r.isEmpty(), "isEmpty");
QTEST(int(std::distance(r.begin(), r.end())), "numRects");
- QList<QRect> rects;
- std::copy(r.begin(), r.end(), std::back_inserter(rects));
+ QList<QRect> rects{r.begin(), r.end()};
QTEST(int(rects.size()), "numRects");
QTEST(rects, "rects");
+ const auto span = r.rects();
+ rects.assign(span.begin(), span.end());
+ QTEST(rects, "rects");
}
@@ -862,6 +871,7 @@ void tst_QRegion::isEmpty()
QCOMPARE(region, QRegion());
QCOMPARE(region.rectCount(), 0);
QCOMPARE(region.boundingRect(), QRect());
+ QVERIFY(region.rects().isEmpty());
}
void tst_QRegion::regionFromPath()
@@ -877,6 +887,10 @@ void tst_QRegion::regionFromPath()
QCOMPARE(rgn.begin()[0], QRect(0, 0, 10, 10));
QCOMPARE(rgn.begin()[1], QRect(0, 100, 100, 1000));
+ QCOMPARE(rgn.rects().size(), 2);
+ QCOMPARE(rgn.rects()[0], QRect(0, 0, 10, 10));
+ QCOMPARE(rgn.rects()[1], QRect(0, 100, 100, 1000));
+
QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 1100));
}
@@ -893,6 +907,12 @@ void tst_QRegion::regionFromPath()
QCOMPARE(rgn.begin()[2], QRect(90, 10, 10, 80));
QCOMPARE(rgn.begin()[3], QRect(0, 90, 100, 10));
+ QCOMPARE(rgn.rects().size(), 4);
+ QCOMPARE(rgn.rects()[0], QRect(0, 0, 100, 10));
+ QCOMPARE(rgn.rects()[1], QRect(0, 10, 10, 80));
+ QCOMPARE(rgn.rects()[2], QRect(90, 10, 10, 80));
+ QCOMPARE(rgn.rects()[3], QRect(0, 90, 100, 10));
+
QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 100));
}
}
diff --git a/tests/auto/gui/platform/qx11info/tst_qx11info.cpp b/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
index a4effb07cc..f71e644a8f 100644
--- a/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
+++ b/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
@@ -7,6 +7,8 @@
#include <QtGui/private/qtx11extras_p.h>
+using namespace Qt::StringLiterals;
+
class tst_QX11Info : public QObject
{
Q_OBJECT
@@ -83,12 +85,21 @@ void initialize()
}
Q_CONSTRUCTOR_FUNCTION(initialize)
+static QString checkSkip() {
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ return "This test is only for X11, not Wayland."_L1;
+ if (QGuiApplication::platformName().startsWith(QLatin1String("offscreen"), Qt::CaseInsensitive))
+ return "This test is only for X11, not offscreen."_L1;
+ return ""_L1;
+}
+
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.");
+ QString result = checkSkip();
+ if (!result.isEmpty())
+ QSKIP(result.toUtf8());
// This relies on the fact that no widget was shown yet,
// so please make sure this method is always the first test.
@@ -110,8 +121,9 @@ 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.");
+ QString result = checkSkip();
+ if (!result.isEmpty())
+ QSKIP(result.toUtf8());
QVERIFY(QX11Info::isPlatformX11());
}
@@ -120,8 +132,9 @@ 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.");
+ QString result = checkSkip();
+ if (!result.isEmpty())
+ QSKIP(result.toUtf8());
// No X11 event received yet
QCOMPARE(QX11Info::appTime(), 0ul);
@@ -348,8 +361,9 @@ 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.");
+ QString result = checkSkip();
+ if (!result.isEmpty())
+ QSKIP(result.toUtf8());
PeekerTest test;
test.show();
@@ -361,8 +375,9 @@ 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.");
+ QString result = checkSkip();
+ if (!result.isEmpty())
+ QSKIP(result.toUtf8());
const bool b = QX11Info::isCompositingManagerRunning();
Q_UNUSED(b);
const bool b2 = QX11Info::isCompositingManagerRunning(0);
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index a438d7ebc8..203fe003a0 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -56,6 +56,10 @@ private slots:
void quotedAndUnquotedIdentifiers();
void whitespaceValues_data();
void whitespaceValues();
+ void strokeLineCapValues_data();
+ void strokeLineCapValues();
+ void strokeLineJoinValues_data();
+ void strokeLineJoinValues();
};
void tst_QCssParser::scanner_data()
@@ -1759,6 +1763,57 @@ void tst_QCssParser::whitespaceValues()
QCOMPARE(rule.declarations.at(0).d->values.first().toString(), value);
}
+void tst_QCssParser::strokeLineCapValues_data()
+{
+ QTest::addColumn<QString>("value");
+
+ QTest::newRow("flatcap") << "flatcap";
+ QTest::newRow("roundcap") << "roundcap";
+ QTest::newRow("squarecap") << "squarecap";
+}
+
+void tst_QCssParser::strokeLineCapValues()
+{
+ QFETCH(QString, value);
+ QCss::Parser parser(QString("foo { -qt-stroke-linecap: %1 }").arg(value));
+ QCss::StyleSheet sheet;
+ QVERIFY(parser.parse(&sheet));
+
+ QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
+ sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+ QCOMPARE(rule.declarations.size(), 1);
+
+ QCOMPARE(rule.declarations.at(0).d->property, QLatin1String("-qt-stroke-linecap"));
+ QCOMPARE(rule.declarations.at(0).d->values.first().type, QCss::Value::KnownIdentifier);
+ QCOMPARE(rule.declarations.at(0).d->values.first().toString(), value);
+}
+
+void tst_QCssParser::strokeLineJoinValues_data()
+{
+ QTest::addColumn<QString>("value");
+
+ QTest::newRow("beveljoin") << "beveljoin";
+ QTest::newRow("miterjoin") << "miterjoin";
+ QTest::newRow("roundjoin") << "roundjoin";
+ QTest::newRow("svgmiterjoin") << "svgmiterjoin";
+}
+
+void tst_QCssParser::strokeLineJoinValues()
+{
+ QFETCH(QString, value);
+ QCss::Parser parser(QString("foo { -qt-stroke-linejoin: %1 }").arg(value));
+ QCss::StyleSheet sheet;
+ QVERIFY(parser.parse(&sheet));
+
+ QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
+ sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+ QCOMPARE(rule.declarations.size(), 1);
+
+ QCOMPARE(rule.declarations.at(0).d->property, QLatin1String("-qt-stroke-linejoin"));
+ QCOMPARE(rule.declarations.at(0).d->values.first().type, QCss::Value::KnownIdentifier);
+ QCOMPARE(rule.declarations.at(0).d->values.first().toString(), value);
+}
+
QTEST_MAIN(tst_QCssParser)
#include "tst_qcssparser.moc"
diff --git a/tests/auto/gui/text/qfontdatabase/CMakeLists.txt b/tests/auto/gui/text/qfontdatabase/CMakeLists.txt
index 18b96ded5d..0cb6e8d7c8 100644
--- a/tests/auto/gui/text/qfontdatabase/CMakeLists.txt
+++ b/tests/auto/gui/text/qfontdatabase/CMakeLists.txt
@@ -47,6 +47,8 @@ set(testdata_resource_files
"../../../shared/resources/testfont_open.otf"
"../../../shared/resources/testfont_variable.ttf"
"LED_REAL.TTF"
+ "QtTestLimitedFont-Regular.ttf"
+ "QtTestFallbackFont-Regular.ttf"
)
qt_internal_add_resource(tst_qfontdatabase "testdata"
diff --git a/tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttf b/tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttf
new file mode 100644
index 0000000000..ae21fec9a5
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttf
Binary files differ
diff --git a/tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttf b/tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttf
new file mode 100644
index 0000000000..2891f8aeff
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttf
Binary files differ
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 849e7432d1..8733f64d97 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -78,6 +78,8 @@ private:
QString m_testFontCondensed;
QString m_testFontItalic;
QString m_testFontVariable;
+ QString m_limitedFont;
+ QString m_fallbackFont;
};
tst_QFontDatabase::tst_QFontDatabase()
@@ -91,11 +93,15 @@ void tst_QFontDatabase::initTestCase()
m_testFontCondensed = QFINDTESTDATA("testfont_condensed.ttf");
m_testFontItalic = QFINDTESTDATA("testfont_italic.ttf");
m_testFontVariable = QFINDTESTDATA("testfont_variable.ttf");
+ m_limitedFont = QFINDTESTDATA("QtTestLimitedFont-Regular.ttf");
+ m_fallbackFont = QFINDTESTDATA("QtTestFallbackFont-Regular.ttf");
QVERIFY(!m_ledFont.isEmpty());
QVERIFY(!m_testFont.isEmpty());
QVERIFY(!m_testFontCondensed.isEmpty());
QVERIFY(!m_testFontItalic.isEmpty());
QVERIFY(!m_testFontVariable.isEmpty());
+ QVERIFY(!m_limitedFont.isEmpty());
+ QVERIFY(!m_fallbackFont.isEmpty());
}
void tst_QFontDatabase::styles_data()
@@ -391,8 +397,14 @@ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
void tst_QFontDatabase::condensedFontWidth()
{
- QFontDatabase::addApplicationFont(m_testFont);
- QFontDatabase::addApplicationFont(m_testFontCondensed);
+ int testFontId = QFontDatabase::addApplicationFont(m_testFont);
+ int testFontCondensedId = QFontDatabase::addApplicationFont(m_testFontCondensed);
+ auto cleanup = qScopeGuard([&testFontId, &testFontCondensedId] {
+ if (testFontId >= 0)
+ QFontDatabase::removeApplicationFont(testFontId);
+ if (testFontCondensedId >= 0)
+ QFontDatabase::removeApplicationFont(testFontCondensedId);
+ });
QVERIFY(QFontDatabase::hasFamily("QtBidiTestFont"));
if (!QFontDatabase::hasFamily("QtBidiTestFontCondensed"))
@@ -410,10 +422,16 @@ void tst_QFontDatabase::condensedFontWidth()
void tst_QFontDatabase::condensedFontMatching()
{
QFontDatabase::removeAllApplicationFonts();
- QFontDatabase::addApplicationFont(m_testFontCondensed);
+ int testFontCondensedId = QFontDatabase::addApplicationFont(m_testFontCondensed);
if (!QFontDatabase::hasFamily("QtBidiTestFont"))
QSKIP("This platform doesn't support preferred font family names (QTBUG-53478)");
- QFontDatabase::addApplicationFont(m_testFont);
+ int testFontId = QFontDatabase::addApplicationFont(m_testFont);
+ auto cleanup = qScopeGuard([&testFontId, &testFontCondensedId] {
+ if (testFontId >= 0)
+ QFontDatabase::removeApplicationFont(testFontId);
+ if (testFontCondensedId >= 0)
+ QFontDatabase::removeApplicationFont(testFontCondensedId);
+ });
// Test we correctly get the condensed font using different font matching methods:
QFont tfcByStretch("QtBidiTestFont");
@@ -561,11 +579,17 @@ void tst_QFontDatabase::addApplicationFontFallback()
{
int ledId = -1;
int id = -1;
- auto cleanup = qScopeGuard([&id, &ledId] {
+ int limitedId = -1;
+ int fallbackId = -1;
+ auto cleanup = qScopeGuard([&id, &ledId, &limitedId, &fallbackId] {
if (id >= 0)
QFontDatabase::removeApplicationFont(id);
if (ledId >= 0)
QFontDatabase::removeApplicationFont(ledId);
+ if (limitedId >= 0)
+ QFontDatabase::removeApplicationFont(limitedId);
+ if (fallbackId >= 0)
+ QFontDatabase::removeApplicationFont(fallbackId);
});
const QChar hebrewChar(0x05D0); // Hebrew 'aleph'
@@ -633,6 +657,107 @@ void tst_QFontDatabase::addApplicationFontFallback()
QCOMPARE(hebrewFontNow, defaultHebrewFont);
}
+ limitedId = QFontDatabase::addApplicationFont(m_limitedFont);
+ QVERIFY(limitedId >= 0);
+
+ fallbackId = QFontDatabase::addApplicationFont(m_fallbackFont);
+ QVERIFY(fallbackId >= 0);
+
+ QFontDatabase::addApplicationFallbackFontFamily(QChar::Script_Common, u"QtTestFallbackFont"_s);
+
+ // The fallback for Common will be used also for Latin, because Latin and Common are
+ // considered the same script by the font matching engine.
+ {
+ QTextLayout layout;
+ layout.setText(u"A'B,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QVERIFY(glyphRuns.size() > 1);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ // When the text only consists of common script characters, the fallback font will also be used.
+ {
+ QTextLayout layout;
+ layout.setText(u"',"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ QVERIFY(QFontDatabase::removeApplicationFallbackFontFamily(QChar::Script_Common, u"QtTestFallbackFont"_s));
+ QFontDatabase::addApplicationFallbackFontFamily(QChar::Script_Latin, u"QtTestFallbackFont"_s);
+
+ // Latin fallback works just the same as Common fallback
+ {
+ QTextLayout layout;
+ layout.setText(u"A'B,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ // When the common character is placed next to a Cyrillic characters, it gets adapted to this,
+ // so the fallback font will not be selected, even if it supports the character in question
+ {
+ QTextLayout layout;
+ layout.setText(u"A'Б,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() != u"QtTestFallbackFont"_s);
+ }
+ }
+
+ QFontDatabase::addApplicationFallbackFontFamily(QChar::Script_Cyrillic, u"QtTestFallbackFont"_s);
+
+ // When we set the fallback font for Cyrillic as well, it gets selected
+ {
+ QTextLayout layout;
+ layout.setText(u"A'Б,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ QVERIFY(QFontDatabase::removeApplicationFallbackFontFamily(QChar::Script_Cyrillic, u"QtTestFallbackFont"_s));
+ QVERIFY(QFontDatabase::removeApplicationFallbackFontFamily(QChar::Script_Latin, u"QtTestFallbackFont"_s));
}
QTEST_MAIN(tst_QFontDatabase)
diff --git a/tests/auto/gui/text/qfontmetrics/CMakeLists.txt b/tests/auto/gui/text/qfontmetrics/CMakeLists.txt
index d014d27d46..ee2f76ef76 100644
--- a/tests/auto/gui/text/qfontmetrics/CMakeLists.txt
+++ b/tests/auto/gui/text/qfontmetrics/CMakeLists.txt
@@ -24,8 +24,12 @@ qt_internal_add_test(tst_qfontmetrics
set_source_files_properties("../../../shared/resources/testfont.ttf"
PROPERTIES QT_RESOURCE_ALIAS "testfont.ttf"
)
+set_source_files_properties("../../../shared/resources/testfont_linemetrics.otf"
+ PROPERTIES QT_RESOURCE_ALIAS "testfont_linemetrics.otf"
+)
set(testfont_resource_files
"../../../shared/resources/testfont.ttf"
+ "../../../shared/resources/testfont_linemetrics.otf"
"ucs4font.ttf"
)
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
index 9471c1d93f..bad33ab0a4 100644
--- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
@@ -36,6 +36,7 @@ private slots:
void verticalMetrics();
void largeText_data();
void largeText(); // QTBUG-123339
+ void typoLineMetrics();
};
void tst_QFontMetrics::same()
@@ -410,5 +411,48 @@ void tst_QFontMetrics::largeText()
QVERIFY(boundingRect.isValid());
}
+void tst_QFontMetrics::typoLineMetrics()
+{
+ QString testFont = QFINDTESTDATA("fonts/testfont_linemetrics.otf");
+ QVERIFY(!testFont.isEmpty());
+
+ int id = QFontDatabase::addApplicationFont(testFont);
+ QVERIFY(id >= 0);
+
+ {
+ auto cleanup = qScopeGuard([&id] {
+ if (id >= 0)
+ QFontDatabase::removeApplicationFont(id);
+ });
+
+ QImage img(100, 100, QImage::Format_ARGB32);
+ img.setDevicePixelRatio(1.0);
+ QFont font(QFontDatabase::applicationFontFamilies(id).at(0), &img);
+ font.setPixelSize(18);
+
+ const qreal unitsPerEm = 1000.0;
+
+ QFontMetrics defaultFm(font);
+ const int defaultAscent = defaultFm.ascent();
+ const int defaultDescent = defaultFm.descent();
+ const int defaultLeading = defaultFm.leading();
+
+ QCOMPARE(defaultAscent, qRound(1234.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(defaultDescent, qRound(5678.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(defaultLeading, 0.0);
+
+ font.setStyleStrategy(QFont::PreferTypoLineMetrics);
+ const QFontMetrics typoFm(font);
+
+ const int typoAscent = typoFm.ascent();
+ const int typoDescent = typoFm.descent();
+ const int typoLeading = typoFm.leading();
+
+ QCOMPARE(typoAscent, qRound(2000.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(typoDescent, qRound(3000.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(typoLeading, qRound(1000.0 / unitsPerEm * font.pixelSize()));
+ }
+}
+
QTEST_MAIN(tst_QFontMetrics)
#include "tst_qfontmetrics.moc"
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 335ee06e2f..600b45575f 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -4053,20 +4053,107 @@ void tst_QTextDocument::restoreStrokeFromHtml()
QTextDocument document;
QTextCursor textCursor(&document);
QTextCharFormat textOutline;
- textOutline.setTextOutline(QPen(Qt::red, 2.3));
- textCursor.insertText("Outlined text", textOutline);
+
+ // Set stroke color and width
+ {
+ QPen pen(Qt::red, 2.3, Qt::SolidLine);
+ textOutline.setTextOutline(pen);
+ textCursor.insertText("Outlined text", textOutline);
+ }
+
+ // Set Cap and Join styles
+ {
+ QPen pen;
+ pen.setCapStyle(Qt::FlatCap);
+ pen.setJoinStyle(Qt::RoundJoin);
+ textOutline.setTextOutline(pen);
+ textCursor.insertBlock();
+ textCursor.insertText("Cap and Join Style", textOutline);
+ }
+
+ // Set Miter limit
+ {
+ QPen pen;
+ pen.setJoinStyle(Qt::MiterJoin);
+ pen.setMiterLimit(4);
+ textOutline.setTextOutline(pen);
+ textCursor.insertBlock();
+ textCursor.insertText("Miter Limit", textOutline);
+ }
+
+ // Set Dash Array and Dash Offset
+ {
+ QPen pen;
+ QList<qreal> pattern;
+ const int dash = 2;
+ const int gap = 4;
+ pattern << dash << gap << dash << gap << dash << gap;
+ pen.setDashPattern(pattern);
+ pen.setDashOffset(3);
+ textOutline.setTextOutline(pen);
+ textCursor.insertBlock();
+ textCursor.insertText("Dash Pattern", textOutline);
+ }
+
{
QTextDocument otherDocument;
otherDocument.setHtml(document.toHtml());
- QCOMPARE(otherDocument.blockCount(), 1);
- QTextBlock block = otherDocument.firstBlock();
- QTextFragment fragment = block.begin().fragment();
- QCOMPARE(fragment.text(), QStringLiteral("Outlined text"));
- QTextCharFormat fmt = fragment.charFormat();
- QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
- QPen pen = fmt.textOutline();
- QCOMPARE(pen.color(), QColor(Qt::red));
- QCOMPARE(pen.widthF(), 2.3);
+ QCOMPARE(otherDocument.blockCount(), document.blockCount());
+
+ QTextBlock block;
+ QTextFragment fragment;
+ QTextCharFormat fmt;
+ QPen pen;
+
+ {
+ block = otherDocument.findBlockByNumber(0);
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Outlined text"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.color(), QColor(Qt::red));
+ QCOMPARE(pen.widthF(), 2.3);
+ }
+
+ {
+ block = otherDocument.findBlockByNumber(1);
+ qDebug() << block.text();
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Cap and Join Style"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.capStyle(), Qt::FlatCap);
+ QCOMPARE(pen.joinStyle(), Qt::RoundJoin);
+ }
+
+ {
+ block = otherDocument.findBlockByNumber(2);
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Miter Limit"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.joinStyle(), Qt::MiterJoin);
+ QCOMPARE(pen.miterLimit(), 4);
+ }
+
+
+ {
+ block = otherDocument.findBlockByNumber(3);
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Dash Pattern"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.dashOffset(), 3);
+ QList<qreal> pattern;
+ const int dash = 2;
+ const int gap = 4;
+ pattern << dash << gap << dash << gap << dash << gap;
+ QCOMPARE(pen.dashPattern(), pattern);
+ }
}
}
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
index 15b30598e6..8fdad207ae 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
@@ -40,7 +40,7 @@ numerals in the same list structure:
1. Introduction
2. Qt Tools
1) Qt Assistant
- 2) Qt Designer
+ 2) Qt Widgets Designer
1. Form Editor
2. Component Architecture
3) Qt Linguist
@@ -70,7 +70,7 @@ column spans, text formatting within cells, and size constraints for columns.
|-------------|------------------------------------|---------------------------|-------------------------|
|9:00 - 11:00 |Introduction to Qt |||
|11:00 - 13:00|Using qmake |Object-oriented Programming|Layouts in Qt |
-|13:00 - 15:00|Qt Designer Tutorial |Extreme Programming |Writing Custom Styles |
+|13:00 - 15:00|Qt Widgets Designer Tutorial |Extreme Programming |Writing Custom Styles |
|15:00 - 17:00|Qt Linguist and Internationalization|Test-Driven Development | |
*Try adding text to the cells in the table and experiment with the alignment of
diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
index e08b299209..e75626eda7 100644
--- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
+++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
@@ -42,10 +42,6 @@ public slots:
}
};
-#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
-# define CAN_IMPLICITLY_UNSET
-#endif
-
void tst_qdesktopservices::handlers()
{
MyUrlHandler fooHandler;
@@ -53,12 +49,10 @@ void tst_qdesktopservices::handlers()
QDesktopServices::setUrlHandler(QString("foo"), &fooHandler, "handle");
QDesktopServices::setUrlHandler(QString("bar"), &barHandler, "handle");
-#ifndef CAN_IMPLICITLY_UNSET
const auto unsetHandlers = qScopeGuard([] {
QDesktopServices::unsetUrlHandler(u"bar"_s);
QDesktopServices::unsetUrlHandler(u"foo"_s);
});
-#endif
QUrl fooUrl("foo://blub/meh");
QUrl barUrl("bar://hmm/hmmmm");
@@ -68,15 +62,6 @@ void tst_qdesktopservices::handlers()
QCOMPARE(fooHandler.lastHandledUrl.toString(), fooUrl.toString());
QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString());
-
-#ifdef CAN_IMPLICITLY_UNSET
- for (int i = 0; i < 2; ++i)
- QTest::ignoreMessage(QtWarningMsg,
- "Please call QDesktopServices::unsetUrlHandler() before destroying a "
- "registered URL handler object.\n"
- "Support for destroying a registered URL handler object is deprecated, "
- "and will be removed in Qt 6.6.");
-#endif
}
QTEST_MAIN(tst_qdesktopservices)
diff --git a/tests/auto/network/access/CMakeLists.txt b/tests/auto/network/access/CMakeLists.txt
index 3ae66e1308..13332f0268 100644
--- a/tests/auto/network/access/CMakeLists.txt
+++ b/tests/auto/network/access/CMakeLists.txt
@@ -13,6 +13,10 @@ add_subdirectory(qnetworkreply)
add_subdirectory(qnetworkcachemetadata)
add_subdirectory(qabstractnetworkcache)
if(QT_FEATURE_http)
+ add_subdirectory(qnetworkreply_local)
+ if(NOT WASM) # QTBUG-121822
+ add_subdirectory(qformdatabuilder)
+ endif()
add_subdirectory(qnetworkrequestfactory)
add_subdirectory(qrestaccessmanager)
endif()
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index d9e82330b2..396a6f2fda 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -1277,7 +1277,7 @@ void tst_Http2::unsupportedAuthenticateChallenge()
bool authenticationRequested = false;
connect(manager.get(), &QNetworkAccessManager::authenticationRequired, reply.get(),
- [&](QNetworkReply *, QAuthenticator *auth) {
+ [&](QNetworkReply *, QAuthenticator *) {
authenticationRequested = true;
});
diff --git a/tests/auto/network/access/qformdatabuilder/CMakeLists.txt b/tests/auto/network/access/qformdatabuilder/CMakeLists.txt
new file mode 100644
index 0000000000..59d1b54e2a
--- /dev/null
+++ b/tests/auto/network/access/qformdatabuilder/CMakeLists.txt
@@ -0,0 +1,34 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qformdatabuilder LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+qt_internal_add_test(tst_qformdatabuilder
+ NO_BATCH # QTBUG-121815
+ DEFINES
+ QTEST_THROW_ON_FAIL
+ QTEST_THROW_ON_SKIP
+ SOURCES
+ tst_qformdatabuilder.cpp
+ LIBRARIES
+ Qt::Core
+ Qt::CorePrivate
+ Qt::Network
+ Qt::NetworkPrivate
+ TESTDATA
+ rfc3252.txt
+ image1.jpg
+ document.docx
+ sheet.xlsx
+)
+
+if(QT_FEATURE_sanitize_undefined)
+ qt_internal_extend_target(tst_qformdatabuilder
+ DEFINES
+ QT_SANITIZE_UNDEFINED # GCC (in)famously doesn't provide a predefined macro for this
+ )
+endif()
diff --git a/tests/auto/network/access/qformdatabuilder/document.docx b/tests/auto/network/access/qformdatabuilder/document.docx
new file mode 100644
index 0000000000..49005f14b6
--- /dev/null
+++ b/tests/auto/network/access/qformdatabuilder/document.docx
Binary files differ
diff --git a/tests/auto/network/access/qformdatabuilder/image1.jpg b/tests/auto/network/access/qformdatabuilder/image1.jpg
new file mode 100644
index 0000000000..d1d27bf7cf
--- /dev/null
+++ b/tests/auto/network/access/qformdatabuilder/image1.jpg
Binary files differ
diff --git a/tests/auto/network/access/qformdatabuilder/rfc3252.txt b/tests/auto/network/access/qformdatabuilder/rfc3252.txt
new file mode 100644
index 0000000000..0521a80d12
--- /dev/null
+++ b/tests/auto/network/access/qformdatabuilder/rfc3252.txt
@@ -0,0 +1 @@
+some text for reference \ No newline at end of file
diff --git a/tests/auto/network/access/qformdatabuilder/sheet.xlsx b/tests/auto/network/access/qformdatabuilder/sheet.xlsx
new file mode 100644
index 0000000000..2cb1ec7361
--- /dev/null
+++ b/tests/auto/network/access/qformdatabuilder/sheet.xlsx
Binary files differ
diff --git a/tests/auto/network/access/qformdatabuilder/tst_qformdatabuilder.cpp b/tests/auto/network/access/qformdatabuilder/tst_qformdatabuilder.cpp
new file mode 100644
index 0000000000..bc6c4b44f0
--- /dev/null
+++ b/tests/auto/network/access/qformdatabuilder/tst_qformdatabuilder.cpp
@@ -0,0 +1,456 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtNetwork/private/qhttpmultipart_p.h>
+#include <QtNetwork/qformdatabuilder.h>
+
+#include <QtCore/qbuffer.h>
+#include <QtCore/qfile.h>
+
+#include <QtTest/qtest.h>
+
+#ifndef QTEST_THROW_ON_FAIL
+# error This test requires QTEST_THROW_ON_FAIL being active.
+#endif
+
+using namespace Qt::StringLiterals;
+
+class tst_QFormDataBuilder : public QObject
+{
+ Q_OBJECT
+
+ void checkBodyPartsAreEquivalent(QByteArrayView expected, QByteArrayView actual);
+
+private Q_SLOTS:
+ void generateQHttpPartWithDevice_data();
+ void generateQHttpPartWithDevice();
+
+ void escapesBackslashAndQuotesInFilenameAndName_data();
+ void escapesBackslashAndQuotesInFilenameAndName();
+
+ void picksUtf8FilenameEncodingIfAsciiDontSuffice_data();
+ void picksUtf8FilenameEncodingIfAsciiDontSuffice();
+
+ void setHeadersDoesNotAffectHeaderFieldsManagedByBuilder_data();
+ void setHeadersDoesNotAffectHeaderFieldsManagedByBuilder();
+
+ void specifyMimeType_data();
+ void specifyMimeType();
+
+ void picksUtf8NameEncodingIfAsciiDoesNotSuffice_data();
+ void picksUtf8NameEncodingIfAsciiDoesNotSuffice();
+
+ void moveSemantics();
+};
+
+void tst_QFormDataBuilder::checkBodyPartsAreEquivalent(QByteArrayView expected, QByteArrayView actual)
+{
+ qsizetype expectedCrlfPos = expected.indexOf("\r\n");
+ qsizetype expectedBoundaryPos = expected.lastIndexOf("--boundary_.oOo.");
+
+ qsizetype actualCrlfPos = actual.indexOf("\r\n");
+ qsizetype actualBoundaryPos = actual.lastIndexOf("--boundary_.oOo.");
+
+ qsizetype start = expectedCrlfPos + 2;
+ qsizetype end = expectedBoundaryPos - expectedCrlfPos - 2;
+
+ QCOMPARE(actualCrlfPos, expectedCrlfPos);
+ QCOMPARE(actualBoundaryPos, expectedBoundaryPos);
+ QCOMPARE(actual.sliced(start, end), expected.sliced(start, end));
+}
+
+void tst_QFormDataBuilder::generateQHttpPartWithDevice_data()
+{
+ QTest::addColumn<QLatin1StringView>("name_data");
+ QTest::addColumn<QString>("real_file_name");
+ QTest::addColumn<QString>("body_name_data");
+ QTest::addColumn<QString>("expected_content_type_data");
+ QTest::addColumn<QString>("expected_content_disposition_data");
+ QTest::addColumn<QString>("content_disposition_must_not_contain_data");
+
+ QTest::newRow("txt-ascii") << "text"_L1 << u"rfc3252.txt"_s << u"rfc3252.txt"_s << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="rfc3252.txt")"_s
+ << u"filename*"_s;
+ QTest::newRow("txt-latin") << "text"_L1 << u"rfc3252.txt"_s << u"szöveg.txt"_s << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="szöveg.txt"; filename*=UTF-8''sz%C3%B6veg.txt)"_s
+ << u""_s;
+ QTest::newRow("txt-unicode") << "text"_L1 << u"rfc3252.txt"_s << u"テキスト.txt"_s << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="テキスト.txt"; filename*=UTF-8''%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88.txt)"_s
+ << u""_s;
+
+ QTest::newRow("jpg-ascii") << "image"_L1 << u"image1.jpg"_s << u"image1.jpg"_s << u"image/jpeg"_s
+ << uR"(form-data; name="image"; filename="image1.jpg")"_s
+ << u"filename*"_s;
+ QTest::newRow("jpg-latin") << "image"_L1 << u"image1.jpg"_s << u"kép.jpg"_s << u"image/jpeg"_s
+ << uR"(form-data; name="image"; filename="kép.jpg"; filename*=UTF-8''k%C3%A9p.jpg)"_s
+ << u""_s;
+ QTest::newRow("jpg-unicode") << "image"_L1 << u"image1.jpg"_s << u"絵.jpg"_s << u"image/jpeg"_s
+ << uR"(form-data; name="image"; filename="絵.jpg"; filename*=UTF-8''%E7%B5%B5.jpg)"_s
+ << u""_s;
+
+ QTest::newRow("doc-ascii") << "text"_L1 << u"document.docx"_s << u"word.docx"_s
+ << u"application/vnd.openxmlformats-officedocument.wordprocessingml.document"_s
+ << uR"(form-data; name="text"; filename="word.docx")"_s
+ << u"filename*"_s;
+ QTest::newRow("doc-latin") << "text"_L1 << u"document.docx"_s << u"szöveg.docx"_s
+ << u"application/vnd.openxmlformats-officedocument.wordprocessingml.document"_s
+ << uR"(form-data; name="text"; filename="szöveg.docx"; filename*=UTF-8''sz%C3%B6veg.docx)"_s
+ << u""_s;
+ QTest::newRow("doc-unicode") << "text"_L1 << u"document.docx"_s << u"テキスト.docx"_s
+ << u"application/vnd.openxmlformats-officedocument.wordprocessingml.document"_s
+ << uR"(form-data; name="text"; filename="テキスト.docx"; filename*=UTF-8''%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88.docx)"_s
+ << u""_s;
+
+ QTest::newRow("xls-ascii") << "spreadsheet"_L1 << u"sheet.xlsx"_s << u"sheet.xlsx"_s
+ << u"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"_s
+ << uR"(form-data; name="spreadsheet"; filename="sheet.xlsx")"_s
+ << u"filename*"_s;
+ QTest::newRow("xls-latin") << "spreadsheet"_L1 << u"sheet.xlsx"_s << u"szöveg.xlsx"_s
+ << u"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"_s
+ << uR"(form-data; name="spreadsheet"; filename="szöveg.xlsx"; filename*=UTF-8''sz%C3%B6veg.xlsx)"_s
+ << u""_s;
+ QTest::newRow("xls-unicode") << "spreadsheet"_L1 << u"sheet.xlsx"_s << u"テキスト.xlsx"_s
+ << u"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"_s
+ << uR"(form-data; name="spreadsheet"; filename="テキスト.xlsx"; filename*=UTF-8''%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88.xlsx)"_s
+ << u""_s;
+}
+
+void tst_QFormDataBuilder::generateQHttpPartWithDevice()
+{
+ QFETCH(const QLatin1StringView, name_data);
+ QFETCH(const QString, real_file_name);
+ QFETCH(const QString, body_name_data);
+ QFETCH(const QString, expected_content_type_data);
+ QFETCH(const QString, expected_content_disposition_data);
+ QFETCH(const QString, content_disposition_must_not_contain_data);
+
+ QString testData = QFileInfo(QFINDTESTDATA(real_file_name)).absoluteFilePath();
+ QFile data_file(testData);
+
+ QFormDataBuilder qfdb;
+ QFormDataPartBuilder &qfdpb = qfdb.part(name_data).setBodyDevice(&data_file, body_name_data);
+ const QHttpPart httpPart = qfdpb.build();
+
+ const auto msg = QDebug::toString(httpPart);
+ QVERIFY(msg.contains(expected_content_type_data));
+ QVERIFY(msg.contains(expected_content_disposition_data));
+ if (!content_disposition_must_not_contain_data.isEmpty())
+ QVERIFY(!msg.contains(content_disposition_must_not_contain_data));
+}
+
+void tst_QFormDataBuilder::escapesBackslashAndQuotesInFilenameAndName_data()
+{
+ QTest::addColumn<QLatin1StringView>("name_data");
+ QTest::addColumn<QString>("body_name_data");
+ QTest::addColumn<QString>("expected_content_type_data");
+ QTest::addColumn<QString>("expected_content_disposition_data");
+
+ QTest::newRow("quote") << "t\"ext"_L1 << uR"(rfc32"52.txt)"_s << u"text/plain"_s
+ << uR"(form-data; name="t\"ext"; filename="rfc32\"52.txt")"_s;
+
+ QTest::newRow("slash") << "t\\ext"_L1 << uR"(rfc32\52.txt)"_s << u"text/plain"_s
+ << uR"(form-data; name="t\\ext"; filename="rfc32\\52.txt")"_s;
+
+ QTest::newRow("quotes") << "t\"e\"xt"_L1 << uR"(rfc3"25"2.txt)"_s << u"text/plain"_s
+ << uR"(form-data; name="t\"e\"xt"; filename="rfc3\"25\"2.txt")"_s;
+
+ QTest::newRow("slashes") << "t\\\\ext"_L1 << uR"(rfc32\\52.txt)"_s << u"text/plain"_s
+ << uR"(form-data; name="t\\\\ext"; filename="rfc32\\\\52.txt")"_s;
+
+ QTest::newRow("quote-slash") << "t\"ex\\t"_L1 << uR"(rfc"32\52.txt)"_s << u"text/plain"_s
+ << uR"(form-data; name="t\"ex\\t"; filename="rfc\"32\\52.txt")"_s;
+
+ QTest::newRow("quotes-slashes") << "t\"e\"x\\t\\"_L1 << uR"(r"f"c3\2\52.txt)"_s << u"text/plain"_s
+ << uR"(form-data; name="t\"e\"x\\t\\"; filename="r\"f\"c3\\2\\52.txt")"_s;
+}
+
+void tst_QFormDataBuilder::escapesBackslashAndQuotesInFilenameAndName()
+{
+ QFETCH(const QLatin1StringView, name_data);
+ QFETCH(const QString, body_name_data);
+ QFETCH(const QString, expected_content_type_data);
+ QFETCH(const QString, expected_content_disposition_data);
+
+ QFile dummy_file(body_name_data);
+
+ QFormDataBuilder qfdb;
+ QFormDataPartBuilder &qfdpb = qfdb.part(name_data).setBodyDevice(&dummy_file, body_name_data);
+ const QHttpPart httpPart = qfdpb.build();
+
+ const auto msg = QDebug::toString(httpPart);
+ QVERIFY(msg.contains(expected_content_type_data));
+ QVERIFY(msg.contains(expected_content_disposition_data));
+}
+
+void tst_QFormDataBuilder::picksUtf8FilenameEncodingIfAsciiDontSuffice_data()
+{
+ QTest::addColumn<QLatin1StringView>("name_data");
+ QTest::addColumn<QAnyStringView>("body_name_data");
+ QTest::addColumn<QString>("expected_content_type_data");
+ QTest::addColumn<QString>("expected_content_disposition_data");
+ QTest::addColumn<QString>("content_disposition_must_not_contain_data");
+
+ QTest::newRow("latin1-ascii") << "text"_L1 << QAnyStringView("rfc3252.txt"_L1) << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="rfc3252.txt")"_s
+ << u"filename*"_s;
+ QTest::newRow("u8-ascii") << "text"_L1 << QAnyStringView(u8"rfc3252.txt") << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="rfc3252.txt")"_s
+ << u"filename*"_s;
+ QTest::newRow("u-ascii") << "text"_L1 << QAnyStringView(u"rfc3252.txt") << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="rfc3252.txt")"_s
+ << u"filename*"_s;
+
+ // 0xF6 is 'ö', use hex value with Latin-1 to avoid interpretation as UTF-8 (0xC3 0xB6)
+ QTest::newRow("latin1-latin") << "text"_L1 << QAnyStringView("sz\xF6veg.txt"_L1) << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="szöveg.txt"; filename*=UTF-8''sz%C3%B6veg.txt)"_s
+ << u""_s;
+ QTest::newRow("u8-latin") << "text"_L1 << QAnyStringView(u8"szöveg.txt") << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="szöveg.txt"; filename*=UTF-8''sz%C3%B6veg.txt)"_s
+ << u""_s;
+ QTest::newRow("u-latin") << "text"_L1 << QAnyStringView(u"szöveg.txt") << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="szöveg.txt"; filename*=UTF-8''sz%C3%B6veg.txt)"_s
+ << u""_s;
+
+ QTest::newRow("u8-u8") << "text"_L1 << QAnyStringView(u8"テキスト.txt") << u"text/plain"_s
+ << uR"(form-data; name="text"; filename="テキスト.txt"; filename*=UTF-8''%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88.txt)"_s
+ << u""_s;
+}
+
+void tst_QFormDataBuilder::picksUtf8FilenameEncodingIfAsciiDontSuffice()
+{
+ QFETCH(const QLatin1StringView, name_data);
+ QFETCH(const QAnyStringView, body_name_data);
+ QFETCH(const QString, expected_content_type_data);
+ QFETCH(const QString, expected_content_disposition_data);
+ QFETCH(const QString, content_disposition_must_not_contain_data);
+
+ QBuffer buff;
+ QFormDataBuilder qfdb;
+ QFormDataPartBuilder &qfdpb = qfdb.part(name_data).setBodyDevice(&buff, body_name_data);
+ const QHttpPart httpPart = qfdpb.build();
+
+ const auto msg = QDebug::toString(httpPart);
+ QVERIFY2(msg.contains(expected_content_type_data),
+ qPrintable(u"content-type not found : "_s + expected_content_type_data));
+ QVERIFY2(msg.contains(expected_content_disposition_data),
+ qPrintable(u"content-disposition not found : "_s + expected_content_disposition_data));
+ if (!content_disposition_must_not_contain_data.isEmpty()) {
+ QVERIFY2(!msg.contains(content_disposition_must_not_contain_data),
+ qPrintable(u"content-disposition contained data it shouldn't : "_s
+ + content_disposition_must_not_contain_data));
+ }
+}
+
+void tst_QFormDataBuilder::setHeadersDoesNotAffectHeaderFieldsManagedByBuilder_data()
+{
+ QTest::addColumn<QLatin1StringView>("name_data");
+ QTest::addColumn<QAnyStringView>("body_name_data");
+ QTest::addColumn<bool>("overwrite");
+ QTest::addColumn<bool>("extra_headers");
+ QTest::addColumn<QStringList>("expected_headers");
+
+ QTest::newRow("content-disposition-is-set-by-default")
+ << "text"_L1 << QAnyStringView("rfc3252.txt"_L1)
+ << false << false
+ << QStringList{
+ uR"("content-disposition":"form-data; name=\"text\"; filename=\"rfc3252.txt\"")"_s,
+ uR"("content-type":"text/plain")"_s};
+
+ QTest::newRow("default-overwrites-preset-content-disposition")
+ << "text"_L1 << QAnyStringView("rfc3252.txt"_L1)
+ << true << false
+ << QStringList{
+ uR"("content-disposition":"form-data; name=\"text\"; filename=\"rfc3252.txt\"")"_s,
+ uR"("content-type":"text/plain")"_s};
+
+ QTest::newRow("added-extra-header")
+ << "text"_L1 << QAnyStringView("rfc3252.txt"_L1)
+ << false << true
+ << QStringList{
+ uR"("content-disposition":"form-data; name=\"text\"; filename=\"rfc3252.txt\"")"_s,
+ uR"("content-type":"text/plain")"_s,
+ uR"("content-length":"70")"_s};
+
+ QTest::newRow("extra-header-and-overwrite")
+ << "text"_L1 << QAnyStringView("rfc3252.txt"_L1)
+ << true << true
+ << QStringList{
+ uR"("content-disposition":"form-data; name=\"text\"; filename=\"rfc3252.txt\"")"_s,
+ uR"("content-type":"text/plain")"_s,
+ uR"("content-length":"70")"_s};
+}
+
+void tst_QFormDataBuilder::setHeadersDoesNotAffectHeaderFieldsManagedByBuilder()
+{
+ QFETCH(const QLatin1StringView, name_data);
+ QFETCH(const QAnyStringView, body_name_data);
+ QFETCH(const bool, overwrite);
+ QFETCH(const bool, extra_headers);
+ QFETCH(const QStringList, expected_headers);
+
+ QBuffer buff;
+
+ QFormDataBuilder qfdb;
+ QFormDataPartBuilder &qfdpb = qfdb.part(name_data).setBodyDevice(&buff, body_name_data);
+
+ if (overwrite || extra_headers) {
+ QHttpHeaders headers;
+
+ if (overwrite) {
+ headers.append(QHttpHeaders::WellKnownHeader::ContentType, "attachment");
+ qfdpb.setHeaders(headers);
+ }
+
+ if (extra_headers) {
+ headers.append(QHttpHeaders::WellKnownHeader::ContentLength, "70");
+ qfdpb.setHeaders(std::move(headers));
+ }
+ }
+
+ const QHttpPart httpPart = qfdpb.build();
+
+ const auto msg = QDebug::toString(httpPart);
+ for (const auto &header : expected_headers)
+ QVERIFY2(msg.contains(header), qPrintable(header));
+}
+
+void tst_QFormDataBuilder::specifyMimeType_data()
+{
+ QTest::addColumn<QLatin1StringView>("name_data");
+ QTest::addColumn<QAnyStringView>("body_name_data");
+ QTest::addColumn<QAnyStringView>("mime_type");
+ QTest::addColumn<QString>("expected_content_type_data");
+
+ QTest::newRow("not-specified") << "text"_L1 << QAnyStringView("rfc3252.txt"_L1)
+ << QAnyStringView("text/plain"_L1) << uR"("content-type":"text/plain")"_s;
+ QTest::newRow("mime-specified") << "text"_L1 << QAnyStringView("rfc3252.txt"_L1)
+ << QAnyStringView("text/plain"_L1) << uR"("content-type":"text/plain")"_s;
+ // wrong mime type specified but it is not overridden by the deduction
+ QTest::newRow("wrong-mime-specified") << "text"_L1 << QAnyStringView("rfc3252.txt"_L1)
+ << QAnyStringView("image/jpeg"_L1) << uR"("content-type":"image/jpeg)"_s;
+}
+
+void tst_QFormDataBuilder::specifyMimeType()
+{
+ QFETCH(const QLatin1StringView, name_data);
+ QFETCH(const QAnyStringView, body_name_data);
+ QFETCH(const QAnyStringView, mime_type);
+ QFETCH(const QString, expected_content_type_data);
+
+ QBuffer buff;
+
+ QFormDataBuilder qfdb;
+ QFormDataPartBuilder &qfdpb = qfdb.part(name_data).setBodyDevice(&buff, body_name_data);
+
+ if (!mime_type.empty())
+ qfdpb.setBodyDevice(&buff, body_name_data, mime_type);
+ else
+ qfdpb.setBodyDevice(&buff, body_name_data);
+
+ const QHttpPart httpPart = qfdpb.build();
+
+ const auto msg = QDebug::toString(httpPart);
+ QVERIFY(msg.contains(expected_content_type_data));
+}
+
+void tst_QFormDataBuilder::picksUtf8NameEncodingIfAsciiDoesNotSuffice_data()
+{
+ QTest::addColumn<QAnyStringView>("name_data");
+ QTest::addColumn<QString>("expected_content_disposition_data");
+
+ QTest::newRow("latin1-ascii") << QAnyStringView("text"_L1) << uR"(form-data; name="text")"_s;
+ QTest::newRow("u8-ascii") << QAnyStringView(u8"text") << uR"(form-data; name="text")"_s;
+ QTest::newRow("u-ascii") << QAnyStringView(u"text") << uR"(form-data; name="text")"_s;
+
+ // 0xF6 is 'ö', use hex value with Latin-1 to avoid interpretation as UTF-8
+ QTest::newRow("latin1-latin") << QAnyStringView("t\xF6xt"_L1) << uR"(form-data; name="töxt")"_s;
+ QTest::newRow("u8-latin") << QAnyStringView(u8"töxt") << uR"(form-data; name="töxt")"_s;
+ QTest::newRow("u-latin") << QAnyStringView(u"töxt") << uR"(form-data; name="töxt")"_s;
+
+ QTest::newRow("u8-u8") << QAnyStringView(u8"テキスト") << uR"(form-data; name="テキスト")"_s;
+}
+
+void tst_QFormDataBuilder::picksUtf8NameEncodingIfAsciiDoesNotSuffice()
+{
+ QFETCH(const QAnyStringView, name_data);
+ QFETCH(const QString, expected_content_disposition_data);
+
+ QFormDataBuilder qfdb;
+ QFormDataPartBuilder &qfdpb = qfdb.part(name_data).setBody("some"_ba);
+ auto msg = QDebug::toString(qfdpb.build());
+
+ QVERIFY2(msg.contains(expected_content_disposition_data),
+ qPrintable(u"content-disposition not found : "_s + expected_content_disposition_data));
+}
+
+void tst_QFormDataBuilder::moveSemantics()
+{
+#if defined(QT_BUILD_INTERNAL) || !defined(QT_UNDEFINED_SANITIZER)
+ constexpr QByteArrayView expected = "--boundary_.oOo._4SUrZy7x9lPHMF3fbRSsE15hiWu5Sbmy\r\n"
+ "content-type: text/plain\r\ncontent-disposition: form-data; name=\"text\"; filename=\"rfc3252.txt\"\r\n\r\n"
+ "some text for reference\r\n"
+ "--boundary_.oOo._4SUrZy7x9lPHMF3fbRSsE15hiWu5Sbmy--\r\n";
+
+ const QString testData = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absoluteFilePath();
+
+ // We get the expected
+ {
+ QFile data_file(testData);
+ QVERIFY2(data_file.open(QIODeviceBase::ReadOnly), qPrintable(data_file.errorString()));
+
+ QFormDataBuilder qfdb;
+ qfdb.part("text"_L1).setBodyDevice(&data_file, "rfc3252.txt");
+ std::unique_ptr<QHttpMultiPart> mp = qfdb.buildMultiPart();
+
+ auto mp_priv = QHttpMultiPartPrivate::get(mp.get());
+ mp_priv->device->open(QIODeviceBase::ReadOnly);
+ const QByteArray actual = mp_priv->device->readAll();
+
+ checkBodyPartsAreEquivalent(expected, actual);
+ }
+
+ // We get the expected from a move constructed qfdb
+ {
+ QFile data_file(testData);
+ QVERIFY2(data_file.open(QIODeviceBase::ReadOnly), qPrintable(data_file.errorString()));
+
+ QFormDataBuilder qfdb;
+ auto &p = qfdb.part("text"_L1);
+ auto qfdb_moved = std::move(qfdb);
+
+ p.setBodyDevice(&data_file, "rfc3252.txt");
+ std::unique_ptr<QHttpMultiPart> mp = qfdb_moved.buildMultiPart();
+
+ auto mp_priv = QHttpMultiPartPrivate::get(mp.get());
+ mp_priv->device->open(QIODeviceBase::ReadOnly);
+ const QByteArray actual = mp_priv->device->readAll();
+
+ checkBodyPartsAreEquivalent(expected, actual);
+ }
+
+ // We get the expected from a move assigned qfdb
+ {
+ QFile data_file(testData);
+ QVERIFY2(data_file.open(QIODeviceBase::ReadOnly), qPrintable(data_file.errorString()));
+
+ QFormDataBuilder qfdb;
+ QFormDataBuilder qfdb_moved;
+
+ qfdb.part("text"_L1).setBodyDevice(&data_file, "rfc3252.txt");
+
+ qfdb_moved = std::move(qfdb);
+ std::unique_ptr<QHttpMultiPart> mp = qfdb_moved.buildMultiPart();
+
+ auto mp_priv = QHttpMultiPartPrivate::get(mp.get());
+ mp_priv->device->open(QIODeviceBase::ReadOnly);
+ const QByteArray actual = mp_priv->device->readAll();
+
+ checkBodyPartsAreEquivalent(expected, actual);
+ }
+#else
+ QSKIP("This test requires -developer-build when --sanitize=undefined is active.");
+#endif
+}
+
+QTEST_MAIN(tst_QFormDataBuilder)
+#include "tst_qformdatabuilder.moc"
diff --git a/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp b/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp
index 457d30feeb..5b6be3c7b4 100644
--- a/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp
+++ b/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp
@@ -436,9 +436,6 @@ void tst_QHttpHeaders::headerValueField()
QRegularExpression re("HTTP header value contained illegal character*");
TEST_ILLEGAL_HEADER_VALUE_CHARACTER("foo\x08" "bar"); // BS
TEST_ILLEGAL_HEADER_VALUE_CHARACTER("foo\x1B" "bar"); // ESC
- // Disallowed UTF-8 characters
- TEST_ILLEGAL_HEADER_VALUE_CHARACTER(u8"€");
- TEST_ILLEGAL_HEADER_VALUE_CHARACTER(u8"𝒜𝒴𝟘𝟡𐎀𐎜𐒀𐒐𝓐𝓩𝔸𝔹𝕀𝕁𝕌𝕍𓂀𓂁𓃀𓃁𓇋𓇌𓉐𓉑𓋴𓋵𓎡𓎢𓎣𓏏");
// Disallowed UTF-16 characters
TEST_ILLEGAL_HEADER_VALUE_CHARACTER(u"€");
TEST_ILLEGAL_HEADER_VALUE_CHARACTER(u"𝒜𝒴𝟘𝟡𐎀𐎜𐒀𐒐𝓐𝓩𝔸𝔹𝕀𝕁𝕌𝕍𓂀𓂁𓃀𓃁𓇋𓇌𓉐𓉑𓋴𓋵𓎡𓎢𓎣𓏏");
diff --git a/tests/auto/network/access/qnetworkcookiejar/testdata/publicsuffix/public_suffix_list.dafsa b/tests/auto/network/access/qnetworkcookiejar/testdata/publicsuffix/public_suffix_list.dafsa
index 2bd4ca05f3..f891b16963 100644
--- a/tests/auto/network/access/qnetworkcookiejar/testdata/publicsuffix/public_suffix_list.dafsa
+++ b/tests/auto/network/access/qnetworkcookiejar/testdata/publicsuffix/public_suffix_list.dafsa
Binary files differ
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index a26d2c809b..06d0847acd 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -6682,7 +6682,6 @@ void tst_QNetworkReply::httpConnectionCount()
int pendingConnectionCount = 0;
- using namespace std::chrono_literals;
const auto newPendingConnection = [&server]() { return server->hasPendingConnections(); };
// If we have http2 enabled then the second connection will take a little
// longer to be established because we will wait for the first one to finish
@@ -10300,6 +10299,9 @@ void tst_QNetworkReply::contentEncoding()
#if QT_CONFIG(http)
void tst_QNetworkReply::contentEncodingBigPayload_data()
{
+#if Q_PROCESSOR_WORDSIZE <= 4
+ QSKIP("Allocating 4GB leads to std::bad_alloc on a 32b architecture");
+#endif
QTest::addColumn<QByteArray>("encoding");
QTest::addColumn<QString>("path");
QTest::addColumn<qint64>("expectedSize");
@@ -10337,7 +10339,7 @@ void tst_QNetworkReply::contentEncodingBigPayload()
request.setDecompressedSafetyCheckThreshold(-1);
QNetworkReplyPtr reply(manager.get(request));
- QTRY_VERIFY2_WITH_TIMEOUT(reply->isFinished(), qPrintable(reply->errorString()), 15000);
+ QTRY_VERIFY2_WITH_TIMEOUT(reply->isFinished(), qPrintable(reply->errorString()), 15s);
QCOMPARE(reply->error(), QNetworkReply::NoError);
QFETCH(qint64, expectedSize);
@@ -10462,7 +10464,7 @@ void tst_QNetworkReply::contentEncodingError()
QUrl(QLatin1String("http://localhost:%1").arg(QString::number(server.serverPort()))));
QNetworkReplyPtr reply(manager.get(request));
- QTRY_VERIFY2_WITH_TIMEOUT(reply->isFinished(), qPrintable(reply->errorString()), 15000);
+ QTRY_VERIFY2_WITH_TIMEOUT(reply->isFinished(), qPrintable(reply->errorString()), 15s);
QTEST(reply->error(), "expectedError");
}
@@ -10532,7 +10534,7 @@ void tst_QNetworkReply::notFoundWithCompression()
QUrl(QLatin1String("http://localhost:%1").arg(QString::number(server.serverPort()))));
QNetworkReplyPtr reply(manager.get(request));
- QTRY_VERIFY2_WITH_TIMEOUT(reply->isFinished(), qPrintable(reply->errorString()), 15000);
+ QTRY_VERIFY2_WITH_TIMEOUT(reply->isFinished(), qPrintable(reply->errorString()), 15s);
QCOMPARE(reply->error(), QNetworkReply::ContentNotFoundError);
QFETCH(QByteArray, expected);
diff --git a/tests/auto/network/access/qnetworkreply_local/CMakeLists.txt b/tests/auto/network/access/qnetworkreply_local/CMakeLists.txt
new file mode 100644
index 0000000000..13a60afb13
--- /dev/null
+++ b/tests/auto/network/access/qnetworkreply_local/CMakeLists.txt
@@ -0,0 +1,9 @@
+qt_internal_add_test(tst_qnetworkreply_local
+ SOURCES
+ minihttpserver.h
+ tst_qnetworkreply_local.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::NetworkPrivate
+ BUNDLE_ANDROID_OPENSSL_LIBS
+)
diff --git a/tests/auto/network/access/qnetworkreply_local/minihttpserver.h b/tests/auto/network/access/qnetworkreply_local/minihttpserver.h
new file mode 100644
index 0000000000..eb0697a6f8
--- /dev/null
+++ b/tests/auto/network/access/qnetworkreply_local/minihttpserver.h
@@ -0,0 +1,246 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MINIHTTPSERVER_H
+#define MINIHTTPSERVER_H
+
+#include <QtNetwork/qtnetworkglobal.h>
+
+#include <QtNetwork/qtcpserver.h>
+#include <QtNetwork/qtcpsocket.h>
+#include <QtNetwork/qlocalsocket.h>
+#if QT_CONFIG(ssl)
+# include <QtNetwork/qsslsocket.h>
+#endif
+#if QT_CONFIG(localserver)
+# include <QtNetwork/qlocalserver.h>
+#endif
+
+#include <QtCore/qpointer.h>
+#include <QtCore/qhash.h>
+
+#include <utility>
+
+static inline QByteArray default200Response()
+{
+ return QByteArrayLiteral("HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/plain\r\n"
+ "Content-Length: 12\r\n"
+ "\r\n"
+ "Hello World!");
+}
+class MiniHttpServerV2 : public QObject
+{
+ Q_OBJECT
+
+public:
+ struct State;
+
+#if QT_CONFIG(localserver)
+ void bind(QLocalServer *server)
+ {
+ Q_ASSERT(!localServer);
+ localServer = server;
+ connect(server, &QLocalServer::newConnection, this,
+ &MiniHttpServerV2::incomingLocalConnection);
+ }
+#endif
+
+ void bind(QTcpServer *server)
+ {
+ Q_ASSERT(!tcpServer);
+ tcpServer = server;
+ connect(server, &QTcpServer::pendingConnectionAvailable, this,
+ &MiniHttpServerV2::incomingConnection);
+ }
+
+ void setDataToTransmit(QByteArray data) { dataToTransmit = std::move(data); }
+
+ void clearServerState()
+ {
+ auto copy = std::exchange(clientStates, {});
+ for (auto [socket, _] : copy.asKeyValueRange()) {
+ if (auto *tcpSocket = qobject_cast<QTcpSocket *>(socket))
+ tcpSocket->disconnectFromHost();
+ else if (auto *localSocket = qobject_cast<QLocalSocket *>(socket))
+ localSocket->disconnectFromServer();
+ else
+ Q_UNREACHABLE_RETURN();
+ socket->deleteLater();
+ }
+ }
+
+ bool hasPendingConnections() const
+ {
+ return
+#if QT_CONFIG(localserver)
+ (localServer && localServer->hasPendingConnections()) ||
+#endif
+ (tcpServer && tcpServer->hasPendingConnections());
+ }
+
+ QString addressForScheme(QStringView scheme) const
+ {
+ using namespace Qt::StringLiterals;
+ if (scheme.startsWith("unix"_L1) || scheme.startsWith("local"_L1)) {
+#if QT_CONFIG(localserver)
+ if (localServer)
+ return localServer->serverName();
+#endif
+ } else if (scheme == "http"_L1) {
+ if (tcpServer)
+ return "%1:%2"_L1.arg(tcpServer->serverAddress().toString(),
+ QString::number(tcpServer->serverPort()));
+ }
+ return {};
+ }
+
+ QList<State> peerStates() const { return clientStates.values(); }
+
+protected:
+#if QT_CONFIG(localserver)
+ void incomingLocalConnection()
+ {
+ auto *socket = localServer->nextPendingConnection();
+ connectSocketSignals(socket);
+ }
+#endif
+
+ void incomingConnection()
+ {
+ auto *socket = tcpServer->nextPendingConnection();
+ connectSocketSignals(socket);
+ }
+
+ void reply(QIODevice *socket)
+ {
+ Q_ASSERT(socket);
+ if (dataToTransmit.isEmpty()) {
+ emit socket->bytesWritten(0); // emulate having written the data
+ return;
+ }
+ if (!stopTransfer)
+ socket->write(dataToTransmit);
+ }
+
+private:
+ void connectSocketSignals(QIODevice *socket)
+ {
+ connect(socket, &QIODevice::readyRead, this, [this, socket]() { readyReadSlot(socket); });
+ connect(socket, &QIODevice::bytesWritten, this,
+ [this, socket]() { bytesWrittenSlot(socket); });
+#if QT_CONFIG(ssl)
+ if (auto *sslSocket = qobject_cast<QSslSocket *>(socket))
+ connect(sslSocket, &QSslSocket::sslErrors, this, &MiniHttpServerV2::slotSslErrors);
+#endif
+
+ if (auto *tcpSocket = qobject_cast<QTcpSocket *>(socket)) {
+ connect(tcpSocket, &QAbstractSocket::errorOccurred, this, &MiniHttpServerV2::slotError);
+ } else if (auto *localSocket = qobject_cast<QLocalSocket *>(socket)) {
+ connect(localSocket, &QLocalSocket::errorOccurred, this,
+ [this](QLocalSocket::LocalSocketError error) {
+ slotError(QAbstractSocket::SocketError(error));
+ });
+ } else {
+ Q_UNREACHABLE_RETURN();
+ }
+ }
+
+ void parseContentLength(State &st, QByteArrayView header)
+ {
+ qsizetype index = header.indexOf("\r\ncontent-length:");
+ if (index == -1)
+ return;
+ st.foundContentLength = true;
+
+ index += sizeof("\r\ncontent-length:") - 1;
+ const auto *end = std::find(header.cbegin() + index, header.cend(), '\r');
+ QByteArrayView num = header.mid(index, std::distance(header.cbegin() + index, end));
+ bool ok = false;
+ st.contentLength = num.toInt(&ok);
+ if (!ok)
+ st.contentLength = -1;
+ }
+
+private slots:
+#if QT_CONFIG(ssl)
+ void slotSslErrors(const QList<QSslError> &errors)
+ {
+ QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender());
+ Q_ASSERT(currentClient);
+ qDebug() << "slotSslErrors" << currentClient->errorString() << errors;
+ }
+#endif
+ void slotError(QAbstractSocket::SocketError err)
+ {
+ QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender());
+ Q_ASSERT(currentClient);
+ qDebug() << "slotError" << err << currentClient->errorString();
+ }
+
+public slots:
+
+ void readyReadSlot(QIODevice *socket)
+ {
+ if (stopTransfer)
+ return;
+ State &st = clientStates[socket];
+ st.receivedData += socket->readAll();
+ const qsizetype doubleEndlPos = st.receivedData.indexOf("\r\n\r\n");
+
+ if (doubleEndlPos != -1) {
+ const qsizetype endOfHeader = doubleEndlPos + 4;
+ st.contentRead = st.receivedData.size() - endOfHeader;
+
+ if (!st.checkedContentLength) {
+ parseContentLength(st, QByteArrayView(st.receivedData).first(endOfHeader));
+ st.checkedContentLength = true;
+ }
+
+ if (st.contentRead < st.contentLength)
+ return;
+
+ // multiple requests incoming, remove the bytes of the current one
+ if (multiple)
+ st.receivedData.remove(0, endOfHeader);
+
+ reply(socket);
+ }
+ }
+
+ void bytesWrittenSlot(QIODevice *socket)
+ {
+ // Disconnect and delete in next cycle (else Windows clients will fail with
+ // RemoteHostClosedError).
+ if (doClose && socket->bytesToWrite() == 0) {
+ disconnect(socket, nullptr, this, nullptr);
+ socket->deleteLater();
+ }
+ }
+
+private:
+ QByteArray dataToTransmit = default200Response();
+
+ QTcpServer *tcpServer = nullptr;
+#if QT_CONFIG(localserver)
+ QLocalServer *localServer = nullptr;
+#endif
+
+ QHash<QIODevice *, State> clientStates;
+
+public:
+ struct State
+ {
+ QByteArray receivedData;
+ qsizetype contentLength = 0;
+ qsizetype contentRead = 0;
+ bool checkedContentLength = false;
+ bool foundContentLength = false;
+ };
+
+ bool doClose = true;
+ bool multiple = false;
+ bool stopTransfer = false;
+};
+
+#endif // MINIHTTPSERVER_H
diff --git a/tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp b/tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp
new file mode 100644
index 0000000000..6d78c81593
--- /dev/null
+++ b/tests/auto/network/access/qnetworkreply_local/tst_qnetworkreply_local.cpp
@@ -0,0 +1,177 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtNetwork/qtnetworkglobal.h>
+
+#include <QtTest/qtest.h>
+
+#include <QtNetwork/qnetworkreply.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+
+#include "minihttpserver.h"
+
+using namespace Qt::StringLiterals;
+
+/*
+ The tests here are meant to be self-contained, using servers in the same
+ process if needed. This enables externals to more easily run the tests too.
+*/
+class tst_QNetworkReply_local : public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase_data();
+
+ void get();
+ void post();
+
+#if QT_CONFIG(localserver)
+ void fullServerName_data();
+ void fullServerName();
+#endif
+};
+
+void tst_QNetworkReply_local::initTestCase_data()
+{
+ QTest::addColumn<QString>("scheme");
+
+ QTest::newRow("http") << "http";
+#if QT_CONFIG(localserver)
+ QTest::newRow("unix") << "unix+http";
+ QTest::newRow("local") << "local+http"; // equivalent to unix, but test that it works
+#endif
+}
+
+static std::unique_ptr<MiniHttpServerV2> getServerForCurrentScheme()
+{
+ auto server = std::make_unique<MiniHttpServerV2>();
+ QFETCH_GLOBAL(QString, scheme);
+ if (scheme.startsWith("unix"_L1) || scheme.startsWith("local"_L1)) {
+#if QT_CONFIG(localserver)
+ QLocalServer *localServer = new QLocalServer(server.get());
+ localServer->listen(u"qt_networkreply_test_"_s
+ % QLatin1StringView(QTest::currentTestFunction())
+ % QString::number(QCoreApplication::applicationPid()));
+ server->bind(localServer);
+#endif
+ } else if (scheme == "http") {
+ QTcpServer *tcpServer = new QTcpServer(server.get());
+ tcpServer->listen(QHostAddress::LocalHost, 0);
+ server->bind(tcpServer);
+ }
+ return server;
+}
+
+static QUrl getUrlForCurrentScheme(MiniHttpServerV2 *server)
+{
+ QFETCH_GLOBAL(QString, scheme);
+ const QString address = server->addressForScheme(scheme);
+ const QString urlString = QLatin1StringView("%1://%2").arg(scheme, address);
+ return { urlString };
+}
+
+void tst_QNetworkReply_local::get()
+{
+ std::unique_ptr<MiniHttpServerV2> server = getServerForCurrentScheme();
+ const QUrl url = getUrlForCurrentScheme(server.get());
+
+ QNetworkAccessManager manager;
+ std::unique_ptr<QNetworkReply> reply(manager.get(QNetworkRequest(url)));
+
+ const bool res = QTest::qWaitFor([reply = reply.get()] { return reply->isFinished(); });
+ QVERIFY(res);
+
+ QCOMPARE(reply->readAll(), QByteArray("Hello World!"));
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+}
+
+void tst_QNetworkReply_local::post()
+{
+ std::unique_ptr<MiniHttpServerV2> server = getServerForCurrentScheme();
+ const QUrl url = getUrlForCurrentScheme(server.get());
+
+ QNetworkAccessManager manager;
+ const QByteArray payload = "Hello from the other side!"_ba;
+ QNetworkRequest req(url);
+ req.setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
+ std::unique_ptr<QNetworkReply> reply(manager.post(req, payload));
+
+ const bool res = QTest::qWaitFor([reply = reply.get()] { return reply->isFinished(); });
+ QVERIFY(res);
+
+ QCOMPARE(reply->readAll(), QByteArray("Hello World!"));
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+
+ auto states = server->peerStates();
+ QCOMPARE(states.size(), 1);
+
+ const auto &firstRequest = states.at(0);
+
+ QVERIFY(firstRequest.checkedContentLength);
+ QCOMPARE(firstRequest.contentLength, payload.size());
+ QCOMPARE_GT(firstRequest.receivedData.size(), payload.size() + 4);
+ QCOMPARE(firstRequest.receivedData.last(payload.size() + 4), "\r\n\r\n" + payload);
+}
+
+#if QT_CONFIG(localserver)
+void tst_QNetworkReply_local::fullServerName_data()
+{
+#if defined(Q_OS_ANDROID) || defined(QT_PLATFORM_UIKIT)
+ QSKIP("While partially supported, the test as-is doesn't make sense on this platform.");
+#else
+
+ QTest::addColumn<QString>("hostAndPath");
+
+ QTest::newRow("dummy-host") << u"://irrelevant/test"_s;
+ QTest::newRow("no-host") << u":///test"_s;
+#endif
+}
+
+void tst_QNetworkReply_local::fullServerName()
+{
+ QFETCH_GLOBAL(QString, scheme);
+ if (!scheme.startsWith("unix"_L1) && !scheme.startsWith("local"_L1))
+ return; // only relevant for local sockets
+
+ MiniHttpServerV2 server;
+ QLocalServer localServer;
+
+ QString path;
+#ifdef Q_OS_WIN
+ path = uR"(\\.\pipe\qt_networkreply_test_fullServerName)"_s
+ % QString::number(QCoreApplication::applicationPid());
+#else
+ path = u"/tmp/qt_networkreply_test_fullServerName"_s
+ % QString::number(QCoreApplication::applicationPid()) % u".sock"_s;
+#endif
+
+ QVERIFY(localServer.listen(path));
+ server.bind(&localServer);
+
+ QFETCH(QString, hostAndPath);
+ QUrl url(scheme % hostAndPath);
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::FullLocalServerNameAttribute, path);
+
+ QNetworkAccessManager manager;
+ std::unique_ptr<QNetworkReply> reply(manager.get(req));
+
+ const bool res = QTest::qWaitFor([reply = reply.get()] { return reply->isFinished(); });
+ QVERIFY(res);
+
+ QCOMPARE(reply->readAll(), QByteArray("Hello World!"));
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+
+ const QByteArray receivedData = server.peerStates().at(0).receivedData;
+ const QByteArray expectedGet = "GET " % url.path().toUtf8() % " HTTP/1.1\r\n";
+ QVERIFY(receivedData.startsWith(expectedGet));
+
+ const QByteArray expectedHost = "host: " % url.host().toUtf8() % "\r\n";
+ QVERIFY(receivedData.contains(expectedHost));
+}
+#endif
+
+QTEST_MAIN(tst_QNetworkReply_local)
+
+#include "tst_qnetworkreply_local.moc"
+#include "moc_minihttpserver.cpp"
diff --git a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp
index 0b6d6f339b..f0b02ae91d 100644
--- a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp
+++ b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp
@@ -3,8 +3,10 @@
#include <QTest>
+#if QT_CONFIG(http)
#include <QtNetwork/QHttp1Configuration>
#include <QtNetwork/QHttp2Configuration>
+#endif
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkCookie>
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index 141ca25021..e5bbf3467c 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -197,6 +197,14 @@ void tst_QNetworkInterface::localAddress_data()
} else if (!ipv6 || entry.prefixLength() != 64) {
continue;
} else {
+#ifdef Q_OS_ANDROID
+ // Android seem to not allow IPv6 connection from interfaces other than wlan,
+ // if it's connected, and wlan is connected by default on Android emulators,
+ // so prefer selecting wlan in this test.
+ const QString scopeId = addr.scopeId();
+ if (!scopeId.isEmpty() && !scopeId.startsWith("wlan"))
+ continue;
+#endif
// add a random node in this IPv6 network
quint64 randomid = qFromBigEndian(Q_UINT64_C(0x8f41f072e5733caa));
QIPv6Address ip6 = addr.toIPv6Address();
diff --git a/tests/auto/other/android_deployment_settings/CMakeLists.txt b/tests/auto/other/android_deployment_settings/CMakeLists.txt
index f2ba135328..9ef457189a 100644
--- a/tests/auto/other/android_deployment_settings/CMakeLists.txt
+++ b/tests/auto/other/android_deployment_settings/CMakeLists.txt
@@ -30,6 +30,7 @@ set_target_properties(${target} PROPERTIES
QT_ANDROID_SDK_BUILD_TOOLS_REVISION "23.0.2"
QT_ANDROID_MIN_SDK_VERSION "1"
QT_ANDROID_TARGET_SDK_VERSION "2"
+ QT_ANDROID_PACKAGE_NAME "org.qtproject.android_deployment_settings_test"
QT_ANDROID_DEPLOYMENT_DEPENDENCIES "dep1.so;dep2.so;dep3.so"
QT_ANDROID_DEPLOYMENT_SETTINGS_FILE "attempt_to_rewrite.json"
QT_ANDROID_EXTRA_LIBS
@@ -53,6 +54,7 @@ set_target_properties(${target} PROPERTIES
QT_ANDROID_SDK_BUILD_TOOLS_REVISION "23.0.2"
QT_ANDROID_MIN_SDK_VERSION "1"
QT_ANDROID_TARGET_SDK_VERSION "2"
+ QT_ANDROID_PACKAGE_NAME "org.qtproject.android_deployment_settings_test"
QT_ANDROID_DEPLOYMENT_DEPENDENCIES "dep1.so;dep2.so;dep3.so"
QT_ANDROID_EXTRA_LIBS
"some/path/to/lib1.so;some/path\\to/lib2.so;some\\path\\to\\lib3.so;some/path/to/lib4.so"
diff --git a/tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp b/tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp
index d68d08b58e..f8428aaf43 100644
--- a/tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp
+++ b/tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp
@@ -76,6 +76,8 @@ void tst_android_deployment_settings::DeploymentSettings_data()
<< "1";
QTest::newRow("android-target-sdk-version") << "android-target-sdk-version"
<< "2";
+ QTest::newRow("android-package-name") << "android-package-name"
+ << "org.qtproject.android_deployment_settings_test";
}
void tst_android_deployment_settings::DeploymentSettings()
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 5fd695e2e6..cab88e2fc0 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -966,6 +966,13 @@ void tst_QAccessibility::mainWindowTest()
QCOMPARE(iface->text(QAccessible::Name), name);
QCOMPARE(iface->role(), QAccessible::Window);
QVERIFY(iface->state().active);
+
+ QTestAccessibility::clearEvents();
+ QLatin1String newName = QLatin1String("Main window with updated title");
+ mw->setWindowTitle(newName);
+ QCOMPARE(iface->text(QAccessible::Name), QLatin1String(newName));
+ QAccessibleEvent event(mw, QAccessible::NameChanged);
+ QVERIFY(QTestAccessibility::containsEvent(&event));
}
QTestAccessibility::clearEvents();
diff --git a/tests/auto/shared/resources/testfont_linemetrics.otf b/tests/auto/shared/resources/testfont_linemetrics.otf
new file mode 100644
index 0000000000..11368f7d9e
--- /dev/null
+++ b/tests/auto/shared/resources/testfont_linemetrics.otf
Binary files differ
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 19afacf6f9..79fe9d6333 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -2344,20 +2344,20 @@ void tst_QSqlDatabase::moveToThread()
auto clonedDb = QSqlDatabase::cloneDatabase(db, "clonedDb");
auto mainThread = QThread::currentThread();
CHECK_DATABASE(db);
- QCOMPARE(db.currentThread(), mainThread);
- QCOMPARE(clonedDb.currentThread(), mainThread);
+ QCOMPARE(db.thread(), mainThread);
+ QCOMPARE(clonedDb.thread(), mainThread);
std::unique_ptr<QThread> t(QThread::create([&] {
db.moveToThread(mainThread);
QThread::currentThread()->exit();
}));
db.moveToThread(t.get());
- QCOMPARE(db.currentThread(), t.get());
- QCOMPARE(clonedDb.currentThread(), mainThread);
+ QCOMPARE(db.thread(), t.get());
+ QCOMPARE(clonedDb.thread(), mainThread);
t->start();
QTRY_VERIFY(t->isRunning());
QTRY_VERIFY(t->wait(30000));
- QCOMPARE(db.currentThread(), mainThread);
- QCOMPARE(clonedDb.currentThread(), mainThread);
+ QCOMPARE(db.thread(), mainThread);
+ QCOMPARE(clonedDb.thread(), mainThread);
db = QSqlDatabase();
clonedDb = QSqlDatabase();
QSqlDatabase::removeDatabase("clonedDb");
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 56fb5cd05f..89033c30e0 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -256,6 +256,9 @@ private slots:
void ibaseDateTimeWithTZ();
void ibaseTimeStampTzArray_data() { generic_data("QIBASE"); }
void ibaseTimeStampTzArray();
+ void ibaseInt128_data() { generic_data("QIBASE"); }
+ void ibaseInt128();
+
void psqlJsonOperator_data() { generic_data("QPSQL"); }
void psqlJsonOperator();
@@ -1875,52 +1878,54 @@ void tst_QSqlQuery::oci_rawField()
// Test whether we can fetch values with more than DOUBLE precision
// note that SQLite highest precision is that of a double, although
// you can define field with higher precision:
+// Test whether we can fetch values with more than DOUBLE precision
+// note that SQLite highest precision is that of a double, although
+// you can define field with higher precision:
void tst_QSqlQuery::precision()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
- if (dbType == QSqlDriver::Interbase)
- QSKIP("DB unable to store high precision");
const auto tidier = qScopeGuard([db, oldPrecision = db.driver()->numericalPrecisionPolicy()]() {
db.driver()->setNumericalPrecisionPolicy(oldPrecision);
});
+ int digits = 21;
+ int decimals = 20;
+ std::array<QLatin1String, 2> precStrings = { "1.2345678901234567891"_L1,
+ "-1.2345678901234567891"_L1 };
+ if (dbType == QSqlDriver::SQLite) {
+ // SQLite 3.45 does not return more, even when speicfied
+ digits = 17;
+ decimals = 16;
+ precStrings = { "1.2345678901234567"_L1, "-1.2345678901234567"_L1 };
+ } else if (dbType == QSqlDriver::Sybase)
+ decimals = 18;
db.driver()->setNumericalPrecisionPolicy(QSql::HighPrecision);
TableScope ts(db, "qtest_precision", __FILE__);
- static const QLatin1String precStr("1.2345678901234567891");
-
- {
- // need a new scope for SQLITE
- QSqlQuery q(db);
- QVERIFY_SQL(q, exec(QLatin1String(tst_Databases::isMSAccess(db)
- ? "CREATE TABLE %1 (col1 number)"
- : "CREATE TABLE %1 (col1 numeric(21, 20))")
- .arg(ts.tableName())));
-
- QVERIFY_SQL(q, exec(QLatin1String("INSERT INTO %1 (col1) VALUES (%2)")
- .arg(ts.tableName(), precStr)));
+ QSqlQuery q(db);
+ QString stmt = "CREATE TABLE %1 (col1 numeric("_L1 + QString::number(digits) + ", "_L1 +
+ QString::number(decimals) + "))"_L1;
+ if (tst_Databases::isMSAccess(db))
+ stmt = "CREATE TABLE %1 (col1 number)"_L1;
+ QVERIFY_SQL(q, exec(stmt.arg(ts.tableName())));
+ for (const auto &precStr : precStrings) {
+ QVERIFY_SQL(q, exec("DELETE FROM %1"_L1.arg(ts.tableName())));
+ QVERIFY_SQL(q, exec("INSERT INTO %1 (col1) VALUES (%2)"_L1.arg(ts.tableName(), precStr)));
QVERIFY_SQL(q, exec("SELECT * FROM " + ts.tableName()));
QVERIFY(q.next());
const QString val = q.value(0).toString();
if (!val.startsWith(precStr)) {
int i = 0;
- while (i < val.size() && precStr[i] != 0 && precStr[i] == val[i].toLatin1())
+ while (i < val.size() && precStr[i] != 0 && precStr[i] == val[i])
++i;
-
- // TDS has crappy precisions by default
- if (dbType == QSqlDriver::Sybase) {
- if (i < 18)
- qWarning("TDS didn't return the right precision");
- } else {
- qWarning() << tst_Databases::dbToString(db) << "didn't return the right precision ("
- << i << "out of 21)," << val;
- }
+ qWarning() << tst_Databases::dbToString(db) << "didn't return the right precision ("
+ << i << "out of " << digits << ")," << val;
}
- } // SQLITE scope
+ }
}
void tst_QSqlQuery::nullResult()
@@ -5034,6 +5039,54 @@ void tst_QSqlQuery::ibaseTimeStampTzArray()
#endif // QT_CONFIG(timezone)
}
+void tst_QSqlQuery::ibaseInt128()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ TableScope ts(db, "int128test", __FILE__);
+ db.setNumericalPrecisionPolicy(QSql::HighPrecision);
+ QSqlQuery q(db);
+ if (!q.exec("CREATE TABLE " + ts.tableName() + " (id INT PRIMARY KEY, price NUMERIC(20, 4))"))
+ QSKIP("Need at least Firebird 4 for this test - skipping");
+
+ QVERIFY_SQL(q, exec("INSERT INTO " + ts.tableName() + "(id,price) values(1,40001.1234)"));
+ QVERIFY_SQL(q, prepare("INSERT INTO " + ts.tableName() + "(id,price) values(2,:amount)"));
+ q.bindValue(":amount", 12345.67890);
+ QVERIFY_SQL(q, exec());
+ {
+ QSqlQuery q2(db);
+ q2.setNumericalPrecisionPolicy(QSql::LowPrecisionDouble);
+ QVERIFY_SQL(q2, exec("SELECT price FROM " + ts.tableName() + " ORDER BY id"));
+ QVERIFY_SQL(q2, next());
+ QCOMPARE(q2.value(0).metaType().id(), QMetaType::Double);
+ QCOMPARE(q2.value(0).toDouble(), 40001.1234);
+ QVERIFY_SQL(q2, next());
+ QCOMPARE(q2.value("price").metaType().id(), QMetaType::Double);
+ QCOMPARE(q2.value("price").toDouble(), 12345.6789);
+ QVERIFY_SQL(q2, exec("SELECT sum(price) FROM " + ts.tableName()));
+ QVERIFY_SQL(q2, next());
+ QCOMPARE(q2.value(0).metaType().id(), QMetaType::Double);
+ QCOMPARE(q2.value(0).toDouble(), 52346.8023);
+ }
+ {
+ QSqlQuery q2(db);
+ q2.setNumericalPrecisionPolicy(QSql::HighPrecision);
+ QVERIFY_SQL(q2, exec("SELECT price FROM " + ts.tableName() + " ORDER BY id"));
+ QVERIFY_SQL(q2, next());
+ QCOMPARE(q2.value(0).metaType().id(), QMetaType::QString);
+ QCOMPARE(q2.value(0).toString(), "40001.1234");
+ QVERIFY_SQL(q2, next());
+ QCOMPARE(q2.value("price").metaType().id(), QMetaType::QString);
+ QCOMPARE(q2.value("price").toString(), "12345.6789");
+ QVERIFY_SQL(q2, exec("SELECT sum(price) FROM " + ts.tableName()));
+ QVERIFY_SQL(q2, next());
+ QCOMPARE(q2.value(0).metaType().id(), QMetaType::QString);
+ QCOMPARE(q2.value(0).toString(), "52346.8023");
+ }
+}
+
void tst_QSqlQuery::ibase_executeBlock()
{
QFETCH(QString, dbName);
diff --git a/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp b/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
index 6aeae86d7d..8e7d5b502e 100644
--- a/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
+++ b/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
@@ -10,7 +10,7 @@
#include <qsqlrecord.h>
-#define NUM_FIELDS 4
+#define NUM_FIELDS 5
class tst_QSqlRecord : public QObject
{
@@ -67,6 +67,7 @@ void tst_QSqlRecord::createTestRecord()
fields[1] = std::make_unique<QSqlField>(QStringLiteral("int"), QMetaType(QMetaType::Int), QStringLiteral("inttable"));
fields[2] = std::make_unique<QSqlField>(QStringLiteral("double"), QMetaType(QMetaType::Double), QStringLiteral("doubletable"));
fields[3] = std::make_unique<QSqlField>(QStringLiteral("bool"), QMetaType(QMetaType::Bool));
+ fields[4] = std::make_unique<QSqlField>(QStringLiteral("öäü@€"), QMetaType(QMetaType::Int));
for (const auto &field : fields)
rec->append(*field);
}
@@ -173,9 +174,22 @@ void tst_QSqlRecord::clearValues()
void tst_QSqlRecord::contains()
{
createTestRecord();
- for (const auto &field : fields)
- QVERIFY(rec->contains(field->name()));
- QVERIFY( !rec->contains( "__Harry__" ) );
+ QStringList fieldNames;
+ for (const auto &field : fields) {
+ fieldNames.append(field->name());
+ if (!field->tableName().isEmpty())
+ fieldNames.append(field->tableName() + u'.' + field->name());
+ }
+ for (const auto &name : std::as_const(fieldNames)) {
+ QVERIFY(rec->contains(name));
+ const QByteArray nameBa = name.toUtf8();
+ QVERIFY(rec->contains(nameBa));
+ const char *nameStr = nameBa.constData();
+ QVERIFY(rec->contains(nameStr));
+ QVERIFY(!rec->contains(name.left(name.size() - 1)));
+ QVERIFY(!rec->contains(name + u'.' + name));
+ }
+ QVERIFY(!rec->contains("__Harry__"));
}
void tst_QSqlRecord::count()
diff --git a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
index d59b6244c1..fb7ffcebc3 100644
--- a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
+++ b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
@@ -1,7 +1,7 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
-#undef QTEST_THROW_ON_FAILURE // fails ### investigate
+#undef QTEST_THROW_ON_FAIL // fails ### investigate
#undef QTEST_THROW_ON_SKIP // fails ### investigate
#include <QtCore/QCoreApplication>
diff --git a/tests/auto/testlib/selftests/eventloop/CMakeLists.txt b/tests/auto/testlib/selftests/eventloop/CMakeLists.txt
index 46b794f895..afaf766f69 100644
--- a/tests/auto/testlib/selftests/eventloop/CMakeLists.txt
+++ b/tests/auto/testlib/selftests/eventloop/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## eventloop Binary:
#####################################################################
diff --git a/tests/auto/testlib/selftests/failcleanup/CMakeLists.txt b/tests/auto/testlib/selftests/failcleanup/CMakeLists.txt
index 0b582ffdc3..10805ba6f7 100644
--- a/tests/auto/testlib/selftests/failcleanup/CMakeLists.txt
+++ b/tests/auto/testlib/selftests/failcleanup/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2022 The Qt Company Ltd.
+# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
diff --git a/tests/auto/testlib/selftests/failcleanuptestcase/CMakeLists.txt b/tests/auto/testlib/selftests/failcleanuptestcase/CMakeLists.txt
index 1a1417f76c..cb11a577f6 100644
--- a/tests/auto/testlib/selftests/failcleanuptestcase/CMakeLists.txt
+++ b/tests/auto/testlib/selftests/failcleanuptestcase/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## failcleanuptestcase Binary:
#####################################################################
diff --git a/tests/auto/testlib/selftests/skipblacklisted/CMakeLists.txt b/tests/auto/testlib/selftests/skipblacklisted/CMakeLists.txt
index cc1a2ff469..0cdcf2c063 100644
--- a/tests/auto/testlib/selftests/skipblacklisted/CMakeLists.txt
+++ b/tests/auto/testlib/selftests/skipblacklisted/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## skipblacklisted Binary:
#####################################################################
diff --git a/tests/auto/testlib/selftests/skipcleanuptestcase/CMakeLists.txt b/tests/auto/testlib/selftests/skipcleanuptestcase/CMakeLists.txt
index 88aae42acd..5c531b46b5 100644
--- a/tests/auto/testlib/selftests/skipcleanuptestcase/CMakeLists.txt
+++ b/tests/auto/testlib/selftests/skipcleanuptestcase/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## skipcleanuptestcase Binary:
#####################################################################
diff --git a/tests/auto/testlib/selftests/subtest/tst_subtest.cpp b/tests/auto/testlib/selftests/subtest/tst_subtest.cpp
index 023c43e2af..3a483f515a 100644
--- a/tests/auto/testlib/selftests/subtest/tst_subtest.cpp
+++ b/tests/auto/testlib/selftests/subtest/tst_subtest.cpp
@@ -1,7 +1,7 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
-#undef QTEST_THROW_ON_FAILURE // code expects old behavior
+#undef QTEST_THROW_ON_FAIL // code expects old behavior
#undef QTEST_THROW_ON_SKIP // code expects old behavior
#include <QtCore/QCoreApplication>
diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
index 5add39ac88..40636f250a 100644
--- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
+++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
@@ -1,7 +1,7 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
-#undef QTEST_THROW_ON_FAILURE // fails ### investigate
+#undef QTEST_THROW_ON_FAIL // fails ### investigate
#include <QtCore/QCoreApplication>
#include <QtCore/QRegularExpression>
diff --git a/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp b/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp
index 3c17acda56..d408554319 100644
--- a/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp
+++ b/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp
@@ -224,6 +224,9 @@ void tst_macdeployqt::initTestCase()
QSKIP("This test requires QProcess support");
#endif
+ if (QProcess::execute("xcode-select", { "-p" }) != 0)
+ QSKIP("Xcode or Xcode command line tools not installed");
+
// Set up test-global unique temporary directory
g_temporaryDirectory = new QTemporaryDir();
g_temporaryDirectory->setAutoRemove(!lcTests().isDebugEnabled());
diff --git a/tests/auto/tools/moc/CMakeLists.txt b/tests/auto/tools/moc/CMakeLists.txt
index 1377c48306..a8df73bdf4 100644
--- a/tests/auto/tools/moc/CMakeLists.txt
+++ b/tests/auto/tools/moc/CMakeLists.txt
@@ -46,7 +46,6 @@ set(JSON_HEADERS
related-metaobjects-name-conflict.h
signal-with-default-arg.h
single-quote-digit-separator-n3781.h
- single_function_keyword.h
slots-with-void-template.h
task192552.h
task234909.h
@@ -71,6 +70,7 @@ list(TRANSFORM comparison_relevant_moc_list APPEND ".json" OUTPUT_VARIABLE moc_
qt_internal_add_test(tst_moc
SOURCES
cxx-attributes.h
+ single_function_keyword.h
tst_moc.cpp
${comparison_relevant_moc_list}
INCLUDE_DIRECTORIES
diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json
index 5cbcb99e68..f82500eda4 100644
--- a/tests/auto/tools/moc/allmocs_baseline_in.json
+++ b/tests/auto/tools/moc/allmocs_baseline_in.json
@@ -2606,87 +2606,6 @@
{
"classes": [
{
- "className": "SingleFunctionKeywordBeforeReturnType",
- "object": true,
- "qualifiedClassName": "SingleFunctionKeywordBeforeReturnType",
- "signals": [
- {
- "access": "public",
- "name": "mySignal",
- "returnType": "void"
- }
- ],
- "slots": [
- {
- "access": "public",
- "name": "mySlot",
- "returnType": "void"
- }
- ],
- "superClasses": [
- {
- "access": "public",
- "name": "QObject"
- }
- ]
- },
- {
- "className": "SingleFunctionKeywordBeforeInline",
- "object": true,
- "qualifiedClassName": "SingleFunctionKeywordBeforeInline",
- "signals": [
- {
- "access": "public",
- "name": "mySignal",
- "returnType": "void"
- }
- ],
- "slots": [
- {
- "access": "public",
- "name": "mySlot",
- "returnType": "void"
- }
- ],
- "superClasses": [
- {
- "access": "public",
- "name": "QObject"
- }
- ]
- },
- {
- "className": "SingleFunctionKeywordAfterInline",
- "object": true,
- "qualifiedClassName": "SingleFunctionKeywordAfterInline",
- "signals": [
- {
- "access": "public",
- "name": "mySignal",
- "returnType": "void"
- }
- ],
- "slots": [
- {
- "access": "public",
- "name": "mySlot",
- "returnType": "void"
- }
- ],
- "superClasses": [
- {
- "access": "public",
- "name": "QObject"
- }
- ]
- }
- ],
- "inputFile": "single_function_keyword.h",
- "outputRevision": 68
- },
- {
- "classes": [
- {
"className": "SlotsWithVoidTemplateTest",
"object": true,
"qualifiedClassName": "SlotsWithVoidTemplateTest",
diff --git a/tests/auto/tools/moc/enum_inc.h b/tests/auto/tools/moc/enum_inc.h
index 7d7b6ae9f3..2b355b7a19 100644
--- a/tests/auto/tools/moc/enum_inc.h
+++ b/tests/auto/tools/moc/enum_inc.h
@@ -1,2 +1,4 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
parcel = 42,
part = 12,
diff --git a/tests/auto/tools/moc/forwarddeclaredparam.h b/tests/auto/tools/moc/forwarddeclaredparam.h
index 176f0c3356..94caae8a5b 100644
--- a/tests/auto/tools/moc/forwarddeclaredparam.h
+++ b/tests/auto/tools/moc/forwarddeclaredparam.h
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef FORWARDDECLAREDPARAM_H
#define FORWARDDECLAREDPARAM_H
struct ForwardDeclaredParam {};
diff --git a/tests/auto/tools/moc/single_function_keyword.h b/tests/auto/tools/moc/single_function_keyword.h
index 0c907db9ef..28fd9ab90a 100644
--- a/tests/auto/tools/moc/single_function_keyword.h
+++ b/tests/auto/tools/moc/single_function_keyword.h
@@ -22,10 +22,7 @@ class SingleFunctionKeywordBeforeInline : public QObject
public:
inline SingleFunctionKeywordBeforeInline() {}
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_CLANG("-Wundefined-inline")
Q_SIGNAL inline void mySignal();
-QT_WARNING_POP
Q_SLOT inline void mySlot() { emit mySignal(); }
};
@@ -36,10 +33,7 @@ class SingleFunctionKeywordAfterInline : public QObject
public:
inline SingleFunctionKeywordAfterInline() {}
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_CLANG("-Wundefined-inline")
inline Q_SIGNAL void mySignal();
-QT_WARNING_POP
inline Q_SLOT void mySlot() { emit mySignal(); }
};
diff --git a/tests/auto/tools/moc/subdir/extradefines.h b/tests/auto/tools/moc/subdir/extradefines.h
index e7888ce80d..efad23be6f 100644
--- a/tests/auto/tools/moc/subdir/extradefines.h
+++ b/tests/auto/tools/moc/subdir/extradefines.h
@@ -1 +1,3 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#define FOO 1
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index d24dfa11f7..4fcb44f00c 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -878,7 +878,14 @@ signals:
void sigWithUnsignedArg(unsigned foo);
void sigWithSignedArg(signed foo);
void sigWithConstSignedArg(const signed foo);
+#ifndef Q_MOC_RUN // QTBUG-126395
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_GCC("-Wvolatile")
+#endif
void sigWithVolatileConstSignedArg(volatile const signed foo);
+#ifndef Q_MOC_RUN // QTBUG-126395
+ QT_WARNING_POP
+#endif
void sigWithCustomType(const MyStruct);
void constSignal1() const;
void constSignal2(int arg) const;
@@ -4710,4 +4717,8 @@ QTEST_MAIN(tst_Moc)
#undef slots
#undef emit
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wvolatile") // should moc itself add this in generated code?
#include "tst_moc.moc"
+QT_WARNING_POP
+#include "moc_single_function_keyword.cpp" // prevents "undefined inline functions" warnings
diff --git a/tests/auto/tools/qdbuscpp2xml/CMakeLists.txt b/tests/auto/tools/qdbuscpp2xml/CMakeLists.txt
index 9dea3f3c4d..8ea0c609c0 100644
--- a/tests/auto/tools/qdbuscpp2xml/CMakeLists.txt
+++ b/tests/auto/tools/qdbuscpp2xml/CMakeLists.txt
@@ -33,3 +33,4 @@ qt_internal_add_resource(tst_qdbuscpp2xml "qdbuscpp2xml"
${qdbuscpp2xml_resource_files}
)
+add_dependencies(tst_qdbuscpp2xml ${QT_CMAKE_EXPORT_NAMESPACE}::qdbuscpp2xml)
diff --git a/tests/auto/tools/qdbusxml2cpp/CMakeLists.txt b/tests/auto/tools/qdbusxml2cpp/CMakeLists.txt
index 29278377b6..44bf8166ee 100644
--- a/tests/auto/tools/qdbusxml2cpp/CMakeLists.txt
+++ b/tests/auto/tools/qdbusxml2cpp/CMakeLists.txt
@@ -15,3 +15,5 @@ qt_internal_add_test(tst_qdbusxml2cpp
SOURCES
tst_qdbusxml2cpp.cpp
)
+
+add_dependencies(tst_qdbusxml2cpp ${QT_CMAKE_EXPORT_NAMESPACE}::qdbusxml2cpp)
diff --git a/tests/auto/tools/qmake/testdata/conflicting_targets/main.cpp b/tests/auto/tools/qmake/testdata/conflicting_targets/main.cpp
index 39de28135a..866a063753 100644
--- a/tests/auto/tools/qmake/testdata/conflicting_targets/main.cpp
+++ b/tests/auto/tools/qmake/testdata/conflicting_targets/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
int main(int, char **)
{
return 0;
diff --git a/tests/auto/tools/qmake/testdata/findDeps/needed.cpp b/tests/auto/tools/qmake/testdata/findDeps/needed.cpp
index 698d0aaa12..726382cf10 100644
--- a/tests/auto/tools/qmake/testdata/findDeps/needed.cpp
+++ b/tests/auto/tools/qmake/testdata/findDeps/needed.cpp
@@ -1 +1,3 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
extern int needed(void) { return 1; }
diff --git a/tests/auto/tools/qmake/testdata/findMocs/digitseparated.h b/tests/auto/tools/qmake/testdata/findMocs/digitseparated.h
index ddedac26e3..10cf31a8a5 100644
--- a/tests/auto/tools/qmake/testdata/findMocs/digitseparated.h
+++ b/tests/auto/tools/qmake/testdata/findMocs/digitseparated.h
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
class AfterDigitSeparator : public QObject
diff --git a/tests/auto/tools/qmake/testdata/include_pwd/anotherheader.h b/tests/auto/tools/qmake/testdata/include_pwd/anotherheader.h
index a3a63e26bf..228a8861b7 100644
--- a/tests/auto/tools/qmake/testdata/include_pwd/anotherheader.h
+++ b/tests/auto/tools/qmake/testdata/include_pwd/anotherheader.h
@@ -1,2 +1,4 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
/* This file should be included indirectly through main.cpp */
diff --git a/tests/auto/tools/qmake/testdata/include_pwd/main.cpp b/tests/auto/tools/qmake/testdata/include_pwd/main.cpp
index c98935f87d..b55f0525ea 100644
--- a/tests/auto/tools/qmake/testdata/include_pwd/main.cpp
+++ b/tests/auto/tools/qmake/testdata/include_pwd/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "someheader.h"
int main()
diff --git a/tests/auto/tools/qmake/testdata/include_pwd/somedirectory/someheader.h b/tests/auto/tools/qmake/testdata/include_pwd/somedirectory/someheader.h
index f977346945..9a26fb7c1e 100644
--- a/tests/auto/tools/qmake/testdata/include_pwd/somedirectory/someheader.h
+++ b/tests/auto/tools/qmake/testdata/include_pwd/somedirectory/someheader.h
@@ -1 +1,3 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "anotherheader.h"
diff --git a/tests/auto/tools/qmake/testdata/quotedfilenames/include folder/header.h b/tests/auto/tools/qmake/testdata/quotedfilenames/include folder/header.h
index 595c0cac3c..b65da1d85c 100644
--- a/tests/auto/tools/qmake/testdata/quotedfilenames/include folder/header.h
+++ b/tests/auto/tools/qmake/testdata/quotedfilenames/include folder/header.h
@@ -1 +1,3 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
/* a random header file */
diff --git a/tests/auto/tools/qmake/testdata/windows_resources/main.cpp b/tests/auto/tools/qmake/testdata/windows_resources/main.cpp
index 237c8ce181..6c1d24751e 100644
--- a/tests/auto/tools/qmake/testdata/windows_resources/main.cpp
+++ b/tests/auto/tools/qmake/testdata/windows_resources/main.cpp
@@ -1 +1,3 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
int main() {}
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index a32b4ab228..278cf4ad23 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -93,6 +93,11 @@ static void copyDir(const QString &sourceDirPath, const QString &targetDirPath)
void tst_qmake::initTestCase()
{
+#if defined(Q_OS_APPLE)
+ if (QProcess::execute("xcode-select", { "-p" }) != 0)
+ QSKIP("Xcode or Xcode command line tools not installed");
+#endif
+
QVERIFY2(tempWorkDir.isValid(), qPrintable(tempWorkDir.errorString()));
QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
QString cmd = QString("%1/qmake").arg(binpath);
diff --git a/tests/auto/tools/qt_cmake_create/testdata/cpp_project/main.cpp b/tests/auto/tools/qt_cmake_create/testdata/cpp_project/main.cpp
index ae659d5ed4..3526286e5e 100644
--- a/tests/auto/tools/qt_cmake_create/testdata/cpp_project/main.cpp
+++ b/tests/auto/tools/qt_cmake_create/testdata/cpp_project/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <iostream>
int main(int, char *[])
diff --git a/tests/auto/tools/qt_cmake_create/testdata/qml_project/main.cpp b/tests/auto/tools/qt_cmake_create/testdata/qml_project/main.cpp
index 13c7014d8c..844e67e2c4 100644
--- a/tests/auto/tools/qt_cmake_create/testdata/qml_project/main.cpp
+++ b/tests/auto/tools/qt_cmake_create/testdata/qml_project/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
#include <QQmlApplicationEngine>
diff --git a/tests/auto/tools/qt_cmake_create/testdata/qrc_project/main.cpp b/tests/auto/tools/qt_cmake_create/testdata/qrc_project/main.cpp
index cd8ed8f57b..72f63e3077 100644
--- a/tests/auto/tools/qt_cmake_create/testdata/qrc_project/main.cpp
+++ b/tests/auto/tools/qt_cmake_create/testdata/qrc_project/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QFile>
#include <QDebug>
diff --git a/tests/auto/tools/qt_cmake_create/testdata/ui_project/main.cpp b/tests/auto/tools/qt_cmake_create/testdata/ui_project/main.cpp
index b0a4ec2647..2e74e1c140 100644
--- a/tests/auto/tools/qt_cmake_create/testdata/ui_project/main.cpp
+++ b/tests/auto/tools/qt_cmake_create/testdata/ui_project/main.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "widget.h"
#include <QApplication>
diff --git a/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.cpp b/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.cpp
index 815d5f8c4b..65c5eae0c9 100644
--- a/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.cpp
+++ b/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "widget.h"
#include "ui_widget.h"
@@ -12,4 +14,3 @@ Widget::~Widget()
{
delete ui;
}
-
diff --git a/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.h b/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.h
index 1fe2322b13..9110f2a20b 100644
--- a/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.h
+++ b/tests/auto/tools/qt_cmake_create/testdata/ui_project/widget.h
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef WIDGET_H
#define WIDGET_H
diff --git a/tests/auto/tools/qt_cmake_create/tst_qt_cmake_create.cpp b/tests/auto/tools/qt_cmake_create/tst_qt_cmake_create.cpp
index 6bbc58ef32..52c3bef14a 100644
--- a/tests/auto/tools/qt_cmake_create/tst_qt_cmake_create.cpp
+++ b/tests/auto/tools/qt_cmake_create/tst_qt_cmake_create.cpp
@@ -42,12 +42,17 @@ void tst_qt_cmake_create::initTestCase()
#ifdef Q_OS_WINDOWS
m_shell = QString("cmd.exe");
m_cmd = QString("%1/qt-cmake-create.bat").arg(binpath);
+ const QString cmake = QStandardPaths::findExecutable("cmake.exe");
#else
m_shell = QString("/bin/sh");
m_cmd = QString("%1/qt-cmake-create").arg(binpath);
QVERIFY(QFile::exists(m_shell));
+ const QString cmake = QStandardPaths::findExecutable("cmake");
#endif
+ if (cmake.isEmpty())
+ QSKIP("CMake not found");
+
QVERIFY(QFile::exists(m_cmd));
}
diff --git a/tests/auto/tools/rcc/data/.gitattributes b/tests/auto/tools/rcc/data/.gitattributes
new file mode 100644
index 0000000000..89d6e8fe1c
--- /dev/null
+++ b/tests/auto/tools/rcc/data/.gitattributes
@@ -0,0 +1,2 @@
+# Keep parentdir.txt with LF line endings
+parentdir.txt -text
diff --git a/tests/auto/tools/rcc/data/deduplication/deduplication.expected b/tests/auto/tools/rcc/data/deduplication/deduplication.expected
new file mode 100644
index 0000000000..bd873437b4
--- /dev/null
+++ b/tests/auto/tools/rcc/data/deduplication/deduplication.expected
@@ -0,0 +1,157 @@
+/****************************************************************************
+** Resource object code
+**
+IGNORE:** Created by: The Resource Compiler for Qt version 6.9.0
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#ifdef _MSC_VER
+// disable informational message "function ... selected for automatic inline expansion"
+#pragma warning (disable: 4711)
+#endif
+
+static const unsigned char qt_resource_data[] = {
+ // b.txt
+ 0x0,0x0,0x0,0xb,
+ 0x62,
+ 0x20,0x74,0x65,0x73,0x74,0x20,0x66,0x69,0x6c,0x65,
+ // c_with_a_content.txt
+ 0x0,0x0,0x0,0xb,
+ 0x61,
+ 0x20,0x74,0x65,0x73,0x74,0x20,0x66,0x69,0x6c,0x65,
+ // b.txt
+ 0x0,0x0,0x0,0xb,
+ 0x62,
+ 0x20,0x74,0x65,0x73,0x74,0x20,0x66,0x69,0x6c,0x65,
+
+};
+
+static const unsigned char qt_resource_name[] = {
+ // files
+ 0x0,0x5,
+ 0x0,0x6d,0x2,0xc3,
+ 0x0,0x66,
+ 0x0,0x69,0x0,0x6c,0x0,0x65,0x0,0x73,
+ // b.txt
+ 0x0,0x5,
+ 0x0,0x65,0x5b,0xf4,
+ 0x0,0x62,
+ 0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
+ // c_with_a_content.txt
+ 0x0,0x14,
+ 0x1,0x61,0x1d,0x34,
+ 0x0,0x63,
+ 0x0,0x5f,0x0,0x77,0x0,0x69,0x0,0x74,0x0,0x68,0x0,0x5f,0x0,0x61,0x0,0x5f,0x0,0x63,0x0,0x6f,0x0,0x6e,0x0,0x74,0x0,0x65,0x0,0x6e,0x0,0x74,0x0,0x2e,
+ 0x0,0x74,0x0,0x78,0x0,0x74,
+ // a.txt
+ 0x0,0x5,
+ 0x0,0x64,0x5b,0xf4,
+ 0x0,0x61,
+ 0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
+ // alias_of_b_compress9.txt
+ 0x0,0x18,
+ 0xb,0x26,0xf,0xb4,
+ 0x0,0x61,
+ 0x0,0x6c,0x0,0x69,0x0,0x61,0x0,0x73,0x0,0x5f,0x0,0x6f,0x0,0x66,0x0,0x5f,0x0,0x62,0x0,0x5f,0x0,0x63,0x0,0x6f,0x0,0x6d,0x0,0x70,0x0,0x72,0x0,0x65,
+ 0x0,0x73,0x0,0x73,0x0,0x39,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
+ // alias_of_b.txt
+ 0x0,0xe,
+ 0x1,0xa4,0x6d,0x34,
+ 0x0,0x61,
+ 0x0,0x6c,0x0,0x69,0x0,0x61,0x0,0x73,0x0,0x5f,0x0,0x6f,0x0,0x66,0x0,0x5f,0x0,0x62,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
+ // alias_of_b_compress9_dupe.txt
+ 0x0,0x1d,
+ 0x9,0x4,0x7a,0x14,
+ 0x0,0x61,
+ 0x0,0x6c,0x0,0x69,0x0,0x61,0x0,0x73,0x0,0x5f,0x0,0x6f,0x0,0x66,0x0,0x5f,0x0,0x62,0x0,0x5f,0x0,0x63,0x0,0x6f,0x0,0x6d,0x0,0x70,0x0,0x72,0x0,0x65,
+ 0x0,0x73,0x0,0x73,0x0,0x39,0x0,0x5f,0x0,0x64,0x0,0x75,0x0,0x70,0x0,0x65,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
+
+};
+
+static const unsigned char qt_resource_struct[] = {
+ // :
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
+0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ // :/files
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x6,0x0,0x0,0x0,0x2,
+0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ // :/files/a.txt
+ 0x0,0x0,0x0,0x4e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xf,
+TIMESTAMP:files/a.txt
+ // :/files/b.txt
+ 0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
+TIMESTAMP:files/b.txt
+ // :/files/c_with_a_content.txt
+ 0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xf,
+TIMESTAMP:files/c_with_a_content.txt
+ // :/files/alias_of_b.txt
+ 0x0,0x0,0x0,0x94,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
+TIMESTAMP:files/b.txt
+ // :/files/alias_of_b_compress9_dupe.txt
+ 0x0,0x0,0x0,0xb6,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1e,
+TIMESTAMP:files/b.txt
+ // :/files/alias_of_b_compress9.txt
+ 0x0,0x0,0x0,0x5e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1e,
+TIMESTAMP:files/b.txt
+
+};
+
+#ifdef QT_NAMESPACE
+# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
+# define QT_RCC_MANGLE_NAMESPACE0(x) x
+# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
+# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
+# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
+ QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
+#else
+# define QT_RCC_PREPEND_NAMESPACE(name) name
+# define QT_RCC_MANGLE_NAMESPACE(name) name
+#endif
+
+#if defined(QT_INLINE_NAMESPACE)
+inline namespace QT_NAMESPACE {
+#elif defined(QT_NAMESPACE)
+namespace QT_NAMESPACE {
+#endif
+
+bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+
+#ifdef QT_NAMESPACE
+}
+#endif
+
+int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
+int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
+{
+ int version = 3;
+ QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
+ (version, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
+{
+ int version = 3;
+ QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
+ (version, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wexit-time-destructors"
+#endif
+
+namespace {
+ struct initializer {
+ initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); }
+ ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); }
+ } dummy;
+}
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
diff --git a/tests/auto/tools/rcc/data/deduplication/deduplication.qrc b/tests/auto/tools/rcc/data/deduplication/deduplication.qrc
new file mode 100644
index 0000000000..fd8a776503
--- /dev/null
+++ b/tests/auto/tools/rcc/data/deduplication/deduplication.qrc
@@ -0,0 +1,10 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>files/a.txt</file>
+ <file>files/b.txt</file>
+ <file alias="files/alias_of_b.txt">files/b.txt</file>
+ <file>files/c_with_a_content.txt</file>
+ <file alias="files/alias_of_b_compress9.txt" compress="9">files/b.txt</file>
+ <file alias="files/alias_of_b_compress9_dupe.txt" compress="9">files/b.txt</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/tools/rcc/data/deduplication/files/a.txt b/tests/auto/tools/rcc/data/deduplication/files/a.txt
new file mode 100644
index 0000000000..abd91bd465
--- /dev/null
+++ b/tests/auto/tools/rcc/data/deduplication/files/a.txt
@@ -0,0 +1 @@
+a test file \ No newline at end of file
diff --git a/tests/auto/tools/rcc/data/deduplication/files/b.txt b/tests/auto/tools/rcc/data/deduplication/files/b.txt
new file mode 100644
index 0000000000..01e4d76fc5
--- /dev/null
+++ b/tests/auto/tools/rcc/data/deduplication/files/b.txt
@@ -0,0 +1 @@
+b test file \ No newline at end of file
diff --git a/tests/auto/tools/rcc/data/deduplication/files/c_with_a_content.txt b/tests/auto/tools/rcc/data/deduplication/files/c_with_a_content.txt
new file mode 100644
index 0000000000..abd91bd465
--- /dev/null
+++ b/tests/auto/tools/rcc/data/deduplication/files/c_with_a_content.txt
@@ -0,0 +1 @@
+a test file \ No newline at end of file
diff --git a/tests/auto/tools/rcc/data/legal/legal.qrc b/tests/auto/tools/rcc/data/legal/legal.qrc
new file mode 100644
index 0000000000..5eb7f58416
--- /dev/null
+++ b/tests/auto/tools/rcc/data/legal/legal.qrc
@@ -0,0 +1,10 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <legal>
+ Copyright (C) 2024 Intel Corporation.
+ SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+ </legal>
+ <qresource>
+ <file>../parentdir.txt</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/tools/rcc/data/legal/rcc_legal.cpp b/tests/auto/tools/rcc/data/legal/rcc_legal.cpp
new file mode 100644
index 0000000000..deec3380aa
--- /dev/null
+++ b/tests/auto/tools/rcc/data/legal/rcc_legal.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+** Resource object code
+** Copyright (C) 2024 Intel Corporation.
+** SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+**
+** Created by: The Resource Compiler for Qt version 6.9.0
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#ifdef _MSC_VER
+// disable informational message "function ... selected for automatic inline expansion"
+#pragma warning (disable: 4711)
+#endif
+
+static const unsigned char qt_resource_data[] = {
+ // parentdir.txt
+ 0x0,0x0,0x0,0x1a,
+ 0x61,
+ 0x62,0x63,0x64,0x65,0x66,0x67,0x69,0x68,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,
+ 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0xa,
+
+};
+
+static const unsigned char qt_resource_name[] = {
+ // parentdir.txt
+ 0x0,0xd,
+ 0x6,0x14,0xd1,0x74,
+ 0x0,0x70,
+ 0x0,0x61,0x0,0x72,0x0,0x65,0x0,0x6e,0x0,0x74,0x0,0x64,0x0,0x69,0x0,0x72,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74,
+
+};
+
+static const unsigned char qt_resource_struct[] = {
+ // :
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
+0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
+ // :/parentdir.txt
+ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
+TIMESTAMP:../parentdir.txt
+
+};
+
+#ifdef QT_NAMESPACE
+# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
+# define QT_RCC_MANGLE_NAMESPACE0(x) x
+# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
+# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
+# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
+ QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
+#else
+# define QT_RCC_PREPEND_NAMESPACE(name) name
+# define QT_RCC_MANGLE_NAMESPACE(name) name
+#endif
+
+#if defined(QT_INLINE_NAMESPACE)
+inline namespace QT_NAMESPACE {
+#elif defined(QT_NAMESPACE)
+namespace QT_NAMESPACE {
+#endif
+
+bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+
+#ifdef QT_NAMESPACE
+}
+#endif
+
+int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
+int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
+{
+ int version = 3;
+ QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
+ (version, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
+{
+ int version = 3;
+ QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
+ (version, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wexit-time-destructors"
+#endif
+
+namespace {
+ struct initializer {
+ initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); }
+ ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); }
+ } dummy;
+}
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp
index 88a6e17e2f..ac024b11d0 100644
--- a/tests/auto/tools/rcc/tst_rcc.cpp
+++ b/tests/auto/tools/rcc/tst_rcc.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>
// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2024 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -148,6 +149,14 @@ void tst_rcc::rcc_data()
QTest::newRow("size-1") << sizesPath << "size-1.qrc" << "size-1.expected";
QTest::newRow("size-2-0-35-1") << sizesPath << "size-2-0-35-1.qrc" <<
(sizeof(size_t) == 8 ? "size-2-0-35-1.expected" : "size-2-0-35-1.expected32");
+
+ QTest::newRow("legal") << m_dataPath + QLatin1StringView("/legal")
+ << "legal.qrc" << "rcc_legal.cpp";
+
+ if (sizeof(size_t) == 8) {
+ const QString deduplicationPath = m_dataPath + QLatin1String("/deduplication");
+ QTest::newRow("deduplication") << deduplicationPath << "deduplication.qrc" << "deduplication.expected";
+ }
}
static QStringList readLinesFromFile(const QString &fileName,
diff --git a/tests/auto/tools/uic/baseline/Widget.ui b/tests/auto/tools/uic/baseline/Widget.ui
index ab94733dcc..285d95eb88 100644
--- a/tests/auto/tools/uic/baseline/Widget.ui
+++ b/tests/auto/tools/uic/baseline/Widget.ui
@@ -1,4 +1,6 @@
<ui version="4.0" >
+ <legal>Copyright (C) 2016 The Qt Company Ltd.
+SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only</legal>
<class>Form</class>
<widget class="QWidget" name="Form" >
<property name="geometry" >
diff --git a/tests/auto/tools/uic/baseline/Widget.ui.h b/tests/auto/tools/uic/baseline/Widget.ui.h
index 4d4846e6c5..a7fa74c447 100644
--- a/tests/auto/tools/uic/baseline/Widget.ui.h
+++ b/tests/auto/tools/uic/baseline/Widget.ui.h
@@ -1,3 +1,8 @@
+/*
+Copyright (C) 2016 The Qt Company Ltd.
+SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+*/
+
/********************************************************************************
** Form generated from reading UI file 'Widget.ui'
**
diff --git a/tests/auto/tools/uic/baseline/qtbug126265.ui b/tests/auto/tools/uic/baseline/qtbug126265.ui
new file mode 100644
index 0000000000..ba89566082
--- /dev/null
+++ b/tests/auto/tools/uic/baseline/qtbug126265.ui
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QPushButton" name="pushButton">
+ <property name="geometry">
+ <rect>
+ <x>70</x>
+ <y>40</y>
+ <width>91</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property name="text(&quot;Hello world!&quot;); injected code;//">
+ <enum>Qt::FocusPolicy::WheelFocus</enum>
+ </property>
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButton_2">
+ <property name="geometry">
+ <rect>
+ <x>70</x>
+ <y>110</y>
+ <width>91</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::FocusPolicy::WheelFocus); injected code;//</enum>
+ </property>
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/tools/uic/baseline/qtbug126265.ui.h b/tests/auto/tools/uic/baseline/qtbug126265.ui.h
new file mode 100644
index 0000000000..3ff99db9bc
--- /dev/null
+++ b/tests/auto/tools/uic/baseline/qtbug126265.ui.h
@@ -0,0 +1,57 @@
+/********************************************************************************
+** Form generated from reading UI file 'qtbug126265.ui'
+**
+** Created by: Qt User Interface Compiler version 6.0.0
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef QTBUG126265_H
+#define QTBUG126265_H
+
+#include <QtCore/QVariant>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QPushButton>
+#include <QtWidgets/QWidget>
+
+QT_BEGIN_NAMESPACE
+
+class Ui_Form
+{
+public:
+ QPushButton *pushButton;
+ QPushButton *pushButton_2;
+
+ void setupUi(QWidget *Form)
+ {
+ if (Form->objectName().isEmpty())
+ Form->setObjectName("Form");
+ Form->resize(400, 300);
+ pushButton = new QPushButton(Form);
+ pushButton->setObjectName("pushButton");
+ pushButton->setGeometry(QRect(70, 40, 91, 29));
+ pushButton_2 = new QPushButton(Form);
+ pushButton_2->setObjectName("pushButton_2");
+ pushButton_2->setGeometry(QRect(70, 110, 91, 29));
+
+ retranslateUi(Form);
+
+ QMetaObject::connectSlotsByName(Form);
+ } // setupUi
+
+ void retranslateUi(QWidget *Form)
+ {
+ Form->setWindowTitle(QCoreApplication::translate("Form", "Form", nullptr));
+ pushButton->setText(QCoreApplication::translate("Form", "PushButton", nullptr));
+ pushButton_2->setText(QCoreApplication::translate("Form", "PushButton", nullptr));
+ } // retranslateUi
+
+};
+
+namespace Ui {
+ class Form: public Ui_Form {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // QTBUG126265_H
diff --git a/tests/auto/wasm/selenium/CMakeLists.txt b/tests/auto/wasm/selenium/CMakeLists.txt
index 335b6d23d9..445030878e 100644
--- a/tests/auto/wasm/selenium/CMakeLists.txt
+++ b/tests/auto/wasm/selenium/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
cmake_minimum_required(VERSION 3.16)
project(tst_qwasmwindow_harness LANGUAGES CXX)
diff --git a/tests/auto/wasm/selenium/qwasmwindow.py b/tests/auto/wasm/selenium/qwasmwindow.py
index 260e9d2d24..df2d39f516 100644
--- a/tests/auto/wasm/selenium/qwasmwindow.py
+++ b/tests/auto/wasm/selenium/qwasmwindow.py
@@ -28,6 +28,24 @@ class WidgetTestCase(unittest.TestCase):
self.addTypeEqualityFunc(Color, assert_colors_equal)
self.addTypeEqualityFunc(Rect, assert_rects_equal)
+ #
+ # This is a manual test
+ # The reason is that the color readback works
+ # even if the display is incorrect
+ #
+ def test_native_widgets(self):
+ screen = Screen(self._driver, ScreenPosition.FIXED,
+ x=0, y=0, width=600, height=1200)
+
+ w0 = Widget(self._driver, "w0", 1)
+ w0.show()
+ #time.sleep(3600)
+ color = w0.color_at(100, 150)
+ self.assertEqual(color.r, 255)
+ self.assertEqual(color.g, 255)
+ self.assertEqual(color.b, 255)
+ self.assertEqual(w0.hasFocus(), True)
+
def test_hasFocus_returnsFalse_whenSetNoFocusShowWasCalled(self):
screen = Screen(self._driver, ScreenPosition.FIXED,
x=0, y=0, width=600, height=1200)
@@ -607,15 +625,30 @@ def clearWidgets(driver):
)
class Widget:
- def __init__(self, driver, name):
+ def __init__(self, driver, name, isNative=0):
self.name=name
self.driver=driver
- self.driver.execute_script(
- f'''
- instance.createWidget('{self.name}');
- '''
- )
+ if isNative == 0:
+ self.driver.execute_script(
+ f'''
+ instance.createWidget('{self.name}');
+ '''
+ )
+ if isNative == 1:
+ self.driver.execute_script(
+ f'''
+ instance.createNativeWidget('{self.name}');
+ '''
+ )
+
+ if isNative == 1:
+ information = self.__window_information()
+ self.screen = Screen(self.driver, screen_name=information['screen']['name'])
+
+ self._window_id = self.__window_information()['id']
+ self.element = self.screen.find_element(
+ By.CSS_SELECTOR, f'#qt-window-{self._window_id}')
def setNoFocusShow(self):
self.driver.execute_script(
@@ -641,6 +674,18 @@ class Widget:
'''
)
+ def color_at(self, x, y):
+ raw = self.driver.execute_script(
+ f'''
+ return arguments[0].querySelector('canvas')
+ .getContext('2d').getImageData({x}, {y}, 1, 1).data;
+ ''', self.element)
+ return Color(r=raw[0], g=raw[1], b=raw[2])
+
+ def __window_information(self):
+ information = call_instance_function(self.driver, 'windowInformation')
+ return next(filter(lambda e: e['title'] == "Dialog", information))
+
class Window:
def __init__(self, parent=None, rect=None, title=None, element=None, visible=True, opengl=0):
diff --git a/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp b/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp
index 365fc74a34..75e23cecda 100644
--- a/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp
+++ b/tests/auto/wasm/selenium/tst_qwasmwindow_harness.cpp
@@ -16,6 +16,10 @@
#include <QApplication>
#include <QDialog>
#include <QSysInfo>
+#include <QTreeView>
+#include <QFileSystemModel>
+#include <QScrollArea>
+#include <QVBoxLayout>
#include <QOpenGLWindow>
#include <QOpenGLFunctions>
@@ -389,6 +393,7 @@ public:
void make(const std::string &name)
{
auto widget = std::make_shared<TestWidget>();
+ widget->setWindowTitle("Dialog");
auto *lineEdit = new QLineEdit(widget.get());
widget->setMinimumSize(200, 200);
@@ -401,6 +406,38 @@ public:
m_widgets[name] = widget;
m_lineEdits[name] = lineEdit;
}
+ void makeNative(const std::string &name)
+ {
+ auto widget = std::make_shared<TestWidget>();
+ widget->setWindowTitle("Dialog");
+ auto *lineEdit = new QLineEdit();
+
+ widget->setMinimumSize(200, 200);
+ widget->setMaximumSize(200, 200);
+ widget->setGeometry(0, m_widgetY, 200, 200);
+ m_widgetY += 200;
+
+ lineEdit->setText("Hello world");
+
+ m_widgets[name] = widget;
+ m_lineEdits[name] = lineEdit;
+
+ QFileSystemModel *model = new QFileSystemModel;
+ model->setRootPath(QDir::currentPath());
+
+ auto *scrollArea = new QScrollArea();
+ auto *layout = new QVBoxLayout(widget.get());
+ auto *treeView = new QTreeView(scrollArea);
+ treeView->setModel(model);
+
+ layout->addWidget(lineEdit);
+ layout->addWidget(scrollArea);
+
+ treeView->setAttribute(Qt::WA_NativeWindow);
+ scrollArea->setAttribute(Qt::WA_NativeWindow);
+ lineEdit->setAttribute(Qt::WA_NativeWindow);
+ widget->setAttribute(Qt::WA_NativeWindow);
+ }
private:
using TestWidgetPtr = std::shared_ptr<TestWidget>;
@@ -503,6 +540,11 @@ void createWidget(const std::string &name)
WidgetStorage::getInstance()->make(name);
}
+void createNativeWidget(const std::string &name)
+{
+ WidgetStorage::getInstance()->makeNative(name);
+}
+
void setWidgetNoFocusShow(const std::string &name)
{
auto w = WidgetStorage::getInstance()->findWidget(name);
@@ -678,6 +720,7 @@ EMSCRIPTEN_BINDINGS(qwasmwindow)
emscripten::function("getOpenGLColorAt_0_0", &getOpenGLColorAt_0_0);
emscripten::function("createWidget", &createWidget);
+ emscripten::function("createNativeWidget", &createNativeWidget);
emscripten::function("setWidgetNoFocusShow", &setWidgetNoFocusShow);
emscripten::function("showWidget", &showWidget);
emscripten::function("activateWidget", &activateWidget);
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index 94afff6e40..26a6245164 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -63,6 +63,7 @@ private slots:
void hideNativeByDestruction();
void explicitDoneAfterButtonClicked();
+ void legacyApiReturnValue();
void cleanup();
};
@@ -511,7 +512,7 @@ QT_WARNING_DISABLE_DEPRECATED
// the button text versions
closeHelper.start(Qt::Key_Enter);
ret = QMessageBox::information(nullptr, "title", "text", "Yes", "No", QString(), 1);
- COMPARE(ret, 3); // Custom button opaque result
+ COMPARE(ret, 1);
QVERIFY(closeHelper.done());
#endif // QT_DEPRECATED_SINCE(6, 2)
#undef COMPARE
@@ -863,5 +864,21 @@ void tst_QMessageBox::explicitDoneAfterButtonClicked()
QCOMPARE(rejectedSpy.size(), 3);
}
+void tst_QMessageBox::legacyApiReturnValue()
+{
+ ExecCloseHelper closeHelper;
+ for (int i = 0; i < 3; ++i) {
+ closeHelper.start(Qt::Key_Enter);
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ QCOMPARE(QMessageBox::warning(nullptr, "Title", "Text",
+ "Button 0", "Button 1", "Button 2", i), i);
+ closeHelper.start(Qt::Key_Escape);
+ QCOMPARE(QMessageBox::warning(nullptr, "Title", "Text",
+ "Button 0", "Button 1", "Button 2", 0, i), i);
+QT_WARNING_POP
+ }
+}
+
QTEST_MAIN(tst_QMessageBox)
#include "tst_qmessagebox.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index c91a0803ee..fad75ec045 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -2976,11 +2976,6 @@ static QSizeF wfh(Qt::SizeHint /*which*/, const QSizeF &constraint)
return result;
}
-bool qFuzzyCompare(const QSizeF &a, const QSizeF &b)
-{
- return qFuzzyCompare(a.width(), b.width()) && qFuzzyCompare(a.height(), b.height());
-}
-
void tst_QGraphicsGridLayout::heightForWidth()
{
QGraphicsWidget *widget = new QGraphicsWidget;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index ee1a8c530a..c3f77957f8 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3872,6 +3872,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
break;
}
case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
mousePressReceiver = qobject_cast<QWidget*>(receiver);
break;
default:
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 7ed1f28b0a..5a316dd55e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -26,6 +26,7 @@
#include <QtWidgets/QStyle>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QScroller>
+#include <QtWidgets/QStackedWidget>
#if QT_CONFIG(opengl)
#include <QtOpenGLWidgets/QOpenGLWidget>
#endif
@@ -114,6 +115,7 @@ protected:
#if defined QT_BUILD_INTERNAL
class FriendlyGraphicsScene : public QGraphicsScene
{
+ using QGraphicsScene::QGraphicsScene;
friend class tst_QGraphicsView;
Q_DECLARE_PRIVATE(QGraphicsScene);
};
@@ -254,6 +256,9 @@ private slots:
#ifndef QT_NO_CURSOR
void QTBUG_7438_cursor();
#endif
+#ifdef QT_BUILD_INTERNAL
+ void QTBUG_53974_mismatched_hide_show_events();
+#endif
void resizeContentsOnItemDrag_data();
void resizeContentsOnItemDrag();
@@ -4975,6 +4980,86 @@ void tst_QGraphicsView::QTBUG_70255_scrollTo()
QCOMPARE(point, QPoint(0, -500));
}
+#ifdef QT_BUILD_INTERNAL
+void tst_QGraphicsView::QTBUG_53974_mismatched_hide_show_events()
+{
+ QGraphicsView *view = new QGraphicsView;
+ FriendlyGraphicsScene *scene = new FriendlyGraphicsScene(view);
+ view->setScene(scene);
+
+ QStackedWidget *lowLevel = new QStackedWidget;
+ lowLevel->addWidget(new QLabel);
+ lowLevel->addWidget(view);
+
+ QStackedWidget topLevel;
+ topLevel.addWidget(new QLabel);
+ topLevel.addWidget(lowLevel);
+
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ topLevel.show();
+ topLevel.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
+
+ // Starting point
+ QCOMPARE_EQ(topLevel.currentIndex(), 0);
+ QCOMPARE_EQ(lowLevel->currentIndex(), 0);
+
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // lowLevel is not visible. Changing the current index there
+ // should not affect the refcount.
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ lowLevel->setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Make lowLevel visible.
+ topLevel.setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Show and hide the QGV a couple of times.
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 1);
+
+ lowLevel->setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 1);
+
+ lowLevel->setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Make lowLevel hidden again.
+ topLevel.setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Change the current index in the hidden lowLevel
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ lowLevel->setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Make lowLevel and the QGV visible.
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ topLevel.setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 1);
+
+ // Make lowLevel hidden (keeping the QGV as current index).
+ topLevel.setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Hide the QGV:
+ lowLevel->setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+}
+#endif
+
void tst_QGraphicsView::resizeContentsOnItemDrag_data()
{
QTest::addColumn<Qt::Alignment>("alignment");
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 34972bc3e8..25e681a415 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -9,6 +9,16 @@
#include <QTableWidget>
#include <QTest>
+QT_BEGIN_NAMESPACE
+QDebug operator<<(QDebug dbg, const QTableWidgetSelectionRange &range)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "Range(" << range.topRow() << "," << range.leftColumn() << "->"
+ << range.bottomRow() << "," << range.rightColumn() << ")";
+ return dbg;
+}
+QT_END_NAMESPACE
+
class QObjectTableItem : public QObject, public QTableWidgetItem
{
Q_OBJECT
@@ -578,7 +588,7 @@ void tst_QTableWidget::selectedSpannedCells_data()
QTest::newRow("merge 2 cells in column, select those and one more")
<< QRect(1, 2, 1, 2) << QPoint(1, 1) << QPoint(1, 3)
- << 3 << QTableWidgetSelectionRange(1, 1, 1, 1);
+ << 1 << QTableWidgetSelectionRange(1, 1, 3, 1);
QTest::newRow("merge 2 cells in column, select rows above")
<< QRect(1, 2, 1, 2) << QPoint(0, 0) << QPoint(3, 1)
@@ -590,7 +600,7 @@ void tst_QTableWidget::selectedSpannedCells_data()
QTest::newRow("merge 3 cells in row, select those and one more")
<< QRect(0, 1, 3, 1) << QPoint(0, 1) << QPoint(3, 1)
- << 4 << QTableWidgetSelectionRange(1, 0, 1, 0);
+ << 1 << QTableWidgetSelectionRange(1, 0, 1, 3);
QTest::newRow("merge 3 cells in row, select adjacent to right")
<< QRect(0, 1, 3, 1) << QPoint(3, 0) << QPoint(3, 2)
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 3447c9af28..cac968c5dd 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -432,6 +432,7 @@ private slots:
void touchUpdateOnNewTouch();
void touchCancel();
void touchEventsForGesturePendingWidgets();
+ void synthMouseDoubleClick();
void styleSheetPropagation();
@@ -477,6 +478,10 @@ private slots:
void reparentWindowHandles_data();
void reparentWindowHandles();
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuTrigger();
+#endif
+
private:
const QString m_platform;
QSize m_testWidgetSize;
@@ -1898,6 +1903,7 @@ void tst_QWidget::focusChainOnReparent()
}
QWidget window2;
+ child22->setParent(child21);
child2->setParent(&window2);
QWidget *expectedNewChain[5] = {&window2, child2, child21, child22, &window2};
@@ -11149,6 +11155,10 @@ void tst_QWidget::hoverPosition()
QVERIFY(QTest::qWaitForWindowExposed(&root));
const QPoint middle(50, 50);
+ // wait until we got the correct global pos
+ QPoint expectedGlobalPos = root.geometry().topLeft() + QPoint(100, 100) + middle;
+ if (!QTest::qWaitFor([&]{ return expectedGlobalPos == h.mapToGlobal(middle); }))
+ QSKIP("Can't move cursor");
QPoint curpos = h.mapToGlobal(middle);
QCursor::setPos(curpos);
if (!QTest::qWaitFor([curpos]{ return QCursor::pos() == curpos; }))
@@ -12248,7 +12258,24 @@ protected:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
++m_mouseEventCount;
- m_lastMouseEventPos = static_cast<QMouseEvent *>(e)->position();
+ {
+ QMouseEvent *me = static_cast<QMouseEvent *>(e);
+ m_lastMouseEventPos = me->position();
+ m_lastMouseTimestamp = me->timestamp();
+ }
+ if (m_acceptMouse)
+ e->accept();
+ else
+ e->ignore();
+ return true;
+
+ case QEvent::MouseButtonDblClick:
+ ++m_mouseEventCount;
+ {
+ QMouseEvent *me = static_cast<QMouseEvent *>(e);
+ m_lastMouseEventPos = me->position();
+ m_doubleClickTimestamp = me->timestamp();
+ }
if (m_acceptMouse)
e->accept();
else
@@ -12274,6 +12301,8 @@ public:
int m_mouseEventCount = 0;
bool m_acceptMouse = true;
QPointF m_lastMouseEventPos;
+ quint64 m_lastMouseTimestamp = 0;
+ quint64 m_doubleClickTimestamp = 0;
};
void tst_QWidget::touchEventSynthesizedMouseEvent()
@@ -12515,6 +12544,50 @@ void tst_QWidget::touchEventsForGesturePendingWidgets()
QVERIFY(parent.m_gestureEventCount > 0);
}
+void tst_QWidget::synthMouseDoubleClick()
+{
+ TouchMouseWidget widget;
+ widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+ widget.show();
+ QWindow* window = widget.windowHandle();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ // tap once; move slightly from press to release
+ QPoint p(20, 20);
+ int expectedMouseEventCount = 0;
+ QTest::touchEvent(window, m_touchScreen).press(1, p, window);
+ QCOMPARE(widget.m_touchBeginCount, 0);
+ QCOMPARE(widget.m_mouseEventCount, ++expectedMouseEventCount);
+ QCOMPARE(widget.m_lastMouseEventPos.toPoint(), p);
+ quint64 mouseTimestamp = widget.m_lastMouseTimestamp;
+ p += {1, 0};
+ QTest::touchEvent(window, m_touchScreen).move(1, p, window);
+ QCOMPARE(widget.m_mouseEventCount, ++expectedMouseEventCount);
+ QCOMPARE(widget.m_lastMouseEventPos.toPoint(), p);
+ QCOMPARE_GT(widget.m_lastMouseTimestamp, mouseTimestamp);
+ mouseTimestamp = widget.m_lastMouseTimestamp;
+ QTest::touchEvent(window, m_touchScreen).release(1, p, window);
+ QCOMPARE(widget.m_mouseEventCount, ++expectedMouseEventCount);
+ QCOMPARE(widget.m_lastMouseEventPos.toPoint(), p);
+ QCOMPARE_GT(widget.m_lastMouseTimestamp, mouseTimestamp);
+ mouseTimestamp = widget.m_lastMouseTimestamp;
+
+ // tap again nearby: a double-click event should be synthesized
+ p += {0, 1};
+ QTest::touchEvent(window, m_touchScreen).press(2, p, window);
+ QCOMPARE(widget.m_touchBeginCount, 0);
+ QCOMPARE(widget.m_mouseEventCount, ++expectedMouseEventCount);
+ QCOMPARE(widget.m_lastMouseEventPos.toPoint(), p);
+ QCOMPARE_GT(widget.m_doubleClickTimestamp, mouseTimestamp);
+ mouseTimestamp = widget.m_doubleClickTimestamp;
+
+ QTest::touchEvent(window, m_touchScreen).release(2, p, window);
+ QCOMPARE(widget.m_mouseEventCount, ++expectedMouseEventCount);
+ QCOMPARE(widget.m_lastMouseEventPos.toPoint(), p);
+ QCOMPARE_GT(widget.m_lastMouseTimestamp, mouseTimestamp);
+ mouseTimestamp = widget.m_lastMouseTimestamp;
+}
+
void tst_QWidget::styleSheetPropagation()
{
QTableView tw;
@@ -14040,5 +14113,41 @@ void tst_QWidget::reparentWindowHandles()
}
}
+#ifndef QT_NO_CONTEXTMENU
+void tst_QWidget::contextMenuTrigger()
+{
+ class ContextMenuWidget : public QWidget
+ {
+ public:
+ int events = 0;
+
+ protected:
+ void contextMenuEvent(QContextMenuEvent *) override { ++events; }
+ };
+
+ const Qt::ContextMenuTrigger wasTrigger = QGuiApplication::styleHints()->contextMenuTrigger();
+ auto restoreTriggerGuard = qScopeGuard([wasTrigger]{
+ QGuiApplication::styleHints()->setContextMenuTrigger(wasTrigger);
+ });
+
+ ContextMenuWidget widget;
+ widget.show();
+ QVERIFY(!qApp->topLevelWindows().empty());
+ auto *window = qApp->topLevelWindows()[0];
+ QVERIFY(window);
+ QCOMPARE(widget.events, 0);
+ QGuiApplication::styleHints()->setContextMenuTrigger(Qt::ContextMenuTrigger::Press);
+ QTest::mousePress(window, Qt::RightButton);
+ QCOMPARE(widget.events, 1);
+ QTest::mouseRelease(window, Qt::RightButton);
+ QCOMPARE(widget.events, 1);
+ QGuiApplication::styleHints()->setContextMenuTrigger(Qt::ContextMenuTrigger::Release);
+ QTest::mousePress(window, Qt::RightButton);
+ QCOMPARE(widget.events, 1);
+ QTest::mouseRelease(window, Qt::RightButton);
+ QCOMPARE(widget.events, 2);
+}
+#endif
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index e771737ae0..1fab69fdcc 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -1634,8 +1634,7 @@ void tst_QWidget_window::mouseMoveWithPopup()
// but the release event will still be delivered to the first popup - dialogs might not get it
QCOMPARE(mouseAction(Qt::LeftButton), QEvent::MouseButtonRelease);
- if (topLevel.popup->mouseReleaseCount != 1
- && !QGuiApplication::platformName().startsWith(QLatin1String("windows"), Qt::CaseInsensitive))
+ if (topLevel.popup->mouseReleaseCount != 1)
QEXPECT_FAIL("Dialog", "Platform specific behavior", Continue);
QCOMPARE(topLevel.popup->mouseReleaseCount, 1);
}
diff --git a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
index 9059a9262e..64ebeb08b0 100644
--- a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
+++ b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
@@ -260,6 +260,7 @@ private slots:
void staticContents();
void scroll();
void paintOnScreenUpdates();
+ void evaluateRhi();
#if defined(QT_BUILD_INTERNAL)
void scrollWithOverlap();
@@ -581,6 +582,222 @@ void tst_QWidgetRepaintManager::paintOnScreenUpdates()
}
}
+class RhiWidgetPrivate : public QWidgetPrivate
+{
+public:
+ RhiWidgetPrivate(const QPlatformBackingStoreRhiConfig &config)
+ : config(config)
+ {
+ }
+
+ QPlatformBackingStoreRhiConfig rhiConfig() const override
+ {
+ return config;
+ }
+
+ QPlatformBackingStoreRhiConfig config = QPlatformBackingStoreRhiConfig::Null;
+};
+
+class RhiWidget : public QWidget
+{
+public:
+ RhiWidget(const QPlatformBackingStoreRhiConfig &config = QPlatformBackingStoreRhiConfig::Null, QWidget *parent = nullptr)
+ : QWidget(*new RhiWidgetPrivate(config), parent, {})
+ {
+ }
+};
+
+void tst_QWidgetRepaintManager::evaluateRhi()
+{
+ const auto *integration = QGuiApplicationPrivate::platformIntegration();
+ if (!integration->hasCapability(QPlatformIntegration::RhiBasedRendering))
+ QSKIP("Platform does not support RHI based rendering");
+
+ // We need full control over whether widgets are native or not
+ const bool nativeSiblingsOriginal = qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
+ qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
+ auto nativeSiblingGuard = qScopeGuard([&]{
+ qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, nativeSiblingsOriginal);
+ });
+
+ auto defaultSurfaceType = QSurface::RasterSurface;
+ bool usesRhiBackingStore = false;
+
+ {
+ // Plain QWidget doesn't enable RHI
+ QWidget regularWidget;
+ regularWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&regularWidget));
+ QVERIFY(!QWidgetPrivate::get(&regularWidget)->usesRhiFlush);
+
+ // The platform might use a non-raster surface type if it uses
+ // an RHI backingstore by default (e.g. Android, iOS, QNX).
+ defaultSurfaceType = regularWidget.windowHandle()->surfaceType();
+
+ // Record whether the platform uses an RHI backingstore,
+ // so we can opt out of some tests further down.
+ if (defaultSurfaceType != QSurface::RasterSurface)
+ usesRhiBackingStore = QWidgetPrivate::get(&regularWidget)->rhi();
+ else
+ QVERIFY(!QWidgetPrivate::get(&regularWidget)->rhi());
+ }
+
+ {
+ // But a top level RHI widget does
+ RhiWidget rhiWidget;
+ rhiWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&rhiWidget));
+ QVERIFY(QWidgetPrivate::get(&rhiWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&rhiWidget)->rhi());
+ }
+
+#if QT_CONFIG(opengl)
+ {
+ // Non-native child RHI widget enables RHI for top level regular widget
+ QWidget topLevel;
+ RhiWidget rhiWidget(QPlatformBackingStoreRhiConfig::OpenGL, &topLevel);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QCOMPARE(topLevel.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->rhi());
+ // Only the native widget that actually flushes will report usesRhiFlush
+ QVERIFY(!QWidgetPrivate::get(&rhiWidget)->usesRhiFlush);
+ // But it should have an RHI it can use
+ QVERIFY(QWidgetPrivate::get(&rhiWidget)->rhi());
+ }
+
+ {
+ // Native child RHI widget does not enable RHI for top level
+ QWidget topLevel;
+ RhiWidget nativeRhiWidget(QPlatformBackingStoreRhiConfig::OpenGL, &topLevel);
+ nativeRhiWidget.setAttribute(Qt::WA_NativeWindow);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QCOMPARE(nativeRhiWidget.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&nativeRhiWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&nativeRhiWidget)->rhi());
+ QCOMPARE(topLevel.windowHandle()->surfaceType(), defaultSurfaceType);
+ QVERIFY(!QWidgetPrivate::get(&topLevel)->usesRhiFlush);
+
+ if (!usesRhiBackingStore)
+ QVERIFY(!QWidgetPrivate::get(&topLevel)->rhi());
+ }
+
+ {
+ // Non-native RHI child of native child enables RHI for native child,
+ // but not top level.
+ QWidget topLevel;
+ QWidget nativeChild(&topLevel);
+ nativeChild.setAttribute(Qt::WA_NativeWindow);
+ RhiWidget rhiWidget(QPlatformBackingStoreRhiConfig::OpenGL, &nativeChild);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ QCOMPARE(nativeChild.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&nativeChild)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&nativeChild)->rhi());
+ QVERIFY(!QWidgetPrivate::get(&rhiWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&rhiWidget)->rhi());
+ QCOMPARE(topLevel.windowHandle()->surfaceType(), defaultSurfaceType);
+ QVERIFY(!QWidgetPrivate::get(&topLevel)->usesRhiFlush);
+ if (!usesRhiBackingStore)
+ QVERIFY(!QWidgetPrivate::get(&topLevel)->rhi());
+ }
+
+ {
+ // Native child RHI widget does not prevent RHI for top level
+ // if non-native RHI child widget is also present.
+ QWidget topLevel;
+ RhiWidget rhiWidget(QPlatformBackingStoreRhiConfig::OpenGL, &topLevel);
+ RhiWidget nativeRhiWidget(QPlatformBackingStoreRhiConfig::OpenGL, &topLevel);
+ nativeRhiWidget.setAttribute(Qt::WA_NativeWindow);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ QCOMPARE(nativeRhiWidget.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&nativeRhiWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&nativeRhiWidget)->rhi());
+ QVERIFY(!QWidgetPrivate::get(&rhiWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&rhiWidget)->rhi());
+ QCOMPARE(topLevel.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->rhi());
+ }
+
+ {
+ // Reparenting into a window that already matches the required
+ // surface type should still mark the parent as flushing with RHI.
+ QWidget topLevel;
+
+ RhiWidget rhiWidget(QPlatformBackingStoreRhiConfig::Null);
+ rhiWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&rhiWidget));
+ QVERIFY(QWidgetPrivate::get(&rhiWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&rhiWidget)->rhi());
+
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ rhiWidget.setParent(&topLevel);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->rhi());
+ }
+
+ {
+ // Non-native RHI child of native child enables RHI for native child,
+ // but does not prevent top level from flushing with RHI.
+ QWidget topLevel;
+ QWidget nativeChild(&topLevel);
+ nativeChild.setAttribute(Qt::WA_NativeWindow);
+ RhiWidget rhiGranchild(QPlatformBackingStoreRhiConfig::OpenGL, &nativeChild);
+ RhiWidget rhiChild(QPlatformBackingStoreRhiConfig::OpenGL, &topLevel);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ QCOMPARE(nativeChild.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&nativeChild)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&nativeChild)->rhi());
+ QVERIFY(!QWidgetPrivate::get(&rhiGranchild)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&rhiGranchild)->rhi());
+ QCOMPARE(topLevel.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&topLevel)->rhi());
+ QVERIFY(!QWidgetPrivate::get(&rhiChild)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&rhiChild)->rhi());
+ }
+
+#if QT_CONFIG(metal)
+ QRhiMetalInitParams metalParams;
+ if (QRhi::probe(QRhi::Metal, &metalParams)) {
+ // Native RHI childen allows mixing RHI backends
+ QWidget topLevel;
+ RhiWidget openglWidget(QPlatformBackingStoreRhiConfig::OpenGL, &topLevel);
+ openglWidget.setAttribute(Qt::WA_NativeWindow);
+ RhiWidget metalWidget(QPlatformBackingStoreRhiConfig::Metal, &topLevel);
+ metalWidget.setAttribute(Qt::WA_NativeWindow);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ QCOMPARE(topLevel.windowHandle()->surfaceType(), defaultSurfaceType);
+ QVERIFY(!QWidgetPrivate::get(&topLevel)->usesRhiFlush);
+ if (!usesRhiBackingStore)
+ QVERIFY(!QWidgetPrivate::get(&topLevel)->rhi());
+
+ QCOMPARE(openglWidget.windowHandle()->surfaceType(), QSurface::OpenGLSurface);
+ QVERIFY(QWidgetPrivate::get(&openglWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&openglWidget)->rhi());
+
+ QCOMPARE(metalWidget.windowHandle()->surfaceType(), QSurface::MetalSurface);
+ QVERIFY(QWidgetPrivate::get(&metalWidget)->usesRhiFlush);
+ QVERIFY(QWidgetPrivate::get(&metalWidget)->rhi());
+
+ QVERIFY(QWidgetPrivate::get(&openglWidget)->rhi() != QWidgetPrivate::get(&metalWidget)->rhi());
+ }
+#endif // QT_CONFIG(metal)
+
+#endif // QT_CONFIG(opengl)
+}
+
#if defined(QT_BUILD_INTERNAL)
/*!
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 52aaf094b4..e7d65db550 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -62,6 +62,7 @@ private slots:
void testPlatformSurfaceEvent();
void embedWidgetWindow();
void testFocus();
+ void parentDestroyed();
void cleanup();
private:
@@ -530,6 +531,36 @@ void tst_QWindowContainer::testFocus()
QVERIFY(!lineEdit->hasFocus());
}
+class CreateDestroyWidget : public QWidget
+{
+public:
+ void create() { QWidget::create(); }
+ void destroy() { QWidget::destroy(); }
+};
+
+void tst_QWindowContainer::parentDestroyed()
+{
+ CreateDestroyWidget topLevel;
+ topLevel.setAttribute(Qt::WA_NativeWindow);
+ QVERIFY(topLevel.windowHandle());
+
+ QPointer<QWindow> window = new QWindow;
+ QWidget *container = QWidget::createWindowContainer(window.get());
+ container->setParent(&topLevel);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QCOMPARE(window->parent(), topLevel.windowHandle());
+
+ // Destroying the widget should not wipe out the contained QWindow
+ topLevel.destroy();
+ QVERIFY(window);
+
+ // Recreating the top level should once again reparent the contained window
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QCOMPARE(window->parent(), topLevel.windowHandle());
+}
+
QTEST_MAIN(tst_QWindowContainer)
#include "tst_qwindowcontainer.moc"
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index b2e77bc935..0623ab4167 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -613,6 +613,9 @@ void tst_QCompleter::fileSystemModel_data()
const QString androidDir = androidHomePath();
const QString tag = QStringLiteral("%1/fil").arg(androidDir);
QTest::newRow(tag.toUtf8().data()) << tag << "" << "files" << androidDir + "/files";
+#elif defined(Q_OS_VXWORKS)
+ QTest::newRow("()") << "" << "" << "/" << "/";
+ QTest::newRow("(/tm)") << "/tm" << "" << "tmp" << "/tmp";
#else
QTest::newRow("()") << "" << "" << "/" << "/";
#if !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX)
diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
index fa1f799855..f91d984656 100644
--- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -431,6 +431,18 @@ void tst_QAbstractScrollArea::sizeHint()
QSize sizeHint = scrollArea.sizeHint();
QCOMPARE(sizeHint, scrollArea.viewportSizeHint());
+ // check if the hScrollbar is taken into account
+ scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ QCOMPARE_GT(scrollArea.sizeHint().height(), scrollArea.viewportSizeHint().height());
+
+ // check if the vScrollbar is taken into account
+ scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ QCOMPARE_GT(scrollArea.sizeHint().width(), scrollArea.viewportSizeHint().width());
+
+ scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+
scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
const QSize sizeHintWithScrollBars = scrollArea.sizeHint();
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index af62d0d089..88a7057d2e 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -96,6 +96,20 @@ private:
QPointer<QDockWidget> &d1, QPointer<QDockWidget> &d2,
QList<int> &path1, QList<int> &path2) const;
+#if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || defined(Q_OS_QNX)
+#define qCreateFloatingTabs(mainWindow, centralWidget, d1, d2, path1, path2)\
+ mainWindow = nullptr;\
+ Q_UNUSED(path1);\
+ Q_UNUSED(path2);\
+ QSKIP("Platform not supported");
+#else
+#define qCreateFloatingTabs(mainWindow, centralWidget, d1, d2, path1, path2)\
+ createFloatingTabs(mainWindow, centralWidget, d1, d2, path1, path2);\
+ std::unique_ptr<QMainWindow> up_mainWindow(mainWindow);\
+ if (!platformSupportingRaise)\
+ QSKIP("Platform not supporting raise(). Floating tab based tests will fail.")
+#endif
+
static inline QPoint dragPoint(QDockWidget* dockWidget);
static inline QPoint home1(QMainWindow* MainWindow)
{ return MainWindow->mapToGlobal(MainWindow->rect().topLeft() + QPoint(0.1 * MainWindow->width(), 0.1 * MainWindow->height())); }
@@ -447,6 +461,23 @@ void tst_QDockWidget::setFloating()
dw.setFloating(dw.isFloating());
QCOMPARE(spy.size(), 0);
spy.clear();
+
+#if defined(QT_BUILD_INTERNAL) && !defined(Q_OS_WIN)
+ // Check that setFloating() reparents the dock widget to the main window,
+ // in case it has a QDockWidgetGroupWindow parent
+ QPointer<QDockWidget> d1;
+ QPointer<QDockWidget> d2;
+ QPointer<QWidget> cent;
+ QMainWindow* mainWindow;
+ QList<int> path1;
+ QList<int> path2;
+ qCreateFloatingTabs(mainWindow, cent, d1, d2, path1, path2);
+ QVERIFY(qobject_cast<QDockWidgetGroupWindow *>(d1->parentWidget()));
+ QVERIFY(qobject_cast<QDockWidgetGroupWindow *>(d2->parentWidget()));
+ d1->setFloating(true);
+ QTRY_COMPARE(mainWindow, d1->parentWidget());
+ QTRY_COMPARE(mainWindow, d2->parentWidget());
+#endif // defined(QT_BUILD_INTERNAL) && !defined(Q_OS_WIN)
}
void tst_QDockWidget::allowedAreas()
@@ -1399,7 +1430,7 @@ void tst_QDockWidget::createFloatingTabs(QMainWindow* &mainWindow, QPointer<QWid
// Test will fail if platform doesn't support raise.
mainWindow->windowHandle()->handle()->raise();
if (!platformSupportingRaise)
- QSKIP("Platform not supporting raise(). Floating tab based tests will fail.");
+ return;
// remember paths to d1 and d2
QMainWindowLayout* layout = qobject_cast<QMainWindowLayout *>(mainWindow->layout());
@@ -1443,8 +1474,7 @@ void tst_QDockWidget::floatingTabs()
QMainWindow* mainWindow;
QList<int> path1;
QList<int> path2;
- createFloatingTabs(mainWindow, cent, d1, d2, path1, path2);
- std::unique_ptr<QMainWindow> up_mainWindow(mainWindow);
+ qCreateFloatingTabs(mainWindow, cent, d1, d2, path1, path2);
QCOMPARE(mainWindow->tabifiedDockWidgets(d1), {d2});
QCOMPARE(mainWindow->tabifiedDockWidgets(d2), {d1});
@@ -1497,9 +1527,13 @@ void tst_QDockWidget::floatingTabs()
QTest::mouseClick(floatButton, Qt::LeftButton, Qt::KeyboardModifiers(), pos1);
QTest::qWait(waitingTime);
- // d1 must be floating again, while d2 is still in its GroupWindow
+ // d1 and d2 must be floating again
QTRY_VERIFY(d1->isFloating());
- QTRY_VERIFY(!d2->isFloating());
+ QTRY_VERIFY(d2->isFloating());
+
+ // d2 was the active tab, so d1 was not visible
+ QTRY_VERIFY(d1->isVisible());
+ QTRY_VERIFY(d2->isVisible());
// Plug back into dock areas
qCDebug(lcTestDockWidget) << "*** test plugging back to dock areas ***";
@@ -1562,8 +1596,7 @@ void tst_QDockWidget::deleteFloatingTabWithSingleDockWidget()
QMainWindow* mainWindow;
QList<int> path1;
QList<int> path2;
- createFloatingTabs(mainWindow, cent, d1, d2, path1, path2);
- std::unique_ptr<QMainWindow> up_mainWindow(mainWindow);
+ qCreateFloatingTabs(mainWindow, cent, d1, d2, path1, path2);
switch (removalReason) {
case ChildRemovalReason::Destroyed:
@@ -1698,6 +1731,9 @@ void tst_QDockWidget::closeAndDelete()
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Test skipped on Wayland.");
#ifdef QT_BUILD_INTERNAL
+ if (QSysInfo::productType() == "rhel")
+ QSKIP("Memory leak on RHEL 9.2 QTBUG-124559", TestFailMode::Abort);
+
// Create a mainwindow with a central widget and two dock widgets
QPointer<QDockWidget> d1;
QPointer<QDockWidget> d2;
@@ -1992,6 +2028,7 @@ void tst_QDockWidget::saveAndRestore()
QCOMPARE(d1->isFloating(), isFloating1);
QCOMPARE(d2->isFloating(), isFloating2);
+#undef qCreateFloatingTabs
#endif // QT_BUILD_INTERNAL
}
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 7c1fb97b97..06750b099b 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -124,6 +124,9 @@ private slots:
void platformMenu();
void addActionQt5connect();
void QTBUG_65488_hiddenActionTriggered();
+ void pressDragRelease_data();
+ void pressDragRelease();
+
protected slots:
void onSimpleActivated( QAction*);
void onComplexActionTriggered();
@@ -141,6 +144,7 @@ private:
int m_simpleActivatedCount;
int m_complexTriggerCount[int('k')];
QMenuBar* taskQTBUG53205MenuBar;
+ QScopedPointer<QPointingDevice> m_touchScreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
};
// Testing get/set functions
@@ -1420,6 +1424,70 @@ void tst_QMenuBar::QTBUG_65488_hiddenActionTriggered()
QCOMPARE(spy.size(), 0);
}
+void tst_QMenuBar::pressDragRelease_data()
+{
+ QTest::addColumn<QPointingDevice *>("device");
+
+ QTest::newRow("mouse") << const_cast<QPointingDevice *>(QPointingDevice::primaryPointingDevice());
+ QTest::newRow("touchscreen") << m_touchScreen.get();
+}
+
+void tst_QMenuBar::pressDragRelease()
+{
+ QFETCH(QPointingDevice *, device);
+
+ QMainWindow w;
+ const TestMenu menu = initWindowWithComplexMenuBar(w);
+ const QMenu *firstMenu = menu.menus.first();
+ QAction *hoveredAction = nullptr;
+ connect(firstMenu, &QMenu::hovered, firstMenu, [&hoveredAction](QAction *hov) { hoveredAction = hov; });
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+ QWindow *win = w.windowHandle();
+ const QPoint p1(50, w.menuBar()->geometry().height() / 2);
+ switch (device->type()) {
+ case QInputDevice::DeviceType::Mouse:
+ case QInputDevice::DeviceType::TouchPad:
+ QTest::mousePress(win, Qt::LeftButton, {}, p1);
+ break;
+ case QInputDevice::DeviceType::TouchScreen:
+ QTest::touchEvent(win, device).press(0, p1);
+ break;
+ default:
+ break;
+ }
+
+ QTRY_VERIFY(firstMenu->isVisible());
+ const QPoint firstMenuItemPos = firstMenu->geometry().center() - QPoint(0, 2);
+ const QPoint firstMenuItemPosInWin = w.mapFromGlobal(firstMenuItemPos);
+ switch (device->type()) {
+ case QInputDevice::DeviceType::Mouse:
+ case QInputDevice::DeviceType::TouchPad:
+ QTest::mouseMove(win, firstMenuItemPosInWin);
+ break;
+ case QInputDevice::DeviceType::TouchScreen:
+ QTest::touchEvent(win, device).move(0, firstMenuItemPosInWin);
+ break;
+ default:
+ break;
+ }
+ QVERIFY(hoveredAction);
+ QCOMPARE(hoveredAction, firstMenu->actionAt(firstMenu->mapFromGlobal(firstMenuItemPos)));
+ QSignalSpy triggeredSpy(hoveredAction, &QAction::triggered);
+ switch (device->type()) {
+ case QInputDevice::DeviceType::Mouse:
+ case QInputDevice::DeviceType::TouchPad:
+ QTest::mouseRelease(win, Qt::LeftButton, {}, firstMenuItemPosInWin);
+ break;
+ case QInputDevice::DeviceType::TouchScreen:
+ QTest::touchEvent(win, device).release(0, firstMenuItemPosInWin);
+ break;
+ default:
+ break;
+ }
+ QTRY_COMPARE(triggeredSpy.size(), 1);
+}
+
// QTBUG-56526
void tst_QMenuBar::platformMenu()
{
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
index 773ccd894c..51f898c953 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -203,7 +203,7 @@ void tst_QOpenGLWidget::deviceLoss()
w->resize(640, 480);
w->show();
- auto rhi = w->backingStore()->handle()->rhi();
+ auto rhi = w->backingStore()->handle()->rhi(w->windowHandle());
QNativeInterface::QEGLContext *rhiContext = nullptr;
if (rhi->backend() == QRhi::OpenGLES2) {
auto rhiHandles = static_cast<const QRhiGles2NativeHandles *>(rhi->nativeHandles());
diff --git a/tests/auto/xml/CMakeLists.txt b/tests/auto/xml/CMakeLists.txt
index 4b8cc88d78..92ac1870f6 100644
--- a/tests/auto/xml/CMakeLists.txt
+++ b/tests/auto/xml/CMakeLists.txt
@@ -1 +1,3 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(dom)
diff --git a/tests/baseline/painting/tst_baseline_painting.cpp b/tests/baseline/painting/tst_baseline_painting.cpp
index f486b33430..c8de08e7d2 100644
--- a/tests/baseline/painting/tst_baseline_painting.cpp
+++ b/tests/baseline/painting/tst_baseline_painting.cpp
@@ -473,17 +473,6 @@ void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, QImage::Fo
p.end();
}
-#define main _realmain
-QTEST_MAIN(tst_Lancelot)
-#undef main
-
-int main(int argc, char *argv[])
-{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
-
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
-}
+QBASELINETEST_MAIN(tst_Lancelot);
#include "tst_baseline_painting.moc"
diff --git a/tests/baseline/shared/baselineprotocol.cpp b/tests/baseline/shared/baselineprotocol.cpp
index 6a38e71831..311b003c07 100644
--- a/tests/baseline/shared/baselineprotocol.cpp
+++ b/tests/baseline/shared/baselineprotocol.cpp
@@ -261,18 +261,21 @@ bool BaselineProtocol::disconnect()
}
-bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const PlatformInfo& clientInfo)
+bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const PlatformInfo &clientInfo, const QString &server)
{
errMsg.clear();
- QByteArray serverName(qgetenv("QT_LANCELOT_SERVER"));
- if (serverName.isNull())
- serverName = "lancelot.test.qt-project.org";
+ QString serverName = server;
+ if (serverName.isEmpty()) {
+ serverName = qEnvironmentVariable("QT_LANCELOT_SERVER");
+ if (serverName.isEmpty())
+ serverName = QStringLiteral("lancelot.test.qt-project.org");
+ }
socket.connectToHost(serverName, ServerPort);
if (!socket.waitForConnected(Timeout)) {
QThread::sleep(std::chrono::seconds{3}); // Wait a bit and try again, the server might just be restarting
if (!socket.waitForConnected(Timeout)) {
- errMsg += QLS("TCP connectToHost failed. Host:") + QLS(serverName) + QLS(" port:") + QString::number(ServerPort);
+ errMsg += QLS("TCP connectToHost failed. Host:") + serverName + QLS(" port:") + QString::number(ServerPort);
return false;
}
}
diff --git a/tests/baseline/shared/baselineprotocol.h b/tests/baseline/shared/baselineprotocol.h
index 598a0cd3af..93d416fcd8 100644
--- a/tests/baseline/shared/baselineprotocol.h
+++ b/tests/baseline/shared/baselineprotocol.h
@@ -115,7 +115,8 @@ public:
// For client:
// For advanced client:
- bool connect(const QString &testCase, bool *dryrun = nullptr, const PlatformInfo& clientInfo = PlatformInfo());
+ bool connect(const QString &testCase, bool *dryrun = nullptr,
+ const PlatformInfo &clientInfo = PlatformInfo(), const QString &server = QString());
bool disconnect();
bool requestBaselineChecksums(const QString &testFunction, ImageItemList *itemList);
bool submitMatch(const ImageItem &item, QByteArray *serverMsg);
diff --git a/tests/baseline/shared/qbaselinetest.cpp b/tests/baseline/shared/qbaselinetest.cpp
index e41b8d5321..964266f1b4 100644
--- a/tests/baseline/shared/qbaselinetest.cpp
+++ b/tests/baseline/shared/qbaselinetest.cpp
@@ -11,6 +11,7 @@
namespace QBaselineTest {
static char *fargv[MAXCMDLINEARGS];
+static QString server;
static bool simfail = false;
static PlatformInfo customInfo;
static bool customAutoModeSet = false;
@@ -33,6 +34,7 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
return;
bool showHelp = false;
+ bool abortOnHelp = true;
int fargc = 0;
int numArgs = *argcp;
@@ -41,7 +43,16 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
QByteArray arg = (*argvp)[i];
QByteArray nextArg = (i+1 < numArgs) ? (*argvp)[i+1] : nullptr;
- if (arg == "-simfail") {
+ if (arg == "-server") {
+ i++;
+ if (!nextArg.isEmpty()) {
+ server = QString::fromLocal8Bit(nextArg);
+ } else {
+ qWarning() << "-server requires parameter";
+ showHelp = true;
+ break;
+ }
+ } else if (arg == "-simfail") {
simfail = true;
} else if (arg == "-fuzzlevel") {
i++;
@@ -77,10 +88,13 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
}
customInfo.addOverride(key, value);
} else {
- if ( (arg == "-help") || (arg == "--help") )
+ if ( (arg == "-help") || (arg == "--help") ) {
showHelp = true;
+ abortOnHelp = false;
+ }
if (fargc >= MAXCMDLINEARGS) {
qWarning() << "Too many command line arguments!";
+ showHelp = true;
break;
}
fargv[fargc++] = (*argvp)[i];
@@ -93,7 +107,9 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
// TBD: arrange for this to be printed *after* QTest's help
QTextStream out(stdout);
out << "\n Baseline testing (lancelot) options:\n";
- out << " -simfail : Force an image comparison mismatch. For testing purposes.\n";
+ out << " -server <host> : Set the network baseline server to connect to.\n";
+ out << " The default is taken from the environment variable QT_LANCELOT_SERVER.\n";
+ out << " -simfail : Force an image comparison mismatch. For development purposes.\n";
out << " -fuzzlevel <int> : Specify the percentage of fuzziness in comparison. Overrides server default. 0 means exact match.\n";
out << " -auto : Inform server that this run is done by a daemon, CI system or similar.\n";
out << " -adhoc (default) : The inverse of -auto; this run is done by human, e.g. for testing.\n";
@@ -104,6 +120,9 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
out << " for example: -compareto QtVersion=4.8.0\n";
out << " Multiple -compareto client specifications may be given.\n";
out << "\n";
+ out.flush();
+ if (abortOnHelp)
+ std::exit(1);
}
}
@@ -182,7 +201,7 @@ bool connect(QByteArray *msg, bool *error)
return false;
}
- if (!proto.connect(testCase, &dryRunMode, clientInfo)) {
+ if (!proto.connect(testCase, &dryRunMode, clientInfo, server)) {
*msg += "Failed to connect to baseline server: " + proto.errorMessage().toLatin1();
*error = true;
return false;
diff --git a/tests/baseline/shared/qbaselinetest.h b/tests/baseline/shared/qbaselinetest.h
index f120e2bcd8..73bb5dfda9 100644
--- a/tests/baseline/shared/qbaselinetest.h
+++ b/tests/baseline/shared/qbaselinetest.h
@@ -66,4 +66,9 @@ do {\
QSKIP("Blacklisted on baseline server.");\
} while (0)
+#define QBASELINETEST_MAIN(TestObject) QTEST_MAIN_WRAPPER(TestObject, \
+ QHashSeed::setDeterministicGlobalSeed(); \
+ QBaselineTest::handleCmdLineArgs(&argc, &argv); \
+ QTEST_MAIN_SETUP())
+
#endif // BASELINETEST_H
diff --git a/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp b/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp
index 67a618988b..1028c68250 100644
--- a/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp
+++ b/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp
@@ -224,17 +224,6 @@ void tst_Stylesheet::tst_QHeaderView()
QBASELINE_TEST(takeSnapshot());
}
-#define main _realmain
-QTEST_MAIN(tst_Stylesheet)
-#undef main
-
-int main(int argc, char *argv[])
-{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
-
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
-}
+QBASELINETEST_MAIN(tst_Stylesheet)
#include "tst_baseline_stylesheet.moc"
diff --git a/tests/baseline/text/tst_baseline_text.cpp b/tests/baseline/text/tst_baseline_text.cpp
index 59a5f478a5..45c709b92f 100644
--- a/tests/baseline/text/tst_baseline_text.cpp
+++ b/tests/baseline/text/tst_baseline_text.cpp
@@ -103,17 +103,6 @@ void tst_Text::tst_differentScriptsBackgrounds()
}
-#define main _realmain
-QTEST_MAIN(tst_Text)
-#undef main
-
-int main(int argc, char *argv[])
-{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
-
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
-}
+QBASELINETEST_MAIN(tst_Text)
#include "tst_baseline_text.moc"
diff --git a/tests/baseline/widgets/tst_baseline_widgets.cpp b/tests/baseline/widgets/tst_baseline_widgets.cpp
index 8a763eb8fa..ffabf9e07e 100644
--- a/tests/baseline/widgets/tst_baseline_widgets.cpp
+++ b/tests/baseline/widgets/tst_baseline_widgets.cpp
@@ -1275,17 +1275,6 @@ void tst_Widgets::tst_QLCDNumber()
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "lcdnumber");
}
-#define main _realmain
-QTEST_MAIN(tst_Widgets)
-#undef main
-
-int main(int argc, char *argv[])
-{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
-
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
-}
+QBASELINETEST_MAIN(tst_Widgets)
#include "tst_baseline_widgets.moc"
diff --git a/tests/benchmarks/corelib/io/qdir/CMakeLists.txt b/tests/benchmarks/corelib/io/qdir/CMakeLists.txt
index f1800fc0cd..00991de9a9 100644
--- a/tests/benchmarks/corelib/io/qdir/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdir/CMakeLists.txt
@@ -1,2 +1,4 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(10000)
add_subdirectory(tree)
diff --git a/tests/benchmarks/corelib/itemmodels/CMakeLists.txt b/tests/benchmarks/corelib/itemmodels/CMakeLists.txt
index cff884ebcc..8dc331aee2 100644
--- a/tests/benchmarks/corelib/itemmodels/CMakeLists.txt
+++ b/tests/benchmarks/corelib/itemmodels/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(QT_FEATURE_proxymodel)
add_subdirectory(qsortfilterproxymodel)
diff --git a/tests/benchmarks/network/access/qdecompresshelper/main.cpp b/tests/benchmarks/network/access/qdecompresshelper/main.cpp
index 09c24af668..7f8b09ef0e 100644
--- a/tests/benchmarks/network/access/qdecompresshelper/main.cpp
+++ b/tests/benchmarks/network/access/qdecompresshelper/main.cpp
@@ -51,13 +51,14 @@ void tst_QDecompressHelper::decompress()
file.seek(0);
QDecompressHelper helper;
helper.setEncoding(encoding);
+ helper.setDecompressedSafetyCheckThreshold(-1);
QVERIFY(helper.isValid());
helper.feed(file.readAll());
qsizetype bytes = 0;
+ QByteArray out(64 * 1024, Qt::Uninitialized);
while (helper.hasData()) {
- QByteArray out(64 * 1024, Qt::Uninitialized);
qsizetype bytesRead = helper.read(out.data(), out.size());
bytes += bytesRead;
}
diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp
index 3b9e843405..e94cd095f9 100644
--- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp
+++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp
@@ -41,8 +41,10 @@ extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) {
trans1.isIdentity();
QColorSpace cs2 = cs;
cs2.setDescription("Hello");
- bool b = (cs == cs2);
- Q_UNUSED(b);
+ Q_ASSERT(cs == cs2);
+ QByteArray profileData = cs2.iccProfile();
+ QColorSpace cs3 = QColorSpace::fromIccProfile(profileData);
+ Q_ASSERT(cs == cs3);
QColor color(0xfaf8fa00);
color = trans1.map(color);
QImage img(16, 2, toFormat(cs.colorModel()));
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt
index f8c7ecb07f..20475da6c4 100644
--- a/tests/manual/CMakeLists.txt
+++ b/tests/manual/CMakeLists.txt
@@ -6,6 +6,7 @@ if(UIKIT)
return()
endif()
+add_subdirectory(assets)
add_subdirectory(corelib)
add_subdirectory(filetest)
# diaglib is broken in dev due to missing
diff --git a/tests/manual/android_content_uri/CMakeLists.txt b/tests/manual/android_content_uri/CMakeLists.txt
index 44df410b4f..368e023ba6 100644
--- a/tests/manual/android_content_uri/CMakeLists.txt
+++ b/tests/manual/android_content_uri/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
cmake_minimum_required(VERSION 3.16)
project(android_content_uri LANGUAGES CXX)
diff --git a/tests/manual/assets/CMakeLists.txt b/tests/manual/assets/CMakeLists.txt
new file mode 100644
index 0000000000..03643aa853
--- /dev/null
+++ b/tests/manual/assets/CMakeLists.txt
@@ -0,0 +1,4 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+add_subdirectory(downloader)
diff --git a/tests/manual/assets/assets.pro b/tests/manual/assets/assets.pro
new file mode 100644
index 0000000000..43f09ba46e
--- /dev/null
+++ b/tests/manual/assets/assets.pro
@@ -0,0 +1,3 @@
+TEMPLATE=subdirs
+
+SUBDIRS = downloader
diff --git a/tests/manual/assets/downloader/CMakeLists.txt b/tests/manual/assets/downloader/CMakeLists.txt
new file mode 100644
index 0000000000..b95161ac02
--- /dev/null
+++ b/tests/manual/assets/downloader/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_manual_downloader Binary:
+#####################################################################
+
+qt_internal_add_manual_test(tst_manual_downloader
+ GUI
+ SOURCES
+ main.cpp
+ LIBRARIES
+ Qt::ExamplesAssetDownloaderPrivate
+ Qt::Widgets
+)
diff --git a/tests/manual/assets/downloader/downloader.pro b/tests/manual/assets/downloader/downloader.pro
new file mode 100644
index 0000000000..53976c538f
--- /dev/null
+++ b/tests/manual/assets/downloader/downloader.pro
@@ -0,0 +1,5 @@
+QT += examples_asset_downloader-private widgets
+
+TARGET = tst_manual_downloader
+
+SOURCES += main.cpp
diff --git a/tests/manual/assets/downloader/main.cpp b/tests/manual/assets/downloader/main.cpp
new file mode 100644
index 0000000000..fd1a56b170
--- /dev/null
+++ b/tests/manual/assets/downloader/main.cpp
@@ -0,0 +1,48 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include <QtExamplesAssetDownloader/assetdownloader.h>
+
+#include <QApplication>
+#include <QMessageBox>
+#include <QProgressDialog>
+
+using namespace Assets::Downloader;
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ app.setOrganizationName("QtProject");
+ app.setApplicationName("Asset Downloader");
+
+ QProgressDialog progress;
+ progress.setAutoClose(false);
+ progress.setRange(0, 0);
+ QObject::connect(&progress, &QProgressDialog::canceled, &app, &QApplication::quit);
+
+ AssetDownloader downloader;
+ downloader.setJsonFileName("car-configurator-assets-v1.json");
+ downloader.setZipFileName("car-configurator-assets-v1.zip");
+ downloader.setDownloadBase(QUrl("https://download.qt.io/learning/examples/"));
+
+ QObject::connect(&downloader, &AssetDownloader::started,
+ &progress, &QProgressDialog::show);
+ QObject::connect(&downloader, &AssetDownloader::progressChanged, &progress, [&progress](
+ int progressValue, int progressMaximum, const QString &progressText) {
+ progress.setLabelText(progressText);
+ progress.setMaximum(progressMaximum);
+ progress.setValue(progressValue);
+ });
+ QObject::connect(&downloader, &AssetDownloader::finished, &progress, [&](bool success) {
+ progress.reset();
+ progress.hide();
+ if (success)
+ QMessageBox::information(nullptr, "Asset Downloader", "Download Finished Successfully.");
+ else
+ QMessageBox::warning(nullptr, "Asset Downloader", "Download Finished with an Error.");
+ });
+
+ downloader.start();
+
+ return app.exec();
+}
diff --git a/tests/manual/dialogs/wizardpanel.cpp b/tests/manual/dialogs/wizardpanel.cpp
index 6fa7d1803a..5e413960e3 100644
--- a/tests/manual/dialogs/wizardpanel.cpp
+++ b/tests/manual/dialogs/wizardpanel.cpp
@@ -229,7 +229,7 @@ Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags)
addPage(new WizardPage(tr("Page 3"), this));
}
-// A dialog using a Wizard as child widget (emulating Qt Designer).
+// A dialog using a Wizard as child widget (emulating Qt Widgets Designer).
class WizardEmbeddingDialog : public QDialog {
public:
explicit WizardEmbeddingDialog(QWidget *parent = nullptr);
diff --git a/tests/manual/examples/corelib/permissions/android/AndroidManifest.xml b/tests/manual/examples/corelib/permissions/android/AndroidManifest.xml
index ec25a929ae..baf025d4bb 100644
--- a/tests/manual/examples/corelib/permissions/android/AndroidManifest.xml
+++ b/tests/manual/examples/corelib/permissions/android/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.example"
+ package="org.qtproject.example.permissions"
android:installLocation="auto"
android:versionCode="-- %%INSERT_VERSION_CODE%% --"
android:versionName="-- %%INSERT_VERSION_NAME%% --">
@@ -35,7 +35,6 @@
<activity
android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
- android:label="-- %%INSERT_APP_NAME%% --"
android:launchMode="singleTop"
android:screenOrientation="unspecified"
android:exported="true">
diff --git a/tests/manual/examples/widgets/richtext/textedit/example.html b/tests/manual/examples/widgets/richtext/textedit/example.html
index ebae3362e9..038f71acfe 100644
--- a/tests/manual/examples/widgets/richtext/textedit/example.html
+++ b/tests/manual/examples/widgets/richtext/textedit/example.html
@@ -19,7 +19,7 @@ hr { height: 1px; border-width: 0; }
<ol style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction</li>
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Tools </li></ol>
<ol type=a style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Assistant</li>
-<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Designer</li>
+<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Widgets Designer</li>
<ol type=A style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Form Editor</li>
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Component Architecture</li></ol>
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Linguist</li></ol>
@@ -64,7 +64,7 @@ hr { height: 1px; border-width: 0; }
<td>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">13:00 - 15:00 </span></p></td>
<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Designer</span> Tutorial </p></td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Widgets Designer</span> Tutorial </p></td>
<td rowspan="2">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Extreme Programming </p></td>
<td>
diff --git a/tests/manual/examples/widgets/richtext/textedit/example.md b/tests/manual/examples/widgets/richtext/textedit/example.md
index 15f3c3cacf..8a5eed72f6 100644
--- a/tests/manual/examples/widgets/richtext/textedit/example.md
+++ b/tests/manual/examples/widgets/richtext/textedit/example.md
@@ -43,7 +43,7 @@ numerals in the same list structure:
1. Introduction
2. Qt Tools
1) Qt Assistant
- 2) Qt Designer
+ 2) Qt Widgets Designer
1. Form Editor
2. Component Architecture
3) Qt Linguist
@@ -78,7 +78,7 @@ column spans, text formatting within cells, and size constraints for columns.
| ------------: | ----------------- | ---------------------- | ------------------------- |
| 9:00 - 11:00 | Introduction to Qt |||
| 11:00 - 13:00 | Using qmake | Object-oriented Programming | Layouts in Qt |
-| 13:00 - 15:00 | Qt Designer Tutorial | Extreme Programming | Writing Custom Styles |
+| 13:00 - 15:00 | Qt Widgets Designer Tutorial | Extreme Programming | Writing Custom Styles |
| 15:00 - 17:00 | Qt Linguist and Internationalization | &nbsp; | &nbsp; |
*Try adding text to the cells in the table and experiment with the alignment of
diff --git a/tests/manual/examples/widgets/scroller/CMakeLists.txt b/tests/manual/examples/widgets/scroller/CMakeLists.txt
index fb9ebc2848..cd920bd361 100644
--- a/tests/manual/examples/widgets/scroller/CMakeLists.txt
+++ b/tests/manual/examples/widgets/scroller/CMakeLists.txt
@@ -1 +1,3 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_example(graphicsview)
diff --git a/tests/manual/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt b/tests/manual/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
index 9a2d66d99e..c468cdc191 100644
--- a/tests/manual/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
+++ b/tests/manual/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
@@ -1,2 +1,4 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
add_subdirectory(basictools)
add_subdirectory(extrafilters)
diff --git a/tests/manual/highdpi/CMakeLists.txt b/tests/manual/highdpi/CMakeLists.txt
index d32e2a52fc..1d5d0ad1ff 100644
--- a/tests/manual/highdpi/CMakeLists.txt
+++ b/tests/manual/highdpi/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(dprgadget)
add_subdirectory(kitchensink)
diff --git a/tests/manual/highdpi/dprgadget/CMakeLists.txt b/tests/manual/highdpi/dprgadget/CMakeLists.txt
index 2c6bd91f0d..5cd0d5812e 100644
--- a/tests/manual/highdpi/dprgadget/CMakeLists.txt
+++ b/tests/manual/highdpi/dprgadget/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## dprgadget Binary:
diff --git a/tests/manual/highdpi/kitchensink/CMakeLists.txt b/tests/manual/highdpi/kitchensink/CMakeLists.txt
index 8caf85983e..e7558c19e0 100644
--- a/tests/manual/highdpi/kitchensink/CMakeLists.txt
+++ b/tests/manual/highdpi/kitchensink/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## kitchensink Binary:
diff --git a/tests/manual/highdpi/pixelgadget/CMakeLists.txt b/tests/manual/highdpi/pixelgadget/CMakeLists.txt
index 2cc04225df..f808786b2a 100644
--- a/tests/manual/highdpi/pixelgadget/CMakeLists.txt
+++ b/tests/manual/highdpi/pixelgadget/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## pixelgadget Binary:
diff --git a/tests/manual/highdpi/screengadget/CMakeLists.txt b/tests/manual/highdpi/screengadget/CMakeLists.txt
index d9045541bb..f4a7aad306 100644
--- a/tests/manual/highdpi/screengadget/CMakeLists.txt
+++ b/tests/manual/highdpi/screengadget/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## screengadget Binary:
diff --git a/tests/manual/inputdevices/CMakeLists.txt b/tests/manual/inputdevices/CMakeLists.txt
index 9440705a9b..54dd2556fb 100644
--- a/tests/manual/inputdevices/CMakeLists.txt
+++ b/tests/manual/inputdevices/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
project(inputdevices)
cmake_minimum_required(VERSION 3.19)
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index ef52a60952..c3bfad32e9 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -2,6 +2,7 @@ TEMPLATE=subdirs
QT_FOR_CONFIG += network-private gui-private
SUBDIRS = \
+assets \
filetest \
embeddedintoforeignwindow \
foreignwindows \
diff --git a/tests/manual/permissions/android/AndroidManifest.xml b/tests/manual/permissions/android/AndroidManifest.xml
index 041c920ad1..db577e6c27 100644
--- a/tests/manual/permissions/android/AndroidManifest.xml
+++ b/tests/manual/permissions/android/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.example"
+ package="org.qtproject.example.tst_manual_permissions"
android:installLocation="auto"
android:versionCode="-- %%INSERT_VERSION_CODE%% --"
android:versionName="-- %%INSERT_VERSION_NAME%% --">
@@ -31,7 +31,6 @@
<activity
android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
- android:label="-- %%INSERT_APP_NAME%% --"
android:launchMode="singleTop"
android:screenOrientation="unspecified"
android:exported="true">
diff --git a/tests/manual/qtabbar/tabbarform.cpp b/tests/manual/qtabbar/tabbarform.cpp
index 51271f7373..8e09e182d8 100644
--- a/tests/manual/qtabbar/tabbarform.cpp
+++ b/tests/manual/qtabbar/tabbarform.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "tabbarform.h"
TabBarForm::TabBarForm(QWidget *parent) :
diff --git a/tests/manual/qtabbar/tabbarform.h b/tests/manual/qtabbar/tabbarform.h
index ac101d6402..ae0ea290de 100644
--- a/tests/manual/qtabbar/tabbarform.h
+++ b/tests/manual/qtabbar/tabbarform.h
@@ -1,3 +1,5 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef TABBARFORM_H
#define TABBARFORM_H
diff --git a/tests/manual/rhi/hdr/CMakeLists.txt b/tests/manual/rhi/hdr/CMakeLists.txt
index cf6e7662a4..dc7bcb906c 100644
--- a/tests/manual/rhi/hdr/CMakeLists.txt
+++ b/tests/manual/rhi/hdr/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_manual_test(hdr
GUI
SOURCES
diff --git a/tests/manual/rhi/imguirenderer/CMakeLists.txt b/tests/manual/rhi/imguirenderer/CMakeLists.txt
index 619c351d7f..8c04918d06 100644
--- a/tests/manual/rhi/imguirenderer/CMakeLists.txt
+++ b/tests/manual/rhi/imguirenderer/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_manual_test(imguirenderer
GUI
SOURCES
diff --git a/tests/manual/wasm/a11y/CMakeLists.txt b/tests/manual/wasm/a11y/CMakeLists.txt
index 5268d53c8b..dee39e1f5f 100644
--- a/tests/manual/wasm/a11y/CMakeLists.txt
+++ b/tests/manual/wasm/a11y/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(QT_FEATURE_widgets)
add_subdirectory(basic_widgets)
endif()
diff --git a/tests/manual/wasm/a11y/basic_widgets/CMakeLists.txt b/tests/manual/wasm/a11y/basic_widgets/CMakeLists.txt
index 11534bdf68..a028f96e1c 100644
--- a/tests/manual/wasm/a11y/basic_widgets/CMakeLists.txt
+++ b/tests/manual/wasm/a11y/basic_widgets/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_manual_test(a11y_basic_widgets
GUI
SOURCES
diff --git a/tests/manual/wasm/clipboard/mainwindow.cpp b/tests/manual/wasm/clipboard/mainwindow.cpp
index 81a95c4218..c67c795b05 100644
--- a/tests/manual/wasm/clipboard/mainwindow.cpp
+++ b/tests/manual/wasm/clipboard/mainwindow.cpp
@@ -275,7 +275,11 @@ void MainWindow::dropEvent(QDropEvent* e)
}
ui->textEdit_2->insertPlainText(" Drop has url data length: " + sizeStr + "\n");
- ui->textEdit_2->insertPlainText(" " + urlStr + " sha1 " + sha1.left(8) + "\n");
+ if (sha1.isEmpty()) {
+ ui->textEdit->insertPlainText(urlStr);
+ }
+ ui->textEdit_2->insertPlainText(" " + urlStr + (!sha1.isEmpty() ? " sha1 " + sha1.left(8) : "") + "\n");
+
}
ui->textEdit_2->insertPlainText("\n");
diff --git a/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
index 9bfa875be7..88ddfac4c8 100644
--- a/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
include_directories(../../qtwasmtestlib/)
# default buid
diff --git a/tests/manual/wasm/network/echo_client_mainthread/CMakeLists.txt b/tests/manual/wasm/network/echo_client_mainthread/CMakeLists.txt
index 05416c0b66..4b81661c79 100644
--- a/tests/manual/wasm/network/echo_client_mainthread/CMakeLists.txt
+++ b/tests/manual/wasm/network/echo_client_mainthread/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_manual_test(echo_client_mainthread
GUI
SOURCES
diff --git a/tests/manual/wasm/network/echo_client_secondarythread/CMakeLists.txt b/tests/manual/wasm/network/echo_client_secondarythread/CMakeLists.txt
index a1f2bef254..d240e9e70b 100644
--- a/tests/manual/wasm/network/echo_client_secondarythread/CMakeLists.txt
+++ b/tests/manual/wasm/network/echo_client_secondarythread/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_manual_test(echo_client_secondarythread
GUI
SOURCES
diff --git a/tests/manual/wasm/network/echo_server/CMakeLists.txt b/tests/manual/wasm/network/echo_server/CMakeLists.txt
index cf98163fb8..72ec413a0e 100644
--- a/tests/manual/wasm/network/echo_server/CMakeLists.txt
+++ b/tests/manual/wasm/network/echo_server/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
project(echo_server)
cmake_minimum_required(VERSION 3.19)
diff --git a/tests/manual/wasm/network/sockify_sockets_auto/CMakeLists.txt b/tests/manual/wasm/network/sockify_sockets_auto/CMakeLists.txt
index fb9a9f8543..68a3993778 100644
--- a/tests/manual/wasm/network/sockify_sockets_auto/CMakeLists.txt
+++ b/tests/manual/wasm/network/sockify_sockets_auto/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_manual_test(sockify_sockets_auto
SOURCES
main.cpp
diff --git a/tests/manual/wasm/qstdweb/CMakeLists.txt b/tests/manual/wasm/qstdweb/CMakeLists.txt
index 5242999ec4..39039c3910 100644
--- a/tests/manual/wasm/qstdweb/CMakeLists.txt
+++ b/tests/manual/wasm/qstdweb/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_manual_test(promise_auto
SOURCES
promise_main.cpp
@@ -94,4 +96,3 @@ add_custom_command(
${CMAKE_CURRENT_BINARY_DIR}/qtwasmtestlib.js)
target_link_options(iodevices_auto PRIVATE -sASYNCIFY -Os)
-
diff --git a/tests/manual/xembed/CMakeLists.txt b/tests/manual/xembed/CMakeLists.txt
index f486f202a5..44bb2ea818 100644
--- a/tests/manual/xembed/CMakeLists.txt
+++ b/tests/manual/xembed/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(QT_FEATURE_gtk3)
add_subdirectory(gtk-container)
diff --git a/tests/manual/xembed/gtk-container/CMakeLists.txt b/tests/manual/xembed/gtk-container/CMakeLists.txt
index c109bbc95b..34a802c142 100644
--- a/tests/manual/xembed/gtk-container/CMakeLists.txt
+++ b/tests/manual/xembed/gtk-container/CMakeLists.txt
@@ -1,3 +1,5 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
qt_find_package(GTK3)
qt_find_package(X11)
diff --git a/tests/testserver/echo/echo.sh b/tests/testserver/echo/echo.sh
index 516b476357..d8fedb1a89 100755
--- a/tests/testserver/echo/echo.sh
+++ b/tests/testserver/echo/echo.sh
@@ -1,6 +1,6 @@
+#!/usr/bin/env bash
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#!/usr/bin/env bash
# Disabled by default, enable it.
sed -i 's/disable\t\t= yes/disable = no/' /etc/xinetd.d/echo