summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/cmake/CMakeLists.txt19
-rw-r--r--tests/auto/cmake/mockplugins/.cmake.conf2
-rw-r--r--tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro5
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/.cmake.conf2
-rw-r--r--tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt123
-rw-r--r--tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt45
-rw-r--r--tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts1
-rw-r--r--tests/auto/cmake/test_static_resources/.cmake.conf2
-rw-r--r--tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp2
-rw-r--r--tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp4
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp2
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt1
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp16
-rw-r--r--tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp6
-rw-r--r--tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp6
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp138
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp78
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp96
-rw-r--r--tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp8
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp14
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp67
-rw-r--r--tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp2
-rw-r--r--tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp24
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp45
-rw-r--r--tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp12
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp42
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp11
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp68
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp6
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp6
-rw-r--r--tests/auto/corelib/io/qprocess/testDetached/main.cpp2
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp16
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp69
-rw-r--r--tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp12
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp12
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp26
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp35
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp6
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp8
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp84
-rw-r--r--tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp2
-rw-r--r--tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp14
-rw-r--r--tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp80
-rw-r--r--tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp10
-rw-r--r--tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp92
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp106
-rw-r--r--tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp150
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp234
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp4
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp64
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp10
-rw-r--r--tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp8
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp8
-rw-r--r--tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp14
-rw-r--r--tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp6
-rw-r--r--tests/auto/corelib/kernel/qmetatype/CMakeLists.txt35
-rw-r--r--tests/auto/corelib/kernel/qmetatype/lib1.cpp5
-rw-r--r--tests/auto/corelib/kernel/qmetatype/lib2.cpp5
-rw-r--r--tests/auto/corelib/kernel/qmetatype/lib_common.cpp13
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp4
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h4
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp120
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype_libs.h24
-rw-r--r--tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp4
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp109
-rw-r--r--tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp136
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp2
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp2
-rw-r--r--tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp12
-rw-r--r--tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp4
-rw-r--r--tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp2
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp45
-rw-r--r--tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp4
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp49
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt8
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt8
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/test.txt6
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp131
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h4
-rw-r--r--tests/auto/corelib/platform/android/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/platform/android/testdata/assets/top_level_dir/file_in_top_dir.txt (renamed from tests/auto/other/android/testdata/assets/test.txt)0
-rw-r--r--tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/file_in_sub_dir.txt1
-rw-r--r--tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/sub_dir_2/sub_dir_3/file_in_sub_dir_3.txt1
-rw-r--r--tests/auto/corelib/platform/android/tst_android.cpp126
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp33
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp14
-rw-r--r--tests/auto/corelib/plugin/quuid/tst_quuid.cpp8
-rw-r--r--tests/auto/corelib/serialization/json/tst_qtjson.cpp2
-rw-r--r--tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp8
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp24
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp4
-rw-r--r--tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp57
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp11
-rw-r--r--tests/auto/corelib/text/CMakeLists.txt1
-rw-r--r--tests/auto/corelib/text/qbytearray/CMakeLists.txt4
-rw-r--r--tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp123
-rw-r--r--tests/auto/corelib/text/qbytearray_large/.gitattributes (renamed from tests/auto/corelib/text/qbytearray/.gitattributes)0
-rw-r--r--tests/auto/corelib/text/qbytearray_large/CMakeLists.txt11
-rw-r--r--tests/auto/corelib/text/qbytearray_large/rfc3252.txt (renamed from tests/auto/corelib/text/qbytearray/rfc3252.txt)0
-rw-r--r--tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp216
-rw-r--r--tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp6
-rw-r--r--tests/auto/corelib/text/qchar/tst_qchar.cpp2
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp26
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp344
-rw-r--r--tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp109
-rw-r--r--tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp4
-rw-r--r--tests/auto/corelib/text/qstringview/tst_qstringview.cpp2
-rw-r--r--tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp6
-rw-r--r--tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp2
-rw-r--r--tests/auto/corelib/thread/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/thread/qfuture/tst_qfuture.cpp110
-rw-r--r--tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp2
-rw-r--r--tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp94
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp33
-rw-r--r--tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp4
-rw-r--r--tests/auto/corelib/time/qdate/tst_qdate.cpp2
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp2
-rw-r--r--tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp10
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp58
-rw-r--r--tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp87
-rw-r--r--tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp72
-rw-r--r--tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp10
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp4
-rw-r--r--tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp28
-rw-r--r--tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp41
-rw-r--r--tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp12
-rw-r--r--tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp4
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp102
-rw-r--r--tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp13
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp24
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp13
-rw-r--r--tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp2
-rw-r--r--tests/auto/corelib/tools/qset/tst_qset.cpp20
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp4
-rw-r--r--tests/auto/corelib/tools/qtaggedpointer/tst_qtaggedpointer.cpp42
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp54
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp160
-rw-r--r--tests/auto/dbus/qdbusabstractadaptor/myobject.h2
-rw-r--r--tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp6
-rw-r--r--tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp14
-rw-r--r--tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp48
-rw-r--r--tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp8
-rw-r--r--tests/auto/dbus/qdbusmarshall/common.h4
-rw-r--r--tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp10
-rw-r--r--tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp9
-rw-r--r--tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp2
-rw-r--r--tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp56
-rw-r--r--tests/auto/dbus/qdbustype/tst_qdbustype.cpp4
-rw-r--r--tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp12
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp3
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp7
-rw-r--r--tests/auto/gui/image/qmovie/tst_qmovie.cpp2
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp76
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp18
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp106
-rw-r--r--tests/auto/gui/kernel/qaction/tst_qaction.cpp62
-rw-r--r--tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp54
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp66
-rw-r--r--tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp2
-rw-r--r--tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp6
-rw-r--r--tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp4
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp65
-rw-r--r--tests/auto/gui/kernel/qscreen/tst_qscreen.cpp10
-rw-r--r--tests/auto/gui/kernel/qtouchevent/BLACKLIST4
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp215
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp84
-rw-r--r--tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp4
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp3
-rw-r--r--tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp4
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp6
-rw-r--r--tests/auto/gui/qvulkan/tst_qvulkan.cpp8
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp48
-rw-r--r--tests/auto/gui/text/CMakeLists.txt1
-rw-r--r--tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp6
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp102
-rw-r--r--tests/auto/gui/text/qfont/BLACKLIST4
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp13
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp10
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp42
-rw-r--r--tests/auto/gui/text/qrawfont/tst_qrawfont.cpp2
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp8
-rw-r--r--tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp24
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp72
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp12
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp37
-rw-r--r--tests/auto/gui/text/qtextformat/tst_qtextformat.cpp20
-rw-r--r--tests/auto/gui/text/qtextimagehandler/CMakeLists.txt23
-rw-r--r--tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp33
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp41
-rw-r--r--tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp4
-rw-r--r--tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp22
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp28
-rw-r--r--tests/auto/gui/text/qzip/tst_qzip.cpp8
-rw-r--r--tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp61
-rw-r--r--tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp36
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp6
-rw-r--r--tests/auto/gui/util/qundogroup/tst_qundogroup.cpp20
-rw-r--r--tests/auto/gui/util/qundostack/tst_qundostack.cpp44
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp11
-rw-r--r--tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp6
-rw-r--r--tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp4
-rw-r--r--tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp2
-rw-r--r--tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp4
-rw-r--r--tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp4
-rw-r--r--tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp22
-rw-r--r--tests/auto/network/access/qnetworkreply/test/CMakeLists.txt1
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp438
-rw-r--r--tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp8
-rw-r--r--tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp6
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp16
-rw-r--r--tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp4
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp2
-rw-r--r--tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp4
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp84
-rw-r--r--tests/auto/network/socket/qsocks5socketengine/BLACKLIST3
-rw-r--r--tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp8
-rw-r--r--tests/auto/network/socket/qtcpserver/BLACKLIST1
-rw-r--r--tests/auto/network/socket/qtcpserver/crashingServer/main.cpp33
-rw-r--r--tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp43
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp32
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp136
-rw-r--r--tests/auto/network/ssl/CMakeLists.txt6
-rw-r--r--tests/auto/network/ssl/qdtls/certs/fluke.cert105
-rw-r--r--tests/auto/network/ssl/qdtls/certs/fluke.key67
-rw-r--r--tests/auto/network/ssl/qocsp/CMakeLists.txt6
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.0.9.842
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.142
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1c41
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.3.0.5 (renamed from tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.0)4
-rw-r--r--tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp67
-rw-r--r--tests/auto/network/ssl/qsslkey/CMakeLists.txt5
-rw-r--r--tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp27
-rw-r--r--tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp234
-rw-r--r--tests/auto/network/ssl/qsslsocket/CMakeLists.txt6
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/ca-generate.sh21
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/ca.conf10
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/ca.crt70
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/ca.key99
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/inter.conf14
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/inter.crt71
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/inter.key99
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/leaf.conf14
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/leaf.crt73
-rw-r--r--tests/auto/network/ssl/qsslsocket/certs/leaf.key127
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp236
-rw-r--r--tests/auto/network/ssl/shared/qopenssl_symbols.h4
-rw-r--r--tests/auto/network/ssl/shared/tlshelpers.h5
-rw-r--r--tests/auto/other/android/CMakeLists.txt21
-rw-r--r--tests/auto/other/android/tst_android.cpp57
-rw-r--r--tests/auto/other/gestures/BLACKLIST30
-rw-r--r--tests/auto/other/gestures/tst_gestures.cpp110
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp16
-rw-r--r--tests/auto/other/qaccessibility/accessiblewidgets.h2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp133
-rw-r--r--tests/auto/other/qaccessibilitymac/CMakeLists.txt20
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp125
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm (renamed from tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm)282
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h16
-rw-r--r--tests/auto/other/qcomplextext/tst_qcomplextext.cpp8
-rw-r--r--tests/auto/other/qfocusevent/tst_qfocusevent.cpp5
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp6
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp6
-rw-r--r--tests/auto/sql/kernel/qsql/tst_qsql.cpp4
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_databases.h14
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp16
-rw-r--r--tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp6
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp56
-rw-r--r--tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp69
-rw-r--r--tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp34
-rw-r--r--tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp6
-rw-r--r--tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp38
-rw-r--r--tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp2
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp36
-rw-r--r--tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp82
-rw-r--r--tests/auto/testlib/selftests/CMakeLists.txt1
-rw-r--r--tests/auto/testlib/selftests/badxml/tst_badxml.cpp6
-rw-r--r--tests/auto/testlib/selftests/catch_p_p.h28
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp85
-rw-r--r--tests/auto/testlib/selftests/crashes/tst_crashes.cpp8
-rw-r--r--tests/auto/testlib/selftests/eventloop/CMakeLists.txt16
-rw-r--r--tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp104
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.junitxml18
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.lightxml18
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.tap56
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.teamcity9
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.txt12
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xml18
-rw-r--r--tests/auto/testlib/selftests/expected_eventloop.junitxml17
-rw-r--r--tests/auto/testlib/selftests/expected_eventloop.lightxml30
-rw-r--r--tests/auto/testlib/selftests/expected_eventloop.tap17
-rw-r--r--tests/auto/testlib/selftests/expected_eventloop.teamcity14
-rw-r--r--tests/auto/testlib/selftests/expected_eventloop.txt11
-rw-r--r--tests/auto/testlib/selftests/expected_eventloop.xml33
-rwxr-xr-xtests/auto/testlib/selftests/generate_expected_output.py4
-rw-r--r--tests/auto/testlib/selftests/qt_attribution.json2
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp9
-rw-r--r--tests/auto/tools/moc/qmlmacro.h19
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp11
-rw-r--r--tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp3
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp2
-rw-r--r--tests/auto/tools/qmakelib/evaltest.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp9
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp115
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp71
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp4
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp8
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp62
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp24
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp14
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp14
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp12
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp68
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp76
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp128
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp52
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp13
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp137
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp203
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp40
-rw-r--r--tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp18
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp92
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp106
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp41
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp94
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp40
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp48
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp128
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp178
-rw-r--r--tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp2
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp53
-rw-r--r--tests/auto/widgets/kernel/qapplication/BLACKLIST1
-rw-r--r--tests/auto/widgets/kernel/qapplication/CMakeLists.txt5
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp152
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp4
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp44
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp13
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp78
-rw-r--r--tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST5
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp571
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp14
-rw-r--r--tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp4
-rw-r--r--tests/auto/widgets/kernel/qwidgetrepaintmanager/BLACKLIST11
-rw-r--r--tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp65
-rw-r--r--tests/auto/widgets/styles/qstyle/tst_qstyle.cpp2
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp20
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp45
-rw-r--r--tests/auto/widgets/util/qscroller/tst_qscroller.cpp62
-rw-r--r--tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp2
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp38
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp48
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp40
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp2
-rw-r--r--tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp4
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp152
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp92
-rw-r--r--tests/auto/widgets/widgets/qdial/tst_qdial.cpp16
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp88
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp398
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp42
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp20
-rw-r--r--tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp18
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp91
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp100
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp4
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp176
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp16
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp36
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp20
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp203
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp86
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp28
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp8
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp65
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp51
-rw-r--r--tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp50
-rw-r--r--tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp36
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp30
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp58
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp60
-rw-r--r--tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp158
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp38
390 files changed, 10181 insertions, 5718 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 163ade3f59..7df2e5a3e9 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -111,6 +111,24 @@ include("${_Qt6CTestMacros}")
if(NOT NO_WIDGETS)
_qt_internal_test_expect_pass(test_build_simple_widget_app)
+ set(extra_widget_app_options "")
+ if(IOS)
+ list(APPEND extra_widget_app_options
+ QMAKE_OPTIONS CONFIG+=iossimulator
+ )
+ endif()
+ if(CMAKE_HOST_WIN32)
+ # Unset MAKEFLAGS environment variable when invoking build tool, it might
+ # have options incompatible with nmake.
+ list(APPEND extra_widget_app_options
+ BUILD_ENVIRONMENT MAKEFLAGS ""
+ )
+ endif()
+
+ _qt_internal_add_qmake_test(test_build_simple_widget_app
+ TESTNAME test_build_simple_widget_app_qmake
+ ${extra_widget_app_options}
+ )
endif()
# We only support a limited subset of cmake tests when targeting iOS:
@@ -156,6 +174,7 @@ endif()
_qt_internal_test_expect_pass(test_multiple_find_package)
_qt_internal_test_expect_pass(test_add_resources_delayed_file)
_qt_internal_test_expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file)
+_qt_internal_test_expect_pass(test_qt_add_resources_rebuild)
if(NOT NO_GUI)
_qt_internal_test_expect_pass(test_private_includes)
diff --git a/tests/auto/cmake/mockplugins/.cmake.conf b/tests/auto/cmake/mockplugins/.cmake.conf
index f7a41402e0..db70cebc03 100644
--- a/tests/auto/cmake/mockplugins/.cmake.conf
+++ b/tests/auto/cmake/mockplugins/.cmake.conf
@@ -1 +1 @@
-set(QT_REPO_MODULE_VERSION "6.4.0")
+set(QT_REPO_MODULE_VERSION "6.4.3")
diff --git a/tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro b/tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro
new file mode 100644
index 0000000000..30834e2ee2
--- /dev/null
+++ b/tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+SOURCES += main.cpp
+QT += widgets
+CONFIG += app_bundle
+TARGET = simple_widget_app
diff --git a/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
index f7a41402e0..db70cebc03 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.4.0")
+set(QT_REPO_MODULE_VERSION "6.4.3")
diff --git a/tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt b/tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt
new file mode 100644
index 0000000000..e7b35b332f
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt
@@ -0,0 +1,123 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_qt_add_resources_rebuild)
+
+set(test_project_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/sample")
+set(test_project_build_dir "${CMAKE_CURRENT_BINARY_DIR}/build_sample")
+
+# Make sure that file paths are 'real' paths
+get_filename_component(test_project_source_dir "${test_project_source_dir}" REALPATH)
+get_filename_component(test_project_build_dir "${test_project_build_dir}" REALPATH)
+
+file(REMOVE_RECURSE "${test_project_build_dir}")
+file(MAKE_DIRECTORY "${test_project_build_dir}")
+
+# For access to _qt_internal_get_cmake_test_configure_options
+find_package(Qt6 COMPONENTS Core REQUIRED)
+include("${_Qt6CTestMacros}")
+
+set(indent " ")
+list(APPEND CMAKE_MESSAGE_INDENT "${indent}")
+
+function(configure_project)
+ message(STATUS "Configuring build")
+ _qt_internal_get_cmake_test_configure_options(option_list)
+ execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
+ "-G${CMAKE_GENERATOR}"
+ ${option_list}
+ -B "${test_project_build_dir}"
+ -S "${test_project_source_dir}"
+ RESULT_VARIABLE result
+ )
+ if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Unable to configure sample project")
+ endif()
+endfunction()
+
+function(try_build)
+ message(STATUS "Building project")
+ execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ --build "${test_project_build_dir}"
+ RESULT_VARIABLE result
+ )
+ if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Unable to build test project")
+ endif()
+endfunction()
+
+function(get_target_path out_var)
+ file(STRINGS "${test_project_build_dir}/targets.txt" targets)
+ list(GET targets 0 first_target_path)
+ message(STATUS "Built target is at '${first_target_path}'")
+ set(${out_var} "${first_target_path}" PARENT_SCOPE)
+endfunction()
+
+function(get_timestamp file_path out_var)
+ message(STATUS "Getting timestamp of built target.")
+ file(TIMESTAMP "${file_path}" value "%s")
+ set(${out_var} "${value}" PARENT_SCOPE)
+endfunction()
+
+function(sleep)
+ # Avoids issues with low resolution modification times (like HFS on macOS).
+ set(seconds 2)
+ message(STATUS "Sleeping for ${seconds} seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep ${seconds})
+endfunction()
+
+function(touch_file)
+ set(input "input.ts")
+ set(input_path "${test_project_source_dir}/${input}")
+ message(STATUS "Touching ${input_path}")
+ file(TOUCH "${input_path}")
+endfunction()
+
+function(assert_timestamp_is_equal before after)
+ set(timestamps "\n${indent}Before TS: ${before}\n${indent} After TS: ${after}")
+ if("${after}" EQUAL "${before}")
+ message(STATUS "Target was not rebuilt. ${timestamps}")
+ else()
+ message(FATAL_ERROR "Target WAS rebuilt. ${timestamps}")
+ endif()
+endfunction()
+
+function(assert_timestamp_is_greater before after)
+ set(timestamps "\n${indent}Before TS: ${before}\n${indent} After TS: ${after}")
+ if("${after}" GREATER "${before}")
+ message(STATUS "Target was correctly rebuilt. ${timestamps}")
+ else()
+ message(FATAL_ERROR "Target was NOT rebuilt. ${timestamps}")
+ endif()
+endfunction()
+
+configure_project()
+try_build()
+get_target_path(target_path)
+
+# Make sure that a second build without changes doesn't rebuild the executable.
+get_timestamp("${target_path}" ts_1)
+sleep()
+try_build()
+get_timestamp("${target_path}" ts_2)
+assert_timestamp_is_equal("${ts_1}" "${ts_2}")
+
+# Touching the input file should cause rcc to rerun, then the compiler, then the linker,
+# and thus the executable timestamp should be updated.
+touch_file()
+try_build()
+get_timestamp("${target_path}" ts_3)
+assert_timestamp_is_greater("${ts_2}" "${ts_3}")
+
+# Check that building again doesn't rebuild the executable.
+sleep()
+try_build()
+get_timestamp("${target_path}" ts_4)
+assert_timestamp_is_equal("${ts_3}" "${ts_4}")
+
+list(POP_BACK CMAKE_MESSAGE_INDENT)
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
new file mode 100644
index 0000000000..0a40a948c6
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.16)
+project(sample LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core)
+
+set(source "${CMAKE_BINARY_DIR}/main.cpp")
+file(GENERATE OUTPUT "${source}" CONTENT "int main() { return 0; }")
+
+qt_add_executable(${PROJECT_NAME} ${source})
+
+# This is a poor man's implementation of qt_add_lupdate.
+set(input "${CMAKE_SOURCE_DIR}/input.ts")
+set(output "${CMAKE_BINARY_DIR}/output.qm")
+add_custom_command(
+ OUTPUT "${output}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${input}" "${output}"
+ DEPENDS "${input}"
+ VERBATIM
+)
+
+# This is where the bug happened before. Adding the target dependency properties used the target
+# as an order-only dependency, instead of depending on the actual dependency file.
+set_source_files_properties("${output}"
+ PROPERTIES _qt_resource_target_dependency "output_target")
+
+add_custom_target(output_target
+ DEPENDS "${output}"
+)
+
+qt_add_resources(${PROJECT_NAME} "res"
+ PREFIX "/"
+ BASE "${CMAKE_CURRENT_BINARY_DIR}"
+ FILES "${output}"
+)
+
+# Write out the location of the binary so its timestamp can be checked by the driving parent
+# project.
+set(target_file_out "${CMAKE_BINARY_DIR}/targets.txt")
+add_custom_target(all_built ALL
+ COMMAND
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:${PROJECT_NAME}>" > "${target_file_out}"
+ VERBATIM
+)
+# Make sure the file path is written out after the executable is linked.
+add_dependencies(all_built ${PROJECT_NAME})
diff --git a/tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts
new file mode 100644
index 0000000000..20a96e90c4
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts
@@ -0,0 +1 @@
+bonk
diff --git a/tests/auto/cmake/test_static_resources/.cmake.conf b/tests/auto/cmake/test_static_resources/.cmake.conf
index f7a41402e0..db70cebc03 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.4.0")
+set(QT_REPO_MODULE_VERSION "6.4.3")
diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
index 50819a3742..854059e7e7 100644
--- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
+++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
@@ -1434,7 +1434,7 @@ void tst_QtConcurrentFilter::incrementalResults()
QCOMPARE(future.isFinished(), true);
QCOMPARE(future.resultCount(), count / 2);
- QCOMPARE(future.results().count(), count / 2);
+ QCOMPARE(future.results().size(), count / 2);
}
void tst_QtConcurrentFilter::noDetach()
diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
index c842fa4341..52406e4a62 100644
--- a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+++ b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
@@ -221,7 +221,7 @@ void tst_QtConcurrentIterateKernel::throttling()
QCOMPARE(iterations.loadRelaxed(), totalIterations);
- QCOMPARE(threads.count(), 1);
+ QCOMPARE(threads.size(), 1);
}
class MultipleResultsFor : public IterateKernel<TestIterator, int>
@@ -239,7 +239,7 @@ public:
void tst_QtConcurrentIterateKernel::multipleResults()
{
QFuture<int> f = startThreadEngine(new MultipleResultsFor(0, 10)).startAsynchronously();
- QCOMPARE(f.results().count() , 10);
+ QCOMPARE(f.results().size() , 10);
QCOMPARE(f.resultAt(0), 0);
QCOMPARE(f.resultAt(5), 5);
QCOMPARE(f.resultAt(9), 9);
diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
index a6c73777a1..d872702567 100644
--- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
@@ -1956,7 +1956,7 @@ void tst_QtConcurrentMap::incrementalResults()
QCOMPARE(future.isFinished(), true);
QCOMPARE(future.resultCount(), count);
- QCOMPARE(future.results().count(), count);
+ QCOMPARE(future.results().size(), count);
}
/*
diff --git a/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt b/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
index 9f3b60481d..540a360319 100644
--- a/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
+++ b/tests/auto/concurrent/qtconcurrentrun/CMakeLists.txt
@@ -9,6 +9,7 @@ qt_internal_add_test(tst_qtconcurrentrun
tst_qtconcurrentrun.cpp
PUBLIC_LIBRARIES
Qt::Concurrent
+ Qt::TestPrivate
)
## Scopes:
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
index 6351854a21..179cf2b006 100644
--- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
@@ -10,12 +10,15 @@
#include <QTimer>
#include <QFutureSynchronizer>
+#include <QtTest/private/qemulationdetector_p.h>
+
using namespace QtConcurrent;
class tst_QtConcurrentRun: public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
void runLightFunction();
void runHeavyFunction();
void returnValue();
@@ -83,6 +86,13 @@ void heavy()
qDebug("done function");
}
+void tst_QtConcurrentRun::initTestCase()
+{
+ // proxy check for QEMU; catches slightly more though
+ if (QTestPrivate::isRunningArmOnX86())
+ QSKIP("Runs into spurious crashes on QEMU -- QTBUG-106906");
+}
+
void tst_QtConcurrentRun::runLightFunction()
{
qDebug("starting function");
@@ -1383,7 +1393,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
future.waitForFinished();
- QCOMPARE(future.results().count(), 0);
+ QCOMPARE(future.results().size(), 0);
QVERIFY(runExecuted);
QVERIFY(!cancelReceivedBeforeSync);
QVERIFY(cancelReceivedAfterSync);
@@ -1403,7 +1413,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
resultFuture.waitForFinished();
- QCOMPARE(future.results().count(), 1);
+ QCOMPARE(future.results().size(), 1);
QCOMPARE(future.result(), 1);
QVERIFY(runExecuted);
QVERIFY(thenExecuted);
@@ -1426,7 +1436,7 @@ void tst_QtConcurrentRun::withPromiseAndThen()
setFlag(syncEnd);
resultFuture.waitForFinished();
- QCOMPARE(future.results().count(), 0);
+ QCOMPARE(future.results().size(), 0);
QVERIFY(runExecuted);
QVERIFY(!thenExecuted);
QVERIFY(cancelExecuted);
diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
index 701b086ab8..51a2273f9d 100644
--- a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+++ b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
@@ -234,7 +234,7 @@ void tst_QtConcurrentThreadEngine::threadCount()
const int repeats = 10;
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser())->startAsynchronously().waitForFinished();
- const auto count = threads.count();
+ const auto count = threads.size();
const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
QVERIFY(count <= maxThreadCount);
QVERIFY(!threads.contains(QThread::currentThread()));
@@ -243,7 +243,7 @@ void tst_QtConcurrentThreadEngine::threadCount()
// Set the finish flag immediately, this should give us one thread only.
for (int i = 0; i < repeats; ++i) {
(new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
- const auto count = threads.count();
+ const auto count = threads.size();
QCOMPARE(count, 1);
QVERIFY(!threads.contains(QThread::currentThread()));
}
@@ -271,7 +271,7 @@ void tst_QtConcurrentThreadEngine::multipleResults()
{
MultipleResultsUser *engine = new MultipleResultsUser();
QFuture<int> f = engine->startAsynchronously();
- QCOMPARE(f.results().count() , 10);
+ QCOMPARE(f.results().size() , 10);
QCOMPARE(f.resultAt(0), 0);
QCOMPARE(f.resultAt(5), 5);
QCOMPARE(f.resultAt(9), 9);
diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
index 162f8ea9fc..af84961531 100644
--- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
@@ -109,7 +109,7 @@ void tst_QAnimationGroup::emptyGroup()
QCOMPARE(group.state(), QAnimationGroup::Stopped);
group.start();
- QCOMPARE(groupStateChangedSpy.count(), 2);
+ QCOMPARE(groupStateChangedSpy.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
@@ -121,7 +121,7 @@ void tst_QAnimationGroup::emptyGroup()
QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimation::pause: Cannot pause a stopped animation");
group.pause();
- QCOMPARE(groupStateChangedSpy.count(), 2);
+ QCOMPARE(groupStateChangedSpy.size(), 2);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
group.start();
@@ -135,7 +135,7 @@ void tst_QAnimationGroup::emptyGroup()
group.stop();
- QCOMPARE(groupStateChangedSpy.count(), 4);
+ QCOMPARE(groupStateChangedSpy.size(), 4);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
}
diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index 6d73725cff..3c5d9ed3a9 100644
--- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -234,38 +234,38 @@ void tst_QParallelAnimationGroup::stateChanged()
//first; let's start forward
group.start();
//all the animations should be started
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
group.setCurrentTime(1500); //anim1 should be finished
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy2.size(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(2500); //anim2 should be finished
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy1.size(), 2); //no change
+ QCOMPARE(spy2.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(3500); //everything should be finished
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2); //no change
- QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy1.size(), 2); //no change
+ QCOMPARE(spy2.size(), 2); //no change
+ QCOMPARE(spy3.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
//cleanup
@@ -280,38 +280,38 @@ void tst_QParallelAnimationGroup::stateChanged()
//only anim3 and anim4 should be started
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 0);
- QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy1.size(), 0);
+ QCOMPARE(spy2.size(), 0);
+ QCOMPARE(spy3.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
group.setCurrentTime(1500); //anim2 should be started
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 0); //no change
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 0); //no change
+ QCOMPARE(spy2.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(500); //anim1 is finally also started
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy2.size(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(0); //everything should be stopped
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy2.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy3.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
}
@@ -405,8 +405,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
QVERIFY(groupStateChangedSpy.isValid());
QVERIFY(childStateChangedSpy.isValid());
- QCOMPARE(groupStateChangedSpy.count(), 0);
- QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(groupStateChangedSpy.size(), 0);
+ QCOMPARE(childStateChangedSpy.size(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(anim.state(), QAnimationGroup::Stopped);
@@ -417,8 +417,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim.state(), QAnimationGroup::Running);
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
+ QCOMPARE(groupStateChangedSpy.size(), 1);
+ QCOMPARE(childStateChangedSpy.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
@@ -428,8 +428,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
// starting directly a running child will not have any effect
anim.start();
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
+ QCOMPARE(groupStateChangedSpy.size(), 1);
+ QCOMPARE(childStateChangedSpy.size(), 1);
anim.pause();
@@ -572,8 +572,8 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
QVERIFY(stateChangedSpy1.isValid());
QVERIFY(stateChangedSpy2.isValid());
- QCOMPARE(stateChangedSpy1.count(), 0);
- QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(stateChangedSpy1.size(), 0);
+ QCOMPARE(stateChangedSpy2.size(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
@@ -598,13 +598,13 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
group.start();
- QCOMPARE(stateChangedSpy1.count(), 3);
+ QCOMPARE(stateChangedSpy1.size(), 3);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(stateChangedSpy2.size(), 4);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
@@ -655,22 +655,22 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
group.addAnimation(&anim1);
group.addAnimation(&anim2);
group.addAnimation(&anim3);
- QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy1.size(), 0);
group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(finishedSpy1.count(), 1);
+ QCOMPARE(stateChangedSpy1.size(), 2);
+ QCOMPARE(finishedSpy1.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(finishedSpy2.count(), 0);
+ QCOMPARE(stateChangedSpy2.size(), 1);
+ QCOMPARE(finishedSpy2.size(), 0);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(stateChangedSpy3.count(), 1);
- QCOMPARE(finishedSpy3.count(), 0);
+ QCOMPARE(stateChangedSpy3.size(), 1);
+ QCOMPARE(finishedSpy3.size(), 0);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()),
QAnimationGroup::Running);
@@ -688,21 +688,21 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
stateChangedSpy3.clear();
group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 1);
+ QCOMPARE(stateChangedSpy1.size(), 2);
+ QCOMPARE(stateChangedSpy2.size(), 1);
+ QCOMPARE(stateChangedSpy3.size(), 1);
group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 2);
+ QCOMPARE(stateChangedSpy1.size(), 2);
+ QCOMPARE(stateChangedSpy2.size(), 1);
+ QCOMPARE(stateChangedSpy3.size(), 2);
group.setCurrentTime(150);
- QCOMPARE(stateChangedSpy1.count(), 4);
- QCOMPARE(stateChangedSpy2.count(), 3);
- QCOMPARE(stateChangedSpy3.count(), 4);
+ QCOMPARE(stateChangedSpy1.size(), 4);
+ QCOMPARE(stateChangedSpy2.size(), 3);
+ QCOMPARE(stateChangedSpy3.size(), 4);
group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 6);
- QCOMPARE(stateChangedSpy2.count(), 5);
- QCOMPARE(stateChangedSpy3.count(), 6);
+ QCOMPARE(stateChangedSpy1.size(), 6);
+ QCOMPARE(stateChangedSpy2.size(), 5);
+ QCOMPARE(stateChangedSpy3.size(), 6);
}
@@ -734,7 +734,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
group.start();
- QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(stateChangedSpy.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
@@ -943,7 +943,7 @@ void tst_QParallelAnimationGroup::pauseResume()
QTest::qWait(100);
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
const int currentTime = group.currentLoopTime();
QCOMPARE(anim->currentLoopTime(), currentTime);
@@ -953,7 +953,7 @@ void tst_QParallelAnimationGroup::pauseResume()
QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Paused);
QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
group.resume();
@@ -961,21 +961,21 @@ void tst_QParallelAnimationGroup::pauseResume()
QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
group.stop();
spy.clear();
new TestAnimation2(500, &group);
group.start();
- QCOMPARE(spy.count(), 1); //the animation should have been started
+ QCOMPARE(spy.size(), 1); //the animation should have been started
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running);
group.setCurrentTime(250); //end of first animation
- QCOMPARE(spy.count(), 2); //the animation should have been stopped
+ QCOMPARE(spy.size(), 2); //the animation should have been stopped
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped);
group.pause();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
+ QCOMPARE(spy.size(), 2); //this shouldn't have changed
group.resume();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
+ QCOMPARE(spy.size(), 2); //this shouldn't have changed
}
// This is a regression test for QTBUG-8910, where a crash occurred when the
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index a5eff80e49..d739164a10 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -283,9 +283,9 @@ void tst_QPropertyAnimation::statesAndSignals()
anim->setCurrentTime(1);
anim->setCurrentTime(100);
- QCOMPARE(finishedSpy.count(), 0);
- QCOMPARE(runningSpy.count(), 0);
- QCOMPARE(currentLoopSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
+ QCOMPARE(runningSpy.size(), 0);
+ QCOMPARE(currentLoopSpy.size(), 0);
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
anim->setLoopCount(3);
@@ -294,26 +294,26 @@ void tst_QPropertyAnimation::statesAndSignals()
if (uncontrolled)
QSKIP("Uncontrolled animations don't handle looping");
- QCOMPARE(currentLoopSpy.count(), 1);
+ QCOMPARE(currentLoopSpy.size(), 1);
QCOMPARE(anim->currentLoop(), 1);
anim->setCurrentTime(0);
- QCOMPARE(currentLoopSpy.count(), 2);
+ QCOMPARE(currentLoopSpy.size(), 2);
QCOMPARE(anim->currentLoop(), 0);
anim->start();
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(runningSpy.count(), 1); //anim must have started
+ QCOMPARE(runningSpy.size(), 1); //anim must have started
QCOMPARE(anim->currentLoop(), 0);
runningSpy.clear();
anim->stop();
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
- QCOMPARE(runningSpy.count(), 1); //anim must have stopped
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.size(), 1); //anim must have stopped
+ QCOMPARE(finishedSpy.size(), 0);
QCOMPARE(anim->currentLoopTime(), 0);
QCOMPARE(anim->currentLoop(), 0);
- QCOMPARE(currentLoopSpy.count(), 2);
+ QCOMPARE(currentLoopSpy.size(), 2);
runningSpy.clear();
{
@@ -321,30 +321,30 @@ void tst_QPropertyAnimation::statesAndSignals()
anim->start();
timeDriver.wait(1000);
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
- QCOMPARE(runningSpy.count(), 2); //started and stopped again
+ QCOMPARE(runningSpy.size(), 2); //started and stopped again
runningSpy.clear();
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(finishedSpy.size(), 1);
QCOMPARE(anim->currentLoopTime(), 100);
QCOMPARE(anim->currentLoop(), 2);
- QCOMPARE(currentLoopSpy.count(), 4);
+ QCOMPARE(currentLoopSpy.size(), 4);
anim->start(); // auto-rewinds
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(anim->currentTime(), 0);
QCOMPARE(anim->currentLoop(), 0);
- QCOMPARE(currentLoopSpy.count(), 5);
- QCOMPARE(runningSpy.count(), 1); // anim has started
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(currentLoopSpy.size(), 5);
+ QCOMPARE(runningSpy.size(), 1); // anim has started
+ QCOMPARE(finishedSpy.size(), 1);
QCOMPARE(anim->currentLoop(), 0);
runningSpy.clear();
timeDriver.wait(1000);
- QCOMPARE(currentLoopSpy.count(), 7);
+ QCOMPARE(currentLoopSpy.size(), 7);
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
QCOMPARE(anim->currentLoop(), 2);
- QCOMPARE(runningSpy.count(), 1); // anim has stopped
- QCOMPARE(finishedSpy.count(), 2);
+ QCOMPARE(runningSpy.size(), 1); // anim has stopped
+ QCOMPARE(finishedSpy.size(), 2);
QCOMPARE(anim->currentLoopTime(), 100);
}
}
@@ -364,8 +364,8 @@ void tst_QPropertyAnimation::deletion1()
anim->setEndValue(20);
anim->setDuration(200);
anim->start();
- QCOMPARE(runningSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 0);
QVERIFY(anim);
QCOMPARE(anim->state(), QAnimationGroup::Running);
@@ -375,8 +375,8 @@ void tst_QPropertyAnimation::deletion1()
timeDriver.wait(150);
QVERIFY(anim); //The animation should not have been deleted
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
- QCOMPARE(runningSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(runningSpy.size(), 2);
+ QCOMPARE(finishedSpy.size(), 1);
anim->start(QVariantAnimation::DeleteWhenStopped);
QVERIFY(anim);
@@ -385,8 +385,8 @@ void tst_QPropertyAnimation::deletion1()
QVERIFY(anim);
QCOMPARE(anim->state(), QAnimationGroup::Running);
timeDriver.wait(150);
- QCOMPARE(runningSpy.count(), 4);
- QCOMPARE(finishedSpy.count(), 2);
+ QCOMPARE(runningSpy.size(), 4);
+ QCOMPARE(finishedSpy.size(), 2);
QVERIFY(!anim); //The animation must have been deleted
delete object;
}
@@ -417,8 +417,8 @@ void tst_QPropertyAnimation::deletion2()
QVERIFY(anim);
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(runningSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 0);
//we can't call deletaLater directly because the delete would only happen in the next loop of _this_ event loop
QTimer::singleShot(0, object, SLOT(deleteLater()));
@@ -451,11 +451,11 @@ void tst_QPropertyAnimation::deletion3()
timeDriver.wait(50);
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(runningSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 0);
delete anim;
- QCOMPARE(runningSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.size(), 2);
+ QCOMPARE(finishedSpy.size(), 0);
}
void tst_QPropertyAnimation::duration0()
@@ -547,7 +547,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
QVERIFY(runningSpy.isValid());
anim->start(QVariantAnimation::DeleteWhenStopped);
timeDriver.wait(anim->duration());
- QCOMPARE(runningSpy.count(), 2); //started and then stopped
+ QCOMPARE(runningSpy.size(), 2); //started and then stopped
QVERIFY(!anim);
}
{
@@ -559,7 +559,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
timeDriver.wait(anim->duration()/2);
QPointer<QVariantAnimation> anim2 = new QPropertyAnimation(&o, "ole");
anim2->setEndValue(100);
- QCOMPARE(runningSpy.count(), 1);
+ QCOMPARE(runningSpy.size(), 1);
QCOMPARE(anim->state(), QVariantAnimation::Running);
//anim2 will interrupt anim1
@@ -908,7 +908,7 @@ void tst_QPropertyAnimation::zeroDurationStart()
anim.start();
//the animation stops immediately
QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
//let's check the first state change
const QVariantList firstChange = spy.first();
@@ -1193,8 +1193,8 @@ void tst_QPropertyAnimation::valueChanged()
QCOMPARE(anim.currentTime(), anim.duration());
//let's check that the values go forward
- QCOMPARE(spy.count(), 6); //we should have got everything from 0 to 5
- for (int i = 0; i < spy.count(); ++i) {
+ QCOMPARE(spy.size(), 6); //we should have got everything from 0 to 5
+ for (int i = 0; i < spy.size(); ++i) {
QCOMPARE(qvariant_cast<QVariant>(spy.at(i).first()).toInt(), i);
}
}
@@ -1324,15 +1324,15 @@ void tst_QPropertyAnimation::zeroLoopCount()
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
QCOMPARE(anim->currentValue().toInt(), 0);
- QCOMPARE(runningSpy.count(), 0);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.size(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
anim->start();
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
QCOMPARE(anim->currentValue().toInt(), 0);
- QCOMPARE(runningSpy.count(), 0);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.size(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
}
diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 61be0d00f5..e6e8731378 100644
--- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -551,8 +551,8 @@ using StateList = QList<QAbstractAnimation::State>;
static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates)
{
bool equals = true;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i >= spy.count() || i >= expectedStates.count()) {
+ for (int i = 0; i < qMax(expectedStates.size(), spy.size()); ++i) {
+ if (i >= spy.size() || i >= expectedStates.size()) {
equals = false;
break;
}
@@ -567,14 +567,14 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates
if (!equals) {
const char *stateStrings[] = {"Stopped", "Paused", "Running"};
QString e,a;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i < expectedStates.count()) {
+ for (int i = 0; i < qMax(expectedStates.size(), spy.size()); ++i) {
+ if (i < expectedStates.size()) {
int exp = int(expectedStates.at(i));
if (!e.isEmpty())
e += QLatin1String(", ");
e += QLatin1String(stateStrings[exp]);
}
- if (i < spy.count()) {
+ if (i < spy.size()) {
QList<QVariant> args = spy.at(i);
QAbstractAnimation::State actual = qvariant_cast<QAbstractAnimation::State>(args.value(1));
if (!a.isEmpty())
@@ -589,7 +589,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates
}
qDebug("\n"
"expected (count == %zd): %s\n"
- "actual (count == %zd): %s\n", size_t(expectedStates.count()), qPrintable(e), size_t(spy.count()), qPrintable(a));
+ "actual (count == %zd): %s\n", size_t(expectedStates.size()), qPrintable(e), size_t(spy.size()), qPrintable(a));
}
return equals;
}
@@ -636,8 +636,8 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused);
- QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped
- QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused
+ QCOMPARE(a1StateChangedSpy.size(), 5); // Running,Paused,Stopped,Running,Stopped
+ QCOMPARE(seqStateChangedSpy.size(), 2); // Running,Paused
QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimation::Running
<< QAbstractAnimation::Paused
@@ -678,7 +678,7 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QCOMPARE(a3_s_o1->currentLoop(), 0);
QVERIFY(a3_s_o1->currentLoopTime() >= 1);
- QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
+ QCOMPARE(seqStateChangedSpy.size(), 3); // Running,Paused,Running
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()),
QAnimationGroup::Running);
@@ -699,13 +699,13 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QCOMPARE(a3_s_o1->currentLoop(), 0);
QVERIFY(a3_s_o1->currentLoopTime() >= 1);
- QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
+ QCOMPARE(seqStateChangedSpy.size(), 4); // Running,Paused,Running,Paused
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()),
QAnimationGroup::Paused);
group.stop();
- QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
+ QCOMPARE(seqStateChangedSpy.size(), 5); // Running,Paused,Running,Paused,Stopped
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()),
QAnimationGroup::Stopped);
}
@@ -749,7 +749,7 @@ void tst_QSequentialAnimationGroup::restart()
QTRY_COMPARE(group.state(), QAnimationGroup::Stopped);
for (int i = 0; i < 3; i++) {
- QCOMPARE(animsStateChanged[i]->count(), 4);
+ QCOMPARE(animsStateChanged[i]->size(), 4);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()),
QAnimationGroup::Running);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()),
@@ -760,22 +760,22 @@ void tst_QSequentialAnimationGroup::restart()
QAnimationGroup::Stopped);
}
- QCOMPARE(seqStateChangedSpy.count(), 2);
+ QCOMPARE(seqStateChangedSpy.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
- for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
+ QCOMPARE(seqCurrentAnimChangedSpy.size(), 6);
+ for(int i=0; i<seqCurrentAnimChangedSpy.size(); i++)
QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qvariant_cast<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0)));
group.start();
- QCOMPARE(animsStateChanged[0]->count(), 5);
- QCOMPARE(animsStateChanged[1]->count(), 4);
- QCOMPARE(animsStateChanged[2]->count(), 4);
- QCOMPARE(seqStateChangedSpy.count(), 3);
+ QCOMPARE(animsStateChanged[0]->size(), 5);
+ QCOMPARE(animsStateChanged[1]->size(), 4);
+ QCOMPARE(animsStateChanged[2]->size(), 4);
+ QCOMPARE(seqStateChangedSpy.size(), 3);
}
void tst_QSequentialAnimationGroup::looping()
@@ -831,21 +831,21 @@ void tst_QSequentialAnimationGroup::looping()
QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused);
- QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped
+ QCOMPARE(a1Spy.size(), 5); // Running,Paused,Stopped,Running,Stopped
QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimation::Running
<< QAbstractAnimation::Paused
<< QAbstractAnimation::Stopped
<< QAbstractAnimation::Running
<< QAbstractAnimation::Stopped)));
- QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped
+ QCOMPARE(a2Spy.size(), 4); // Running,Stopped,Running,Stopped
QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running
<< QAbstractAnimation::Stopped
<< QAbstractAnimation::Running
<< QAbstractAnimation::Paused)));
- QCOMPARE(seqSpy.count(), 2); // Running,Paused
- QCOMPARE(groupSpy.count(), 2); // Running,Paused
+ QCOMPARE(seqSpy.size(), 2); // Running,Paused
+ QCOMPARE(groupSpy.size(), 2); // Running,Paused
// Looping, current time = duration + 1
group.setCurrentTime(group.duration() + 1);
@@ -866,8 +866,8 @@ void tst_QSequentialAnimationGroup::looping()
QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
QCOMPARE(a3_s_o1->state(), QAnimationGroup::Stopped);
- QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped
- QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped
+ QCOMPARE(a1Spy.size(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped
+ QCOMPARE(a2Spy.size(), 4); // Running, Stopped, Running, Stopped
QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running
<< QAbstractAnimation::Stopped
<< QAbstractAnimation::Running
@@ -878,7 +878,7 @@ void tst_QSequentialAnimationGroup::looping()
<< QAbstractAnimation::Stopped
<< QAbstractAnimation::Running
<< QAbstractAnimation::Paused)));
- QCOMPARE(groupSpy.count(), 2);
+ QCOMPARE(groupSpy.size(), 2);
}
void tst_QSequentialAnimationGroup::startDelay()
@@ -1077,8 +1077,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
QVERIFY(groupStateChangedSpy.isValid());
QVERIFY(childStateChangedSpy.isValid());
- QCOMPARE(groupStateChangedSpy.count(), 0);
- QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(groupStateChangedSpy.size(), 0);
+ QCOMPARE(childStateChangedSpy.size(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(anim.state(), QAnimationGroup::Stopped);
@@ -1089,8 +1089,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim.state(), QAnimationGroup::Running);
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
+ QCOMPARE(groupStateChangedSpy.size(), 1);
+ QCOMPARE(childStateChangedSpy.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
@@ -1100,8 +1100,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
// starting directly a running child will not have any effect
anim.start();
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
+ QCOMPARE(groupStateChangedSpy.size(), 1);
+ QCOMPARE(childStateChangedSpy.size(), 1);
anim.pause();
@@ -1244,8 +1244,8 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild()
QVERIFY(stateChangedSpy1.isValid());
QVERIFY(stateChangedSpy2.isValid());
- QCOMPARE(stateChangedSpy1.count(), 0);
- QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(stateChangedSpy1.size(), 0);
+ QCOMPARE(stateChangedSpy2.size(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
QCOMPARE(anim2->state(), QAnimationGroup::Stopped);
@@ -1283,7 +1283,7 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild()
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim2->state(), QAnimationGroup::Running);
- QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(stateChangedSpy2.size(), 4);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
@@ -1323,7 +1323,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
group.setLoopCount(2);
group.start();
- QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(stateChangedSpy.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
@@ -1400,7 +1400,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
const int actualDuration = notTimeDriven.currentLoopTime();
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(group.currentLoopTime(), actualDuration);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
//2nd case:
// lets make sure the seeking will work again
@@ -1416,29 +1416,29 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
//3rd case:
//now let's add a perfectly defined animation at the end
- QCOMPARE(animStateChangedSpy.count(), 0);
+ QCOMPARE(animStateChangedSpy.size(), 0);
group.start();
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running);
QCOMPARE(group.currentLoopTime(), 0);
QCOMPARE(notTimeDriven.currentLoopTime(), 0);
- QCOMPARE(animStateChangedSpy.count(), 0);
+ QCOMPARE(animStateChangedSpy.size(), 0);
QTest::qWait(300); //wait for the end of notTimeDriven
QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim.state(), QAnimationGroup::Running);
QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim));
- QCOMPARE(animStateChangedSpy.count(), 1);
+ QCOMPARE(animStateChangedSpy.size(), 1);
QTest::qWait(300); //wait for the end of anim
QTRY_COMPARE(anim.state(), QAnimationGroup::Stopped);
QCOMPARE(anim.currentLoopTime(), anim.duration());
//we should simply be at the end
- QCOMPARE(spy.count(), 1);
- QCOMPARE(animStateChangedSpy.count(), 2);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(animStateChangedSpy.size(), 2);
QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime());
}
@@ -1623,7 +1623,7 @@ void tst_QSequentialAnimationGroup::pauseResume()
QTest::qWait(100);
QTRY_COMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
const int currentTime = group.currentLoopTime();
QCOMPARE(anim->currentLoopTime(), currentTime);
@@ -1633,7 +1633,7 @@ void tst_QSequentialAnimationGroup::pauseResume()
QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Paused);
QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
group.resume();
@@ -1641,7 +1641,7 @@ void tst_QSequentialAnimationGroup::pauseResume()
QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QSequentialAnimationGroup::bindings()
@@ -1667,18 +1667,18 @@ void tst_QSequentialAnimationGroup::bindings()
group.setCurrentTime(int(totalDuration * 0.5 / 3));
QCOMPARE(currentAnim.value(), anim1.get());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
group.setCurrentTime(int(totalDuration * 1.5 / 3));
QCOMPARE(currentAnim.value(), anim2.get());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// change to other style of formulating a binding to test both
currentAnim.setBinding(group.bindableCurrentAnimation().makeBinding());
group.setCurrentTime(int(totalDuration * 2.5 / 3));
QCOMPARE(currentAnim.value(), anim3.get());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
// currentAnimation is read-only. Binding it to something should have no effect
QProperty<QAbstractAnimation *> leader;
diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
index 77a7fa4194..832319a652 100644
--- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
+++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
@@ -60,7 +60,11 @@ void tst_QGetPutEnv::getSetCheck()
QCOMPARE(sresult, QString());
#endif
- QVERIFY(qputenv(varName, QByteArray("supervalue")));
+ constexpr char varValueFullString[] = "supervalue123";
+ const auto varValueQBA = QByteArray::fromRawData(varValueFullString, sizeof varValueFullString - 4);
+ QCOMPARE_EQ(varValueQBA, "supervalue");
+
+ QVERIFY(qputenv(varName, varValueQBA));
QVERIFY(qEnvironmentVariableIsSet(varName));
QVERIFY(!qEnvironmentVariableIsEmpty(varName));
@@ -187,7 +191,7 @@ void tst_QGetPutEnv::intValue()
bool actualOk = !ok;
// Self-test: confirm that it was like the docs said it should be
- if (value.length() < maxlen) {
+ if (value.size() < maxlen) {
QCOMPARE(value.toInt(&actualOk, 0), expected);
QCOMPARE(actualOk, ok);
}
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 752fb948a5..9f5b227695 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -84,7 +84,7 @@ void tst_QGlobal::for_each()
foreach(int i, list) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// do it again, to make sure we don't have any for-scoping
// problems with older compilers
@@ -92,21 +92,21 @@ void tst_QGlobal::for_each()
foreach(int i, list) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// check whether we can pass a constructor as container argument
counter = 0;
foreach (int i, QList<int>(list)) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// check whether we can use a lambda
counter = 0;
foreach (int i, [&](){ return list; }()) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// Should also work with an existing variable
int local = 0;
@@ -114,7 +114,7 @@ void tst_QGlobal::for_each()
foreach (local, list) {
QCOMPARE(local, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
QCOMPARE(local, counter - 1);
// Test the macro does not mess if/else conditions
@@ -124,7 +124,7 @@ void tst_QGlobal::for_each()
QCOMPARE(i, counter++);
else
QFAIL("If/Else mismatch");
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
counter = 0;
if (false)
@@ -135,7 +135,7 @@ void tst_QGlobal::for_each()
foreach (int i, list)
if (false) { }
else QCOMPARE(i, counter++);
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// break and continue
counter = 0;
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index 5de7830113..7a5eba6dd3 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -30,6 +30,8 @@ private slots:
#ifdef QT_BUILD_INTERNAL
void cleanupFuncinfo_data();
void cleanupFuncinfo();
+ void cleanupFuncinfoBad_data();
+ void cleanupFuncinfoBad();
#endif
void qMessagePattern_data();
@@ -599,6 +601,26 @@ void tst_qmessagehandler::cleanupFuncinfo_data()
<< "int TestClass1::operator>(int)"
<< "TestClass1::operator>";
+ QTest::newRow("gcc_40")
+ << "Polymorphic<void (*)(int)>::~Polymorphic()"
+ << "Polymorphic::~Polymorphic";
+
+ QTest::newRow("gcc_41")
+ << "function<void (int*)>()::S::f()"
+ << "function()::S::f";
+
+ QTest::newRow("msvc_41")
+ << "void `void function<void __cdecl(int *)>(void)'::`2'::S::f(void)"
+ << "function(void)'::`2'::S::f";
+
+ QTest::newRow("gcc_42")
+ << "function<Polymorphic<void (int*)> >()::S::f(Polymorphic<void (int*)>*)"
+ << "function()::S::f";
+
+ QTest::newRow("msvc_42")
+ << "void `void function<Polymorphic<void __cdecl(int *)> >(void)'::`2'::S::f(Polymorphic<void __cdecl(int *)> *)"
+ << "function(void)'::`2'::S::f";
+
QTest::newRow("objc_1")
<< "-[SomeClass someMethod:withArguments:]"
<< "-[SomeClass someMethod:withArguments:]";
@@ -614,6 +636,14 @@ void tst_qmessagehandler::cleanupFuncinfo_data()
QTest::newRow("objc_4")
<< "__31-[SomeClass someMethodSchedulingBlock]_block_invoke"
<< "__31-[SomeClass someMethodSchedulingBlock]_block_invoke";
+
+ QTest::newRow("thunk-1")
+ << "non-virtual thunk to QFutureWatcherBasePrivate::postCallOutEvent(QFutureCallOutEvent const&)"
+ << "QFutureWatcherBasePrivate::postCallOutEvent";
+
+ QTest::newRow("thunk-2")
+ << "virtual thunk to std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()"
+ << "std::basic_iostream::~basic_iostream";
}
#endif
@@ -634,6 +664,41 @@ void tst_qmessagehandler::cleanupFuncinfo()
QEXPECT_FAIL("TestClass1::nested_struct_const", "Nested function processing is broken", Continue);
QTEST(QString::fromLatin1(result), "expected");
}
+
+void tst_qmessagehandler::cleanupFuncinfoBad_data()
+{
+ QTest::addColumn<QByteArray>("funcinfo");
+
+ auto addBadFrame = [i = 0](const char *symbol) mutable {
+ QTest::addRow("%d", ++i) << QByteArray(symbol);
+ };
+ addBadFrame("typeinfo for QEventLoop");
+ addBadFrame("typeinfo name for QtPrivate::ResultStoreBase");
+ addBadFrame("typeinfo name for ._anon_476");
+ addBadFrame("typeinfo name for std::__1::__function::__base<bool (void*, void*)>");
+ addBadFrame("vtable for BezierEase");
+ addBadFrame("vtable for Polymorphic<void ()>");
+ addBadFrame("vtable for Polymorphic<void (*)(int)>");
+ addBadFrame("TLS wrapper function for (anonymous namespace)::jitStacks");
+ addBadFrame("lcCheckIndex()::category");
+ addBadFrame("guard variable for lcEPDetach()::category");
+ addBadFrame("guard variable for QImageReader::read(QImage*)::disableNxImageLoading");
+ addBadFrame("VTT for std::__1::ostrstream");
+ addBadFrame("qIsRelocatable<(anonymous namespace)::Data>");
+ addBadFrame("qt_incomplete_metaTypeArray<(anonymous namespace)::qt_meta_stringdata_CLASSQNonContiguousByteDeviceIoDeviceImplENDCLASS_t, QtPrivate::TypeAndForceComplete<void, std::integral_constant<bool, true> > >");
+ addBadFrame("f()::i");
+}
+
+void tst_qmessagehandler::cleanupFuncinfoBad()
+{
+ QFETCH(QByteArray, funcinfo);
+
+ // A corrupted stack trace may find non-sensical symbols that aren't
+ // functions. The result doesn't matter, so long as we don't crash or hang.
+
+ QByteArray result = qCleanupFuncinfo(funcinfo);
+ qDebug() << "Decode of" << funcinfo << "produced" << result;
+}
#endif
void tst_qmessagehandler::qMessagePattern_data()
@@ -774,7 +839,7 @@ void tst_qmessagehandler::qMessagePattern()
QVERIFY(!output.isEmpty());
QCOMPARE(!output.contains("QT_MESSAGE_PATTERN"), valid);
- for (const QByteArray &e : qAsConst(expected)) {
+ for (const QByteArray &e : std::as_const(expected)) {
if (!output.contains(e)) {
// use QDebug so we get proper string escaping for the newlines
QString buf;
diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
index a3b31eda3f..f860a91cf5 100644
--- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
+++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
@@ -611,7 +611,7 @@ template <typename UInt> static void boundedQuality_template()
QVector<UInt> buffer(BufferCount, filler);
generate(buffer.begin(), buffer.end(), [&] { return rng.bounded(Bound); });
- for (UInt value : qAsConst(buffer)) {
+ for (UInt value : std::as_const(buffer)) {
QVERIFY(value < Bound);
histogram[value]++;
}
diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
index 93e0d6fce8..6fe192f3ab 100644
--- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
@@ -15,6 +15,7 @@ class tst_QBuffer : public QObject
Q_OBJECT
private slots:
void open();
+ void openWriteOnlyDoesNotTruncate();
void getSetCheck();
void readBlock();
void readBlockPastEnd();
@@ -111,6 +112,29 @@ void tst_QBuffer::open()
b.close();
}
+void tst_QBuffer::openWriteOnlyDoesNotTruncate()
+{
+ QBuffer b;
+ const auto data = QByteArrayLiteral("Hey, presto!");
+
+ {
+ QVERIFY(b.open(QIODevice::WriteOnly));
+ b.write(data);
+ b.close();
+ }
+ {
+ QVERIFY(b.open(QIODevice::ReadOnly));
+ QCOMPARE(b.readAll(), data);
+ b.close();
+ }
+ {
+ QVERIFY(b.open(QIODevice::WriteOnly));
+ QCOMPARE(b.size(), data.size());
+ QCOMPARE(b.pos(), 0);
+ b.close();
+ }
+}
+
// some status() tests, too
void tst_QBuffer::readBlock()
{
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index cfc786b292..65a7daaf7d 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -17,7 +17,6 @@
#if defined(Q_OS_WIN)
#include <QtCore/private/qfsfileengine_p.h>
-#include "../../../network-settings.h"
#endif
#if defined(Q_OS_WIN) && !defined(_WIN32_WINNT)
@@ -522,12 +521,12 @@ void tst_QDir::removeRecursively_data()
<< tmpdir + "two/three"
<< "relative";
QDir dir;
- for (int i = 0; i < dirs.count(); ++i)
+ for (int i = 0; i < dirs.size(); ++i)
dir.mkpath(dirs.at(i));
QStringList files;
files << tmpdir + "one/file";
files << tmpdir + "two/three/file";
- for (int i = 0; i < files.count(); ++i) {
+ for (int i = 0; i < files.size(); ++i) {
QFile file(files.at(i));
QVERIFY(file.open(QIODevice::WriteOnly));
file.write("Hello");
@@ -627,7 +626,7 @@ void tst_QDir::exists_data()
QTest::newRow("simple dir") << (m_dataPath + "/resources") << true;
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true;
#if defined(Q_OS_WIN)
- const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString uncRoot = QStringLiteral("//") + QTest::uncServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
QTest::newRow("unc 3") << uncRoot + "/testshare" << true;
@@ -1020,7 +1019,7 @@ void tst_QDir::entryListSimple_data()
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2;
#if defined(Q_OS_WIN)
- const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString uncRoot = QStringLiteral("//") + QTest::uncServerName();
QTest::newRow("unc 1") << uncRoot << 2;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2;
QTest::newRow("unc 3") << uncRoot + "/testshare" << 2;
@@ -1046,7 +1045,7 @@ void tst_QDir::entryListSimple()
QDir dir(dirName);
QStringList actual = dir.entryList();
- QVERIFY2(actual.count() >= countMin, msgEntryListFailed(actual.count(), countMin, dirName).constData());
+ QVERIFY2(actual.size() >= countMin, msgEntryListFailed(actual.size(), countMin, dirName).constData());
}
void tst_QDir::entryListWithSymLinks()
@@ -1255,11 +1254,11 @@ void tst_QDir::setNameFilters()
dir.setNameFilters(nameFilters);
QStringList actual = dir.entryList();
- int max = qMin(actual.count(), expected.count());
+ int max = qMin(actual.size(), expected.size());
for (int i=0; i<max; ++i)
QCOMPARE(actual[i], expected[i]);
- QCOMPARE(actual.count(), expected.count());
+ QCOMPARE(actual.size(), expected.size());
}
void
@@ -1735,7 +1734,7 @@ void tst_QDir::homePath()
QVERIFY(QDir::isAbsolutePath(strHome));
#ifdef Q_OS_UNIX
- if (strHome.length() > 1) // root dir = "/"
+ if (strHome.size() > 1) // root dir = "/"
QVERIFY(!strHome.endsWith('/'));
QByteArray envHome = qgetenv("HOME");
@@ -1749,7 +1748,7 @@ void tst_QDir::homePath()
#endif
QStringList entries = homeDir.entryList();
- for (int i = 0; i < entries.count(); ++i) {
+ for (int i = 0; i < entries.size(); ++i) {
QFileInfo fi(QDir::homePath() + "/" + entries[i]);
QCOMPARE(fi.exists(), true);
}
@@ -1765,7 +1764,7 @@ void tst_QDir::tempPath()
QVERIFY(QDir::isAbsolutePath(path));
#ifdef Q_OS_UNIX
- if (path.length() > 1) // root dir = "/"
+ if (path.size() > 1) // root dir = "/"
QVERIFY(!path.endsWith('/'));
#elif defined(Q_OS_WIN)
if (path.length() > 3) // root dir = "c:/"; "//" is not really valid...
@@ -1846,10 +1845,10 @@ void tst_QDir::searchPaths()
QFETCH(QString, expectedAbsolutePath);
bool exists = !expectedAbsolutePath.isEmpty();
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
QDir::setSearchPaths(searchPathPrefixList.at(i), searchPathsList.at(i).split(","));
}
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
QCOMPARE(QDir::searchPaths(searchPathPrefixList.at(i)), searchPathsList.at(i).split(","));
}
@@ -1860,19 +1859,19 @@ void tst_QDir::searchPaths()
QCOMPARE(QFileInfo(filename).absoluteFilePath(), expectedAbsolutePath);
}
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
QDir::setSearchPaths(searchPathPrefixList.at(i), QStringList());
}
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
QVERIFY(QDir::searchPaths(searchPathPrefixList.at(i)).isEmpty());
}
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
foreach (QString path, searchPathsList.at(i).split(",")) {
QDir::addSearchPath(searchPathPrefixList.at(i), path);
}
}
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
QCOMPARE(QDir::searchPaths(searchPathPrefixList.at(i)), searchPathsList.at(i).split(","));
}
@@ -1883,10 +1882,10 @@ void tst_QDir::searchPaths()
QCOMPARE(QFileInfo(filename).absoluteFilePath(), expectedAbsolutePath);
}
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
QDir::setSearchPaths(searchPathPrefixList.at(i), QStringList());
}
- for (int i = 0; i < searchPathPrefixList.count(); ++i) {
+ for (int i = 0; i < searchPathPrefixList.size(); ++i) {
QVERIFY(QDir::searchPaths(searchPathPrefixList.at(i)).isEmpty());
}
}
@@ -2213,7 +2212,7 @@ void tst_QDir::drives()
}
QCOMPARE(foundsystem, true);
#else
- QCOMPARE(list.count(), 1); //root
+ QCOMPARE(list.size(), 1); //root
QCOMPARE(list.at(0).absolutePath(), QLatin1String("/"));
#endif
}
@@ -2225,7 +2224,7 @@ void tst_QDir::arrayOperator()
QStringList entries(dir1.entryList());
int i = dir2.count();
- QCOMPARE(i, entries.count());
+ QCOMPARE(i, entries.size());
--i;
for (;i>=0;--i) {
QCOMPARE(dir2[i], entries.at(i));
@@ -2393,7 +2392,7 @@ void tst_QDir::cdBelowRoot_data()
const QString systemRoot = QString::fromLocal8Bit(qgetenv("SystemRoot"));
QTest::newRow("windows-drive")
<< systemDrive << systemRoot.mid(3) << QDir::cleanPath(systemRoot);
- const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString uncRoot = QStringLiteral("//") + QTest::uncServerName();
const QString testDirectory = QStringLiteral("testshare");
QTest::newRow("windows-share")
<< uncRoot << testDirectory << QDir::cleanPath(uncRoot + QLatin1Char('/') + testDirectory);
@@ -2478,7 +2477,7 @@ void tst_QDir::stdfilesystem()
QCOMPARE(entries, QStringList() << "subdir2" << "subdir1");
QCOMPARE(filteredDir.sorting(), QDir::SortFlag::Reversed);
QCOMPARE(filteredDir.filter(), QDir::Filter::Dirs);
- QCOMPARE(filteredDir.nameFilters().length(), 1);
+ QCOMPARE(filteredDir.nameFilters().size(), 1);
QCOMPARE(filteredDir.nameFilters().first(), "subdir*");
}
#else
diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp
index 628f1acad6..303c2c9dcf 100644
--- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp
+++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp
@@ -18,9 +18,7 @@
#define Q_NO_SYMLINKS
#endif
-#if defined(Q_OS_WIN)
-# include "../../../network-settings.h"
-#endif
+#include "../../../../shared/filesystem.h"
#ifdef Q_OS_ANDROID
#include <QStandardPaths>
@@ -533,7 +531,7 @@ void tst_QDirIterator::longPath()
QCOMPARE(n, m);
dirName.chop(1);
- while (dirName.length() > 0 && dir.exists(dirName) && dir.rmdir(dirName)) {
+ while (dirName.size() > 0 && dir.exists(dirName) && dir.rmdir(dirName)) {
dirName.chop(1);
}
dir.cdUp();
@@ -563,11 +561,11 @@ void tst_QDirIterator::uncPaths_data()
{
QTest::addColumn<QString>("dirName");
QTest::newRow("uncserver")
- <<QString("//" + QtNetworkSettings::winServerName());
+ <<QString("//" + QTest::uncServerName());
QTest::newRow("uncserver/testshare")
- <<QString("//" + QtNetworkSettings::winServerName() + "/testshare");
+ <<QString("//" + QTest::uncServerName() + "/testshare");
QTest::newRow("uncserver/testshare/tmp")
- <<QString("//" + QtNetworkSettings::winServerName() + "/testshare/tmp");
+ <<QString("//" + QTest::uncServerName() + "/testshare/tmp");
}
void tst_QDirIterator::uncPaths()
{
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 828a90e86e..9fe8dee040 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -74,9 +74,7 @@ QT_END_NAMESPACE
# undef fileno
#endif
-#if defined(Q_OS_WIN)
-#include "../../../network-settings.h"
-#endif
+#include "../../../../shared/filesystem.h"
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
@@ -170,6 +168,7 @@ private slots:
void permissionsNtfs_data();
void permissionsNtfs();
#endif
+ void setPermissions_data();
void setPermissions();
void copy();
void copyAfterFail();
@@ -542,7 +541,7 @@ void tst_QFile::exists()
QVERIFY(!file.exists());
#if defined(Q_OS_WIN)
- const QString uncPath = "//" + QtNetworkSettings::winServerName() + "/testshare/readme.txt";
+ const QString uncPath = "//" + QTest::uncServerName() + "/testshare/readme.txt";
QFile unc(uncPath);
QVERIFY2(unc.exists(), msgFileDoesNotExist(uncPath).constData());
#endif
@@ -608,7 +607,7 @@ void tst_QFile::open_data()
QTest::newRow("//./PhysicalDrive0") << QString("//./PhysicalDrive0") << int(QIODevice::ReadOnly)
<< false << QFile::OpenError;
}
- QTest::newRow("uncFile") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri" << int(QIODevice::ReadOnly)
+ QTest::newRow("uncFile") << "//" + QTest::uncServerName() + "/testshare/test.pri" << int(QIODevice::ReadOnly)
<< true << QFile::NoError;
#endif
}
@@ -682,7 +681,7 @@ void tst_QFile::size_data()
QTest::newRow( "exist01" ) << m_testFile << (qint64)245;
#if defined(Q_OS_WIN)
// Only test UNC on Windows./
- QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testshare/test.pri") << (qint64)34;
+ QTest::newRow("unc") << "//" + QString(QTest::uncServerName() + "/testshare/test.pri") << (qint64)34;
#endif
}
@@ -1419,21 +1418,38 @@ void tst_QFile::permissionsNtfs()
}
#endif
+void tst_QFile::setPermissions_data()
+{
+ QTest::addColumn<bool>("opened");
+ QTest::newRow("closed") << false; // chmod()
+ QTest::newRow("opened") << true; // fchmod()
+}
+
void tst_QFile::setPermissions()
{
- if ( QFile::exists( "createme.txt" ) )
- QFile::remove( "createme.txt" );
+#ifdef Q_OS_QNX
+ QSKIP("This test doesn't pass on QNX and no one has cared to investigate.");
+#endif
+ QFETCH(bool, opened);
+
+ auto remove = []() { QFile::remove("createme.txt"); };
+ auto guard = qScopeGuard(remove);
+ remove();
QVERIFY( !QFile::exists( "createme.txt" ) );
QFile f("createme.txt");
QVERIFY2(f.open(QIODevice::WriteOnly | QIODevice::Truncate), msgOpenFailed(f).constData());
f.putChar('a');
- f.close();
+ if (!opened)
+ f.close();
QFile::Permissions perms(QFile::WriteUser | QFile::ReadUser);
+ QVERIFY(f.setPermissions(QFile::ReadUser));
+ QVERIFY((f.permissions() & perms) == QFile::ReadUser);
QVERIFY(f.setPermissions(perms));
QVERIFY((f.permissions() & perms) == perms);
+ // we should end the test with the file in writeable state
}
void tst_QFile::copy()
@@ -1769,7 +1785,7 @@ void tst_QFile::largeUncFileSupport()
qint64 size = Q_INT64_C(8589934592);
qint64 dataOffset = Q_INT64_C(8589914592);
QByteArray knownData("LargeFile content at offset 8589914592");
- QString largeFile("//" + QtNetworkSettings::winServerName() + "/testsharelargefile/file.bin");
+ QString largeFile("//" + QTest::uncServerName() + "/testsharelargefile/file.bin");
const QByteArray largeFileEncoded = QFile::encodeName(largeFile);
{
@@ -2450,7 +2466,7 @@ void tst_QFile::writeLargeDataBlock_data()
#if defined(Q_OS_WIN) && !defined(QT_NO_NETWORK)
// Some semi-randomness to avoid collisions.
QTest::newRow("unc file")
- << QString("//" + QtNetworkSettings::winServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt")
+ << QString("//" + QTest::uncServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt")
.arg(QHostInfo::localHostName())
.arg(QTime::currentTime().msec()) << (int)OpenQFile;
#endif
@@ -2618,7 +2634,7 @@ static void unixPipe_helper(int pipes[2])
QFile f;
if (useStdio) {
FILE *fh = fdopen(pipes[0], "rb");
- QVERIFY(f.open(fh, QIODevice::ReadOnly | QIODevice::Unbuffered));
+ QVERIFY(f.open(fh, QIODevice::ReadOnly | QIODevice::Unbuffered, QFileDevice::AutoCloseHandle));
} else {
QVERIFY(f.open(pipes[0], QIODevice::ReadOnly | QIODevice::Unbuffered));
}
@@ -2875,7 +2891,7 @@ void tst_QFile::miscWithUncPathAsCurrentDir()
{
#if defined(Q_OS_WIN)
QString current = QDir::currentPath();
- const QString path = QLatin1String("//") + QtNetworkSettings::winServerName()
+ const QString path = QLatin1String("//") + QTest::uncServerName()
+ QLatin1String("/testshare");
QVERIFY2(QDir::setCurrent(path), qPrintable(QDir::toNativeSeparators(path)));
QFile file("test.pri");
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 80f204156e..40f4c57202 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -31,9 +31,6 @@
#endif
#include <qplatformdefs.h>
#include <qdebug.h>
-#if defined(Q_OS_WIN)
-#include "../../../network-settings.h"
-#endif
#include <private/qfileinfo_p.h>
#include "../../../../shared/filesystem.h"
@@ -383,7 +380,7 @@ void tst_QFileInfo::isDir_data()
//QTest::newRow("drive 2") << "t:s" << false;
#endif
#if defined(Q_OS_WIN)
- const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString uncRoot = QStringLiteral("//") + QTest::uncServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
QTest::newRow("unc 3") << uncRoot + "/testshare" << true;
@@ -426,7 +423,7 @@ void tst_QFileInfo::isRoot_data()
#endif
#if defined(Q_OS_WIN)
- const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString uncRoot = QStringLiteral("//") + QTest::uncServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
QTest::newRow("unc 3") << uncRoot + "/testshare" << false;
@@ -470,7 +467,7 @@ void tst_QFileInfo::exists_data()
QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << true;
#if defined(Q_OS_WIN)
- const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString uncRoot = QStringLiteral("//") + QTest::uncServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
QTest::newRow("unc 3") << uncRoot + "/testshare" << true;
@@ -1732,7 +1729,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
{
// Symlink to UNC share
pwd.mkdir("unc");
- QString uncTarget = QStringLiteral("//") + QtNetworkSettings::winServerName() + "/testshare";
+ QString uncTarget = QStringLiteral("//") + QTest::uncServerName() + "/testshare";
QString uncSymlink = QDir::toNativeSeparators(pwd.absolutePath().append("\\unc\\link_to_unc"));
QTest::newRow("UNC symlink")
<< NtfsTestResource(NtfsTestResource::SymLink, uncSymlink, uncTarget)
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index acf26039d1..dfdf4e05c1 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -147,8 +147,8 @@ void tst_QFileSystemWatcher::basicTest()
testFile.close();
// waiting max 5 seconds for notification for file modification to trigger
- QTRY_COMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QTRY_COMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QString fileName = changedSpy.at(0).at(0).toString();
QCOMPARE(fileName, testFile.fileName());
@@ -165,7 +165,7 @@ void tst_QFileSystemWatcher::basicTest()
timer.start(5000);
eventLoop.exec();
- QCOMPARE(changedSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
// readd the file watch with a relative path
const QString relativeTestFileName = QDir::current().relativeFilePath(testFile.fileName());
@@ -175,7 +175,7 @@ void tst_QFileSystemWatcher::basicTest()
testFile.write(QByteArray("hello multiverse!"));
testFile.close();
- QTRY_VERIFY(changedSpy.count() > 0);
+ QTRY_VERIFY(changedSpy.size() > 0);
QVERIFY(watcher.removePath(relativeTestFileName));
@@ -191,8 +191,8 @@ void tst_QFileSystemWatcher::basicTest()
#if !defined(Q_OS_QNX)
// waiting max 5 seconds for notification for file permission modification to trigger
- QTRY_COMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QTRY_COMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
fileName = changedSpy.at(0).at(0).toString();
QCOMPARE(fileName, testFile.fileName());
@@ -209,7 +209,7 @@ void tst_QFileSystemWatcher::basicTest()
timer.start(5000);
eventLoop.exec();
- QCOMPARE(changedSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
// readd the file watch
QVERIFY(watcher.addPath(testFile.fileName()));
@@ -220,8 +220,8 @@ void tst_QFileSystemWatcher::basicTest()
// waiting max 5 seconds for notification for file removal to trigger
// > 0 && < 3 because some platforms may emit two changes
// XXX: which platforms? (QTBUG-23370)
- QTRY_VERIFY(changedSpy.count() > 0 && changedSpy.count() < 3);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QTRY_VERIFY(changedSpy.size() > 0 && changedSpy.size() < 3);
+ QCOMPARE(changedSpy.at(0).size(), 1);
fileName = changedSpy.at(0).at(0).toString();
QCOMPARE(fileName, testFile.fileName());
@@ -237,7 +237,7 @@ void tst_QFileSystemWatcher::basicTest()
timer.start(5000);
eventLoop.exec();
- QCOMPARE(changedSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
QVERIFY(testFile.remove());
}
@@ -301,7 +301,7 @@ void tst_QFileSystemWatcher::watchDirectory()
timer.start(5000);
eventLoop.exec();
- QCOMPARE(changedSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
QVERIFY(watcher.addPaths(testDirs).isEmpty());
@@ -321,10 +321,10 @@ void tst_QFileSystemWatcher::watchDirectory()
signalCounter[testDirName] = 0;
// waiting max 5 seconds for notification for directory removal to trigger
- QTRY_COMPARE(changedSpy.count(), testDirs.size() * 2);
- for (int i = 0; i < changedSpy.count(); i++) {
+ QTRY_COMPARE(changedSpy.size(), testDirs.size() * 2);
+ for (int i = 0; i < changedSpy.size(); i++) {
const auto &signal = changedSpy.at(i);
- QCOMPARE(signal.count(), 1);
+ QCOMPARE(signal.size(), 1);
auto it = signalCounter.find(signal.at(0).toString());
QVERIFY(it != signalCounter.end());
@@ -352,7 +352,7 @@ void tst_QFileSystemWatcher::watchDirectory()
timer.start(5000);
eventLoop.exec();
- QCOMPARE(changedSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
for (const auto &testDirName : testDirs)
QVERIFY(temporaryDir.rmdir(testDirName));
@@ -364,12 +364,12 @@ void tst_QFileSystemWatcher::addPath()
QFileSystemWatcher watcher;
QString home = QDir::homePath();
QVERIFY(watcher.addPath(home));
- QCOMPARE(watcher.directories().count(), 1);
+ QCOMPARE(watcher.directories().size(), 1);
QCOMPARE(watcher.directories().first(), home);
// second watch on an already-watched path should fail
QVERIFY(!watcher.addPath(home));
- QCOMPARE(watcher.directories().count(), 1);
+ QCOMPARE(watcher.directories().size(), 1);
// With empty string
QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::addPath: path is empty");
@@ -382,9 +382,9 @@ void tst_QFileSystemWatcher::removePath()
QString home = QDir::homePath();
QVERIFY(watcher.addPath(home));
QVERIFY(watcher.removePath(home));
- QCOMPARE(watcher.directories().count(), 0);
+ QCOMPARE(watcher.directories().size(), 0);
QVERIFY(!watcher.removePath(home));
- QCOMPARE(watcher.directories().count(), 0);
+ QCOMPARE(watcher.directories().size(), 0);
// With empty string
QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::removePath: path is empty");
@@ -396,8 +396,14 @@ void tst_QFileSystemWatcher::addPaths()
QFileSystemWatcher watcher;
QStringList paths;
paths << QDir::homePath() << QDir::tempPath();
+#ifndef Q_OS_QNX
+ // Adding this makes QNX fail and we haven't investigated why
+ for (const QFileInfo &fi : QDir::drives())
+ paths << fi.absoluteFilePath(); // on Unix, this will be just "/"
+#endif
+
QCOMPARE(watcher.addPaths(paths), QStringList());
- QCOMPARE(watcher.directories().count(), 2);
+ QCOMPARE(watcher.directories().size(), paths.size());
// With empty list
paths.clear();
@@ -464,10 +470,16 @@ void tst_QFileSystemWatcher::removePaths()
QFileSystemWatcher watcher;
QStringList paths;
paths << QDir::homePath() << QDir::tempPath();
+#ifndef Q_OS_QNX
+ // Adding this makes QNX fail and we haven't investigated why
+ for (const QFileInfo &fi : QDir::drives())
+ paths << fi.absoluteFilePath(); // on Unix, this will be just "/"
+#endif
+
QCOMPARE(watcher.addPaths(paths), QStringList());
- QCOMPARE(watcher.directories().count(), 2);
+ QCOMPARE(watcher.directories().size(), paths.size());
QCOMPARE(watcher.removePaths(paths), QStringList());
- QCOMPARE(watcher.directories().count(), 0);
+ QCOMPARE(watcher.directories().size(), 0);
//With empty list
paths.clear();
@@ -556,7 +568,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
QTest::qWait(2000);
#endif
- QTRY_VERIFY(fileChangedSpy.count() > 0);
+ QTRY_VERIFY(fileChangedSpy.size() > 0);
QVERIFY2(dirChangedSpy.count() == 0, dirChangedSpy.receivedFilesMessage());
fileChangedSpy.clear();
@@ -567,7 +579,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
timer.start(3000);
eventLoop.exec();
- int fileChangedSpyCount = fileChangedSpy.count();
+ int fileChangedSpyCount = fileChangedSpy.size();
#ifdef Q_OS_WIN
if (fileChangedSpyCount != 0)
QEXPECT_FAIL("", "See QTBUG-30943", Continue);
@@ -579,7 +591,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
QVERIFY(QFile::remove(testFileName));
- QTRY_VERIFY(fileChangedSpy.count() > 0);
+ QTRY_VERIFY(fileChangedSpy.size() > 0);
QTRY_COMPARE(dirChangedSpy.count(), 1);
fileChangedSpy.clear();
@@ -591,7 +603,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
timer.start(3000);
eventLoop.exec();
- QCOMPARE(fileChangedSpy.count(), 0);
+ QCOMPARE(fileChangedSpy.size(), 0);
QCOMPARE(dirChangedSpy.count(), 1);
// QTBUG-61792, removal should succeed (bug on Windows which uses one change
@@ -613,9 +625,11 @@ void tst_QFileSystemWatcher::nonExistingFile()
QStringList() << "../..//./does-not-exist");
// empty path is not actually a failure
+ QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::addPaths: list is empty");
QCOMPARE(watcher.addPaths(QStringList() << QString()), QStringList());
// empty path is not actually a failure
+ QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::removePaths: list is empty");
QCOMPARE(watcher.removePaths(QStringList() << QString()), QStringList());
}
@@ -694,7 +708,7 @@ void tst_QFileSystemWatcher::QTBUG2331()
// remove directory, we should get one change signal, and we should no longer
// be watching the directory.
QVERIFY(temporaryDirectory.remove());
- QTRY_COMPARE(changedSpy.count(), 1);
+ QTRY_COMPARE(changedSpy.size(), 1);
QCOMPARE(watcher.directories(), QStringList());
}
#endif // QT_BUILD_INTERNAL
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
index 07c2aa27b7..2eb927c429 100644
--- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
@@ -174,13 +174,13 @@ void tst_QIODevice::read_QByteArray()
f.open(QIODevice::ReadOnly);
QByteArray b = f.read(10);
- QCOMPARE(b.length(), 10);
+ QCOMPARE(b.size(), 10);
b = f.read(256);
- QCOMPARE(b.length(), 256);
+ QCOMPARE(b.size(), 256);
b = f.read(0);
- QCOMPARE(b.length(), 0);
+ QCOMPARE(b.size(), 0);
}
//--------------------------------------------------------------------
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index a0a9bb940e..cddaff8957 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -78,7 +78,7 @@ public:
{
QString ret;
QTextStream out(&ret);
- for (int a = 0; a < _configitemEntryOrder.count(); a++) {
+ for (int a = 0; a < _configitemEntryOrder.size(); a++) {
out << _configitemEntryOrder[a]
<< " = "
<< _values.value(_configitemEntryOrder[a]) << Qt::endl;
@@ -153,7 +153,7 @@ inline QString cleanLogLine(const QString &qstring)
buf.remove("../");
buf.remove("qlog/");
QString ret;
- for (int i = 0; i < buf.length(); i++) {
+ for (int i = 0; i < buf.size(); i++) {
if (buf[i] >= '!' && buf[i] <= 'z')
ret += buf[i];
}
@@ -903,7 +903,7 @@ private slots:
buf = QStringLiteral("Digia.Berlin.Office.com.debug: Berlin \"from Thread 2\" :false");
compareagainst.append(cleanLogLine(buf));
- for (int i = 0; i < threadtest.count(); i++) {
+ for (int i = 0; i < threadtest.size(); i++) {
if (!compareagainst.contains(cleanLogLine(threadtest[i]))){
fprintf(stdout, "%s\r\n", threadtest[i].toLatin1().constData());
QVERIFY2(false, "Multithread log is not complete!");
diff --git a/tests/auto/corelib/io/qprocess/testDetached/main.cpp b/tests/auto/corelib/io/qprocess/testDetached/main.cpp
index 57d39f4f13..4282621f0b 100644
--- a/tests/auto/corelib/io/qprocess/testDetached/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testDetached/main.cpp
@@ -41,7 +41,7 @@ struct Args
static Args parseArguments(const QStringList &args)
{
Args result;
- if (args.count() < 2) {
+ if (args.size() < 2) {
result.exitCode = 128;
result.errorMessage = "Usage: testDetached [--out-channel={stdout|stderr}] filename.txt\n";
return result;
diff --git a/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp b/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp
index 1441c8ed0c..ddf0ef0ad7 100644
--- a/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp
@@ -2,6 +2,22 @@
// Copyright (C) 2020 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#if __has_include(<sys/resource.h>)
+# include <sys/resource.h>
+# if defined(RLIMIT_CORE)
+static bool disableCoreDumps()
+{
+ // Unix: set our core dump limit to zero to request no dialogs.
+ if (struct rlimit rlim; getrlimit(RLIMIT_CORE, &rlim) == 0) {
+ rlim.rlim_cur = 0;
+ setrlimit(RLIMIT_CORE, &rlim);
+ }
+ return true;
+}
+static bool disabledCoreDumps = disableCoreDumps();
+# endif // RLIMIT_CORE
+#endif // <sys/resource.h>
+
void crashFallback(volatile int *ptr = nullptr)
{
*ptr = 0;
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index a2b3dfc154..0159c4a385 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -154,6 +154,9 @@ private:
void tst_QProcess::initTestCase()
{
+#if defined(QT_ASAN_ENABLED)
+ QSKIP("Skipping QProcess tests under ASAN as they are flaky (QTBUG-109329)");
+#endif
QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
// chdir to our testdata path and execute helper apps relative to that.
QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessNormal")).absolutePath();
@@ -244,7 +247,7 @@ void tst_QProcess::simpleStart()
process.reset();
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(0).at(0)), QProcess::Starting);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(1).at(0)), QProcess::Running);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning);
@@ -381,10 +384,10 @@ void tst_QProcess::crashTest()
QVERIFY(process->waitForFinished(30000));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit);
QCOMPARE(process->exitStatus(), QProcess::CrashExit);
@@ -392,7 +395,7 @@ void tst_QProcess::crashTest()
// delete process;
process.reset();
- QCOMPARE(stateSpy.count(), 3);
+ QCOMPARE(stateSpy.size(), 3);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(0).at(0)), QProcess::Starting);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(1).at(0)), QProcess::Running);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning);
@@ -419,10 +422,10 @@ void tst_QProcess::crashTest2()
if (QTestEventLoop::instance().timeout())
QFAIL("Failed to detect crash : operation timed out");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit);
QCOMPARE(process.exitStatus(), QProcess::CrashExit);
@@ -528,9 +531,9 @@ void tst_QProcess::echoTest2()
break;
}
- QVERIFY(spy0.count() > 0);
- QVERIFY(spy1.count() > 0);
- QVERIFY(spy2.count() > 0);
+ QVERIFY(spy0.size() > 0);
+ QVERIFY(spy1.size() > 0);
+ QVERIFY(spy2.size() > 0);
QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello"));
QCOMPARE(process.readAllStandardError(), QByteArray("Hello"));
@@ -631,8 +634,8 @@ void tst_QProcess::exitStatus()
QFETCH(QStringList, processList);
QFETCH(QList<QProcess::ExitStatus>, exitStatus);
- QCOMPARE(exitStatus.count(), processList.count());
- for (int i = 0; i < processList.count(); ++i) {
+ QCOMPARE(exitStatus.size(), processList.size());
+ for (int i = 0; i < processList.size(); ++i) {
process.start(processList.at(i));
QVERIFY(process.waitForStarted(5000));
QVERIFY(process.waitForFinished(30000));
@@ -685,7 +688,7 @@ void tst_QProcess::readTimeoutAndThenCrash()
QVERIFY(process.waitForFinished(5000));
QCOMPARE(process.state(), QProcess::NotRunning);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed);
}
@@ -862,7 +865,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
proc.start("testProcessEcho/testProcessEcho");
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
proc.write("A");
@@ -870,7 +873,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
if (QTestEventLoop::instance().timeout())
QFAIL("Operation timed out");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTestEventLoop::instance().enterLoop(1);
QVERIFY(QTestEventLoop::instance().timeout());
@@ -1282,7 +1285,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
QTestEventLoop::instance().enterLoop(30);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
process.disconnect();
QVERIFY(process.waitForFinished(5000));
@@ -1318,7 +1321,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
QTestEventLoop::instance().enterLoop(30);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
process.write("", 1);
process.disconnect();
QVERIFY(process.waitForFinished());
@@ -1508,7 +1511,7 @@ void tst_QProcess::failToStart()
for (int j = 0; j < 8; ++j) {
for (int i = 0; i < attempts; ++i) {
- QCOMPARE(errorSpy.count(), j * attempts + i);
+ QCOMPARE(errorSpy.size(), j * attempts + i);
process.start("/blurp");
switch (j) {
@@ -1532,12 +1535,12 @@ void tst_QProcess::failToStart()
}
QCOMPARE(process.error(), QProcess::FailedToStart);
- QCOMPARE(errorSpy.count(), j * attempts + i + 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(errorSpy.size(), j * attempts + i + 1);
+ QCOMPARE(finishedSpy.size(), 0);
int it = j * attempts + i + 1;
- QCOMPARE(stateSpy.count(), it * 2);
+ QCOMPARE(stateSpy.size(), it * 2);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning);
}
@@ -1561,8 +1564,8 @@ void tst_QProcess::failToStartWithWait()
process.waitForStarted();
QCOMPARE(process.error(), QProcess::FailedToStart);
- QCOMPARE(errorSpy.count(), i + 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(errorSpy.size(), i + 1);
+ QCOMPARE(finishedSpy.size(), 0);
}
}
@@ -1588,8 +1591,8 @@ void tst_QProcess::failToStartWithEventLoop()
loop.exec();
QCOMPARE(process.error(), QProcess::FailedToStart);
- QCOMPARE(errorSpy.count(), i + 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(errorSpy.size(), i + 1);
+ QCOMPARE(finishedSpy.size(), 0);
}
}
@@ -1621,7 +1624,7 @@ void tst_QProcess::failToStartEmptyArgs()
};
QVERIFY(!process.waitForStarted());
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(process.error(), QProcess::FailedToStart);
}
@@ -1860,9 +1863,9 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
QVERIFY(!process.waitForReadyRead()); // used to crash
process.start("doesntexist");
QVERIFY(!process.waitForReadyRead());
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(errorSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
}
void tst_QProcess::setStandardInputFile()
@@ -2317,7 +2320,7 @@ void tst_QProcess::invalidProgramString()
process.start(programString);
QCOMPARE(process.error(), QProcess::FailedToStart);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!QProcess::startDetached(programString));
}
@@ -2336,8 +2339,8 @@ void tst_QProcess::onlyOneStartedSignal()
process.start("testProcessNormal/testProcessNormal");
QVERIFY(process.waitForStarted(5000));
QVERIFY(process.waitForFinished(5000));
- QCOMPARE(spyStarted.count(), 1);
- QCOMPARE(spyFinished.count(), 1);
+ QCOMPARE(spyStarted.size(), 1);
+ QCOMPARE(spyFinished.size(), 1);
spyStarted.clear();
spyFinished.clear();
@@ -2346,8 +2349,8 @@ void tst_QProcess::onlyOneStartedSignal()
QVERIFY(process.waitForFinished(5000));
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
- QCOMPARE(spyStarted.count(), 1);
- QCOMPARE(spyFinished.count(), 1);
+ QCOMPARE(spyStarted.size(), 1);
+ QCOMPARE(spyFinished.size(), 1);
}
class BlockOnReadStdOut : public QObject
@@ -2597,7 +2600,7 @@ void tst_QProcess::startFromCurrentWorkingDir()
}
QCOMPARE(process.waitForStarted(), success);
- QCOMPARE(errorSpy.count(), int(!success));
+ QCOMPARE(errorSpy.size(), int(!success));
if (success) {
QVERIFY(process.waitForFinished());
} else {
diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
index 32a12c30bd..9bf8508697 100644
--- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
+++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
@@ -130,7 +130,7 @@ void tst_QProcessEnvironment::toStringList()
e.insert("FOO", "bar");
QStringList result = e.toStringList();
QVERIFY(!result.isEmpty());
- QCOMPARE(result.length(), 1);
+ QCOMPARE(result.size(), 1);
QCOMPARE(result.at(0), QString("FOO=bar"));
e.clear();
@@ -142,7 +142,7 @@ void tst_QProcessEnvironment::toStringList()
e.insert("A", "bc");
e.insert("HELLO", "World");
result = e.toStringList();
- QCOMPARE(result.length(), 4);
+ QCOMPARE(result.size(), 4);
// order is not specified, so use contains()
QVERIFY(result.contains("FOO=bar"));
@@ -159,7 +159,7 @@ void tst_QProcessEnvironment::keys()
e.insert("FOO", "bar");
QStringList result = e.keys();
- QCOMPARE(result.length(), 1);
+ QCOMPARE(result.size(), 1);
QCOMPARE(result.at(0), QString("FOO"));
e.clear();
@@ -171,7 +171,7 @@ void tst_QProcessEnvironment::keys()
e.insert("A", "bc");
e.insert("HELLO", "World");
result = e.keys();
- QCOMPARE(result.length(), 4);
+ QCOMPARE(result.size(), 4);
// order is not specified, so use contains()
QVERIFY(result.contains("FOO"));
@@ -194,7 +194,7 @@ void tst_QProcessEnvironment::insertEnv()
e.insert(e2);
QStringList keys = e.keys();
- QCOMPARE(keys.length(), 5);
+ QCOMPARE(keys.size(), 5);
QCOMPARE(e.value("FOO"), QString("bar"));
QCOMPARE(e.value("A"), QString("bc"));
@@ -244,7 +244,7 @@ void tst_QProcessEnvironment::caseSensitivity()
QCOMPARE(e.value("foo"), QString("bar"));
QStringList list = e.toStringList();
- QCOMPARE(list.length(), 2);
+ QCOMPARE(list.size(), 2);
QVERIFY(list.contains("foo=bar"));
QVERIFY(list.contains("FOO=baz"));
#endif
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index 13508d953a..1631222c08 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -37,6 +37,7 @@ private slots:
void searchPath_data();
void searchPath();
void doubleSlashInRoot();
+ void setLocale_data();
void setLocale();
void lastModified();
void resourcesInStaticPlugins();
@@ -556,13 +557,22 @@ void tst_QResourceEngine::doubleSlashInRoot()
QVERIFY(QFile::exists("://secondary_root/runtime_resource/search_file.txt"));
}
+void tst_QResourceEngine::setLocale_data()
+{
+ QTest::addColumn<QString>("prefix");
+ QTest::newRow("built-in") << QString();
+ QTest::newRow("runtime") << "/runtime_resource/";
+}
+
void tst_QResourceEngine::setLocale()
{
+ QFETCH(QString, prefix);
QLocale::setDefault(QLocale::c());
// default constructed QResource gets the default locale
QResource resource;
- resource.setFileName("aliasdir/aliasdir.txt");
+ resource.setFileName(prefix + "aliasdir/aliasdir.txt");
+ QVERIFY(resource.isValid());
QCOMPARE(resource.compressionAlgorithm(), QResource::NoCompression);
// change the default locale and make sure it doesn't affect the resource
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 19ed36589e..753d3f8b8a 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -550,7 +550,7 @@ void tst_QSettings::ctor()
QCOMPARE(settings1.value("alpha/beta/geometry/width").toInt(), 3);
QCOMPARE(settings1.value("alpha/beta/geometry/height").toInt(), 4);
QCOMPARE(settings1.value("alpha/gamma/splitter").toInt(), 5);
- QCOMPARE(settings1.allKeys().count(), 6);
+ QCOMPARE(settings1.allKeys().size(), 6);
QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), -7);
QCOMPARE(settings2.value("alpha/beta/geometry/x").toInt(), 1);
@@ -558,7 +558,7 @@ void tst_QSettings::ctor()
QCOMPARE(settings2.value("alpha/beta/geometry/width").toInt(), 3);
QCOMPARE(settings2.value("alpha/beta/geometry/height").toInt(), 4);
QCOMPARE(settings2.value("alpha/gamma/splitter").toInt(), 5);
- QCOMPARE(settings2.allKeys().count(), 6);
+ QCOMPARE(settings2.allKeys().size(), 6);
}
{
@@ -569,7 +569,7 @@ void tst_QSettings::ctor()
QCOMPARE(settings1.value("alpha/beta/geometry/width").toInt(), 3);
QCOMPARE(settings1.value("alpha/beta/geometry/height").toInt(), 4);
QCOMPARE(settings1.value("alpha/gamma/splitter").toInt(), 5);
- QCOMPARE(settings1.allKeys().count(), 6);
+ QCOMPARE(settings1.allKeys().size(), 6);
}
{
@@ -1731,12 +1731,12 @@ void tst_QSettings::sync()
QCOMPARE(settings2.value("moo/beta/geometry/width").toInt(), 3);
QCOMPARE(settings2.value("moo/beta/geometry/height").toInt(), 4);
QCOMPARE(settings2.value("moo/gamma/splitter").toInt(), 5);
- QCOMPARE(settings2.allKeys().count(), 11);
+ QCOMPARE(settings2.allKeys().size(), 11);
// Now, software.org.ini no longer exists, this is same as another app
// clearing all settings.
settings1.sync();
- QCOMPARE(settings1.allKeys().count(), 0);
+ QCOMPARE(settings1.allKeys().size(), 0);
// Now "some other app" will change software.org.ini
QVERIFY(QFile::rename((userConfDir + "other.software.org.ini").toLatin1(),
@@ -1754,7 +1754,7 @@ void tst_QSettings::sync()
QCOMPARE(settings1.value("moo/beta/geometry/width").toInt(), 3);
QCOMPARE(settings1.value("moo/beta/geometry/height").toInt(), 4);
QCOMPARE(settings1.value("moo/gamma/splitter").toInt(), 5);
- QCOMPARE(settings1.allKeys().count(), 11);
+ QCOMPARE(settings1.allKeys().size(), 11);
}
void tst_QSettings::syncNonWriteableDir()
@@ -2441,17 +2441,17 @@ void tst_QSettings::testArrays()
QCOMPARE(settings1.value("ene").toInt(), 2);
QCOMPARE(settings1.value("due").toInt(), 3);
QCOMPARE(settings1.value("rike").toInt(), 4);
- QCOMPARE(settings1.allKeys().count(), 3);
+ QCOMPARE(settings1.allKeys().size(), 3);
settings1.setArrayIndex(1);
QCOMPARE(settings1.value("ene").toInt(), 5);
QCOMPARE(settings1.value("due").toInt(), 6);
QCOMPARE(settings1.value("rike").toInt(), 7);
- QCOMPARE(settings1.allKeys().count(), 3);
+ QCOMPARE(settings1.allKeys().size(), 3);
settings1.setArrayIndex(2);
QCOMPARE(settings1.value("ene").toInt(), 8);
QCOMPARE(settings1.value("due").toInt(), 9);
QCOMPARE(settings1.value("rike").toInt(), 10);
- QCOMPARE(settings1.allKeys().count(), 3);
+ QCOMPARE(settings1.allKeys().size(), 3);
settings1.endArray();
settings1.endGroup();
@@ -2501,17 +2501,17 @@ void tst_QSettings::testArrays()
QCOMPARE(settings1.value("ene").toInt(), 2);
QCOMPARE(settings1.value("due").toInt(), 3);
QCOMPARE(settings1.value("rike").toInt(), 4);
- QCOMPARE(settings1.allKeys().count(), 3);
+ QCOMPARE(settings1.allKeys().size(), 3);
settings1.setArrayIndex(1);
QCOMPARE(settings1.value("ene").toInt(), 5);
QCOMPARE(settings1.value("due").toInt(), 6);
QCOMPARE(settings1.value("rike").toInt(), 7);
- QCOMPARE(settings1.allKeys().count(), 3);
+ QCOMPARE(settings1.allKeys().size(), 3);
settings1.setArrayIndex(2);
QCOMPARE(settings1.value("ene").toInt(), 8);
QCOMPARE(settings1.value("due").toInt(), 9);
QCOMPARE(settings1.value("rike").toInt(), 10);
- QCOMPARE(settings1.allKeys().count(), 3);
+ QCOMPARE(settings1.allKeys().size(), 3);
settings1.endArray();
settings1.endGroup();
@@ -2683,7 +2683,7 @@ QString escapeWeirdChars(const QString &s)
QString result;
bool escapeNextDigit = false;
- for (int i = 0; i < s.length(); ++i) {
+ for (int i = 0; i < s.size(); ++i) {
QChar c = s.at(i);
if (c.unicode() < ' ' || c.unicode() > '~'
|| (escapeNextDigit && c.unicode() >= '0' && c.unicode() <= 'f')) {
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 2c0500eec9..d37651bd7a 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -24,6 +24,8 @@
#define Q_XDG_PLATFORM
#endif
+using namespace Qt::StringLiterals;
+
// Update this when adding new enum values; update enumNames too
static const int MaxStandardLocation = QStandardPaths::AppConfigLocation;
@@ -147,12 +149,12 @@ void tst_qstandardpaths::testDefaultLocations()
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), expectedConfHome);
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), expectedConfHome);
const QStringList confDirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
- QCOMPARE(confDirs.count(), 2);
+ QCOMPARE(confDirs.size(), 2);
QVERIFY(confDirs.contains(expectedConfHome));
QCOMPARE(QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation), confDirs);
const QStringList genericDataDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
- QCOMPARE(genericDataDirs.count(), 3);
+ QCOMPARE(genericDataDirs.size(), 3);
const QString expectedDataHome = QDir::homePath() + QString::fromLatin1("/.local/share");
QCOMPARE(genericDataDirs.at(0), expectedDataHome);
QCOMPARE(genericDataDirs.at(1), QString::fromLatin1("/usr/local/share"));
@@ -260,7 +262,7 @@ void tst_qstandardpaths::testLocateAll()
#ifdef Q_XDG_PLATFORM
setCustomLocations();
const QStringList appsDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "applications", QStandardPaths::LocateDirectory);
- QCOMPARE(appsDirs.count(), 0); // they don't exist yet
+ QCOMPARE(appsDirs.size(), 0); // they don't exist yet
const QStringList expectedAppsDirs = QStringList() << m_localAppDir + QLatin1String("/applications")
<< m_globalAppDir + QLatin1String("/applications");
QDir().mkdir(expectedAppsDirs.at(0));
@@ -301,7 +303,7 @@ void tst_qstandardpaths::testDataLocation()
const QString expectedAppDataDir = QDir::homePath() + QString::fromLatin1("/.local/share/Qt/QtTest");
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), expectedAppDataDir);
const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation);
- QCOMPARE(appDataDirs.count(), 3);
+ QCOMPARE(appDataDirs.size(), 3);
QCOMPARE(appDataDirs.at(0), expectedAppDataDir);
QCOMPARE(appDataDirs.at(1), QString::fromLatin1("/usr/local/share/Qt/QtTest"));
QCOMPARE(appDataDirs.at(2), QString::fromLatin1("/usr/share/Qt/QtTest"));
@@ -724,6 +726,31 @@ void tst_qstandardpaths::testXdgPathCleanup()
QVERIFY(!appsDirs.contains("/applications"));
QVERIFY(!appsDirs.contains(uncleanGlobalAppDir + "/applications"));
QVERIFY(!appsDirs.contains("relative/path/applications"));
+
+ const QString uncleanGlobalConfigDir = "/./" + QFile::encodeName(m_globalConfigDir);
+ qputenv("XDG_CONFIG_DIRS", QFile::encodeName(uncleanGlobalConfigDir) + "::relative/path");
+ const QStringList configDirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
+ QVERIFY(!configDirs.contains("relative/path"_L1));
+ QVERIFY(!configDirs.contains(""_L1));
+
+ // Relative paths in XDG_* env vars are ignored
+ const QString relative("./someRelativeDir");
+
+ qputenv("XDG_CACHE_HOME", relative.toLatin1());
+ const QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ QCOMPARE_NE(cacheDir, relative);
+
+ qputenv("XDG_DATA_HOME", relative.toLatin1());
+ const QString localDataDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
+ QCOMPARE_NE(localDataDir, relative);
+
+ qputenv("XDG_CONFIG_HOME", relative.toLatin1());
+ const QString localConfig = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
+ QCOMPARE_NE(localConfig, relative);
+
+ qputenv("XDG_RUNTIME_DIR", relative.toLatin1());
+ const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
+ QCOMPARE_NE(runtimeDir, relative);
#endif
}
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 7761ac5a6a..227c6260d3 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -229,9 +229,9 @@ void tst_QTemporaryDir::fileTemplate()
QVERIFY(tempDir.isValid());
QString dirName = QDir(tempDir.path()).dirName();
- if (prefix.length()) {
- QCOMPARE(dirName.left(prefix.length()), prefix);
- QCOMPARE(dirName.right(suffix.length()), suffix);
+ if (prefix.size()) {
+ QCOMPARE(dirName.left(prefix.size()), prefix);
+ QCOMPARE(dirName.right(suffix.size()), suffix);
}
}
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index ba37285d5f..556571b346 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -230,11 +230,11 @@ void tst_QTemporaryFile::fileTemplate()
QVERIFY2(file.open(), qPrintable(file.errorString()));
QString fileName = QFileInfo(file).fileName();
- if (prefix.length())
- QCOMPARE(fileName.left(prefix.length()), prefix);
+ if (prefix.size())
+ QCOMPARE(fileName.left(prefix.size()), prefix);
- if (suffix.length())
- QCOMPARE(fileName.right(suffix.length()), suffix);
+ if (suffix.size())
+ QCOMPARE(fileName.right(suffix.size()), suffix);
}
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 48ffa09906..7de738a83b 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1090,7 +1090,7 @@ void tst_QUrl::toAndFromStringList()
QFETCH(QStringList, strings);
const QList<QUrl> urls = QUrl::fromStringList(strings);
- QCOMPARE(urls.count(), strings.count());
+ QCOMPARE(urls.size(), strings.size());
const QStringList converted = QUrl::toStringList(urls);
QCOMPARE(converted, strings);
}
@@ -3799,106 +3799,106 @@ void tst_QUrl::setComponents_data()
QTest::newRow("invalid-username-1") << QUrl("http://example.com")
<< int(UserName) << "{}" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-username-2") << QUrl("http://example.com")
<< int(UserName) << "foo/bar" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-username-3") << QUrl("http://example.com")
<< int(UserName) << "foo:bar" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-password-1") << QUrl("http://example.com")
<< int(Password) << "{}" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-password-2") << QUrl("http://example.com")
<< int(Password) << "foo/bar" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-password-3") << QUrl("http://example.com")
<< int(Password) << "foo:bar" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-userinfo-1") << QUrl("http://example.com")
<< int(UserInfo) << "{}" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-userinfo-2") << QUrl("http://example.com")
<< int(UserInfo) << "foo/bar" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-host-1") << QUrl("http://example.com")
<< int(Host) << "-not-valid-" << Tolerant << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-host-2") << QUrl("http://example.com")
<< int(Host) << "%31%30.%30.%30.%31" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-authority-1") << QUrl("http://example.com")
<< int(Authority) << "-not-valid-" << Tolerant << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-authority-2") << QUrl("http://example.com")
<< int(Authority) << "%31%30.%30.%30.%31" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-path-0") << QUrl("http://example.com")
<< int(Path) << "{}" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-query-1") << QUrl("http://example.com")
<< int(Query) << "{}" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("invalid-fragment-1") << QUrl("http://example.com")
<< int(Fragment) << "{}" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
// these test cases are "compound invalid":
// they produces isValid == false, but the original is still available
QTest::newRow("invalid-path-1") << QUrl("/relative")
<< int(Path) << "c:/" << Strict << false
- << PrettyDecoded << "c:/" << "";
+ << PrettyDecoded << "c:/" << QString();
QTest::newRow("invalid-path-2") << QUrl("http://example.com")
<< int(Path) << "relative" << Strict << false
- << PrettyDecoded << "relative" << "";
+ << PrettyDecoded << "relative" << QString();
QTest::newRow("invalid-path-3") << QUrl("trash:/")
<< int(Path) << "//path" << Tolerant << false
- << PrettyDecoded << "//path" << "";
+ << PrettyDecoded << "//path" << QString();
// -- test bad percent encoding --
// unnecessary to test the scheme, since percent-decoding is not performed in it;
// see tests above
QTest::newRow("bad-percent-username") << QUrl("http://example.com")
<< int(UserName) << "bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-password") << QUrl("http://user@example.com")
<< int(Password) << "bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-userinfo-1") << QUrl("http://example.com")
<< int(UserInfo) << "bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-userinfo-2") << QUrl("http://example.com")
<< int(UserInfo) << "bar%:foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-userinfo-3") << QUrl("http://example.com")
<< int(UserInfo) << "bar:%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-authority-1") << QUrl("http://example.com")
<< int(Authority) << "bar%foo@example.org" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-authority-2") << QUrl("http://example.com")
<< int(Authority) << "bar%:foo@example.org" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-authority-3") << QUrl("http://example.com")
<< int(Authority) << "bar:%foo@example.org" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-authority-4") << QUrl("http://example.com")
<< int(Authority) << "bar:foo@bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-host") << QUrl("http://example.com")
<< int(Host) << "bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-path") << QUrl("http://example.com")
<< int(Path) << "/bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-query") << QUrl("http://example.com")
<< int(Query) << "bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("bad-percent-fragment") << QUrl("http://example.com")
<< int(Fragment) << "bar%foo" << Strict << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
// -- test decoded behaviour --
// '%' characters are not permitted in the scheme, this tests that it fails to set anything
@@ -3914,7 +3914,7 @@ void tst_QUrl::setComponents_data()
// '%' characters are not permitted in the hostname, these test that it fails to set anything
QTest::newRow("invalid-host-encode") << QUrl("http://example.com")
<< int(Host) << "ex%61mple.com" << Decoded << false
- << PrettyDecoded << "" << "";
+ << PrettyDecoded << QString() << QString();
QTest::newRow("path-encode") << QUrl("http://example.com/foo")
<< int(Path) << "/bar%23" << Decoded << true
<< PrettyDecoded << "/bar%2523" << "http://example.com/bar%2523";
@@ -3953,41 +3953,44 @@ void tst_QUrl::setComponents()
QFETCH(int, encoding);
QFETCH(QString, output);
+#define QNULLCOMPARE(a, b) \
+ do { QCOMPARE(a, b); QCOMPARE(a.isNull(), b.isNull()); } while (false)
+
switch (component) {
case Scheme:
// scheme is only parsed in strict mode
copy.setScheme(newValue);
- QCOMPARE(copy.scheme(), output);
+ QCOMPARE(copy.scheme(), output); // schemes don't become null
break;
case Path:
copy.setPath(newValue, QUrl::ParsingMode(parsingMode));
- QCOMPARE(copy.path(QUrl::ComponentFormattingOptions(encoding)), output);
+ QNULLCOMPARE(copy.path(QUrl::ComponentFormattingOptions(encoding)), output);
break;
case UserInfo:
copy.setUserInfo(newValue, QUrl::ParsingMode(parsingMode));
- QCOMPARE(copy.userInfo(QUrl::ComponentFormattingOptions(encoding)), output);
+ QNULLCOMPARE(copy.userInfo(QUrl::ComponentFormattingOptions(encoding)), output);
break;
case UserName:
copy.setUserName(newValue, QUrl::ParsingMode(parsingMode));
- QCOMPARE(copy.userName(QUrl::ComponentFormattingOptions(encoding)), output);
+ QNULLCOMPARE(copy.userName(QUrl::ComponentFormattingOptions(encoding)), output);
break;
case Password:
copy.setPassword(newValue, QUrl::ParsingMode(parsingMode));
- QCOMPARE(copy.password(QUrl::ComponentFormattingOptions(encoding)), output);
+ QNULLCOMPARE(copy.password(QUrl::ComponentFormattingOptions(encoding)), output);
break;
case Host:
copy.setHost(newValue, QUrl::ParsingMode(parsingMode));
- QCOMPARE(copy.host(QUrl::ComponentFormattingOptions(encoding)), output);
+ QNULLCOMPARE(copy.host(QUrl::ComponentFormattingOptions(encoding)), output);
break;
case Authority:
copy.setAuthority(newValue, QUrl::ParsingMode(parsingMode));
- QCOMPARE(copy.authority(QUrl::ComponentFormattingOptions(encoding)), output);
+ QNULLCOMPARE(copy.authority(QUrl::ComponentFormattingOptions(encoding)), output);
break;
case Query:
@@ -4002,6 +4005,7 @@ void tst_QUrl::setComponents()
QCOMPARE(copy.fragment(QUrl::ComponentFormattingOptions(encoding)), output);
break;
}
+#undef QNULLCOMPARE
QFETCH(bool, isValid);
QCOMPARE(copy.isValid(), isValid);
diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
index aa7564f300..d2767f5082 100644
--- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
+++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
@@ -721,7 +721,7 @@ void tst_QUrlInternal::encodingRecodeInvalidUtf8()
output = QTest::currentDataTag();
if (!qt_urlRecode(output, input, QUrl::FullyEncoded))
output += input;
- for (int i = int(strlen(QTest::currentDataTag())); i < output.length(); ++i) {
+ for (int i = int(strlen(QTest::currentDataTag())); i < output.size(); ++i) {
QVERIFY2(output.at(i).unicode() < 0x80 || output.at(i) == QChar::ReplacementCharacter,
qPrintable(QString("Character at i == %1 was U+%2").arg(i).arg(output.at(i).unicode(), 4, 16, QLatin1Char('0'))));
}
diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
index 43a407da9d..906670809f 100644
--- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
+++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
@@ -210,22 +210,25 @@ void tst_QUrlQuery::constructing()
void tst_QUrlQuery::addRemove()
{
QUrlQuery query;
+ QCOMPARE(query, query);
{
// one item
query.addQueryItem("a", "b");
QVERIFY(!query.isEmpty());
QVERIFY(query.hasQueryItem("a"));
+ QCOMPARE_NE(query, QUrlQuery());
QCOMPARE(query.queryItemValue("a"), QString("b"));
QCOMPARE(query.allQueryItemValues("a"), QStringList() << "b");
QList<QPair<QString, QString> > allItems = query.queryItems();
- QCOMPARE(allItems.count(), 1);
+ QCOMPARE(allItems.size(), 1);
QCOMPARE(allItems.at(0).first, QString("a"));
QCOMPARE(allItems.at(0).second, QString("b"));
}
QUrlQuery original = query;
+ QCOMPARE(query, original);
{
// two items
@@ -238,7 +241,7 @@ void tst_QUrlQuery::addRemove()
QCOMPARE(query.allQueryItemValues("c"), QStringList() << "d");
QList<QPair<QString, QString> > allItems = query.queryItems();
- QCOMPARE(allItems.count(), 2);
+ QCOMPARE(allItems.size(), 2);
QVERIFY(allItems.contains(qItem("a", "b")));
QVERIFY(allItems.contains(qItem("c", "d")));
@@ -261,7 +264,7 @@ void tst_QUrlQuery::addRemove()
QCOMPARE(query.allQueryItemValues("a"), QStringList() << "b");
QList<QPair<QString, QString> > allItems = query.queryItems();
- QCOMPARE(allItems.count(), 1);
+ QCOMPARE(allItems.size(), 1);
QCOMPARE(allItems.at(0).first, QString("a"));
QCOMPARE(allItems.at(0).second, QString("b"));
@@ -285,7 +288,7 @@ void tst_QUrlQuery::addRemove()
QCOMPARE(query.allQueryItemValues("e"), QStringList() << emptyButNotNull);
QList<QPair<QString, QString> > allItems = query.queryItems();
- QCOMPARE(allItems.count(), 2);
+ QCOMPARE(allItems.size(), 2);
QVERIFY(allItems.contains(qItem("a", "b")));
QVERIFY(allItems.contains(qItem("e", emptyButNotNull)));
@@ -298,6 +301,9 @@ void tst_QUrlQuery::addRemove()
query.removeQueryItem("a");
query.removeQueryItem("e");
QVERIFY(query.isEmpty());
+ QVERIFY(query.isDetached());
+ QCOMPARE_NE(query, original);
+ QCOMPARE(query, QUrlQuery());
}
}
diff --git a/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp b/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp
index e36642974a..9d738941ef 100644
--- a/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp
+++ b/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp
@@ -50,7 +50,7 @@ void tst_QUrlUts46::idnaTestV2_data()
Q_ASSERT(s.startsWith('[') && s.endsWith(']'));
- const auto errors = s.sliced(1, s.length() - 2).split(',');
+ const auto errors = s.sliced(1, s.size() - 2).split(',');
// NOTE: empty string is not in fatalErrors and it's ok
return std::all_of(errors.begin(), errors.end(),
[](auto &e) { return !fatalErrors.contains(e.trimmed()); });
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 423cc1bdc8..ddeb9da649 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -156,8 +156,8 @@ QtTestModel::QtTestModel(const QList<QList<QString> > tbl, QObject *parent)
: QAbstractItemModel(parent), wrongIndex(false)
{
table = tbl;
- rCount = tbl.count();
- cCount = tbl.at(0).count();
+ rCount = tbl.size();
+ cCount = tbl.at(0).size();
}
QModelIndex QtTestModel::index(int row, int column, const QModelIndex &parent) const
@@ -191,7 +191,7 @@ bool QtTestModel::insertRows(int row, int count, const QModelIndex &parent)
QAbstractItemModel::beginInsertRows(parent, row, row + count - 1);
int cc = columnCount(parent);
table.insert(row, count, QList<QString>(cc));
- rCount = table.count();
+ rCount = table.size();
QAbstractItemModel::endInsertRows();
return true;
}
@@ -202,7 +202,7 @@ bool QtTestModel::insertColumns(int column, int count, const QModelIndex &parent
int rc = rowCount(parent);
for (int i = 0; i < rc; ++i)
table[i].insert(column, 1, "");
- cCount = table.at(0).count();
+ cCount = table.at(0).size();
QAbstractItemModel::endInsertColumns();
return true;
}
@@ -218,7 +218,7 @@ bool QtTestModel::removeRows( int row, int count, const QModelIndex & parent)
for (int r = row+count-1; r >= row; --r)
table.remove(r);
- rCount = table.count();
+ rCount = table.size();
QAbstractItemModel::endRemoveRows();
return true;
@@ -232,7 +232,7 @@ bool QtTestModel::removeColumns(int column, int count, const QModelIndex & paren
for (int r = 0; r < rCount; ++r)
table[r].remove(c);
- cCount = table.at(0).count();
+ cCount = table.at(0).size();
QAbstractItemModel::endRemoveColumns();
return true;
@@ -260,7 +260,7 @@ bool QtTestModel::moveRows(const QModelIndex &sourceParent, int src, int cnt,
}
}
- rCount = table.count();
+ rCount = table.size();
QAbstractItemModel::endMoveRows();
return true;
@@ -290,7 +290,7 @@ bool QtTestModel::moveColumns(const QModelIndex &sourceParent, int src, int cnt,
}
}
- cCount = table.at(0).count();
+ cCount = table.at(0).size();
QAbstractItemModel::endMoveColumns();
return true;
@@ -418,7 +418,7 @@ void tst_QAbstractItemModel::match()
QModelIndex start = model.index(0, 0, QModelIndex());
QVERIFY(start.isValid());
QModelIndexList res = model.match(start, Qt::DisplayRole, QVariant("1"), 3);
- QCOMPARE(res.count(), 1);
+ QCOMPARE(res.size(), 1);
QModelIndex idx = model.index(1, 0, QModelIndex());
bool areEqual = (idx == res.first());
QVERIFY(areEqual);
@@ -429,42 +429,42 @@ void tst_QAbstractItemModel::match()
model.setData(model.index(3, 0, QModelIndex()), "boar", Qt::DisplayRole);
res = model.match(start, Qt::DisplayRole, QVariant("dog"), -1, Qt::MatchExactly);
- QCOMPARE(res.count(), 1);
+ QCOMPARE(res.size(), 1);
res = model.match(start, Qt::DisplayRole, QVariant("a"), -1, Qt::MatchContains);
- QCOMPARE(res.count(), 3);
+ QCOMPARE(res.size(), 3);
res = model.match(start, Qt::DisplayRole, QVariant("b"), -1, Qt::MatchStartsWith);
- QCOMPARE(res.count(), 2);
+ QCOMPARE(res.size(), 2);
res = model.match(start, Qt::DisplayRole, QVariant("t"), -1, Qt::MatchEndsWith);
- QCOMPARE(res.count(), 2);
+ QCOMPARE(res.size(), 2);
res = model.match(start, Qt::DisplayRole, QVariant("*a*"), -1, Qt::MatchWildcard);
- QCOMPARE(res.count(), 3);
+ QCOMPARE(res.size(), 3);
res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, Qt::MatchRegularExpression);
- QCOMPARE(res.count(), 2);
+ QCOMPARE(res.size(), 2);
res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, Qt::MatchRegularExpression | Qt::MatchCaseSensitive);
- QCOMPARE(res.count(), 0);
+ QCOMPARE(res.size(), 0);
res = model.match(start, Qt::DisplayRole, QVariant("BOAR"), -1, Qt::MatchFixedString);
- QCOMPARE(res.count(), 1);
+ QCOMPARE(res.size(), 1);
res = model.match(start, Qt::DisplayRole, QVariant("bat"), -1,
Qt::MatchFixedString | Qt::MatchCaseSensitive);
- QCOMPARE(res.count(), 1);
+ QCOMPARE(res.size(), 1);
res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1,
Qt::MatchRegularExpression);
- QCOMPARE(res.count(), 2);
+ QCOMPARE(res.size(), 2);
res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1,
Qt::MatchRegularExpression | Qt::MatchCaseSensitive);
- QCOMPARE(res.count(), 0);
+ QCOMPARE(res.size(), 0);
res = model.match(start, Qt::DisplayRole, QVariant(QRegularExpression(".*O.*")),
-1, Qt::MatchRegularExpression);
- QCOMPARE(res.count(), 0);
+ QCOMPARE(res.size(), 0);
res = model.match(start,
Qt::DisplayRole,
QVariant(QRegularExpression(".*O.*",
QRegularExpression::CaseInsensitiveOption)),
-1,
Qt::MatchRegularExpression);
- QCOMPARE(res.count(), 2);
+ QCOMPARE(res.size(), 2);
// Ensure that the case sensitivity is properly ignored when passing a
// QRegularExpression object.
@@ -474,7 +474,7 @@ void tst_QAbstractItemModel::match()
QRegularExpression::CaseInsensitiveOption)),
-1,
Qt::MatchRegularExpression | Qt::MatchCaseSensitive);
- QCOMPARE(res.count(), 2);
+ QCOMPARE(res.size(), 2);
}
typedef QPair<int, int> Position;
@@ -757,7 +757,7 @@ void tst_QAbstractItemModel::dropMimeData()
// get the mimeData from the "selected" indexes
QModelIndexList selectedIndexes;
- for (int i = 0; i < selection.count(); ++i)
+ for (int i = 0; i < selection.size(); ++i)
selectedIndexes << src.index(selection.at(i).first, selection.at(i).second, QModelIndex());
QMimeData *md = src.mimeData(selectedIndexes);
// do the drop
@@ -828,8 +828,8 @@ void tst_QAbstractItemModel::removeRows()
QVERIFY(rowsRemovedSpy.isValid());
QCOMPARE(model.removeRows(6, 4), true);
- QCOMPARE(rowsAboutToBeRemovedSpy.count(), 1);
- QCOMPARE(rowsRemovedSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeRemovedSpy.size(), 1);
+ QCOMPARE(rowsRemovedSpy.size(), 1);
}
void tst_QAbstractItemModel::removeColumns()
@@ -843,8 +843,8 @@ void tst_QAbstractItemModel::removeColumns()
QVERIFY(columnsRemovedSpy.isValid());
QCOMPARE(model.removeColumns(6, 4), true);
- QCOMPARE(columnsAboutToBeRemovedSpy.count(), 1);
- QCOMPARE(columnsRemovedSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeRemovedSpy.size(), 1);
+ QCOMPARE(columnsRemovedSpy.size(), 1);
}
void tst_QAbstractItemModel::insertRows()
@@ -858,8 +858,8 @@ void tst_QAbstractItemModel::insertRows()
QVERIFY(rowsInsertedSpy.isValid());
QCOMPARE(model.insertRows(6, 4), true);
- QCOMPARE(rowsAboutToBeInsertedSpy.count(), 1);
- QCOMPARE(rowsInsertedSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeInsertedSpy.size(), 1);
+ QCOMPARE(rowsInsertedSpy.size(), 1);
}
void tst_QAbstractItemModel::insertColumns()
@@ -873,8 +873,8 @@ void tst_QAbstractItemModel::insertColumns()
QVERIFY(columnsInsertedSpy.isValid());
QCOMPARE(model.insertColumns(6, 4), true);
- QCOMPARE(columnsAboutToBeInsertedSpy.count(), 1);
- QCOMPARE(columnsInsertedSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeInsertedSpy.size(), 1);
+ QCOMPARE(columnsInsertedSpy.size(), 1);
}
void tst_QAbstractItemModel::moveRows()
@@ -888,8 +888,8 @@ void tst_QAbstractItemModel::moveRows()
QVERIFY(rowsMovedSpy.isValid());
QCOMPARE(model.moveRows(QModelIndex(), 6, 4, QModelIndex(), 1), true);
- QCOMPARE(rowsAboutToBeMovedSpy.count(), 1);
- QCOMPARE(rowsMovedSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeMovedSpy.size(), 1);
+ QCOMPARE(rowsMovedSpy.size(), 1);
}
void tst_QAbstractItemModel::moveColumns()
@@ -903,12 +903,12 @@ void tst_QAbstractItemModel::moveColumns()
QVERIFY(columnsMovedSpy.isValid());
QCOMPARE(model.moveColumns(QModelIndex(), 6, 4, QModelIndex(), 1), true);
- QCOMPARE(columnsAboutToBeMovedSpy.count(), 1);
- QCOMPARE(columnsMovedSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeMovedSpy.size(), 1);
+ QCOMPARE(columnsMovedSpy.size(), 1);
QCOMPARE(model.moveColumn(QModelIndex(), 4, QModelIndex(), 1), true);
- QCOMPARE(columnsAboutToBeMovedSpy.count(), 2);
- QCOMPARE(columnsMovedSpy.count(), 2);
+ QCOMPARE(columnsAboutToBeMovedSpy.size(), 2);
+ QCOMPARE(columnsMovedSpy.size(), 2);
}
void tst_QAbstractItemModel::reset()
@@ -918,7 +918,7 @@ void tst_QAbstractItemModel::reset()
QSignalSpy resetSpy(&model, &QtTestModel::modelReset);
QVERIFY(resetSpy.isValid());
model.reset();
- QCOMPARE(resetSpy.count(), 1);
+ QCOMPARE(resetSpy.size(), 1);
}
void tst_QAbstractItemModel::complexChangesWithPersistent()
@@ -1847,7 +1847,7 @@ void ListenerObject::slotAboutToBeReset()
void ListenerObject::slotReset()
{
- for (const auto &idx : qAsConst(m_persistentIndexes)) {
+ for (const auto &idx : std::as_const(m_persistentIndexes)) {
QVERIFY(!idx.isValid());
}
}
diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
index b8283709e2..3bea468e5b 100644
--- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
@@ -225,7 +225,7 @@ void tst_QAbstractProxyModel::headerDataInBounds()
QCOMPARE(proxy.rowCount(), 1);
QCOMPARE(proxy.columnCount(), 5);
- QCOMPARE(headerDataChangedSpy.count(), 1);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
QCOMPARE(headerDataChangedSpy[0][0].value<Qt::Orientation>(), Qt::Horizontal);
QCOMPARE(headerDataChangedSpy[0][1].value<int>(), 0);
QCOMPARE(headerDataChangedSpy[0][2].value<int>(), 4);
@@ -244,7 +244,7 @@ void tst_QAbstractProxyModel::headerDataInBounds()
});
QCOMPARE(proxy.rowCount(), 2);
QCOMPARE(proxy.columnCount(), 5);
- QCOMPARE(headerDataChangedSpy.count(), 1);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
for (int i = 0; i < proxy.columnCount(); ++i) {
QString expected = QString("Col%1").arg(proxy.columnCount() - i);
@@ -255,7 +255,7 @@ void tst_QAbstractProxyModel::headerDataInBounds()
QCOMPARE(proxy.rowCount(), 1);
QCOMPARE(proxy.columnCount(), 5);
- QCOMPARE(headerDataChangedSpy.count(), 1);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
for (int i = 0; i < proxy.columnCount(); ++i) {
QString expected = QString("Col%1").arg(proxy.columnCount() - i);
@@ -266,7 +266,7 @@ void tst_QAbstractProxyModel::headerDataInBounds()
QCOMPARE(proxy.rowCount(), 0);
QCOMPARE(proxy.columnCount(), 5);
- QCOMPARE(headerDataChangedSpy.count(), 2);
+ QCOMPARE(headerDataChangedSpy.size(), 2);
QCOMPARE(headerDataChangedSpy[1][0].value<Qt::Orientation>(), Qt::Horizontal);
QCOMPARE(headerDataChangedSpy[1][1].value<int>(), 0);
QCOMPARE(headerDataChangedSpy[1][2].value<int>(), 4);
@@ -291,7 +291,7 @@ void tst_QAbstractProxyModel::itemData()
QFETCH(QModelIndex, index);
QFETCH(int, count);
SubQAbstractProxyModel model;
- QCOMPARE(model.itemData(index).count(), count);
+ QCOMPARE(model.itemData(index).size(), count);
}
void tst_QAbstractProxyModel::mapFromSource_data()
diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
index 9990aaf2ed..45d734d9e8 100644
--- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
@@ -46,9 +46,9 @@ static QString rowSpyToText(const QSignalSpy &spy)
if (!spy.isValid())
return QStringLiteral("THE SIGNALSPY IS INVALID!");
QString str;
- for (int i = 0; i < spy.count(); ++i) {
+ for (int i = 0; i < spy.size(); ++i) {
str += spy.at(i).at(1).toString() + QLatin1Char(',') + spy.at(i).at(2).toString();
- if (i + 1 < spy.count())
+ if (i + 1 < spy.size())
str += QLatin1Char(';');
}
return str;
@@ -149,8 +149,8 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateThenRemoveTwoEmptyModelsCo
// Then the proxy should still be empty (and no signals emitted)
QCOMPARE(pm.rowCount(), 0);
QCOMPARE(pm.columnCount(), 0);
- QCOMPARE(rowATBISpy.count(), 0);
- QCOMPARE(rowInsertedSpy.count(), 0);
+ QCOMPARE(rowATBISpy.size(), 0);
+ QCOMPARE(rowInsertedSpy.size(), 0);
// When removing the empty models
pm.removeSourceModel(&i1);
@@ -159,8 +159,8 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateThenRemoveTwoEmptyModelsCo
// Then the proxy should still be empty (and no signals emitted)
QCOMPARE(pm.rowCount(), 0);
QCOMPARE(pm.columnCount(), 0);
- QCOMPARE(rowATBRSpy.count(), 0);
- QCOMPARE(rowRemovedSpy.count(), 0);
+ QCOMPARE(rowATBRSpy.size(), 0);
+ QCOMPARE(rowRemovedSpy.size(), 0);
}
void tst_QConcatenateTablesProxyModel::shouldAggregateTwoEmptyModelsWhichThenGetFilled()
@@ -205,14 +205,14 @@ void tst_QConcatenateTablesProxyModel::shouldHandleDataChanged()
mod.item(0, 0)->setData("a", Qt::EditRole);
// Then the change should be notified to the proxy
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0));
QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("aBC"));
// Same test with the other model
mod2.item(0, 2)->setData("f", Qt::EditRole);
- QCOMPARE(dataChangedSpy.count(), 2);
+ QCOMPARE(dataChangedSpy.size(), 2);
QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2));
QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEf"));
}
@@ -230,14 +230,14 @@ void tst_QConcatenateTablesProxyModel::shouldHandleSetData()
pm.setData(pm.index(0, 0), "a");
// Then the change should be notified to the proxy
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0));
QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("aBC"));
// Same test with the other model
pm.setData(pm.index(1, 2), "f");
- QCOMPARE(dataChangedSpy.count(), 2);
+ QCOMPARE(dataChangedSpy.size(), 2);
QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2));
QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEf"));
}
@@ -256,7 +256,7 @@ void tst_QConcatenateTablesProxyModel::shouldHandleSetItemData()
std::make_pair<int, QVariant>(Qt::UserRole, 88) });
// Then the change should be notified to the proxy
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0));
QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("XBC"));
QCOMPARE(pm.index(0, 0).data(Qt::UserRole).toInt(), 88);
@@ -265,7 +265,7 @@ void tst_QConcatenateTablesProxyModel::shouldHandleSetItemData()
pm.setItemData(pm.index(1, 2), QMap<int, QVariant>{ std::make_pair<int, QVariant>(Qt::DisplayRole, QStringLiteral("Y")),
std::make_pair<int, QVariant>(Qt::UserRole, 89) });
- QCOMPARE(dataChangedSpy.count(), 2);
+ QCOMPARE(dataChangedSpy.size(), 2);
QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2));
QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEY"));
QCOMPARE(pm.index(1, 2).data(Qt::UserRole).toInt(), 89);
@@ -302,10 +302,10 @@ void tst_QConcatenateTablesProxyModel::shouldHandleRowInsertionAndRemoval()
mod2.removeRow(0);
// Then the proxy should notify its users and show changes
- QCOMPARE(rowATBRSpy.count(), 1);
+ QCOMPARE(rowATBRSpy.size(), 1);
QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1);
QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1);
- QCOMPARE(rowRemovedSpy.count(), 1);
+ QCOMPARE(rowRemovedSpy.size(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1);
QCOMPARE(pm.rowCount(), 2);
@@ -318,10 +318,10 @@ void tst_QConcatenateTablesProxyModel::shouldHandleRowInsertionAndRemoval()
mod2.removeRow(0);
// Then the proxy should notify its users and show changes
- QCOMPARE(rowATBRSpy.count(), 1);
+ QCOMPARE(rowATBRSpy.size(), 1);
QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1);
QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1);
- QCOMPARE(rowRemovedSpy.count(), 1);
+ QCOMPARE(rowRemovedSpy.size(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1);
QCOMPARE(pm.rowCount(), 1);
@@ -357,10 +357,10 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateAnotherModelThenRemoveMode
pm.removeSourceModel(&mod3);
// Then the proxy should notify its users about the row removed
- QCOMPARE(rowATBRSpy.count(), 1);
+ QCOMPARE(rowATBRSpy.size(), 1);
QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 2);
QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 3);
- QCOMPARE(rowRemovedSpy.count(), 1);
+ QCOMPARE(rowRemovedSpy.size(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 2);
QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 3);
QCOMPARE(pm.rowCount(), 2);
@@ -371,10 +371,10 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateAnotherModelThenRemoveMode
rowATBRSpy.clear();
rowRemovedSpy.clear();
pm.removeSourceModel(&mod2);
- QCOMPARE(rowATBRSpy.count(), 1);
+ QCOMPARE(rowATBRSpy.size(), 1);
QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1);
QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1);
- QCOMPARE(rowRemovedSpy.count(), 1);
+ QCOMPARE(rowRemovedSpy.size(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1);
QCOMPARE(pm.rowCount(), 1);
@@ -384,10 +384,10 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateAnotherModelThenRemoveMode
rowATBRSpy.clear();
rowRemovedSpy.clear();
pm.removeSourceModel(&mod);
- QCOMPARE(rowATBRSpy.count(), 1);
+ QCOMPARE(rowATBRSpy.size(), 1);
QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 0);
QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 0);
- QCOMPARE(rowRemovedSpy.count(), 1);
+ QCOMPARE(rowRemovedSpy.size(), 1);
QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 0);
QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 0);
QCOMPARE(pm.rowCount(), 0);
@@ -423,11 +423,11 @@ void tst_QConcatenateTablesProxyModel::shouldUseSmallestColumnCount()
// Test setData in an ignored column (QTBUG-91253)
QSignalSpy dataChangedSpy(&pm, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
mod.setData(mod.index(0, 1), "b");
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
// Test dataChanged across all columns, some visible, some ignored
mod.dataChanged(mod.index(0, 0), mod.index(0, 2));
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0));
QCOMPARE(dataChangedSpy.at(0).at(1).toModelIndex(), pm.index(0, 0));
}
@@ -517,8 +517,8 @@ void tst_QConcatenateTablesProxyModel::shouldPropagateLayoutChanged()
QItemSelectionModel selection(&pm);
selection.select(pm.index(1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
const QModelIndexList lst = selection.selectedIndexes();
- QCOMPARE(lst.count(), 3);
- for (int col = 0; col < lst.count(); ++col) {
+ QCOMPARE(lst.size(), 3);
+ for (int col = 0; col < lst.size(); ++col) {
QCOMPARE(lst.at(col).row(), 1);
QCOMPARE(lst.at(col).column(), col);
}
@@ -533,13 +533,13 @@ void tst_QConcatenateTablesProxyModel::shouldPropagateLayoutChanged()
QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC"));
QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456"));
QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("123"));
- QCOMPARE(layoutATBCSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), 1);
+ QCOMPARE(layoutATBCSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 1);
// And the selection should be updated accordingly (it became row 2)
const QModelIndexList lstAfter = selection.selectedIndexes();
- QCOMPARE(lstAfter.count(), 3);
- for (int col = 0; col < lstAfter.count(); ++col) {
+ QCOMPARE(lstAfter.size(), 3);
+ for (int col = 0; col < lstAfter.size(); ++col) {
QCOMPARE(lstAfter.at(col).row(), 2);
QCOMPARE(lstAfter.at(col).column(), col);
}
@@ -574,14 +574,14 @@ void tst_QConcatenateTablesProxyModel::shouldReactToModelReset()
// Then the proxy should emit the reset signals, and show the new data
QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC"));
QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF"));
- QCOMPARE(rowATBRSpy.count(), 0);
- QCOMPARE(rowRemovedSpy.count(), 0);
- QCOMPARE(rowATBISpy.count(), 0);
- QCOMPARE(rowInsertedSpy.count(), 0);
- QCOMPARE(colATBRSpy.count(), 0);
- QCOMPARE(colRemovedSpy.count(), 0);
- QCOMPARE(modelATBResetSpy.count(), 1);
- QCOMPARE(modelResetSpy.count(), 1);
+ QCOMPARE(rowATBRSpy.size(), 0);
+ QCOMPARE(rowRemovedSpy.size(), 0);
+ QCOMPARE(rowATBISpy.size(), 0);
+ QCOMPARE(rowInsertedSpy.size(), 0);
+ QCOMPARE(colATBRSpy.size(), 0);
+ QCOMPARE(colRemovedSpy.size(), 0);
+ QCOMPARE(modelATBResetSpy.size(), 1);
+ QCOMPARE(modelResetSpy.size(), 1);
}
void tst_QConcatenateTablesProxyModel::shouldUpdateColumnsOnModelReset()
@@ -616,14 +616,14 @@ void tst_QConcatenateTablesProxyModel::shouldUpdateColumnsOnModelReset()
qsfpm.setSourceModel(&mod2Columns);
// Then the proxy should reset, and show the new data
- QCOMPARE(modelATBResetSpy.count(), 1);
- QCOMPARE(modelResetSpy.count(), 1);
- QCOMPARE(rowATBRSpy.count(), 0);
- QCOMPARE(rowRemovedSpy.count(), 0);
- QCOMPARE(rowATBISpy.count(), 0);
- QCOMPARE(rowInsertedSpy.count(), 0);
- QCOMPARE(colATBRSpy.count(), 0);
- QCOMPARE(colRemovedSpy.count(), 0);
+ QCOMPARE(modelATBResetSpy.size(), 1);
+ QCOMPARE(modelResetSpy.size(), 1);
+ QCOMPARE(rowATBRSpy.size(), 0);
+ QCOMPARE(rowRemovedSpy.size(), 0);
+ QCOMPARE(rowATBISpy.size(), 0);
+ QCOMPARE(rowInsertedSpy.size(), 0);
+ QCOMPARE(colATBRSpy.size(), 0);
+ QCOMPARE(colRemovedSpy.size(), 0);
QCOMPARE(pm.rowCount(), 2);
QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("WX"));
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index 1ce10c46aa..e5470fc3d1 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -587,7 +587,7 @@ void tst_QItemModel::setData()
QVERIFY(currentModel);
QSignalSpy spy(currentModel, &QAbstractItemModel::dataChanged);
QVERIFY(spy.isValid());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QFETCH(bool, isEmpty);
if (isEmpty)
@@ -611,7 +611,7 @@ void tst_QItemModel::setData()
// Changing the text shouldn't change the layout, parent, pointer etc.
QModelIndex changedIndex = currentModel->index(0, 0, topIndex);
QCOMPARE(changedIndex, index);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QItemModel::setHeaderData_data()
@@ -661,7 +661,7 @@ void tst_QItemModel::setHeaderData()
++signalCount;
}
}
- QCOMPARE(spy.count(), signalCount);
+ QCOMPARE(spy.size(), signalCount);
}
void tst_QItemModel::sort_data()
@@ -692,7 +692,7 @@ void tst_QItemModel::sort()
for (int i=-1; i < 10; ++i){
currentModel->sort(i);
if (index != currentModel->index(0, 0, topIndex)){
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
index = currentModel->index(0, 0, topIndex);
spy.clear();
}
@@ -858,7 +858,7 @@ void tst_QItemModel::remove()
if (shouldSucceed && dyingIndex.isValid())
QCOMPARE(dyingIndex.row(), start + 1);
- if (rowsAboutToBeRemovedSpy.count() > 0){
+ if (rowsAboutToBeRemovedSpy.size() > 0){
QList<QVariant> arguments = rowsAboutToBeRemovedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
@@ -868,7 +868,7 @@ void tst_QItemModel::remove()
QVERIFY(parentOfRemoved == parent);
}
- if (rowsRemovedSpy.count() > 0){
+ if (rowsRemovedSpy.size() > 0){
QList<QVariant> arguments = rowsRemovedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
@@ -879,26 +879,26 @@ void tst_QItemModel::remove()
}
// Only the row signals should have been emitted
- if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >=1 ){
- QCOMPARE(columnsAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(columnsRemovedSpy.count(), 0);
- QCOMPARE(rowsRemovedSpy.count(), 0);
+ if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >=1 ){
+ QCOMPARE(columnsAboutToBeRemovedSpy.size(), 0);
+ QCOMPARE(rowsAboutToBeRemovedSpy.size(), 0);
+ QCOMPARE(columnsRemovedSpy.size(), 0);
+ QCOMPARE(rowsRemovedSpy.size(), 0);
}
else {
- QCOMPARE(columnsAboutToBeRemovedSpy.count(), 0);
- QCOMPARE(rowsAboutToBeRemovedSpy.count(), numberOfRowsAboutToBeRemovedSignals);
- QCOMPARE(columnsRemovedSpy.count(), 0);
- QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals);
+ QCOMPARE(columnsAboutToBeRemovedSpy.size(), 0);
+ QCOMPARE(rowsAboutToBeRemovedSpy.size(), numberOfRowsAboutToBeRemovedSignals);
+ QCOMPARE(columnsRemovedSpy.size(), 0);
+ QCOMPARE(rowsRemovedSpy.size(), numberOfRowsRemovedSignals);
}
// The row count should only change *after* rowsAboutToBeRemoved has been emitted
if (shouldSucceed) {
- if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0){
+ if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0){
QCOMPARE(afterAboutToRemoveRowCount, beforeRemoveRowCount);
QCOMPARE(afterRemoveRowCount, beforeRemoveRowCount-count-(numberOfRowsRemovedSignals-1));
}
- if (modelResetSpy.count() == 0 )
+ if (modelResetSpy.size() == 0 )
QCOMPARE(currentModel->rowCount(parentOfRemoved), beforeRemoveRowCount-count-(numberOfRowsRemovedSignals-1));
}
else {
@@ -913,7 +913,7 @@ void tst_QItemModel::remove()
disconnect(currentModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(slot_rowsRemoved(QModelIndex)));
modelResetSpy.clear();
- QCOMPARE(modelResetSpy.count(), 0);
+ QCOMPARE(modelResetSpy.size(), 0);
//
// Test remove column
@@ -928,26 +928,26 @@ void tst_QItemModel::remove()
if (currentModel->removeColumns(start, count, parentOfRemoved)) {
currentModel->submit();
// Didn't reset the rows, so they should still be at the same value
- if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >= 1){
- QCOMPARE(columnsAboutToBeRemovedSpy.count(), 0);
+ if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >= 1){
+ QCOMPARE(columnsAboutToBeRemovedSpy.size(), 0);
//QCOMPARE(rowsAboutToBeRemovedSpy.count(), numberOfRowsAboutToBeRemovedSignals);
- QCOMPARE(columnsRemovedSpy.count(), 0);
+ QCOMPARE(columnsRemovedSpy.size(), 0);
//QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals);
}
else {
- QCOMPARE(columnsAboutToBeRemovedSpy.count(), numberOfColumnsAboutToBeRemovedSignals);
- QCOMPARE(rowsAboutToBeRemovedSpy.count(), numberOfRowsAboutToBeRemovedSignals);
- QCOMPARE(columnsRemovedSpy.count(), numberOfColumnsRemovedSignals);
- QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals);
+ QCOMPARE(columnsAboutToBeRemovedSpy.size(), numberOfColumnsAboutToBeRemovedSignals);
+ QCOMPARE(rowsAboutToBeRemovedSpy.size(), numberOfRowsAboutToBeRemovedSignals);
+ QCOMPARE(columnsRemovedSpy.size(), numberOfColumnsRemovedSignals);
+ QCOMPARE(rowsRemovedSpy.size(), numberOfRowsRemovedSignals);
}
// The column count should only change *after* rowsAboutToBeRemoved has been emitted
if (shouldSucceed) {
- if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0){
+ if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0){
QCOMPARE(afterAboutToRemoveColumnCount, beforeRemoveColumnCount);
QCOMPARE(afterRemoveColumnCount, beforeRemoveColumnCount-count-(numberOfColumnsRemovedSignals-1));
}
- if (modelResetSpy.count() == 0)
+ if (modelResetSpy.size() == 0)
QCOMPARE(currentModel->columnCount(parentOfRemoved), beforeRemoveColumnCount-count-(numberOfColumnsRemovedSignals-1));
}
else
@@ -958,7 +958,7 @@ void tst_QItemModel::remove()
disconnect(currentModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
this, SLOT(slot_columnsRemoved(QModelIndex)));
- if (columnsAboutToBeRemovedSpy.count() > 0){
+ if (columnsAboutToBeRemovedSpy.size() > 0){
QList<QVariant> arguments = columnsAboutToBeRemovedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
@@ -968,7 +968,7 @@ void tst_QItemModel::remove()
QVERIFY(parentOfRemoved == parent);
}
- if (columnsRemovedSpy.count() > 0){
+ if (columnsRemovedSpy.size() > 0){
QList<QVariant> arguments = columnsRemovedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
@@ -1197,7 +1197,7 @@ void tst_QItemModel::insert()
QCOMPARE(currentModel->insertRows(start, count, parentOfInserted), shouldSucceed);
currentModel->submit();
- if (rowsAboutToBeInsertedSpy.count() > 0){
+ if (rowsAboutToBeInsertedSpy.size() > 0){
QList<QVariant> arguments = rowsAboutToBeInsertedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
@@ -1207,7 +1207,7 @@ void tst_QItemModel::insert()
QVERIFY(parentOfInserted == parent);
}
- if (rowsInsertedSpy.count() > 0){
+ if (rowsInsertedSpy.size() > 0){
QList<QVariant> arguments = rowsInsertedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
@@ -1218,25 +1218,25 @@ void tst_QItemModel::insert()
}
// Only the row signals should have been emitted
- if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >= 1) {
- QCOMPARE(columnsAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(rowsAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(columnsInsertedSpy.count(), 0);
- QCOMPARE(rowsInsertedSpy.count(), 0);
+ if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >= 1) {
+ QCOMPARE(columnsAboutToBeInsertedSpy.size(), 0);
+ QCOMPARE(rowsAboutToBeInsertedSpy.size(), 0);
+ QCOMPARE(columnsInsertedSpy.size(), 0);
+ QCOMPARE(rowsInsertedSpy.size(), 0);
}
else {
- QCOMPARE(columnsAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(rowsAboutToBeInsertedSpy.count(), numberOfRowsAboutToBeInsertedSignals);
- QCOMPARE(columnsInsertedSpy.count(), 0);
- QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals);
+ QCOMPARE(columnsAboutToBeInsertedSpy.size(), 0);
+ QCOMPARE(rowsAboutToBeInsertedSpy.size(), numberOfRowsAboutToBeInsertedSignals);
+ QCOMPARE(columnsInsertedSpy.size(), 0);
+ QCOMPARE(rowsInsertedSpy.size(), numberOfRowsInsertedSignals);
}
// The row count should only change *after* rowsAboutToBeInserted has been emitted
if (shouldSucceed) {
- if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0) {
+ if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0) {
QCOMPARE(afterAboutToInsertRowCount, beforeInsertRowCount);
QCOMPARE(afterInsertRowCount, beforeInsertRowCount+count+(numberOfRowsInsertedSignals-1));
}
- if (modelResetSpy.count() == 0)
+ if (modelResetSpy.size() == 0)
QCOMPARE(currentModel->rowCount(parentOfInserted), beforeInsertRowCount+count+(numberOfRowsInsertedSignals-1));
}
else {
@@ -1264,27 +1264,27 @@ void tst_QItemModel::insert()
// Some models don't let you insert the column, only row
if (currentModel->insertColumns(start, count, parentOfInserted)) {
currentModel->submit();
- if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >= 1) {
+ if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >= 1) {
// Didn't reset the rows, so they should still be at the same value
- QCOMPARE(columnsAboutToBeInsertedSpy.count(), 0);
+ QCOMPARE(columnsAboutToBeInsertedSpy.size(), 0);
//QCOMPARE(rowsAboutToBeInsertedSpy.count(), numberOfRowsAboutToBeInsertedSignals);
- QCOMPARE(columnsInsertedSpy.count(), 0);
+ QCOMPARE(columnsInsertedSpy.size(), 0);
//QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals);
}
else {
// Didn't reset the rows, so they should still be at the same value
- QCOMPARE(columnsAboutToBeInsertedSpy.count(), numberOfColumnsAboutToBeInsertedSignals);
- QCOMPARE(rowsAboutToBeInsertedSpy.count(), numberOfRowsAboutToBeInsertedSignals);
- QCOMPARE(columnsInsertedSpy.count(), numberOfColumnsInsertedSignals);
- QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals);
+ QCOMPARE(columnsAboutToBeInsertedSpy.size(), numberOfColumnsAboutToBeInsertedSignals);
+ QCOMPARE(rowsAboutToBeInsertedSpy.size(), numberOfRowsAboutToBeInsertedSignals);
+ QCOMPARE(columnsInsertedSpy.size(), numberOfColumnsInsertedSignals);
+ QCOMPARE(rowsInsertedSpy.size(), numberOfRowsInsertedSignals);
}
// The column count should only change *after* rowsAboutToBeInserted has been emitted
if (shouldSucceed) {
- if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0) {
+ if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0) {
QCOMPARE(afterAboutToInsertColumnCount, beforeInsertColumnCount);
QCOMPARE(afterInsertColumnCount, beforeInsertColumnCount+count+(numberOfColumnsInsertedSignals-1));
}
- if (modelResetSpy.count() == 0)
+ if (modelResetSpy.size() == 0)
QCOMPARE(currentModel->columnCount(parentOfInserted), beforeInsertColumnCount+count+(numberOfColumnsInsertedSignals-1));
}
else
@@ -1295,7 +1295,7 @@ void tst_QItemModel::insert()
disconnect(currentModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
this, SLOT(slot_columnsInserted(QModelIndex)));
- if (columnsAboutToBeInsertedSpy.count() > 0){
+ if (columnsAboutToBeInsertedSpy.size() > 0){
QList<QVariant> arguments = columnsAboutToBeInsertedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
@@ -1305,7 +1305,7 @@ void tst_QItemModel::insert()
QVERIFY(parentOfInserted == parent);
}
- if (columnsInsertedSpy.count() > 0){
+ if (columnsInsertedSpy.size() > 0){
QList<QVariant> arguments = columnsInsertedSpy.at(0);
QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0)));
int first = arguments.at(1).toInt();
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 1a9875a1eb..2d09b01c26 100644
--- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -141,8 +141,8 @@ QDataStream &operator>>(QDataStream &s, QModelIndex &output)
QDataStream &operator<<(QDataStream &s, const QModelIndexList &input)
{
- s << input.count();
- for (int i=0; i<input.count(); ++i)
+ s << input.size();
+ for (int i=0; i<input.size(); ++i)
s << input.at(i);
return s;
}
@@ -278,7 +278,7 @@ void tst_QItemSelectionModel::clear()
QFETCH(IntList, commandList);
// do selections
- for (int i=0; i<indexList.count(); ++i) {
+ for (int i=0; i<indexList.size(); ++i) {
selection->select(indexList.at(i), (QItemSelectionModel::SelectionFlags)commandList.at(i));
}
// test that we have selected items
@@ -292,7 +292,7 @@ void tst_QItemSelectionModel::clearAndSelect()
{
// populate selectionmodel
selection->select(model->index(1, 1, QModelIndex()), QItemSelectionModel::Select);
- QCOMPARE(selection->selectedIndexes().count(), 1);
+ QCOMPARE(selection->selectedIndexes().size(), 1);
QVERIFY(selection->hasSelection());
// ClearAndSelect with empty selection
@@ -310,26 +310,26 @@ void tst_QItemSelectionModel::toggleSelection()
//and hasSelection returns the correct value
selection->clearSelection();
- QCOMPARE(selection->selectedIndexes().count(), 0);
+ QCOMPARE(selection->selectedIndexes().size(), 0);
QVERIFY(selection->hasSelection()==false);
QModelIndex index=model->index(1, 1, QModelIndex());
// populate selectionmodel
selection->select(index, QItemSelectionModel::Toggle);
- QCOMPARE(selection->selectedIndexes().count(), 1);
+ QCOMPARE(selection->selectedIndexes().size(), 1);
QVERIFY(selection->hasSelection()==true);
selection->select(index, QItemSelectionModel::Toggle);
- QCOMPARE(selection->selectedIndexes().count(), 0);
+ QCOMPARE(selection->selectedIndexes().size(), 0);
QVERIFY(selection->hasSelection()==false);
// populate selectionmodel with rows
selection->select(index, QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
- QCOMPARE(selection->selectedIndexes().count(), model->columnCount());
+ QCOMPARE(selection->selectedIndexes().size(), model->columnCount());
QVERIFY(selection->hasSelection()==true);
selection->select(index, QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
- QCOMPARE(selection->selectedIndexes().count(), 0);
+ QCOMPARE(selection->selectedIndexes().size(), 0);
QVERIFY(selection->hasSelection()==false);
}
@@ -1221,7 +1221,7 @@ void tst_QItemSelectionModel::select()
int lastCommand = 0;
// do selections
- for (int i = 0; i<commandList.count(); ++i) {
+ for (int i = 0; i<commandList.size(); ++i) {
if (useRanges) {
selection->select(QItemSelection(indexList.at(2*i), indexList.at(2*i+1)),
(QItemSelectionModel::SelectionFlags)commandList.at(i));
@@ -1238,13 +1238,13 @@ void tst_QItemSelectionModel::select()
QVERIFY(selection->hasSelection()!=selectedList.isEmpty());
// test that the number of indices are as expected
- QVERIFY2(selectedList.count() == expectedList.count(),
+ QVERIFY2(selectedList.size() == expectedList.size(),
QString("expected indices: %1 actual indices: %2")
- .arg(expectedList.count())
- .arg(selectedList.count()).toLatin1());
+ .arg(expectedList.size())
+ .arg(selectedList.size()).toLatin1());
// test existence of each index
- for (int i=0; i<expectedList.count(); ++i) {
+ for (int i=0; i<expectedList.size(); ++i) {
QVERIFY2(selectedList.contains(expectedList.at(i)),
QString("expected index(%1, %2) not found in selectedIndexes()")
.arg(expectedList.at(i).row())
@@ -1252,7 +1252,7 @@ void tst_QItemSelectionModel::select()
}
// test that isSelected agrees
- for (int i=0; i<indexList.count(); ++i) {
+ for (int i=0; i<indexList.size(); ++i) {
QModelIndex idx = indexList.at(i);
QVERIFY2(selection->isSelected(idx) == selectedList.contains(idx),
QString("isSelected(index: %1, %2) does not match selectedIndexes()")
@@ -1263,7 +1263,7 @@ void tst_QItemSelectionModel::select()
//for now we assume Rows/Columns flag is the same for all commands, therefore we just check lastCommand
// test that isRowSelected agrees
if (lastCommand & QItemSelectionModel::Rows) {
- for (int i=0; i<selectedList.count(); ++i)
+ for (int i=0; i<selectedList.size(); ++i)
QVERIFY2(selection->isRowSelected(selectedList.at(i).row(),
model->parent(selectedList.at(i))),
QString("isRowSelected(row: %1) does not match selectedIndexes()")
@@ -1272,7 +1272,7 @@ void tst_QItemSelectionModel::select()
// test that isColumnSelected agrees
if (lastCommand & QItemSelectionModel::Columns) {
- for (int i=0; i<selectedList.count(); ++i)
+ for (int i=0; i<selectedList.size(); ++i)
QVERIFY2(selection->isColumnSelected(selectedList.at(i).column(),
model->parent(selectedList.at(i))),
QString("isColumnSelected(column: %1) does not match selectedIndexes()")
@@ -1456,8 +1456,8 @@ void tst_QItemSelectionModel::persistentselections()
QCOMPARE(model->columnCount(QModelIndex()), 5);
// do selections
- for (int i=0; i<commandList.count(); ++i) {
- if (indexList.count() == commandList.count()) {
+ for (int i=0; i<commandList.size(); ++i) {
+ if (indexList.size() == commandList.size()) {
QModelIndex index = model->index(indexList.at(i).first,
indexList.at(i).second,
QModelIndex());
@@ -1478,18 +1478,18 @@ void tst_QItemSelectionModel::persistentselections()
QVERIFY(selection->hasSelection());
// insert/delete row and/or columns
- if (insertRows.count() > 1)
+ if (insertRows.size() > 1)
model->insertRows(insertRows.at(0), insertRows.at(1), QModelIndex());
- if (insertColumns.count() > 1)
+ if (insertColumns.size() > 1)
model->insertColumns(insertColumns.at(0), insertColumns.at(1), QModelIndex());
- if (deleteRows.count() > 1)
+ if (deleteRows.size() > 1)
model->removeRows(deleteRows.at(0), deleteRows.at(1), QModelIndex());
- if (deleteColumns.count() > 1)
+ if (deleteColumns.size() > 1)
model->removeColumns(deleteColumns.at(0), deleteColumns.at(1), QModelIndex());
// check that the selected items are the correct number and indexes
QModelIndexList selectedList = selection->selectedIndexes();
- QCOMPARE(selectedList.count(), expectedList.count());
+ QCOMPARE(selectedList.size(), expectedList.size());
for (const auto &pair : expectedList) {
QModelIndex index = model->index(pair.first, pair.second, QModelIndex());
QVERIFY(selectedList.contains(index));
@@ -1515,7 +1515,7 @@ void tst_QItemSelectionModel::resetModel()
selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
model.reset();
@@ -1524,8 +1524,8 @@ void tst_QItemSelectionModel::resetModel()
selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(1).count(), 2);
+ QCOMPARE(spy.size(), 2);
+ QCOMPARE(spy.at(1).size(), 2);
// make sure we don't get an "old selection"
QCOMPARE(spy.at(1).at(1).userType(), qMetaTypeId<QItemSelection>());
QVERIFY(qvariant_cast<QItemSelection>(spy.at(1).at(1)).isEmpty());
@@ -1580,14 +1580,14 @@ void tst_QItemSelectionModel::removeRows()
QModelIndex br = model.index(selectBottom, selectRight);
selections.select(QItemSelection(tl, br), QItemSelectionModel::ClearAndSelect);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(selections.isSelected(tl));
QVERIFY(selections.isSelected(br));
QVERIFY(selections.hasSelection());
model.removeRows(removeTop, removeBottom - removeTop + 1);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
tl = model.index(expectedTop, expectedLeft);
br = model.index(expectedBottom, expectedRight);
QVERIFY(selections.isSelected(tl));
@@ -1643,14 +1643,14 @@ void tst_QItemSelectionModel::removeColumns()
QModelIndex br = model.index(selectBottom, selectRight);
selections.select(QItemSelection(tl, br), QItemSelectionModel::ClearAndSelect);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(selections.isSelected(tl));
QVERIFY(selections.isSelected(br));
QVERIFY(selections.hasSelection());
model.removeColumns(removeLeft, removeRight - removeLeft + 1);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
tl = model.index(expectedTop, expectedLeft);
br = model.index(expectedBottom, expectedRight);
QVERIFY(selections.isSelected(tl));
@@ -1721,7 +1721,7 @@ void tst_QItemSelectionModel::modelLayoutChanged()
QFETCH(int, sortColumn);
QFETCH(IntPairPairList, expectedSelectedRanges);
- MyStandardItemModel model(items.at(0).count(), items.count());
+ MyStandardItemModel model(items.at(0).size(), items.size());
// initialize model data
for (int i = 0; i < model.rowCount(); ++i) {
for (int j = 0; j < model.columnCount(); ++j) {
@@ -1746,10 +1746,10 @@ void tst_QItemSelectionModel::modelLayoutChanged()
// verify that selection is as expected
QItemSelection selection = selectionModel.selection();
- QCOMPARE(selection.count(), expectedSelectedRanges.count());
+ QCOMPARE(selection.size(), expectedSelectedRanges.size());
QCOMPARE(selectionModel.hasSelection(), !expectedSelectedRanges.isEmpty());
- for (int i = 0; i < expectedSelectedRanges.count(); ++i) {
+ for (int i = 0; i < expectedSelectedRanges.size(); ++i) {
IntPairPair expectedRange = expectedSelectedRanges.at(i);
IntPair expectedTl = expectedRange.first;
IntPair expectedBr = expectedRange.second;
@@ -1803,21 +1803,21 @@ void tst_QItemSelectionModel::selectedRows()
MyStandardItemModel model(rowCount, columnCount);
QItemSelectionModel selectionModel(&model);
- for (int i = 0; i < selectRows.count(); ++i)
+ for (int i = 0; i < selectRows.size(); ++i)
selectionModel.select(model.index(selectRows.at(i), 0),
QItemSelectionModel::Select
|QItemSelectionModel::Rows);
- for (int j = 0; j < selectRows.count(); ++j)
+ for (int j = 0; j < selectRows.size(); ++j)
QVERIFY(selectionModel.isRowSelected(expectedRows.at(j), QModelIndex()));
- for (int k = 0; k < selectRows.count(); ++k)
+ for (int k = 0; k < selectRows.size(); ++k)
QVERIFY(!selectionModel.isRowSelected(unexpectedRows.at(k), QModelIndex()));
QModelIndexList selectedRowIndexes = selectionModel.selectedRows(column);
- QCOMPARE(selectedRowIndexes.count(), expectedRows.count());
+ QCOMPARE(selectedRowIndexes.size(), expectedRows.size());
std::sort(selectedRowIndexes.begin(), selectedRowIndexes.end());
- for (int l = 0; l < selectedRowIndexes.count(); ++l) {
+ for (int l = 0; l < selectedRowIndexes.size(); ++l) {
QCOMPARE(selectedRowIndexes.at(l).row(), expectedRows.at(l));
QCOMPARE(selectedRowIndexes.at(l).column(), column);
}
@@ -1863,21 +1863,21 @@ void tst_QItemSelectionModel::selectedColumns()
MyStandardItemModel model(rowCount, columnCount);
QItemSelectionModel selectionModel(&model);
- for (int i = 0; i < selectColumns.count(); ++i)
+ for (int i = 0; i < selectColumns.size(); ++i)
selectionModel.select(model.index(0, selectColumns.at(i)),
QItemSelectionModel::Select
|QItemSelectionModel::Columns);
- for (int j = 0; j < selectColumns.count(); ++j)
+ for (int j = 0; j < selectColumns.size(); ++j)
QVERIFY(selectionModel.isColumnSelected(expectedColumns.at(j), QModelIndex()));
- for (int k = 0; k < selectColumns.count(); ++k)
+ for (int k = 0; k < selectColumns.size(); ++k)
QVERIFY(!selectionModel.isColumnSelected(unexpectedColumns.at(k), QModelIndex()));
QModelIndexList selectedColumnIndexes = selectionModel.selectedColumns(row);
- QCOMPARE(selectedColumnIndexes.count(), expectedColumns.count());
+ QCOMPARE(selectedColumnIndexes.size(), expectedColumns.size());
std::sort(selectedColumnIndexes.begin(), selectedColumnIndexes.end());
- for (int l = 0; l < selectedColumnIndexes.count(); ++l) {
+ for (int l = 0; l < selectedColumnIndexes.size(); ++l) {
QCOMPARE(selectedColumnIndexes.at(l).column(), expectedColumns.at(l));
QCOMPARE(selectedColumnIndexes.at(l).row(), row);
}
@@ -1908,18 +1908,18 @@ void tst_QItemSelectionModel::setCurrentIndex()
treemodel->index(0, 0, treemodel->index(1, 0)),
QItemSelectionModel::SelectCurrent);
- QCOMPARE(currentSpy.count(), 1);
- QCOMPARE(rowSpy.count(), 1);
- QCOMPARE(columnSpy.count(), 1);
+ QCOMPARE(currentSpy.size(), 1);
+ QCOMPARE(rowSpy.size(), 1);
+ QCOMPARE(columnSpy.size(), 1);
// Select another row in the same parent
selectionModel.setCurrentIndex(
treemodel->index(1, 0, treemodel->index(1, 0)),
QItemSelectionModel::SelectCurrent);
- QCOMPARE(currentSpy.count(), 2);
- QCOMPARE(rowSpy.count(), 2);
- QCOMPARE(columnSpy.count(), 1);
+ QCOMPARE(currentSpy.size(), 2);
+ QCOMPARE(rowSpy.size(), 2);
+ QCOMPARE(columnSpy.size(), 1);
}
void tst_QItemSelectionModel::splitOnInsert()
@@ -2043,14 +2043,14 @@ void tst_QItemSelectionModel::unselectable()
}
QItemSelectionModel selectionModel(&model);
selectionModel.select(QItemSelection(model.index(0, 0), model.index(9, 0)), QItemSelectionModel::Select);
- QCOMPARE(selectionModel.selectedIndexes().count(), 10);
- QCOMPARE(selectionModel.selectedRows().count(), 10);
+ QCOMPARE(selectionModel.selectedIndexes().size(), 10);
+ QCOMPARE(selectionModel.selectedRows().size(), 10);
QVERIFY(selectionModel.hasSelection());
for (int j = 0; j < 10; ++j)
model.item(j)->setFlags({ });
QVERIFY(!selectionModel.hasSelection());
- QCOMPARE(selectionModel.selectedIndexes().count(), 0);
- QCOMPARE(selectionModel.selectedRows().count(), 0);
+ QCOMPARE(selectionModel.selectedIndexes().size(), 0);
+ QCOMPARE(selectionModel.selectedRows().size(), 0);
}
void tst_QItemSelectionModel::selectedIndexes()
@@ -2064,8 +2064,8 @@ void tst_QItemSelectionModel::selectedIndexes()
//we select the 1st row
selectionModel.select(selection, QItemSelectionModel::Rows | QItemSelectionModel::Select);
- QCOMPARE(selectionModel.selectedRows().count(), 1);
- QCOMPARE(selectionModel.selectedIndexes().count(), model.columnCount());
+ QCOMPARE(selectionModel.selectedRows().size(), 1);
+ QCOMPARE(selectionModel.selectedIndexes().size(), model.columnCount());
}
@@ -2103,14 +2103,14 @@ void tst_QItemSelectionModel::layoutChanged()
QtTestTableModel model(1,1);
QItemSelectionModel selectionModel(&model);
selectionModel.select(model.index(0,0), QItemSelectionModel::Select);
- QCOMPARE(selectionModel.selectedIndexes().count() , 1);
+ QCOMPARE(selectionModel.selectedIndexes().size() , 1);
emit model.layoutAboutToBeChanged();
model.row_count = 5;
emit model.layoutChanged();
//The selection should not change.
- QCOMPARE(selectionModel.selectedIndexes().count() , 1);
+ QCOMPARE(selectionModel.selectedIndexes().size() , 1);
QCOMPARE(selectionModel.selectedIndexes().first() , model.index(0,0));
}
@@ -2190,7 +2190,7 @@ void tst_QItemSelectionModel::isRowSelected()
model.setData(model.index(0,0), 0, Qt::UserRole - 1);
QItemSelectionModel sel(&model);
sel.select( QItemSelection(model.index(0,0), model.index(0, 1)), QItemSelectionModel::Select);
- QCOMPARE(sel.selectedIndexes().count(), 1);
+ QCOMPARE(sel.selectedIndexes().size(), 1);
QVERIFY(sel.isRowSelected(0, QModelIndex()));
}
@@ -2215,7 +2215,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal()
QSignalSpy deselectSpy(&selectionModel, &QItemSelectionModel::selectionChanged);
QVERIFY(deselectSpy.isValid());
model.removeRows(0, 1, root);
- QCOMPARE(deselectSpy.count(), 1);
+ QCOMPARE(deselectSpy.size(), 1);
// More testing stress for the patch.
model.clear();
@@ -2244,7 +2244,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal()
QVERIFY(selectionModel.selection().contains(sel2));
deselectSpy.clear();
model.removeRow(0, model.index(0, 0));
- QCOMPARE(deselectSpy.count(), 1);
+ QCOMPARE(deselectSpy.size(), 1);
QVERIFY(!selectionModel.selection().contains(sel));
QVERIFY(selectionModel.selection().contains(sel2));
}
@@ -2266,7 +2266,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1()
selection.select(QItemSelection(indexList.first(), indexList.last()), QItemSelectionModel::Select);
//let's check the selection hasn't changed
- QCOMPARE(selection.selectedIndexes().count(), indexList.count());
+ QCOMPARE(selection.selectedIndexes().size(), indexList.size());
for (const auto &index : indexList)
QVERIFY(selection.isSelected(index));
@@ -2274,7 +2274,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1()
QCOMPARE(proxy.rowCount(), 3);
//let's check the selection hasn't changed
- QCOMPARE(selection.selectedIndexes().count(), indexList.count());
+ QCOMPARE(selection.selectedIndexes().size(), indexList.size());
for (const auto &index : indexList)
QVERIFY(selection.isSelected(index));
}
@@ -2323,7 +2323,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2()
QCOMPARE(proxy.rowCount(), int(cNumRows));
//let's check the selection hasn't changed
- QCOMPARE(selection.selectedIndexes().count(), indexList.count());
+ QCOMPARE(selection.selectedIndexes().size(), indexList.size());
for (const auto &index : indexList)
QVERIFY(selection.isSelected(index));
}
@@ -2347,11 +2347,11 @@ void tst_QItemSelectionModel::layoutChangedTreeSelection()
selModel.select(sub23.index(), QItemSelectionModel::Select);
QModelIndexList list = selModel.selectedIndexes();
- QCOMPARE(list.count(), 4);
+ QCOMPARE(list.size(), 4);
model.sort(0); //this will provoke a relayout
- QCOMPARE(selModel.selectedIndexes().count(), 4);
+ QCOMPARE(selModel.selectedIndexes().size(), 4);
}
class RemovalObserver : public QObject
@@ -2410,7 +2410,7 @@ void tst_QItemSelectionModel::setModel()
QStringListModel model(QStringList() << "Blah" << "Blah" << "Blah");
sel.setModel(&model);
QCOMPARE(sel.model(), &model);
- QCOMPARE(modelChangedSpy.count(), 1);
+ QCOMPARE(modelChangedSpy.size(), 1);
sel.select(model.index(0), QItemSelectionModel::Select);
QVERIFY(!sel.selection().isEmpty());
sel.setModel(0);
@@ -2777,7 +2777,7 @@ void tst_QItemSelectionModel::QTBUG58851()
QVERIFY(selections.isSelected(i));
}
proxy.sort(1, Qt::DescendingOrder);
- QCOMPARE(selections.selectedIndexes().count(), (int)expectedSelectedIndexes.size());
+ QCOMPARE(selections.selectedIndexes().size(), (int)expectedSelectedIndexes.size());
for (const QPersistentModelIndex &i : expectedSelectedIndexes) {
QVERIFY(selections.isSelected(i));
}
@@ -2851,12 +2851,12 @@ void tst_QItemSelectionModel::QTBUG18001()
QItemSelectionModel selectionModel(&model);
- for (int i = 0; i < indexesToSelect.count(); ++i) {
+ for (int i = 0; i < indexesToSelect.size(); ++i) {
QModelIndex idx = model.index( indexesToSelect.at(i).first, indexesToSelect.at(i).second );
selectionModel.select(idx, QItemSelectionModel::SelectionFlag(selectionCommands.at(i)));
}
- for (int i = 0; i < expectedSelectedRows.count(); ++i) {
+ for (int i = 0; i < expectedSelectedRows.size(); ++i) {
const bool expected = expectedSelectedRows.at(i);
const bool actual = selectionModel.isRowSelected(i, QModelIndex());
QByteArray description = QByteArray("Row ") + QByteArray::number(i)
@@ -2865,7 +2865,7 @@ void tst_QItemSelectionModel::QTBUG18001()
QVERIFY2(expected == actual, description.data());
}
- for (int i = 0; i < expectedSelectedColums.count(); ++i) {
+ for (int i = 0; i < expectedSelectedColums.size(); ++i) {
const bool expected = expectedSelectedColums.at(i);
const bool actual = selectionModel.isColumnSelected(i, QModelIndex());
QByteArray description = QByteArray("Col ") + QByteArray::number(i)
@@ -2888,7 +2888,7 @@ void tst_QItemSelectionModel::QTBUG93305()
QModelIndex index = model->index(1, 0, QModelIndex());
selection->select(index, QItemSelectionModel::ClearAndSelect);
QVERIFY(selection->hasSelection());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// removing row 0 does not change which cells are selected, but it
// does change the row number of the selected cells. Thus it changes
@@ -2899,7 +2899,7 @@ void tst_QItemSelectionModel::QTBUG93305()
// delete row 0
model->removeRows(0, 1, QModelIndex());
QVERIFY(selection->hasSelection());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
// inserting a row before the first row again does not change which cells
// are selected, but does change the row number of the selected cells.
@@ -2909,12 +2909,12 @@ void tst_QItemSelectionModel::QTBUG93305()
// insert row 0 again
model->insertRows(0, 1, QModelIndex());
QVERIFY(selection->hasSelection());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
// test for inserting multiple (6) rows
model->insertRows(0, 6, QModelIndex());
QVERIFY(selection->hasSelection());
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
}
QTEST_MAIN(tst_QItemSelectionModel)
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 99151a2065..43651a8d7a 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -216,16 +216,16 @@ void tst_QSortFilterProxyModel::sort()
// prepare model
QStandardItem *root = m_model->invisibleRootItem ();
QList<QStandardItem *> items;
- for (int i = 0; i < initial.count(); ++i) {
+ for (int i = 0; i < initial.size(); ++i) {
items.append(new QStandardItem(initial.at(i)));
}
root->insertRows(0, items);
- QCOMPARE(m_model->rowCount(QModelIndex()), initial.count());
+ QCOMPARE(m_model->rowCount(QModelIndex()), initial.size());
QCOMPARE(m_model->columnCount(QModelIndex()), 1);
// make sure the proxy is unsorted
QCOMPARE(m_proxy->columnCount(QModelIndex()), 1);
- QCOMPARE(m_proxy->rowCount(QModelIndex()), initial.count());
+ QCOMPARE(m_proxy->rowCount(QModelIndex()), initial.size());
for (int row = 0; row < m_proxy->rowCount(QModelIndex()); ++row) {
QModelIndex index = m_proxy->index(row, 0, QModelIndex());
QCOMPARE(m_proxy->data(index, Qt::DisplayRole).toString(), initial.at(row));
@@ -413,10 +413,10 @@ void tst_QSortFilterProxyModel::insertRows()
QFETCH(QStringList, insert);
QFETCH(int, position);
// prepare model
- m_model->insertRows(0, initial.count(), QModelIndex());
+ m_model->insertRows(0, initial.size(), QModelIndex());
//m_model->insertColumns(0, 1, QModelIndex());
QCOMPARE(m_model->columnCount(QModelIndex()), 1);
- QCOMPARE(m_model->rowCount(QModelIndex()), initial.count());
+ QCOMPARE(m_model->rowCount(QModelIndex()), initial.size());
for (int row = 0; row < m_model->rowCount(QModelIndex()); ++row) {
QModelIndex index = m_model->index(row, 0, QModelIndex());
m_model->setData(index, initial.at(row), Qt::DisplayRole);
@@ -433,12 +433,12 @@ void tst_QSortFilterProxyModel::insertRows()
}
// insert the row
- m_proxy->insertRows(position, insert.count(), QModelIndex());
- QCOMPARE(m_model->rowCount(QModelIndex()), expected.count());
- QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.count());
+ m_proxy->insertRows(position, insert.size(), QModelIndex());
+ QCOMPARE(m_model->rowCount(QModelIndex()), expected.size());
+ QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.size());
// set the data for the inserted row
- for (int i = 0; i < insert.count(); ++i) {
+ for (int i = 0; i < insert.size(); ++i) {
QModelIndex index = m_proxy->index(position + i, 0, QModelIndex());
m_proxy->setData(index, insert.at(i), Qt::DisplayRole);
}
@@ -827,8 +827,8 @@ void tst_QSortFilterProxyModel::removeRows()
// remove the rows
QCOMPARE(proxy.removeRows(position, count, QModelIndex()), success);
- QCOMPARE(model.rowCount(QModelIndex()), expectedSource.count());
- QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxy.count());
+ QCOMPARE(model.rowCount(QModelIndex()), expectedSource.size());
+ QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxy.size());
// make sure the model is correct after remove
for (int row = 0; row < model.rowCount(QModelIndex()); ++row)
@@ -1073,8 +1073,8 @@ void tst_QSortFilterProxyModel::removeColumns()
// remove the columns
QCOMPARE(proxy.removeColumns(position, count, QModelIndex()), success);
- QCOMPARE(model.columnCount(QModelIndex()), expectedSource.count());
- QCOMPARE(proxy.columnCount(QModelIndex()), expectedProxy.count());
+ QCOMPARE(model.columnCount(QModelIndex()), expectedSource.size());
+ QCOMPARE(proxy.columnCount(QModelIndex()), expectedProxy.size());
// make sure the model is correct after remove
for (int col = 0; col < model.columnCount(QModelIndex()); ++col)
@@ -1124,9 +1124,9 @@ void tst_QSortFilterProxyModel::filterColumns()
QFETCH(QStringList, initial);
QFETCH(bool, data);
// prepare model
- m_model->setColumnCount(initial.count());
+ m_model->setColumnCount(initial.size());
m_model->setRowCount(1);
- QCOMPARE(m_model->columnCount(QModelIndex()), initial.count());
+ QCOMPARE(m_model->columnCount(QModelIndex()), initial.size());
QCOMPARE(m_model->rowCount(QModelIndex()), 1);
// set data
QCOMPARE(m_model->rowCount(QModelIndex()), 1);
@@ -1203,8 +1203,8 @@ void tst_QSortFilterProxyModel::filter()
QFETCH(QStringList, expected);
// prepare model
- QVERIFY(m_model->insertRows(0, initial.count(), QModelIndex()));
- QCOMPARE(m_model->rowCount(QModelIndex()), initial.count());
+ QVERIFY(m_model->insertRows(0, initial.size(), QModelIndex()));
+ QCOMPARE(m_model->rowCount(QModelIndex()), initial.size());
// set data
QCOMPARE(m_model->columnCount(QModelIndex()), 1);
for (int row = 0; row < m_model->rowCount(QModelIndex()); ++row) {
@@ -1214,7 +1214,7 @@ void tst_QSortFilterProxyModel::filter()
setupFilter(m_proxy, pattern);
// make sure the proxy is unfiltered
QCOMPARE(m_proxy->columnCount(QModelIndex()), 1);
- QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.count());
+ QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.size());
// make sure the model is unchanged
for (int row = 0; row < m_model->rowCount(QModelIndex()); ++row) {
QModelIndex index = m_model->index(row, 0, QModelIndex());
@@ -1262,7 +1262,7 @@ void tst_QSortFilterProxyModel::buildHierarchy(const QStringList &l, QAbstractIt
QStack<int> row_stack;
QModelIndex parent;
QStack<QModelIndex> parent_stack;
- for (int i = 0; i < l.count(); ++i) {
+ for (int i = 0; i < l.size(); ++i) {
QString token = l.at(i);
if (token == QLatin1String("<")) { // start table
++ind;
@@ -1292,7 +1292,7 @@ void tst_QSortFilterProxyModel::checkHierarchy(const QStringList &l, const QAbst
QStack<int> row_stack;
QModelIndex parent;
QStack<QModelIndex> parent_stack;
- for (int i = 0; i < l.count(); ++i) {
+ for (int i = 0; i < l.size(); ++i) {
QString token = l.at(i);
if (token == QLatin1String("<")) { // start table
++indent;
@@ -1402,9 +1402,9 @@ void tst_QSortFilterProxyModel::filterCurrent()
QVERIFY(spy.isValid());
view.setCurrentIndex(proxy.index(0, 0));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
setupFilter(&proxy, QLatin1String("^B"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QSortFilterProxyModel::filter_qtbug30662()
@@ -1472,7 +1472,7 @@ void tst_QSortFilterProxyModel::changeSourceLayoutFilteredOut()
// Filter everything out
setupFilter(&proxy, QLatin1String("c"));
- QCOMPARE(removeSpy.count(), 1);
+ QCOMPARE(removeSpy.size(), 1);
QCOMPARE(0, proxy.rowCount());
// change layout of source model
@@ -1482,7 +1482,7 @@ void tst_QSortFilterProxyModel::changeSourceLayoutFilteredOut()
// Remove filter; we expect an insert
setupFilter(&proxy, "");
- QCOMPARE(insertSpy.count(), 1);
+ QCOMPARE(insertSpy.size(), 1);
QCOMPARE(beforeSortFilter, proxy.rowCount());
}
@@ -1561,9 +1561,9 @@ void tst_QSortFilterProxyModel::removeSourceRows()
proxy.setSourceModel(&model);
model.insertColumns(0, 1);
- model.insertRows(0, sourceItems.count());
+ model.insertRows(0, sourceItems.size());
- for (int i = 0; i < sourceItems.count(); ++i) {
+ for (int i = 0; i < sourceItems.size(); ++i) {
QModelIndex sindex = model.index(i, 0, QModelIndex());
model.setData(sindex, sourceItems.at(i), Qt::DisplayRole);
QModelIndex pindex = proxy.index(i, 0, QModelIndex());
@@ -1586,16 +1586,16 @@ void tst_QSortFilterProxyModel::removeSourceRows()
model.removeRows(start, count, QModelIndex());
- QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count());
- for (int i = 0; i < aboutToRemoveSpy.count(); ++i) {
+ QCOMPARE(aboutToRemoveSpy.size(), expectedRemovedProxyIntervals.size());
+ for (int i = 0; i < aboutToRemoveSpy.size(); ++i) {
const auto &args = aboutToRemoveSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}
- QCOMPARE(removeSpy.count(), expectedRemovedProxyIntervals.count());
- for (int i = 0; i < removeSpy.count(); ++i) {
+ QCOMPARE(removeSpy.size(), expectedRemovedProxyIntervals.size());
+ for (int i = 0; i < removeSpy.size(); ++i) {
const auto &args = removeSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
@@ -1603,11 +1603,11 @@ void tst_QSortFilterProxyModel::removeSourceRows()
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}
- QCOMPARE(insertSpy.count(), 0);
- QCOMPARE(aboutToInsertSpy.count(), 0);
+ QCOMPARE(insertSpy.size(), 0);
+ QCOMPARE(aboutToInsertSpy.size(), 0);
- QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.count());
- for (int i = 0; i < expectedProxyItems.count(); ++i) {
+ QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.size());
+ for (int i = 0; i < expectedProxyItems.size(); ++i) {
QModelIndex pindex = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(pindex, Qt::DisplayRole).toString(), expectedProxyItems.at(i));
}
@@ -1654,9 +1654,9 @@ void tst_QSortFilterProxyModel::insertSourceRows()
proxy.setSourceModel(&model);
model.insertColumns(0, 1);
- model.insertRows(0, sourceItems.count());
+ model.insertRows(0, sourceItems.size());
- for (int i = 0; i < sourceItems.count(); ++i) {
+ for (int i = 0; i < sourceItems.size(); ++i) {
QModelIndex index = model.index(i, 0, QModelIndex());
model.setData(index, sourceItems.at(i), Qt::DisplayRole);
}
@@ -1666,13 +1666,13 @@ void tst_QSortFilterProxyModel::insertSourceRows()
model.insertRows(start, newItems.size(), QModelIndex());
- QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.count());
- for (int i = 0; i < newItems.count(); ++i) {
+ QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.size());
+ for (int i = 0; i < newItems.size(); ++i) {
QModelIndex index = model.index(start + i, 0, QModelIndex());
model.setData(index, newItems.at(i), Qt::DisplayRole);
}
- for (int i = 0; i < proxyItems.count(); ++i) {
+ for (int i = 0; i < proxyItems.size(); ++i) {
QModelIndex index = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), proxyItems.at(i));
}
@@ -1745,9 +1745,9 @@ void tst_QSortFilterProxyModel::changeFilter()
proxy.setSourceModel(&model);
model.insertColumns(0, 1);
- model.insertRows(0, sourceItems.count());
+ model.insertRows(0, sourceItems.size());
- for (int i = 0; i < sourceItems.count(); ++i) {
+ for (int i = 0; i < sourceItems.size(); ++i) {
QModelIndex index = model.index(i, 0, QModelIndex());
model.setData(index, sourceItems.at(i), Qt::DisplayRole);
}
@@ -1763,9 +1763,9 @@ void tst_QSortFilterProxyModel::changeFilter()
setupFilter(&proxy, initialFilter);
- QCOMPARE(initialRemoveSpy.count(), initialRemoveIntervals.count());
- QCOMPARE(initialInsertSpy.count(), 0);
- for (int i = 0; i < initialRemoveSpy.count(); ++i) {
+ QCOMPARE(initialRemoveSpy.size(), initialRemoveIntervals.size());
+ QCOMPARE(initialInsertSpy.size(), 0);
+ for (int i = 0; i < initialRemoveSpy.size(); ++i) {
const auto &args = initialRemoveSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
@@ -1773,8 +1773,8 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(args.at(2).toInt(), initialRemoveIntervals.at(i).second);
}
- QCOMPARE(proxy.rowCount(QModelIndex()), initialProxyItems.count());
- for (int i = 0; i < initialProxyItems.count(); ++i) {
+ QCOMPARE(proxy.rowCount(QModelIndex()), initialProxyItems.size());
+ for (int i = 0; i < initialProxyItems.size(); ++i) {
QModelIndex index = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initialProxyItems.at(i));
}
@@ -1787,8 +1787,8 @@ void tst_QSortFilterProxyModel::changeFilter()
setupFilter(&proxy, finalFilter);
- QCOMPARE(finalRemoveSpy.count(), finalRemoveIntervals.count());
- for (int i = 0; i < finalRemoveSpy.count(); ++i) {
+ QCOMPARE(finalRemoveSpy.size(), finalRemoveIntervals.size());
+ for (int i = 0; i < finalRemoveSpy.size(); ++i) {
const auto &args = finalRemoveSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
@@ -1796,8 +1796,8 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(args.at(2).toInt(), finalRemoveIntervals.at(i).second);
}
- QCOMPARE(finalInsertSpy.count(), insertIntervals.count());
- for (int i = 0; i < finalInsertSpy.count(); ++i) {
+ QCOMPARE(finalInsertSpy.size(), insertIntervals.size());
+ for (int i = 0; i < finalInsertSpy.size(); ++i) {
const auto &args = finalInsertSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
@@ -1805,8 +1805,8 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second);
}
- QCOMPARE(proxy.rowCount(QModelIndex()), finalProxyItems.count());
- for (int i = 0; i < finalProxyItems.count(); ++i) {
+ QCOMPARE(proxy.rowCount(QModelIndex()), finalProxyItems.size());
+ for (int i = 0; i < finalProxyItems.size(); ++i) {
QModelIndex index = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), finalProxyItems.at(i));
}
@@ -1969,9 +1969,9 @@ void tst_QSortFilterProxyModel::changeSourceData()
proxy.setDynamicSortFilter(dynamic);
proxy.setSourceModel(&model);
model.insertColumns(0, 1);
- model.insertRows(0, sourceItems.count());
+ model.insertRows(0, sourceItems.size());
- for (int i = 0; i < sourceItems.count(); ++i) {
+ for (int i = 0; i < sourceItems.size(); ++i) {
QModelIndex index = model.index(i, 0, QModelIndex());
model.setData(index, sourceItems.at(i), Qt::DisplayRole);
}
@@ -1981,8 +1981,8 @@ void tst_QSortFilterProxyModel::changeSourceData()
setupFilter(&proxy, filter);
- QCOMPARE(proxy.rowCount(), expectedInitialProxyItems.count());
- for (int i = 0; i < expectedInitialProxyItems.count(); ++i) {
+ QCOMPARE(proxy.rowCount(), expectedInitialProxyItems.size());
+ for (int i = 0; i < expectedInitialProxyItems.size(); ++i) {
const QModelIndex index = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expectedInitialProxyItems.at(i));
}
@@ -2002,8 +2002,8 @@ void tst_QSortFilterProxyModel::changeSourceData()
model.setData(index, newValue, Qt::DisplayRole);
}
- QCOMPARE(removeSpy.count(), removeIntervals.count());
- for (int i = 0; i < removeSpy.count(); ++i) {
+ QCOMPARE(removeSpy.size(), removeIntervals.size());
+ for (int i = 0; i < removeSpy.size(); ++i) {
const auto &args = removeSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
@@ -2011,8 +2011,8 @@ void tst_QSortFilterProxyModel::changeSourceData()
QCOMPARE(args.at(2).toInt(), removeIntervals.at(i).second);
}
- QCOMPARE(insertSpy.count(), insertIntervals.count());
- for (int i = 0; i < insertSpy.count(); ++i) {
+ QCOMPARE(insertSpy.size(), insertIntervals.size());
+ for (int i = 0; i < insertSpy.size(); ++i) {
const auto &args = insertSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
@@ -2020,29 +2020,29 @@ void tst_QSortFilterProxyModel::changeSourceData()
QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second);
}
- QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.count());
- for (int i = 0; i < proxyItems.count(); ++i) {
+ QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.size());
+ for (int i = 0; i < proxyItems.size(); ++i) {
QModelIndex index = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), proxyItems.at(i));
}
if (expectedDataChangedRow == -1) {
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
} else {
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
const QModelIndex idx = dataChangedSpy.at(0).at(0).value<QModelIndex>();
QCOMPARE(idx.row(), expectedDataChangedRow);
QCOMPARE(idx.column(), 0);
}
- QCOMPARE(layoutChangedSpy.count(), expectedLayoutChanged ? 1 : 0);
+ QCOMPARE(layoutChangedSpy.size(), expectedLayoutChanged ? 1 : 0);
}
// Checks that the model is a table, and that each and every row is like this:
// i-th row: ( rows.at(i), i )
static void checkSortedTableModel(const QAbstractItemModel *model, const QStringList &rows)
{
- QCOMPARE(model->rowCount(), rows.length());
+ QCOMPARE(model->rowCount(), rows.size());
QCOMPARE(model->columnCount(), 2);
for (int row = 0; row < model->rowCount(); ++row) {
@@ -2066,7 +2066,7 @@ void tst_QSortFilterProxyModel::changeSourceDataKeepsStableSorting_qtbug1548()
// Build a table of pairs (string, #row) in each row
QStandardItemModel model(0, 2);
- for (int rowNumber = 0; rowNumber < rows.length(); ++rowNumber) {
+ for (int rowNumber = 0; rowNumber < rows.size(); ++rowNumber) {
QStandardItem *column0 = new QStandardItem(rows.at(rowNumber));
column0->setCheckable(true);
column0->setCheckState(Qt::Unchecked);
@@ -2120,7 +2120,7 @@ void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440()
QSignalSpy spy(&proxy, &QAbstractItemModel::dataChanged);
QVERIFY(spy.isValid());
- QCOMPARE(spy.length(), 0);
+ QCOMPARE(spy.size(), 0);
QModelIndex index;
@@ -2133,13 +2133,13 @@ void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440()
index = model.index(0, 0);
QVERIFY(index.isValid());
model.setData(index, QStringLiteral("teststring"), Qt::DisplayRole);
- QCOMPARE(spy.length(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(2).value<QList<int> >(), expectedChangedRoles);
index = model.index(1, 0);
QVERIFY(index.isValid());
model.setData(index, QStringLiteral("teststring2"), Qt::EditRole);
- QCOMPARE(spy.length(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(spy.at(1).at(2).value<QList<int> >(), expectedChangedRoles);
}
@@ -2386,8 +2386,8 @@ void tst_QSortFilterProxyModel::sortFilterRole()
const QList<int> orderedItems({2, 1});
- model.insertRows(0, sourceItems.count());
- for (int i = 0; i < sourceItems.count(); ++i) {
+ model.insertRows(0, sourceItems.size());
+ for (int i = 0; i < sourceItems.size(); ++i) {
QModelIndex index = model.index(i, 0, QModelIndex());
model.setData(index, sourceItems.at(i).first, Qt::DisplayRole);
model.setData(index, sourceItems.at(i).second, Qt::UserRole);
@@ -2417,7 +2417,7 @@ void tst_QSortFilterProxyModel::sortFilterRole()
proxy.setFilterRole(Qt::DisplayRole);
setupFilter(&proxy, QLatin1String("a|c"));
- QCOMPARE(proxy.rowCount(), orderedItems.count());
+ QCOMPARE(proxy.rowCount(), orderedItems.size());
for (int i = 0; i < proxy.rowCount(); ++i) {
QModelIndex index = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(index, Qt::DisplayRole), sourceItems.at(orderedItems.at(i)).first);
@@ -2439,10 +2439,10 @@ void tst_QSortFilterProxyModel::selectionFilteredOut()
QVERIFY(spy.isValid());
view.setCurrentIndex(proxy.index(0, 0));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
setupFilter(&proxy, QLatin1String("^B"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QSortFilterProxyModel::match_data()
@@ -2519,9 +2519,9 @@ void tst_QSortFilterProxyModel::match()
proxy.setSourceModel(&model);
model.insertColumns(0, 1);
- model.insertRows(0, sourceItems.count());
+ model.insertRows(0, sourceItems.size());
- for (int i = 0; i < sourceItems.count(); ++i) {
+ for (int i = 0; i < sourceItems.size(); ++i) {
QModelIndex index = model.index(i, 0, QModelIndex());
model.setData(index, sourceItems.at(i), Qt::DisplayRole);
}
@@ -2531,10 +2531,10 @@ void tst_QSortFilterProxyModel::match()
QModelIndex startIndex = proxy.index(proxyStartRow, 0);
QModelIndexList indexes = proxy.match(startIndex, Qt::DisplayRole, what,
- expectedProxyItems.count(),
+ expectedProxyItems.size(),
matchFlags);
- QCOMPARE(indexes.count(), expectedProxyItems.count());
- for (int i = 0; i < indexes.count(); ++i)
+ QCOMPARE(indexes.size(), expectedProxyItems.size());
+ for (int i = 0; i < indexes.size(); ++i)
QCOMPARE(indexes.at(i).row(), expectedProxyItems.at(i));
}
@@ -2597,13 +2597,13 @@ void tst_QSortFilterProxyModel::insertIntoChildrenlessItem()
QVERIFY(rowsInsertedSpy.isValid());
(void)proxy.rowCount(QModelIndex()); // force mapping of "a", "b", "c"
- QCOMPARE(colsInsertedSpy.count(), 0);
- QCOMPARE(rowsInsertedSpy.count(), 0);
+ QCOMPARE(colsInsertedSpy.size(), 0);
+ QCOMPARE(rowsInsertedSpy.size(), 0);
// now add a child to itemB ==> should get insert notification from the proxy
itemB->appendRow(new QStandardItem("a.0"));
- QCOMPARE(colsInsertedSpy.count(), 1);
- QCOMPARE(rowsInsertedSpy.count(), 1);
+ QCOMPARE(colsInsertedSpy.size(), 1);
+ QCOMPARE(rowsInsertedSpy.size(), 1);
QVariantList args = colsInsertedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), proxy.mapFromSource(itemB->index()));
@@ -2679,11 +2679,11 @@ void tst_QSortFilterProxyModel::insertRowIntoFilteredParent()
QStandardItem *itemB = new QStandardItem();
itemA->appendRow(itemB);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
itemA->removeRow(0);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild()
@@ -2710,9 +2710,9 @@ void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild()
setupFilter(&proxy, QLatin1String("C")); // A and B will be filtered out, C filtered in
// we should now have been notified that the subtree represented by itemA has been removed
- QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(removedSpy.size(), 1);
// we should NOT get any inserts; itemC should be filtered because its parent (itemA) is
- QCOMPARE(insertedSpy.count(), 0);
+ QCOMPARE(insertedSpy.size(), 0);
}
void tst_QSortFilterProxyModel::sourceInsertRows()
@@ -2805,7 +2805,7 @@ void tst_QSortFilterProxyModel::sortColumnTracking2()
model.insertColumn(0,items);
QCOMPARE(proxyModel.sortColumn(), 0);
QCOMPARE(proxyModel.data(proxyModel.index(0,0)).toString(),QString::fromLatin1("aa"));
- const int zzIndex = items.count() - 3; // 2 invalid at end.
+ const int zzIndex = items.size() - 3; // 2 invalid at end.
QCOMPARE(proxyModel.data(proxyModel.index(zzIndex,0)).toString(),QString::fromLatin1("zz"));
}
@@ -2897,16 +2897,16 @@ void tst_QSortFilterProxyModel::staticSorting()
// prepare model
QStandardItem *root = model.invisibleRootItem ();
QList<QStandardItem *> items;
- for (int i = 0; i < initial.count(); ++i) {
+ for (int i = 0; i < initial.size(); ++i) {
items.append(new QStandardItem(initial.at(i)));
}
root->insertRows(0, items);
- QCOMPARE(model.rowCount(QModelIndex()), initial.count());
+ QCOMPARE(model.rowCount(QModelIndex()), initial.size());
QCOMPARE(model.columnCount(QModelIndex()), 1);
// make sure the proxy is unsorted
QCOMPARE(proxy.columnCount(QModelIndex()), 1);
- QCOMPARE(proxy.rowCount(QModelIndex()), initial.count());
+ QCOMPARE(proxy.rowCount(QModelIndex()), initial.size());
for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) {
QModelIndex index = proxy.index(row, 0, QModelIndex());
QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initial.at(row));
@@ -2956,7 +2956,7 @@ void tst_QSortFilterProxyModel::dynamicSorting()
QCOMPARE(proxy1.columnCount(QModelIndex()), 1);
//the model should not be sorted because sorting has not been set to dynamic yet.
- QCOMPARE(proxy1.rowCount(QModelIndex()), initial.count());
+ QCOMPARE(proxy1.rowCount(QModelIndex()), initial.size());
for (int row = 0; row < proxy1.rowCount(QModelIndex()); ++row) {
QModelIndex index = proxy1.index(row, 0, QModelIndex());
QCOMPARE(proxy1.data(index, Qt::DisplayRole).toString(), initial.at(row));
@@ -3214,25 +3214,25 @@ void tst_QSortFilterProxyModel::removeRowsRecursive()
QList<QPersistentModelIndex> sourceIndexes;
QList<QPersistentModelIndex> proxyIndexes;
- for (const auto item : qAsConst(items)) {
+ for (const auto item : std::as_const(items)) {
QModelIndex idx = item->index();
sourceIndexes << idx;
proxyIndexes << proxy.mapFromSource(idx);
}
- for (const auto &pidx : qAsConst(sourceIndexes))
+ for (const auto &pidx : std::as_const(sourceIndexes))
QVERIFY(pidx.isValid());
- for (const auto &pidx : qAsConst(proxyIndexes))
+ for (const auto &pidx : std::as_const(proxyIndexes))
QVERIFY(pidx.isValid());
QList<QStandardItem*> itemRow = pItem1->takeRow(0);
- QCOMPARE(itemRow.count(), 1);
+ QCOMPARE(itemRow.size(), 1);
QCOMPARE(itemRow.first(), pItem11);
- for (const auto &pidx : qAsConst(sourceIndexes))
+ for (const auto &pidx : std::as_const(sourceIndexes))
QVERIFY(!pidx.isValid());
- for (const auto &pidx : qAsConst(proxyIndexes))
+ for (const auto &pidx : std::as_const(proxyIndexes))
QVERIFY(!pidx.isValid());
delete pItem11;
@@ -3266,7 +3266,7 @@ void tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel()
QItemSelectionModel ism(proxyModel);
ism.select(mi, QItemSelectionModel::Select);
QModelIndexList mil = ism.selectedIndexes();
- QCOMPARE(mil.count(), 1);
+ QCOMPARE(mil.size(), 1);
QCOMPARE(mil.first(), mi);
toggleProxy->setSourceModel(model2);
@@ -3337,10 +3337,10 @@ void tst_QSortFilterProxyModel::appearsAndSort()
QCOMPARE(secondProxyModel.data(secondProxyModel.index(1,0), Qt::DisplayRole).toString(), QString::fromLatin1("b"));
QCOMPARE(secondProxyModel.data(secondProxyModel.index(2,0), Qt::DisplayRole).toString(), QString::fromLatin1("a"));
- QCOMPARE(spyAbout1.count(), 1);
- QCOMPARE(spyChanged1.count(), 1);
- QCOMPARE(spyAbout2.count(), 1);
- QCOMPARE(spyChanged2.count(), 1);
+ QCOMPARE(spyAbout1.size(), 1);
+ QCOMPARE(spyChanged1.size(), 1);
+ QCOMPARE(spyAbout2.size(), 1);
+ QCOMPARE(spyChanged2.size(), 1);
}
void tst_QSortFilterProxyModel::unnecessaryDynamicSorting()
@@ -4647,7 +4647,7 @@ public:
return lst.at(index.row());
return QVariant();
}
- int rowCount(const QModelIndex & = QModelIndex()) const override { return lst.count(); }
+ int rowCount(const QModelIndex & = QModelIndex()) const override { return lst.size(); }
void replaceData(const QStringList &newData)
{
@@ -4788,7 +4788,7 @@ void tst_QSortFilterProxyModel::removeIntervals()
model.replaceData(sourceItems);
proxy.setSourceModel(&model);
- for (int i = 0; i < sourceItems.count(); ++i) {
+ for (int i = 0; i < sourceItems.size(); ++i) {
QModelIndex sindex = model.index(i, 0, QModelIndex());
QModelIndex pindex = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(pindex, Qt::DisplayRole), model.data(sindex, Qt::DisplayRole));
@@ -4813,16 +4813,16 @@ void tst_QSortFilterProxyModel::removeIntervals()
model.replaceData(replacementSourceItems);
- QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count());
- for (int i = 0; i < aboutToRemoveSpy.count(); ++i) {
+ QCOMPARE(aboutToRemoveSpy.size(), expectedRemovedProxyIntervals.size());
+ for (int i = 0; i < aboutToRemoveSpy.size(); ++i) {
const auto &args = aboutToRemoveSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first);
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}
- QCOMPARE(removeSpy.count(), expectedRemovedProxyIntervals.count());
- for (int i = 0; i < removeSpy.count(); ++i) {
+ QCOMPARE(removeSpy.size(), expectedRemovedProxyIntervals.size());
+ for (int i = 0; i < removeSpy.size(); ++i) {
const auto &args = removeSpy.at(i);
QCOMPARE(args.at(1).userType(), QMetaType::Int);
QCOMPARE(args.at(2).userType(), QMetaType::Int);
@@ -4830,11 +4830,11 @@ void tst_QSortFilterProxyModel::removeIntervals()
QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second);
}
- QCOMPARE(insertSpy.count(), 0);
- QCOMPARE(aboutToInsertSpy.count(), 0);
+ QCOMPARE(insertSpy.size(), 0);
+ QCOMPARE(aboutToInsertSpy.size(), 0);
- QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.count());
- for (int i = 0; i < expectedProxyItems.count(); ++i) {
+ QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.size());
+ for (int i = 0; i < expectedProxyItems.size(); ++i) {
QModelIndex pindex = proxy.index(i, 0, QModelIndex());
QCOMPARE(proxy.data(pindex, Qt::DisplayRole).toString(), expectedProxyItems.at(i));
}
@@ -4861,7 +4861,7 @@ void tst_QSortFilterProxyModel::dynamicFilterWithoutSort()
QCOMPARE(model.stringList(), QStringList() << "Monday" << "Tuesday" << "Wednesday" << "Thursday" << "Friday");
- QCOMPARE(resetSpy.count(), 1);
+ QCOMPARE(resetSpy.size(), 1);
}
void tst_QSortFilterProxyModel::checkSetNewModel()
@@ -5114,7 +5114,7 @@ void tst_QSortFilterProxyModel::filterAndInsertRow()
QVERIFY(proxyModel.insertRow(row));
QCOMPARE(model.stringList(), expectedModelList);
- QCOMPARE(proxyModel.rowCount(), expectedProxyModelList.count());
+ QCOMPARE(proxyModel.rowCount(), expectedProxyModelList.size());
for (int r = 0; r < proxyModel.rowCount(); ++r) {
QModelIndex index = proxyModel.index(r, 0);
QVERIFY(index.isValid());
@@ -5387,7 +5387,7 @@ void tst_QSortFilterProxyModel::filterCaseSensitivityBinding()
QRegularExpression regExp("pattern", QRegularExpression::CaseInsensitiveOption);
proxyModel.setFilterRegularExpression(regExp);
QCOMPARE(proxyModel.filterCaseSensitivity(), Qt::CaseInsensitive);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!proxyModel.bindableFilterCaseSensitivity().hasBinding());
}
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
index a880f8d204..eb137d4821 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
@@ -119,7 +119,7 @@ static void fillModel(QStandardItemModel &model, const QString &str)
QCOMPARE(str.count('['), str.count(']'));
QStandardItem *item = nullptr;
QString data;
- for ( int i = 0 ; i < str.length() ; ++i ) {
+ for ( int i = 0 ; i < str.size() ; ++i ) {
const QChar ch = str.at(i);
if ((ch == '[' || ch == ']' || ch == ' ') && !data.isEmpty()) {
if (data.endsWith('*')) {
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp
index bce7b1733d..b99269d81c 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp
@@ -118,12 +118,12 @@ void tst_QSortFilterProxyModelRegularExpression::tst_regexCaseSensitivityNotific
QSortFilterProxyModel proxy;
QSignalSpy spy(&proxy, &QSortFilterProxyModel::filterCaseSensitivityChanged);
proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QRegularExpression re("regex");
QVERIFY(!re.patternOptions().testFlag(QRegularExpression::CaseInsensitiveOption));
proxy.setFilterRegularExpression(re);
QCOMPARE(proxy.filterCaseSensitivity(), Qt::CaseSensitive);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
QTEST_MAIN(tst_QSortFilterProxyModelRegularExpression)
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index ac2eda0ef0..084b7c5f0c 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -406,7 +406,7 @@ void tst_QStringListModel::setData_emits_on_change_only()
const QModelIndex modelIdx = model.index(0, 0);
const QString newStringData = QStringLiteral("test");
QVERIFY(model.setData(modelIdx, newStringData));
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
const QList<QVariant> spyList = dataChangedSpy.takeFirst();
QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx);
QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx);
diff --git a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp
index 353d700e2d..8d34f0a574 100644
--- a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp
@@ -264,8 +264,8 @@ void tst_QTransposeProxyModel::sort()
QVERIFY(layoutAboutToBeChangedSpy.isValid());
QPersistentModelIndex firstIndexBeforeSort = proxyModel.index(0, 0);
baseModel.sort(0, Qt::AscendingOrder);
- QCOMPARE(layoutChangedSpy.count(), 1);
- QCOMPARE(layoutAboutToBeChangedSpy.count(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 1);
+ QCOMPARE(layoutAboutToBeChangedSpy.size(), 1);
QCOMPARE(layoutChangedSpy.takeFirst().at(1).toInt(), int(QAbstractItemModel::HorizontalSortHint));
QCOMPARE(firstIndexBeforeSort.data().toString(), firstItemBeforeSort);
for (int i = 0; i < 100; ++i)
@@ -298,8 +298,8 @@ void tst_QTransposeProxyModel::removeColumnBase()
QVERIFY(model->removeColumn(1, parent));
QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount - 1);
QCOMPARE(proxy.index(1, 0, proxy.mapFromSource(parent)).data(), expectedNewVal);
- QCOMPARE(rowRemoveSpy.count(), 1);
- QCOMPARE(rowAboutToBeRemoveSpy.count(), 1);
+ QCOMPARE(rowRemoveSpy.size(), 1);
+ QCOMPARE(rowAboutToBeRemoveSpy.size(), 1);
for (const auto &spyArgs : {rowRemoveSpy.takeFirst(),
rowAboutToBeRemoveSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
@@ -412,8 +412,8 @@ void tst_QTransposeProxyModel::insertColumnBase()
QVERIFY(model->insertColumn(1, parent));
QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount + 1);
QVERIFY(!proxy.index(1, 0, proxy.mapFromSource(parent)).data().isValid());
- QCOMPARE(rowInsertSpy.count(), 1);
- QCOMPARE(rowAboutToBeInsertSpy.count(), 1);
+ QCOMPARE(rowInsertSpy.size(), 1);
+ QCOMPARE(rowAboutToBeInsertSpy.size(), 1);
for (const auto &spyArgs : {rowInsertSpy.takeFirst(),
rowAboutToBeInsertSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
@@ -450,8 +450,8 @@ void tst_QTransposeProxyModel::removeRowBase()
QVERIFY(model->removeRow(1, parent));
QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount - 1);
QCOMPARE(proxy.index(0, 1, proxy.mapFromSource(parent)).data(), expectedNewVal);
- QCOMPARE(columnsRemoveSpy.count(), 1);
- QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1);
+ QCOMPARE(columnsRemoveSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeRemoveSpy.size(), 1);
for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(),
columnsAboutToBeRemoveSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
@@ -488,8 +488,8 @@ void tst_QTransposeProxyModel::insertRowBase()
QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount + 1);
QVariant result = proxy.index(0, 1, proxy.mapFromSource(parent)).data();
QVERIFY(result.isNull() || (result.metaType().id() == QMetaType::QString && result.toString().isNull()));
- QCOMPARE(columnsInsertSpy.count(), 1);
- QCOMPARE(columnsAboutToBeInsertSpy.count(), 1);
+ QCOMPARE(columnsInsertSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeInsertSpy.size(), 1);
for (const auto &spyArgs : {columnsInsertSpy.takeFirst(),
columnsAboutToBeInsertSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
@@ -534,10 +534,10 @@ void tst_QTransposeProxyModel::removeColumnProxy()
QCOMPARE(model->rowCount(sourceParent), oldRowCount - 1);
QCOMPARE(proxy.index(0, 1, proxyParent).data(), expectedNewVal);
QCOMPARE(model->index(1, 0, sourceParent).data(), expectedNewVal);
- QCOMPARE(columnsRemoveSpy.count(), 1);
- QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1);
- QCOMPARE(rowsRemoveSpy.count(), 1);
- QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1);
+ QCOMPARE(columnsRemoveSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeRemoveSpy.size(), 1);
+ QCOMPARE(rowsRemoveSpy.size(), 1);
+ QCOMPARE(rowsAboutToBeRemoveSpy.size(), 1);
for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(),
columnsAboutToBeRemoveSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent);
@@ -589,10 +589,10 @@ void tst_QTransposeProxyModel::insertColumnProxy()
QVERIFY(result.isNull() || (result.metaType().id() == QMetaType::QString && result.toString().isNull()));
result = model->index(1, 0, sourceParent).data();
QVERIFY(result.isNull() || (result.metaType().id() == QMetaType::QString && result.toString().isNull()));
- QCOMPARE(columnsInsertSpy.count(), 1);
- QCOMPARE(columnsAboutToBeInsertSpy.count(), 1);
- QCOMPARE(rowsInsertSpy.count(), 1);
- QCOMPARE(rowsAboutToBeInsertSpy.count(), 1);
+ QCOMPARE(columnsInsertSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeInsertSpy.size(), 1);
+ QCOMPARE(rowsInsertSpy.size(), 1);
+ QCOMPARE(rowsAboutToBeInsertSpy.size(), 1);
for (const auto &spyArgs : {columnsInsertSpy.takeFirst(),
columnsAboutToBeInsertSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent);
@@ -642,10 +642,10 @@ void tst_QTransposeProxyModel::removeRowProxy()
QCOMPARE(model->columnCount(sourceParent), oldColCount - 1);
QCOMPARE(proxy.index(1, 0, proxyParent).data(), expectedNewVal);
QCOMPARE(model->index(0, 1, sourceParent).data(), expectedNewVal);
- QCOMPARE(columnsRemoveSpy.count(), 1);
- QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1);
- QCOMPARE(rowsRemoveSpy.count(), 1);
- QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1);
+ QCOMPARE(columnsRemoveSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeRemoveSpy.size(), 1);
+ QCOMPARE(rowsRemoveSpy.size(), 1);
+ QCOMPARE(rowsAboutToBeRemoveSpy.size(), 1);
for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(),
columnsAboutToBeRemoveSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent);
@@ -694,10 +694,10 @@ void tst_QTransposeProxyModel::insertRowProxy()
QCOMPARE(model->columnCount(sourceParent), oldColCount + 1);
QVERIFY(proxy.index(1, 0, proxyParent).data().isNull());
QVERIFY(model->index(0, 1, sourceParent).data().isNull());
- QCOMPARE(columnsInsertSpy.count(), 1);
- QCOMPARE(columnsAboutToBeInsertSpy.count(), 1);
- QCOMPARE(rowsInsertSpy.count(), 1);
- QCOMPARE(rowsAboutToBeInsertSpy.count(), 1);
+ QCOMPARE(columnsInsertSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeInsertSpy.size(), 1);
+ QCOMPARE(rowsInsertSpy.size(), 1);
+ QCOMPARE(rowsAboutToBeInsertSpy.size(), 1);
for (const auto &spyArgs : {columnsInsertSpy.takeFirst(),
columnsAboutToBeInsertSpy.takeFirst()}) {
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent);
@@ -869,8 +869,8 @@ void tst_QTransposeProxyModel::moveRowsBase()
QVERIFY(model.moveRows(QModelIndex(), 0, 1, QModelIndex(), 2));
for (int i = 0; i < expectedNewVal.size(); ++i)
QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i));
- QCOMPARE(columnsMoveSpy.count(), 1);
- QCOMPARE(columnsAboutToBeMoveSpy.count(), 1);
+ QCOMPARE(columnsMoveSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeMoveSpy.size(), 1);
for (const auto &spyArgs : {columnsMoveSpy.takeFirst(),
columnsAboutToBeMoveSpy.takeFirst()}) {
QVERIFY(!spyArgs.at(0).value<QModelIndex>().isValid());
@@ -901,10 +901,10 @@ void tst_QTransposeProxyModel::moveColumnsProxy()
QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i));
for (int i = 0; i < expectedNewVal.size(); ++i)
QCOMPARE(model.index(i, 0).data(), expectedNewVal.at(i));
- QCOMPARE(columnsMoveSpy.count(), 1);
- QCOMPARE(columnsAboutToBeMoveSpy.count(), 1);
- QCOMPARE(rowsMoveSpy.count(), 1);
- QCOMPARE(rowsAboutToBeMoveSpy.count(), 1);
+ QCOMPARE(columnsMoveSpy.size(), 1);
+ QCOMPARE(columnsAboutToBeMoveSpy.size(), 1);
+ QCOMPARE(rowsMoveSpy.size(), 1);
+ QCOMPARE(rowsAboutToBeMoveSpy.size(), 1);
for (const auto &spyArgs : {columnsMoveSpy.takeFirst(),
columnsAboutToBeMoveSpy.takeFirst(),
rowsMoveSpy.takeFirst(),rowsAboutToBeMoveSpy.takeFirst()}) {
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index 8ddca93cb7..46d52c2340 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -175,7 +175,7 @@ void tst_QCoreApplication::argc()
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
TestApplication app(argc, argv);
QCOMPARE(argc, 1);
- QCOMPARE(app.arguments().count(), 1);
+ QCOMPARE(app.arguments().size(), 1);
}
{
@@ -186,7 +186,7 @@ void tst_QCoreApplication::argc()
const_cast<char*>("arg3") };
TestApplication app(argc, argv);
QCOMPARE(argc, 4);
- QCOMPARE(app.arguments().count(), 4);
+ QCOMPARE(app.arguments().size(), 4);
}
{
@@ -194,7 +194,7 @@ void tst_QCoreApplication::argc()
char **argv = 0;
TestApplication app(argc, argv);
QCOMPARE(argc, 0);
- QCOMPARE(app.arguments().count(), 0);
+ QCOMPARE(app.arguments().size(), 0);
}
{
@@ -203,7 +203,7 @@ void tst_QCoreApplication::argc()
const_cast<char*>("-qmljsdebugger=port:3768,block") };
TestApplication app(argc, argv);
QCOMPARE(argc, 1);
- QCOMPARE(app.arguments().count(), 1);
+ QCOMPARE(app.arguments().size(), 1);
}
}
@@ -1021,7 +1021,7 @@ void tst_QCoreApplication::addRemoveLibPaths()
TestApplication app(argc, argv);
// If libraryPaths only contains currentDir, neither will be in libraryPaths now.
- if (paths.length() != 1 && currentDir != paths[0]) {
+ if (paths.size() != 1 && currentDir != paths[0]) {
// Check that modifications stay alive across the creation of an application.
QVERIFY(QCoreApplication::libraryPaths().contains(currentDir));
QVERIFY(!QCoreApplication::libraryPaths().contains(paths[0]));
diff --git a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
index b8ed0031cd..ddb765cf82 100644
--- a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
+++ b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
@@ -8,9 +8,7 @@
#include <QTest>
#include <QTimer>
-#if __has_include(<chrono>)
-# include <chrono>
-#endif
+#include <chrono>
static const int minResolution = 400; // the minimum resolution for the tests
@@ -495,9 +493,6 @@ void tst_QDeadlineTimer::expire()
void tst_QDeadlineTimer::stdchrono()
{
-#if !__has_include(<chrono>)
- QSKIP("std::chrono not found on this system");
-#else
using namespace std::chrono;
QFETCH_GLOBAL(Qt::TimerType, timerType);
@@ -697,7 +692,6 @@ void tst_QDeadlineTimer::stdchrono()
QVERIFY(deadline.deadline<steady_clock>() <= (steady_clock::now() + seconds(1) + milliseconds(minResolution)));
QVERIFY(deadline.deadline<system_clock>() > (system_clock::now() + seconds(1) - milliseconds(minResolution)));
QVERIFY(deadline.deadline<system_clock>() <= (system_clock::now() + seconds(1) + milliseconds(minResolution)));
-#endif
}
QTEST_MAIN(tst_QDeadlineTimer)
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index df5f5fef1d..99563f187a 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -159,7 +159,7 @@ private:
bool foundCoarse = false;
bool foundVeryCoarse = false;
const QList<QAbstractEventDispatcher::TimerInfo> timers = registeredTimers();
- for (int i = 0; i < timers.count(); ++i) {
+ for (int i = 0; i < timers.size(); ++i) {
const QAbstractEventDispatcher::TimerInfo &timerInfo = timers.at(i);
if (timerInfo.timerId == m_preciseTimerId) {
QCOMPARE(timerInfo.interval, int(PreciseTimerInterval));
@@ -201,7 +201,7 @@ void tst_QEventDispatcher::registerTimer()
return;
// check that all 3 are present in the eventDispatcher's registeredTimer() list
- QCOMPARE(timers.registeredTimers().count(), 3);
+ QCOMPARE(timers.registeredTimers().size(), 3);
QVERIFY(timers.foundPrecise());
QVERIFY(timers.foundCoarse());
QVERIFY(timers.foundVeryCoarse());
@@ -236,7 +236,7 @@ void tst_QEventDispatcher::registerTimer()
timers.unregister(timers.preciseTimerId());
if (QTest::currentTestFailed())
return;
- QCOMPARE(timers.registeredTimers().count(), 2);
+ QCOMPARE(timers.registeredTimers().size(), 2);
QVERIFY(!timers.foundPrecise());
QVERIFY(timers.foundCoarse());
QVERIFY(timers.foundVeryCoarse());
@@ -260,7 +260,7 @@ void tst_QEventDispatcher::registerTimer()
timers.unregister(timers.coarseTimerId());
if (QTest::currentTestFailed())
return;
- QCOMPARE(timers.registeredTimers().count(), 1);
+ QCOMPARE(timers.registeredTimers().size(), 1);
QVERIFY(!timers.foundPrecise());
QVERIFY(!timers.foundCoarse());
QVERIFY(timers.foundVeryCoarse());
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
index 74b08601b7..16437d39f9 100644
--- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
@@ -174,8 +174,8 @@ void tst_QEventLoop::processEvents()
// process posted events, QEventLoop::processEvents() should return
// true
QVERIFY(eventLoop.processEvents());
- QCOMPARE(aboutToBlockSpy.count(), 0);
- QCOMPARE(awakeSpy.count(), 1);
+ QCOMPARE(aboutToBlockSpy.size(), 0);
+ QCOMPARE(awakeSpy.size(), 1);
// allow any session manager to complete its handshake, so that
// there are no pending events left. This tests that we are able
@@ -196,8 +196,8 @@ void tst_QEventLoop::processEvents()
// processEvents is entered. There is no guarantee that that the
// processEvents call actually blocked, since the OS may introduce
// native events at any time.
- QVERIFY(awakeSpy.count() > 0);
- QVERIFY(awakeSpy.count() >= aboutToBlockSpy.count());
+ QVERIFY(awakeSpy.size() > 0);
+ QVERIFY(awakeSpy.size() >= aboutToBlockSpy.size());
killTimer(timerId);
}
@@ -240,7 +240,7 @@ void tst_QEventLoop::exec()
QVERIFY(spy.isValid());
thread.cond.wakeOne();
thread.cond.wait(&thread.mutex);
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
int v = thread.result1;
QCOMPARE(v, 0);
@@ -249,7 +249,7 @@ void tst_QEventLoop::exec()
thread.cond.wakeOne();
thread.mutex.unlock();
thread.wait();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
v = thread.result2;
QCOMPARE(v, -1);
}
@@ -307,7 +307,7 @@ void tst_QEventLoop::wakeUp()
QTimer::singleShot(1000, &eventLoop, SLOT(quit()));
(void) eventLoop.exec();
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
thread.quit();
(void) eventLoop.exec();
diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
index 36f792ec8a..fbf9fb8d6e 100644
--- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
@@ -1498,8 +1498,8 @@ void tst_QMetaObjectBuilder::usage_signal()
QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged);
testObject->emitIntPropChanged();
- QCOMPARE(propChangedSpy.count(), 1);
- QCOMPARE(propChangedSpy.at(0).count(), 1);
+ QCOMPARE(propChangedSpy.size(), 1);
+ QCOMPARE(propChangedSpy.at(0).size(), 1);
QCOMPARE(propChangedSpy.at(0).at(0).toInt(), testObject->intProp());
}
@@ -1514,7 +1514,7 @@ void tst_QMetaObjectBuilder::usage_property()
QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged);
QVERIFY(testObject->intProp() != 123);
testObject->setProperty("intProp", 123);
- QCOMPARE(propChangedSpy.count(), 1);
+ QCOMPARE(propChangedSpy.size(), 1);
prop = testObject->property("intProp");
QCOMPARE(prop.metaType(), QMetaType(QMetaType::Int));
QCOMPARE(prop.toInt(), 123);
diff --git a/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt b/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt
index 264c459a89..a63bc2714c 100644
--- a/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt
+++ b/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt
@@ -7,6 +7,35 @@
# Collect test data
list(APPEND test_data "./typeFlags.bin")
+qt_internal_add_cmake_library(qmetatype_lib1
+ INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qmetatype"
+ SOURCES
+ lib1.cpp
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+qt_internal_add_cmake_library(qmetatype_lib2
+ INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qmetatype"
+ SOURCES
+ lib2.cpp
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+set_target_properties(qmetatype_lib1 PROPERTIES
+ VERSION 1.0.0
+ SOVERSION 0
+ C_VISIBILITY_PRESET "hidden"
+ CXX_VISIBILITY_PRESET "hidden"
+ VISIBILITY_INLINES_HIDDEN ON
+)
+set_target_properties(qmetatype_lib2 PROPERTIES
+ VERSION 1.0.0
+ SOVERSION 0
+ C_VISIBILITY_PRESET "hidden"
+ CXX_VISIBILITY_PRESET "hidden"
+ VISIBILITY_INLINES_HIDDEN ON
+)
+
qt_internal_add_test(tst_qmetatype
SOURCES
tst_qmetatype.h tst_qmetatype.cpp tst_qmetatype2.cpp
@@ -18,6 +47,8 @@ qt_internal_add_test(tst_qmetatype
PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::Gui
+ qmetatype_lib1
+ qmetatype_lib2
TESTDATA ${test_data}
)
@@ -25,7 +56,3 @@ qt_internal_extend_target(tst_qmetatype CONDITION MSVC
COMPILE_OPTIONS
/bigobj
)
-
-#### Keys ignored in scope 3:.:.:qmetatype.pro:CLANG:
-# QMAKE_CFLAGS_RELEASE = "--O2" "--g"
-# QMAKE_CXXFLAGS_RELEASE = "--O2" "--g"
diff --git a/tests/auto/corelib/kernel/qmetatype/lib1.cpp b/tests/auto/corelib/kernel/qmetatype/lib1.cpp
new file mode 100644
index 0000000000..6a811241e9
--- /dev/null
+++ b/tests/auto/corelib/kernel/qmetatype/lib1.cpp
@@ -0,0 +1,5 @@
+// Copyright (C) 2022 Intel Corporation
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#define LIB_NAMESPACE Lib1
+#include "lib_common.cpp"
diff --git a/tests/auto/corelib/kernel/qmetatype/lib2.cpp b/tests/auto/corelib/kernel/qmetatype/lib2.cpp
new file mode 100644
index 0000000000..b5a56f6c68
--- /dev/null
+++ b/tests/auto/corelib/kernel/qmetatype/lib2.cpp
@@ -0,0 +1,5 @@
+// Copyright (C) 2022 Intel Corporation
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#define LIB_NAMESPACE Lib2
+#include "lib_common.cpp"
diff --git a/tests/auto/corelib/kernel/qmetatype/lib_common.cpp b/tests/auto/corelib/kernel/qmetatype/lib_common.cpp
new file mode 100644
index 0000000000..f0554ec25c
--- /dev/null
+++ b/tests/auto/corelib/kernel/qmetatype/lib_common.cpp
@@ -0,0 +1,13 @@
+// Copyright (C) 2022 Intel Corporation
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <qcollator.h>
+#include "tst_qmetatype_libs.h"
+
+#define DECLARE_FUNCTION(TYPE, ID) \
+ Q_DECL_EXPORT QMetaType metatype_ ## TYPE() \
+ { return QMetaType::fromType<TYPE>(); }
+
+namespace LIB_NAMESPACE {
+FOR_EACH_METATYPE_LIBS(DECLARE_FUNCTION)
+}
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 652065a6e5..364955c7b3 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -525,14 +525,14 @@ void tst_QMetaType::properties()
QCOMPARE(v.typeName(), "QVariantList");
QList<QVariant> values = v.toList();
- QCOMPARE(values.count(), 2);
+ QCOMPARE(values.size(), 2);
QCOMPARE(values.at(0).toInt(), 42);
values << 43 << "world";
QVERIFY(setProperty("prop", values));
v = property("prop");
- QCOMPARE(v.toList().count(), 4);
+ QCOMPARE(v.toList().size(), 4);
}
void tst_QMetaType::normalizedTypes()
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h
index 37d9f958e9..7e3d584a67 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h
@@ -106,6 +106,10 @@ private slots:
void fromType();
void operatorEq_data();
void operatorEq();
+ void operatorEq2_data();
+ void operatorEq2();
+ void operatorEqAcrossLibs_data();
+ void operatorEqAcrossLibs();
void typesWithInaccessibleDTors();
void voidIsNotUnknown();
void typeNameNormalization();
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
index 95cc0e7ed8..265ec3095f 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "tst_qmetatype.h"
-#include "tst_qvariant_common.h"
+#include "tst_qmetatype_libs.h"
#include <QtCore/private/qmetaobjectbuilder_p.h>
@@ -412,6 +412,124 @@ void tst_QMetaType::operatorEq()
QCOMPARE(typeB == typeA, eq);
QCOMPARE(typeA != typeB, !eq);
QCOMPARE(typeB != typeA, !eq);
+
+#if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY)
+ // for built-in types or locally-defined types, this must also hold true
+ if (eq)
+ QCOMPARE(typeA.iface(), typeB.iface());
+#endif
+}
+
+void tst_QMetaType::operatorEq2_data()
+{
+ create_data();
+}
+
+void tst_QMetaType::operatorEq2()
+{
+ QFETCH(int, type);
+ QMetaType fromType1, fromType2;
+ QMetaType fromId1(type), fromId2(type);
+
+ switch (type) {
+ case QMetaType::UnknownType:
+ break;
+#define GET_METATYPE_FROM_TYPE(MetaTypeName, MetaTypeId, RealType) \
+ case QMetaType::MetaTypeName: \
+ fromType1 = QMetaType::fromType<RealType>(); \
+ fromType2 = QMetaType::fromType<RealType>(); \
+ break;
+FOR_EACH_CORE_METATYPE(GET_METATYPE_FROM_TYPE)
+#undef GET_METATYPE_FROM_TYPE
+ }
+
+ // sanity check
+ QCOMPARE(fromId1.id(), type);
+ QCOMPARE(fromId2.id(), type);
+
+ // confirm that they're all equal
+ QCOMPARE(fromId1, fromId2);
+ QCOMPARE(fromType1, fromType2);
+ QCOMPARE(fromType1, fromId1);
+ QCOMPARE(fromType2, fromId2);
+
+#if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY)
+ // for built-in types (other than void), this must be true
+ if (type != QMetaType::Void) {
+ QCOMPARE(fromType1.iface(), fromId1.iface());
+ QCOMPARE(fromType2.iface(), fromId1.iface());
+ }
+#endif
+}
+
+#define DECLARE_LIB_FUNCTION(TYPE, ID) \
+ Q_DECL_IMPORT QMetaType metatype_ ## TYPE();
+namespace Lib1 { FOR_EACH_METATYPE_LIBS(DECLARE_LIB_FUNCTION) }
+namespace Lib2 { FOR_EACH_METATYPE_LIBS(DECLARE_LIB_FUNCTION) }
+#undef DECLARE_LIB_FUNCTION
+
+using LibMetatypeFunction = QMetaType (*)();
+void tst_QMetaType::operatorEqAcrossLibs_data()
+{
+ QTest::addColumn<int>("builtinTypeId");
+ QTest::addColumn<QMetaType>("localType");
+ QTest::addColumn<LibMetatypeFunction>("lib1Function");
+ QTest::addColumn<LibMetatypeFunction>("lib2Function");
+
+#define ADD_ROW(TYPE, ID) \
+ QTest::addRow(QT_STRINGIFY(TYPE)) << int(ID) \
+ << QMetaType::fromType<TYPE>() \
+ << &Lib1::metatype_ ## TYPE \
+ << &Lib2::metatype_ ## TYPE;
+FOR_EACH_METATYPE_LIBS(ADD_ROW)
+#undef ADD_ROW
+}
+
+void tst_QMetaType::operatorEqAcrossLibs()
+{
+ QFETCH(int, builtinTypeId);
+ QFETCH(QMetaType, localType);
+ QFETCH(LibMetatypeFunction, lib1Function);
+ QFETCH(LibMetatypeFunction, lib2Function);
+
+ QMetaType lib1Type = lib1Function();
+ QMetaType lib2Type = lib2Function();
+
+ const QtPrivate::QMetaTypeInterface *localIface = localType.iface();
+ const QtPrivate::QMetaTypeInterface *lib1Iface = lib1Type.iface();
+ const QtPrivate::QMetaTypeInterface *lib2Iface = lib2Type.iface();
+
+ // DO THIS FIRST:
+ // if this isn't a built-in type, then the QMetaTypeInterface::typeId is
+ // initially set to 0
+ QCOMPARE(lib1Type, lib2Type);
+
+ int actualTypeId = localType.id();
+ bool builtinTypeExpected = builtinTypeId != QMetaType::UnknownType;
+ bool builtinTypeActually = actualTypeId < QMetaType::User;
+
+ qDebug() << "QMetaType for type" << QByteArray(localType.name())
+ << "(type ID" << (actualTypeId >= 0x1000 ? Qt::hex : Qt::dec) << actualTypeId << ')'
+ << (builtinTypeActually ? "IS" : "is NOT") << "a built-in type;"
+ << "local interface:" << static_cast<const void *>(localIface)
+ << "lib1 interface:" << static_cast<const void *>(lib1Iface)
+ << "lib2 interface:" << static_cast<const void *>(lib2Iface);
+
+ QCOMPARE(builtinTypeActually, builtinTypeExpected);
+ QCOMPARE(lib1Type.id(), actualTypeId);
+ QCOMPARE(lib2Type.id(), actualTypeId);
+ QCOMPARE(QByteArray(lib1Type.name()), QByteArray(localType.name()));
+ QCOMPARE(QByteArray(lib2Type.name()), QByteArray(localType.name()));
+ QCOMPARE(lib1Type, localType);
+ QCOMPARE(lib2Type, localType);
+
+#if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY)
+ if (actualTypeId < QMetaType::FirstGuiType && actualTypeId != QMetaType::Void) {
+ // for built-in QtCore types, we expect the interfaces to be the same too
+ QCOMPARE(lib1Iface, localIface);
+ QCOMPARE(lib2Iface, localIface);
+ }
+#endif
}
class WithPrivateDTor {
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype_libs.h b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype_libs.h
new file mode 100644
index 0000000000..908e80f9a8
--- /dev/null
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype_libs.h
@@ -0,0 +1,24 @@
+// Copyright (C) 2022 Intel Corporation
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef TST_QMETATYPE_LIBS_H
+#define TST_QMETATYPE_LIBS_H
+
+#include <qmetatype.h>
+
+#include <stdlib.h> // for div_t
+
+// void: builtin metatype, special
+// int: builtin metatype, primitive type
+// QString: builtin metatype, class
+// QCollator: not builtin, class, Q_CORE_EXPORT
+// div_t: not builtin, class, no export
+#define FOR_EACH_METATYPE_LIBS(F) \
+ F(void, QMetaType::Void) \
+ F(int, QMetaType::Int) \
+ F(QString, QMetaType::QString) \
+ F(QCollator, QMetaType::UnknownType) \
+ F(div_t, QMetaType::UnknownType) \
+ /**/
+
+#endif // TST_QMETATYPE_LIBS_H
diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
index 03b07c41ec..6bf00ff57e 100644
--- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
+++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
@@ -71,8 +71,8 @@ void tst_QMimeData::data() const
// set text, verify
mimeData.setData("text/plain", "pirates");
QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates"));
- QCOMPARE(mimeData.data("text/html").length(), 0);
- QCOMPARE(mimeData.data("text/markdown").length(), 0);
+ QCOMPARE(mimeData.data("text/html").size(), 0);
+ QCOMPARE(mimeData.data("text/markdown").size(), 0);
// html time
mimeData.setData("text/html", "ninjas");
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index f765440e71..47cc30bd04 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -147,6 +147,7 @@ private slots:
void singleShotConnection();
void objectNameBinding();
void emitToDestroyedClass();
+ void declarativeData();
};
struct QObjectCreatedOnShutdown
@@ -959,7 +960,7 @@ void tst_QObject::disconnectNotify_receiverDestroyed()
QVERIFY(QObject::connect((SenderObject *)&s, SIGNAL(signal1()),
(ReceiverObject *)&r, SLOT(slot1())));
}
- QCOMPARE(s.disconnectedSignals.count(), 1);
+ QCOMPARE(s.disconnectedSignals.size(), 1);
QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1));
s.disconnectedSignals.clear();
@@ -970,7 +971,7 @@ void tst_QObject::disconnectNotify_receiverDestroyed()
(ReceiverObject *)&r, SLOT(slot3())));
}
- QCOMPARE(s.disconnectedSignals.count(), 1);
+ QCOMPARE(s.disconnectedSignals.size(), 1);
QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal3));
s.disconnectedSignals.clear();
@@ -980,7 +981,7 @@ void tst_QObject::disconnectNotify_receiverDestroyed()
QVERIFY(QObject::connect((SenderObject *)&s, SIGNAL(destroyed()), (ReceiverObject *)&r, SLOT(slot3())));
}
- QCOMPARE(s.disconnectedSignals.count(), 1);
+ QCOMPARE(s.disconnectedSignals.size(), 1);
QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&QObject::destroyed));
}
@@ -995,10 +996,10 @@ void tst_QObject::disconnectNotify_metaObjConnection()
QVERIFY(c);
QVERIFY(QObject::disconnect(c));
- QCOMPARE(s.disconnectedSignals.count(), 1);
+ QCOMPARE(s.disconnectedSignals.size(), 1);
QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1));
- QCOMPARE(s.disconnectedSignals.count(), 1);
+ QCOMPARE(s.disconnectedSignals.size(), 1);
}
}
@@ -2124,18 +2125,18 @@ void tst_QObject::metamethod()
QVERIFY(!(m.attributes() & QMetaMethod::Compatibility));
m = mobj->method(mobj->indexOfMethod("invoke1()"));
- QCOMPARE(m.parameterNames().count(), 0);
- QCOMPARE(m.parameterTypes().count(), 0);
+ QCOMPARE(m.parameterNames().size(), 0);
+ QCOMPARE(m.parameterTypes().size(), 0);
m = mobj->method(mobj->indexOfMethod("invoke2(int)"));
- QCOMPARE(m.parameterNames().count(), 1);
- QCOMPARE(m.parameterTypes().count(), 1);
+ QCOMPARE(m.parameterNames().size(), 1);
+ QCOMPARE(m.parameterTypes().size(), 1);
QCOMPARE(m.parameterTypes().at(0), QByteArray("int"));
QVERIFY(m.parameterNames().at(0).isEmpty());
m = mobj->method(mobj->indexOfMethod("invoke3(int,int)"));
- QCOMPARE(m.parameterNames().count(), 2);
- QCOMPARE(m.parameterTypes().count(), 2);
+ QCOMPARE(m.parameterNames().size(), 2);
+ QCOMPARE(m.parameterTypes().size(), 2);
QCOMPARE(m.parameterTypes().at(0), QByteArray("int"));
QCOMPARE(m.parameterNames().at(0), QByteArray("hinz"));
QCOMPARE(m.parameterTypes().at(1), QByteArray("int"));
@@ -2950,22 +2951,22 @@ void tst_QObject::dynamicProperties()
// set a dynamic property
QVERIFY(!obj.setProperty("myuserproperty", "Hello"));
- QCOMPARE(obj.changedDynamicProperties.count(), 1);
+ QCOMPARE(obj.changedDynamicProperties.size(), 1);
QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty"));
//check if there is no redundant DynamicPropertyChange events
QVERIFY(!obj.setProperty("myuserproperty", "Hello"));
- QCOMPARE(obj.changedDynamicProperties.count(), 1);
+ QCOMPARE(obj.changedDynamicProperties.size(), 1);
QCOMPARE(obj.property("myuserproperty").type(), QVariant::String);
QCOMPARE(obj.property("myuserproperty").toString(), QString("Hello"));
- QCOMPARE(obj.dynamicPropertyNames().count(), 1);
+ QCOMPARE(obj.dynamicPropertyNames().size(), 1);
QCOMPARE(obj.dynamicPropertyNames().first(), QByteArray("myuserproperty"));
// change type of the dynamic property
obj.changedDynamicProperties.clear();
QVERIFY(!obj.setProperty("myuserproperty", QByteArray("Hello")));
- QCOMPARE(obj.changedDynamicProperties.count(), 1);
+ QCOMPARE(obj.changedDynamicProperties.size(), 1);
QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty"));
QCOMPARE(obj.property("myuserproperty").type(), QVariant::ByteArray);
QCOMPARE(obj.property("myuserproperty").toString(), QByteArray("Hello"));
@@ -2974,7 +2975,7 @@ void tst_QObject::dynamicProperties()
obj.changedDynamicProperties.clear();
QVERIFY(!obj.setProperty("myuserproperty", QVariant()));
- QCOMPARE(obj.changedDynamicProperties.count(), 1);
+ QCOMPARE(obj.changedDynamicProperties.size(), 1);
QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty"));
obj.changedDynamicProperties.clear();
@@ -8241,5 +8242,81 @@ signals:
void aSignal5(const std::unique_ptr<const QObject> &);
};
+#ifdef QT_BUILD_INTERNAL
+/*
+ Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
+ to the currently destroyed child, calls to the QtDeclarative handlers need to be
+ correctly guarded. QTBUG-105286
+*/
+namespace QtDeclarative {
+static QAbstractDeclarativeData *theData;
+
+static void destroyed(QAbstractDeclarativeData *data, QObject *)
+{
+ QCOMPARE(data, theData);
+}
+static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
+{
+ QCOMPARE(data, theData);
+}
+// we can't use QCOMPARE in the next two functions, as they don't return void
+static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
+{
+ QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
+ return 0;
+}
+static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
+{
+ QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
+ return true;
+}
+
+class Object : public QObject
+{
+ Q_OBJECT
+public:
+ using QObject::QObject;
+ ~Object()
+ {
+ if (Object *p = static_cast<Object *>(parent()))
+ p->emitSignal();
+ }
+
+ void emitSignal()
+ {
+ emit theSignal();
+ }
+
+signals:
+ void theSignal();
+};
+
+}
+#endif
+
+void tst_QObject::declarativeData()
+{
+#ifdef QT_BUILD_INTERNAL
+ QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
+ QtDeclarative::destroyed);
+ QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
+ QtDeclarative::signalEmitted);
+ QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
+ QtDeclarative::receivers);
+ QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
+ QtDeclarative::isSignalConnected);
+
+ QtDeclarative::Object p;
+ QObjectPrivate *priv = QObjectPrivate::get(&p);
+ priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
+
+ connect(&p, &QtDeclarative::Object::theSignal, &p, []{
+ });
+
+ QtDeclarative::Object *child = new QtDeclarative::Object;
+ child->setParent(&p);
+#endif
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
index c0471890ee..56da58c291 100644
--- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
+++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
@@ -6,6 +6,7 @@
#include <qtest.h>
#include <qproperty.h>
#include <private/qproperty_p.h>
+#include <private/qobject_p.h>
#if __has_include(<source_location>) && __cplusplus >= 202002L && !defined(Q_CLANG_QDOC)
#include <source_location>
@@ -66,6 +67,7 @@ private slots:
void quntypedBindableApi();
void readonlyConstQBindable();
void qobjectBindableManualNotify();
+ void qobjectBindableReallocatedBindingStorage();
void qobjectBindableSignalTakingNewValue();
void testNewStuff();
@@ -85,6 +87,8 @@ private slots:
void noDoubleNotification();
void groupedNotifications();
void groupedNotificationConsistency();
+ void bindingGroupMovingBindingData();
+ void bindingGroupBindingDeleted();
void uninstalledBindingDoesNotEvaluate();
void notify();
@@ -95,6 +99,8 @@ private slots:
void qpropertyAlias();
void scheduleNotify();
+
+ void notifyAfterAllDepsGone();
};
void tst_QProperty::functorBinding()
@@ -387,7 +393,7 @@ void tst_QProperty::changeHandler()
}
testProperty = 3;
- QCOMPARE(recordedValues.count(), 2);
+ QCOMPARE(recordedValues.size(), 2);
QCOMPARE(recordedValues.at(0), 1);
QCOMPARE(recordedValues.at(1), 2);
}
@@ -430,7 +436,7 @@ void tst_QProperty::subscribe()
}
testProperty = 3;
- QCOMPARE(recordedValues.count(), 3);
+ QCOMPARE(recordedValues.size(), 3);
QCOMPARE(recordedValues.at(0), 42);
QCOMPARE(recordedValues.at(1), 1);
QCOMPARE(recordedValues.at(2), 2);
@@ -865,7 +871,7 @@ void tst_QProperty::notifiedProperty()
check();
instance.property.setValue(42);
- QCOMPARE(instance.recordedValues.count(), 1);
+ QCOMPARE(instance.recordedValues.size(), 1);
QCOMPARE(instance.recordedValues.at(0), 42);
instance.recordedValues.clear();
check();
@@ -895,7 +901,7 @@ void tst_QProperty::notifiedProperty()
subscribedCount = 0;
QCOMPARE(instance.property.value(), 100);
- QCOMPARE(instance.recordedValues.count(), 1);
+ QCOMPARE(instance.recordedValues.size(), 1);
QCOMPARE(instance.recordedValues.at(0), 100);
instance.recordedValues.clear();
check();
@@ -903,7 +909,7 @@ void tst_QProperty::notifiedProperty()
injectedValue = 200;
QCOMPARE(instance.property.value(), 200);
- QCOMPARE(instance.recordedValues.count(), 1);
+ QCOMPARE(instance.recordedValues.size(), 1);
QCOMPARE(instance.recordedValues.at(0), 200);
instance.recordedValues.clear();
check();
@@ -912,7 +918,7 @@ void tst_QProperty::notifiedProperty()
injectedValue = 400;
QCOMPARE(instance.property.value(), 400);
- QCOMPARE(instance.recordedValues.count(), 1);
+ QCOMPARE(instance.recordedValues.size(), 1);
QCOMPARE(instance.recordedValues.at(0), 400);
instance.recordedValues.clear();
check();
@@ -1151,12 +1157,12 @@ void tst_QProperty::qobjectBindableManualNotify()
object.fooData.setValueBypassingBindings(42);
// there is no change.
QCOMPARE(fooChangeCount, 0);
- QCOMPARE(fooChangedSpy.count(), 0);
+ QCOMPARE(fooChangedSpy.size(), 0);
// Once we notify manually
object.fooData.notify();
// observers are notified and the signal arrives.
QCOMPARE(fooChangeCount, 1);
- QCOMPARE(fooChangedSpy.count(), 1);
+ QCOMPARE(fooChangedSpy.size(), 1);
// If we set a binding
int i = 1;
@@ -1165,20 +1171,37 @@ void tst_QProperty::qobjectBindableManualNotify()
QCOMPARE(object.foo(), 1);
// and the change and signal count are incremented.
QCOMPARE(fooChangeCount, 2);
- QCOMPARE(fooChangedSpy.count(), 2);
+ QCOMPARE(fooChangedSpy.size(), 2);
// Changing a non-property won't trigger any notification.
i = 2;
QCOMPARE(fooChangeCount, 2);
- QCOMPARE(fooChangedSpy.count(), 2);
+ QCOMPARE(fooChangedSpy.size(), 2);
// Manually triggering the notification
object.fooData.notify();
// increments the change count
QCOMPARE(fooChangeCount, 3);
- QCOMPARE(fooChangedSpy.count(), 3);
+ QCOMPARE(fooChangedSpy.size(), 3);
// but doesn't actually cause a binding reevaluation.
QCOMPARE(object.foo(), 1);
}
+
+struct ReallocObject : QObject {
+ ReallocObject()
+ { v.setBinding([this] { return x.value() + y.value() + z.value(); }); }
+ Q_OBJECT_BINDABLE_PROPERTY(ReallocObject, int, v)
+ Q_OBJECT_BINDABLE_PROPERTY(ReallocObject, int, x)
+ Q_OBJECT_BINDABLE_PROPERTY(ReallocObject, int, y)
+ Q_OBJECT_BINDABLE_PROPERTY(ReallocObject, int, z)
+};
+
+void tst_QProperty::qobjectBindableReallocatedBindingStorage()
+{
+ ReallocObject object;
+ object.x = 1;
+ QCOMPARE(object.v.value(), 1);
+}
+
void tst_QProperty::qobjectBindableSignalTakingNewValue()
{
// Given an object of type MyQObject,
@@ -1557,7 +1580,7 @@ void tst_QProperty::compatPropertySignals()
tester.setProp2(10);
QCOMPARE(prop2Observer.value(), 10);
- QCOMPARE(prop2Spy.count(), 1);
+ QCOMPARE(prop2Spy.size(), 1);
QList<QVariant> arguments = prop2Spy.takeFirst();
QCOMPARE(arguments.size(), 1);
QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int);
@@ -1573,7 +1596,7 @@ void tst_QProperty::compatPropertySignals()
tester.setProp3(5);
QCOMPARE(prop3Observer.value(), 5);
- QCOMPARE(prop3Spy.count(), 1);
+ QCOMPARE(prop3Spy.size(), 1);
// Compat property with signal, default value, and custom setter. Signal has parameter.
QProperty<int> prop4Observer;
@@ -1585,7 +1608,7 @@ void tst_QProperty::compatPropertySignals()
tester.setProp4(10);
QCOMPARE(prop4Observer.value(), 10);
- QCOMPARE(prop4Spy.count(), 1);
+ QCOMPARE(prop4Spy.size(), 1);
arguments = prop4Spy.takeFirst();
QCOMPARE(arguments.size(), 1);
QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int);
@@ -1594,7 +1617,7 @@ void tst_QProperty::compatPropertySignals()
tester.setProp4(42);
QCOMPARE(prop4Observer.value(), 42);
- QCOMPARE(prop4Spy.count(), 1);
+ QCOMPARE(prop4Spy.size(), 1);
arguments = prop4Spy.takeFirst();
QCOMPARE(arguments.size(), 1);
QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int);
@@ -1603,7 +1626,7 @@ void tst_QProperty::compatPropertySignals()
tester.setProp4(0);
QCOMPARE(prop4Observer.value(), 42);
- QCOMPARE(prop4Spy.count(), 1);
+ QCOMPARE(prop4Spy.size(), 1);
arguments = prop4Spy.takeFirst();
QCOMPARE(arguments.size(), 1);
QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int);
@@ -1940,6 +1963,63 @@ void tst_QProperty::groupedNotificationConsistency()
QVERIFY(areEqual); // value changed runs after everything has been evaluated
}
+void tst_QProperty::bindingGroupMovingBindingData()
+{
+ auto tester = std::make_unique<ClassWithNotifiedProperty>();
+ auto testerPriv = QObjectPrivate::get(tester.get());
+
+ auto dummyNotifier = tester->property.addNotifier([](){});
+ auto bindingData = testerPriv->bindingStorage.bindingData(&tester->property);
+ QVERIFY(bindingData); // we have a notifier, so there should be binding data
+
+ Qt::beginPropertyUpdateGroup();
+ auto cleanup = qScopeGuard([](){ Qt::endPropertyUpdateGroup(); });
+ tester->property = 42;
+ QCOMPARE(testerPriv->bindingStorage.bindingData(&tester->property), bindingData);
+ auto proxyData = QPropertyBindingDataPointer::proxyData(bindingData);
+ // as we've modified the property, we now should have a proxy for the delayed notification
+ QVERIFY(proxyData);
+ // trigger binding data reallocation
+ std::array<QUntypedPropertyData, 10> propertyDataArray;
+ for (auto&& data: propertyDataArray)
+ testerPriv->bindingStorage.bindingData(&data, true);
+ // binding data has moved
+ QVERIFY(testerPriv->bindingStorage.bindingData(&tester->property) != bindingData);
+ bindingData = testerPriv->bindingStorage.bindingData(&tester->property);
+ // the proxy data has been updated
+ QCOMPARE(proxyData->originalBindingData, bindingData);
+
+ tester.reset();
+ // the property data is gone, proxyData should have been informed
+ QCOMPARE(proxyData->originalBindingData, nullptr);
+ QVERIFY(proxyData);
+}
+
+void tst_QProperty::bindingGroupBindingDeleted()
+{
+ auto deleter = std::make_unique<ClassWithNotifiedProperty>();
+ auto toBeDeleted = std::make_unique<ClassWithNotifiedProperty>();
+
+ bool calledHandler = false;
+ deleter->property.setBinding([&](){
+ int newValue = toBeDeleted->property;
+ if (newValue == 42)
+ toBeDeleted.reset();
+ return newValue;
+ });
+ auto handler = toBeDeleted->property.onValueChanged([&]() { calledHandler = true; } );
+ {
+ Qt::beginPropertyUpdateGroup();
+ auto cleanup = qScopeGuard([](){ Qt::endPropertyUpdateGroup(); });
+ QVERIFY(toBeDeleted);
+ toBeDeleted->property = 42;
+ // ASAN should not complain here
+ }
+ QVERIFY(!toBeDeleted);
+ // the change notification is sent, even if the binding is deleted during evaluation
+ QVERIFY(calledHandler);
+}
+
void tst_QProperty::uninstalledBindingDoesNotEvaluate()
{
QProperty<int> i;
@@ -1991,7 +2071,7 @@ void tst_QProperty::notify()
testProperty = 4;
QCOMPARE(value, 3);
- QCOMPARE(recordedValues.count(), 2);
+ QCOMPARE(recordedValues.size(), 2);
QCOMPARE(recordedValues.at(0), 1);
QCOMPARE(recordedValues.at(1), 2);
}
@@ -2042,6 +2122,28 @@ void tst_QProperty::scheduleNotify()
QCOMPARE(p.value(), 0);
}
+void tst_QProperty::notifyAfterAllDepsGone()
+{
+ bool b = true;
+ QProperty<int> iprop;
+ QProperty<int> jprop(42);
+ iprop.setBinding([&](){
+ if (b)
+ return jprop.value();
+ return 13;
+ });
+ int changeCounter = 0;
+ auto keepAlive = iprop.onValueChanged([&](){ changeCounter++; });
+ QCOMPARE(iprop.value(), 42);
+ jprop = 44;
+ QCOMPARE(iprop.value(), 44);
+ QCOMPARE(changeCounter, 1);
+ b = false;
+ jprop = 43;
+ QCOMPARE(iprop.value(), 13);
+ QCOMPARE(changeCounter, 2);
+}
+
QTEST_MAIN(tst_QProperty);
#undef QT_SOURCE_LOCATION_NAMESPACE
diff --git a/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp b/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp
index 968b45aae1..6dc4fde7ca 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp
+++ b/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
QCoreApplication app(argc, argv);
QStringList arguments = app.arguments();
- if (app.arguments().count() != 2) {
+ if (app.arguments().size() != 2) {
qWarning("Please call the helper with the function to call as argument");
return EXIT_FAILURE;
}
diff --git a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp
index 63a33d73a0..3cd9357268 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp
+++ b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp
@@ -122,7 +122,7 @@ void tst_QSharedMemory::cleanup()
jail.clear();
keys.append(EXISTING_SHARE);
- for (int i = 0; i < keys.count(); ++i) {
+ for (int i = 0; i < keys.size(); ++i) {
QSharedMemory sm(keys.at(i));
if (!sm.create(1024)) {
//if (sm.error() != QSharedMemory::KeyError)
diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
index 59ef20c6e4..c78650efba 100644
--- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
+++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
@@ -309,8 +309,8 @@ void tst_QSocketNotifier::posixSockets()
passive->waitForBytesWritten(5000);
QTestEventLoop::instance().enterLoop(3);
- QCOMPARE(readSpy.count(), 1);
- QCOMPARE(errorSpy.count(), 0);
+ QCOMPARE(readSpy.size(), 1);
+ QCOMPARE(errorSpy.size(), 0);
char buffer[100];
int r = qt_safe_read(posixSocket, buffer, 100);
@@ -324,9 +324,9 @@ void tst_QSocketNotifier::posixSockets()
qt_safe_write(posixSocket, "goodbye", 8);
QTestEventLoop::instance().enterLoop(3);
- QCOMPARE(readSpy.count(), 1);
- QCOMPARE(writeSpy.count(), 1);
- QCOMPARE(errorSpy.count(), 0);
+ QCOMPARE(readSpy.size(), 1);
+ QCOMPARE(writeSpy.size(), 1);
+ QCOMPARE(errorSpy.size(), 0);
// Write notifier may have fired before the read notifier inside
// QTcpSocket, give QTcpSocket a chance to see the incoming data
@@ -387,7 +387,7 @@ void tst_QSocketNotifier::asyncMultipleDatagram()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
delete m_asyncSender;
delete m_asyncReceiver;
diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp
index 979649d662..b2de1d764c 100644
--- a/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp
+++ b/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
QStringList arguments = app.arguments();
// binary name is not used here
arguments.takeFirst();
- if (arguments.count() < 1) {
+ if (arguments.size() < 1) {
qWarning("Please call the helper with the function to call as argument");
return EXIT_FAILURE;
}
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
if (function == QLatin1String("acquire")) {
int count = 1;
bool ok = true;
- if (arguments.count())
+ if (arguments.size())
count = arguments.takeFirst().toInt(&ok);
if (!ok)
count = 1;
diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp
index e2f557b698..4435256d97 100644
--- a/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp
+++ b/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp
@@ -189,7 +189,7 @@ void tst_QSystemSemaphore::processes()
QList<QString> scripts(processes, "acquirerelease");
QList<QProcess*> consumers;
- for (int i = 0; i < scripts.count(); ++i) {
+ for (int i = 0; i < scripts.size(); ++i) {
QProcess *p = new QProcess;
p->setProcessChannelMode(QProcess::ForwardedChannels);
consumers.append(p);
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index c91aba4790..e2bde37a7e 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -84,7 +84,7 @@ void tst_QTimer::zeroTimer()
// Pass timeout to work round glib issue, see QTBUG-84291.
QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX);
- QCOMPARE(timeoutSpy.count(), 1);
+ QCOMPARE(timeoutSpy.size(), 1);
}
void tst_QTimer::singleShotTimeout()
@@ -98,9 +98,9 @@ void tst_QTimer::singleShotTimeout()
timer.start(100);
QVERIFY(timeoutSpy.wait(500));
- QCOMPARE(timeoutSpy.count(), 1);
+ QCOMPARE(timeoutSpy.size(), 1);
QTest::qWait(500);
- QCOMPARE(timeoutSpy.count(), 1);
+ QCOMPARE(timeoutSpy.size(), 1);
}
#define TIMEOUT_TIMEOUT 200
@@ -111,12 +111,12 @@ void tst_QTimer::timeout()
QSignalSpy timeoutSpy(&timer, &QTimer::timeout);
timer.start(100);
- QCOMPARE(timeoutSpy.count(), 0);
+ QCOMPARE(timeoutSpy.size(), 0);
- QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > 0, TIMEOUT_TIMEOUT);
- int oldCount = timeoutSpy.count();
+ QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.size() > 0, TIMEOUT_TIMEOUT);
+ int oldCount = timeoutSpy.size();
- QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > oldCount, TIMEOUT_TIMEOUT);
+ QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.size() > oldCount, TIMEOUT_TIMEOUT);
}
void tst_QTimer::remainingTime()
@@ -240,19 +240,14 @@ void tst_QTimer::remainingTimeDuringActivation()
namespace {
-#if __has_include(<chrono>)
template <typename T>
std::chrono::milliseconds to_ms(T t)
{ return std::chrono::duration_cast<std::chrono::milliseconds>(t); }
-#endif
} // unnamed namespace
void tst_QTimer::basic_chrono()
{
-#if !__has_include(<chrono>)
- QSKIP("This test requires C++11 <chrono> support");
-#else
// duplicates zeroTimer, singleShotTimeout, interval and remainingTime
using namespace std::chrono;
QTimer timer;
@@ -264,24 +259,24 @@ void tst_QTimer::basic_chrono()
QCoreApplication::processEvents();
- QCOMPARE(timeoutSpy.count(), 1);
+ QCOMPARE(timeoutSpy.size(), 1);
timeoutSpy.clear();
timer.start(milliseconds(100));
- QCOMPARE(timeoutSpy.count(), 0);
+ QCOMPARE(timeoutSpy.size(), 0);
QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT));
- QVERIFY(timeoutSpy.count() > 0);
- int oldCount = timeoutSpy.count();
+ QVERIFY(timeoutSpy.size() > 0);
+ int oldCount = timeoutSpy.size();
QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT));
- QVERIFY(timeoutSpy.count() > oldCount);
+ QVERIFY(timeoutSpy.size() > oldCount);
timeoutSpy.clear();
timer.start(to_ms(microseconds(200000)));
QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(200));
QTest::qWait(50);
- QCOMPARE(timeoutSpy.count(), 0);
+ QCOMPARE(timeoutSpy.size(), 0);
milliseconds rt = timer.remainingTimeAsDuration();
QVERIFY2(rt.count() >= 50 && rt.count() <= 200, qPrintable(QString::number(rt.count())));
@@ -290,10 +285,9 @@ void tst_QTimer::basic_chrono()
timer.setSingleShot(true);
timer.start(milliseconds(100));
QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT));
- QCOMPARE(timeoutSpy.count(), 1);
+ QCOMPARE(timeoutSpy.size(), 1);
QTest::qWait(500);
- QCOMPARE(timeoutSpy.count(), 1);
-#endif
+ QCOMPARE(timeoutSpy.size(), 1);
}
void tst_QTimer::livelock_data()
@@ -518,6 +512,7 @@ void tst_QTimer::moveToThread()
#endif
QTimer ti1;
QTimer ti2;
+ ti1.setSingleShot(true);
ti1.start(MOVETOTHREAD_TIMEOUT);
ti2.start(MOVETOTHREAD_TIMEOUT);
QVERIFY((ti1.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff));
@@ -890,9 +885,6 @@ void tst_QTimer::singleShotToFunctors()
void tst_QTimer::singleShot_chrono()
{
-#if !__has_include(<chrono>)
- QSKIP("This test requires C++11 <chrono> support");
-#else
// duplicates singleShotStaticFunctionZeroTimeout and singleShotToFunctors
using namespace std::chrono;
{
@@ -929,7 +921,6 @@ void tst_QTimer::singleShot_chrono()
QTRY_COMPARE(count, 3);
_e.reset();
-#endif
}
class DontBlockEvents : public QObject
@@ -1011,7 +1002,7 @@ void tst_QTimer::postedEventsShouldNotStarveTimers()
timer.start();
SlotRepeater slotRepeater;
slotRepeater.repeatThisSlot();
- QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > 5, 100);
+ QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.size() > 5, 100);
}
struct DummyFunctor {
@@ -1054,7 +1045,7 @@ void tst_QTimer::callOnTimeout()
QTest::qWait(100);
QCOMPARE(count, 2);
- QCOMPARE(timeoutSpy.count(), 1);
+ QCOMPARE(timeoutSpy.size(), 1);
// Test that connection is bound to context lifetime
QVERIFY(connection);
diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
index 372a7a9db1..5e7a42d6da 100644
--- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
@@ -98,7 +98,7 @@ void tst_QTranslator::load()
file.open(QFile::ReadOnly);
QByteArray data = file.readAll();
QTranslator tor;
- QVERIFY(tor.load((const uchar *)data.constData(), data.length()));
+ QVERIFY(tor.load((const uchar *)data.constData(), data.size()));
QCOMPARE(tor.isEmpty(), isEmpty);
QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation);
QCOMPARE(tor.filePath(), "");
@@ -331,7 +331,7 @@ void tst_QTranslator::dependencies()
QFile file("dependencies_la.qm");
file.open(QFile::ReadOnly);
QByteArray data = file.readAll();
- QVERIFY(tor.load((const uchar *)data.constData(), data.length()));
+ QVERIFY(tor.load((const uchar *)data.constData(), data.size()));
QVERIFY(!tor.isEmpty());
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!"));
}
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index f20fd0cd87..867332e48f 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -3067,57 +3067,57 @@ void tst_QVariant::convertIterables() const
{
QStringList list;
list.append("Hello");
- QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().size(), list.size());
}
{
QByteArrayList list;
list.append("Hello");
- QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().size(), list.size());
}
{
QVariantList list;
list.append("World");
- QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().size(), list.size());
}
{
QMap<QString, int> map;
map.insert("3", 4);
- QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
- QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size());
map.insert("4", 5);
- QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
- QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size());
}
{
QVariantMap map;
map.insert("3", 4);
- QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
- QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size());
map.insert("4", 5);
- QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
- QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size());
}
{
QHash<QString, int> hash;
hash.insert("3", 4);
- QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
- QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size());
hash.insert("4", 5);
- QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
- QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size());
}
{
QVariantHash hash;
hash.insert("3", 4);
- QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
- QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size());
hash.insert("4", 5);
- QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
- QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size());
}
}
@@ -4303,7 +4303,7 @@ void testSequentialIteration()
int numSeen = 0;
auto varList = listVariant.value<QVariantList>();
auto varIter = varList.begin();
- for (const QVariant &v : qAsConst(listIter)) {
+ for (const QVariant &v : std::as_const(listIter)) {
QVERIFY(ContainerAPI<Container>::compare(v, *varIter));
++varIter;
++numSeen;
@@ -4715,6 +4715,13 @@ void tst_QVariant::metaEnums()
METAENUMS_TEST(MetaEnumTest_Enum5_value);
METAENUMS_TEST(MetaEnumTest_Enum6_value);
METAENUMS_TEST(MetaEnumTest_Enum8_value);
+
+#undef METAENUMS_TEST
+
+ testVariantMeta(Qt::RichText, &ok, "RichText");
+ testVariantMeta(Qt::Alignment(Qt::AlignBottom), &ok, "AlignBottom");
+ testVariantMeta(Qt::Alignment(Qt::AlignHCenter | Qt::AlignBottom), &ok,
+ "AlignHCenter|AlignBottom");
}
void tst_QVariant::nullConvert()
@@ -5166,7 +5173,7 @@ void tst_QVariant::constructFromIncompatibleMetaType()
void tst_QVariant::copyNonDefaultConstructible()
{
NonDefaultConstructible ndc(42);
- QVariant var(QMetaType::fromType<NonDefaultConstructible>(), &ndc);
+ QVariant var = QVariant::fromValue(ndc);
QVERIFY(var.isDetached());
QCOMPARE(var.metaType(), QMetaType::fromType<NonDefaultConstructible>());
QVERIFY(var.constData() != &ndc);
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt
index 2d7844493f..a7faa8d078 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt
@@ -45,6 +45,14 @@ qt_internal_add_resource(tst_qmimedatabase-cache "testdata"
${testdata_resource_files}
)
+qt_internal_add_resource(tst_qmimedatabase-cache "testfiles"
+ PREFIX
+ "/files"
+ FILES
+ "../test.txt"
+ "../test.qml"
+)
+
# special case begin
set(corelib_source_dir ../../../../../../src/corelib)
include(${corelib_source_dir}/mimetypes/mimetypes_resources.cmake)
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt
index 47e9a2f1d7..c373b40af4 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt
@@ -45,6 +45,14 @@ qt_internal_add_resource(tst_qmimedatabase-xml "testdata"
${testdata_resource_files}
)
+qt_internal_add_resource(tst_qmimedatabase-xml "testfiles"
+ PREFIX
+ "/files"
+ FILES
+ "../test.txt"
+ "../test.qml"
+)
+
# special case begin
set(corelib_source_dir ../../../../../../src/corelib)
include(${corelib_source_dir}/mimetypes/mimetypes_resources.cmake)
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/test.txt b/tests/auto/corelib/mimetypes/qmimedatabase/test.txt
new file mode 100644
index 0000000000..752cf553e9
--- /dev/null
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/test.txt
@@ -0,0 +1,6 @@
+// Copyright (C) 2012 David Faure <faure@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick 1.1
+Item {
+}
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index fae26f4971..ce0d9c8047 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -6,6 +6,8 @@
#include "qstandardpaths.h"
#ifdef Q_OS_UNIX
+#include <dirent.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
@@ -25,6 +27,8 @@
#include <QProcess>
#endif
+using namespace Qt::StringLiterals;
+
static const char *const additionalMimeFiles[] = {
"yast2-metapackage-handler-mimetypes.xml",
"qml-again.xml",
@@ -245,6 +249,7 @@ void tst_QMimeDatabase::mimeTypeForFileName_data()
// fdo bug 15436, needs shared-mime-info >= 0.40 (and this tests the globs2-parsing code).
QTest::newRow("glob that ends with *, also matches *.pdf. *.pdf has higher weight") << "README.pdf" << "application/pdf";
QTest::newRow("directory") << "/" << "inode/directory";
+ QTest::newRow("resource-directory") << ":/files/" << "inode/directory";
QTest::newRow("doesn't exist, no extension") << "IDontExist" << "application/octet-stream";
QTest::newRow("doesn't exist but has known extension") << "IDontExist.txt" << "text/plain";
QTest::newRow("empty") << "" << "application/octet-stream";
@@ -277,7 +282,7 @@ void tst_QMimeDatabase::mimeTypeForFileName()
QVERIFY(mimes.isEmpty());
} else {
QVERIFY2(!mimes.isEmpty(), msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData());
- QVERIFY2(mimes.count() == 1, msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData());
+ QVERIFY2(mimes.size() == 1, msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData());
QCOMPARE(mimes.first().name(), expectedMimeType);
}
}
@@ -328,7 +333,7 @@ void tst_QMimeDatabase::inheritance()
const QMimeType directory = db.mimeTypeForName(QString::fromLatin1("inode/directory"));
QVERIFY(directory.isValid());
- QCOMPARE(directory.parentMimeTypes().count(), 0);
+ QCOMPARE(directory.parentMimeTypes().size(), 0);
QVERIFY(!directory.inherits(QLatin1String("application/octet-stream")));
// Check that text/x-patch knows that it inherits from text/plain (it says so explicitly)
@@ -349,7 +354,7 @@ void tst_QMimeDatabase::inheritance()
const QStringList shellParents = shellscript.parentMimeTypes();
QVERIFY(shellParents.contains(QLatin1String("text/plain")));
QVERIFY(shellParents.contains(QLatin1String("application/x-executable")));
- QCOMPARE(shellParents.count(), 2); // only the above two
+ QCOMPARE(shellParents.size(), 2); // only the above two
const QStringList allShellAncestors = shellscript.allAncestors();
QVERIFY(allShellAncestors.contains(QLatin1String("text/plain")));
QVERIFY(allShellAncestors.contains(QLatin1String("application/x-executable")));
@@ -497,6 +502,42 @@ void tst_QMimeDatabase::mimeTypeForFileWithContent()
QCOMPARE(mime.name(), QString::fromLatin1("application/smil+xml"));
}
+ // Test what happens with Qt resources (file engines in general)
+ {
+ QFile rccFile(":/files/test.txt");
+
+ mime = db.mimeTypeForFile(rccFile.fileName());
+ QCOMPARE(mime.name(), "text/plain"_L1);
+
+ QVERIFY(rccFile.open(QIODevice::ReadOnly));
+ mime = db.mimeTypeForData(&rccFile);
+ QCOMPARE(mime.name(), "text/x-qml"_L1);
+ QVERIFY(rccFile.isOpen());
+
+ mime = db.mimeTypeForFile(rccFile.fileName(), QMimeDatabase::MatchContent);
+ QCOMPARE(mime.name(), "text/x-qml"_L1);
+ }
+
+ // Directories
+ {
+ mime = db.mimeTypeForFile("/");
+ QCOMPARE(mime.name(), "inode/directory"_L1);
+
+ QString dirName = QDir::tempPath();
+ if (!dirName.endsWith(u'/'))
+ dirName += u'/';
+ mime = db.mimeTypeForFile(dirName);
+ QCOMPARE(mime.name(), "inode/directory"_L1);
+
+ while (dirName.endsWith(u'/'))
+ dirName.chop(1);
+ mime = db.mimeTypeForFile(dirName);
+ QCOMPARE(mime.name(), "inode/directory"_L1);
+
+ mime = db.mimeTypeForFile(":/files");
+ QCOMPARE(mime.name(), "inode/directory"_L1);
+ }
+
// Test what happens with an incorrect path
mime = db.mimeTypeForFile(QString::fromLatin1("file:///etc/passwd" /* incorrect code, use a path instead */));
QVERIFY(mime.isDefault());
@@ -584,6 +625,82 @@ void tst_QMimeDatabase::mimeTypeForFileAndContent()
QCOMPARE(buffer.pos(), qint64(0));
}
+#ifdef Q_OS_UNIX
+void tst_QMimeDatabase::mimeTypeForUnixSpecials_data()
+{
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<QString>("expected");
+
+ static const char * const mimeTypes[] = {
+ "inode/blockdevice",
+ "inode/chardevice",
+ "inode/fifo",
+ "inode/socket",
+ };
+ enum SpecialType {
+ FoundBlock = 0,
+ FoundChar = 1,
+ FoundFifo = 2,
+ FoundSocket = 3,
+ };
+ uint found = 0;
+ auto nothingfound = []() {
+ QSKIP("No special Unix inode types found!");
+ };
+
+ // on a standard Linux system (systemd), /dev/log is a symlink to a socket
+ // and /dev/initctl is a symlink to a FIFO
+ int devfd = open("/dev", O_RDONLY);
+ DIR *devdir = fdopendir(devfd); // takes ownership
+ if (!devdir)
+ return nothingfound();
+
+ while (struct dirent *ent = readdir(devdir)) {
+ struct stat statbuf;
+ if (fstatat(devfd, ent->d_name, &statbuf, 0) < 0)
+ continue;
+
+ SpecialType type;
+ if (S_ISBLK(statbuf.st_mode)) {
+ type = FoundBlock;
+ } else if (S_ISCHR(statbuf.st_mode)) {
+ type = FoundChar;
+ } else if (S_ISFIFO(statbuf.st_mode)) {
+ type = FoundFifo;
+ } else if (S_ISSOCK(statbuf.st_mode)) {
+ type = FoundSocket;
+ } else {
+ if (!S_ISREG(statbuf.st_mode) && !S_ISDIR(statbuf.st_mode))
+ qWarning("Could not tell what file type '%s' is: %#o'",
+ ent->d_name, statbuf.st_mode);
+ continue;
+ }
+
+ if (found & (1U << type))
+ continue; // we've already seen such a type
+
+ const char *mimeType = mimeTypes[type];
+ QTest::addRow("%s", mimeType)
+ << u"/dev/"_s + QFile::decodeName(ent->d_name) << mimeType;
+ found |= (1U << type);
+ }
+ closedir(devdir);
+
+ if (!found)
+ nothingfound();
+}
+
+void tst_QMimeDatabase::mimeTypeForUnixSpecials()
+{
+ QFETCH(QString, name);
+ QFETCH(QString, expected);
+
+ qInfo() << "Testing that" << name << "is" << expected;
+ QMimeDatabase db;
+ QCOMPARE(db.mimeTypeForFile(name).name(), expected);
+}
+#endif
+
void tst_QMimeDatabase::allMimeTypes()
{
QMimeDatabase db;
@@ -591,7 +708,7 @@ void tst_QMimeDatabase::allMimeTypes()
QVERIFY(!lst.isEmpty());
// Hardcoding this is the only way to check both providers find the same number of mimetypes.
- QCOMPARE(lst.count(), 851);
+ QCOMPARE(lst.size(), 851);
foreach (const QMimeType &mime, lst) {
const QString name = mime.name();
@@ -741,7 +858,7 @@ void tst_QMimeDatabase::findByFileName()
//qDebug() << Q_FUNC_INFO << "mimeTypeForFile() returned" << resultMimeTypeName;
const bool failed = resultMimeTypeName != mimeTypeName;
- const bool shouldFail = (xFail.length() >= 1 && xFail.at(0) == QLatin1Char('x'));
+ const bool shouldFail = (xFail.size() >= 1 && xFail.at(0) == QLatin1Char('x'));
if (shouldFail != failed) {
// Results are ambiguous when multiple MIME types have the same glob
// -> accept the current result if the found MIME type actually
@@ -788,7 +905,7 @@ void tst_QMimeDatabase::findByData()
QByteArray data = f.read(16384);
const QString resultMimeTypeName = database.mimeTypeForData(data).name();
- if (xFail.length() >= 2 && xFail.at(1) == QLatin1Char('x')) {
+ if (xFail.size() >= 2 && xFail.at(1) == QLatin1Char('x')) {
// Expected to fail
QVERIFY2(resultMimeTypeName != mimeTypeName, qPrintable(resultMimeTypeName));
} else {
@@ -819,7 +936,7 @@ void tst_QMimeDatabase::findByFile()
QMimeDatabase database;
const QString resultMimeTypeName = database.mimeTypeForFile(filePath).name();
//qDebug() << Q_FUNC_INFO << filePath << "->" << resultMimeTypeName;
- if (xFail.length() >= 3 && xFail.at(2) == QLatin1Char('x')) {
+ if (xFail.size() >= 3 && xFail.at(2) == QLatin1Char('x')) {
// Expected to fail
QVERIFY2(resultMimeTypeName != mimeTypeName, qPrintable(resultMimeTypeName));
} else {
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
index 5818e1b6eb..4622a72536 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
@@ -37,6 +37,10 @@ private slots:
void mimeTypeForData();
void mimeTypeForFileAndContent_data();
void mimeTypeForFileAndContent();
+#ifdef Q_OS_UNIX
+ void mimeTypeForUnixSpecials_data();
+ void mimeTypeForUnixSpecials();
+#endif
void allMimeTypes();
void suffixes_data();
void suffixes();
diff --git a/tests/auto/corelib/platform/android/CMakeLists.txt b/tests/auto/corelib/platform/android/CMakeLists.txt
index c2749825ac..6c08080e6a 100644
--- a/tests/auto/corelib/platform/android/CMakeLists.txt
+++ b/tests/auto/corelib/platform/android/CMakeLists.txt
@@ -7,6 +7,10 @@
qt_internal_add_test(tst_android
SOURCES
tst_android.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
)
if(ANDROID)
diff --git a/tests/auto/other/android/testdata/assets/test.txt b/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/file_in_top_dir.txt
index 61e2c47c25..61e2c47c25 100644
--- a/tests/auto/other/android/testdata/assets/test.txt
+++ b/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/file_in_top_dir.txt
diff --git a/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/file_in_sub_dir.txt b/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/file_in_sub_dir.txt
new file mode 100644
index 0000000000..61e2c47c25
--- /dev/null
+++ b/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/file_in_sub_dir.txt
@@ -0,0 +1 @@
+FooBar \ No newline at end of file
diff --git a/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/sub_dir_2/sub_dir_3/file_in_sub_dir_3.txt b/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/sub_dir_2/sub_dir_3/file_in_sub_dir_3.txt
new file mode 100644
index 0000000000..61e2c47c25
--- /dev/null
+++ b/tests/auto/corelib/platform/android/testdata/assets/top_level_dir/sub_dir/sub_dir_2/sub_dir_3/file_in_sub_dir_3.txt
@@ -0,0 +1 @@
+FooBar \ No newline at end of file
diff --git a/tests/auto/corelib/platform/android/tst_android.cpp b/tests/auto/corelib/platform/android/tst_android.cpp
index 2fa6ec6415..bb1fdcae1c 100644
--- a/tests/auto/corelib/platform/android/tst_android.cpp
+++ b/tests/auto/corelib/platform/android/tst_android.cpp
@@ -4,8 +4,14 @@
#include <jni.h>
#include <QTest>
+#include <QGuiApplication>
#include <QtCore/qnativeinterface.h>
#include <QtCore/qjniobject.h>
+#include <QtCore/qdiriterator.h>
+#include <QScreen>
+#include <qpa/qplatformscreen.h>
+#include <qpa/qplatformnativeinterface.h>
+#include <QtCore/qdiriterator.h>
class tst_Android : public QObject
{
@@ -13,9 +19,11 @@ Q_OBJECT
private slots:
void assetsRead();
void assetsNotWritable();
+ void assetsIterating();
void testAndroidSdkVersion();
void testAndroidActivity();
void testRunOnAndroidMainThread();
+ void testFullScreenDimensions();
};
void tst_Android::assetsRead()
@@ -41,6 +49,27 @@ void tst_Android::assetsNotWritable()
QVERIFY(!file.open(QIODevice::Append));
}
+void tst_Android::assetsIterating()
+{
+ QStringList assets = {"assets:/top_level_dir/file_in_top_dir.txt",
+ "assets:/top_level_dir/sub_dir",
+ "assets:/top_level_dir/sub_dir/file_in_sub_dir.txt",
+ "assets:/top_level_dir/sub_dir/sub_dir_2",
+ "assets:/top_level_dir/sub_dir/sub_dir_2/sub_dir_3",
+ "assets:/top_level_dir/sub_dir/sub_dir_2/sub_dir_3/file_in_sub_dir_3.txt"};
+
+ // Note that we have an "assets:/top_level_dir/sub_dir/empty_sub_dir" in the test's
+ // assets physical directory, but empty folders are not packaged in the built apk,
+ // so it's expected to not have such folder be listed in the assets on runtime
+
+ QDirIterator it("assets:/top_level_dir", QDirIterator::Subdirectories);
+ QStringList iteratorAssets;
+ while (it.hasNext())
+ iteratorAssets.append(it.next());
+
+ QVERIFY(assets == iteratorAssets);
+}
+
void tst_Android::testAndroidSdkVersion()
{
QVERIFY(QNativeInterface::QAndroidApplication::sdkVersion() > 0);
@@ -164,6 +193,103 @@ void tst_Android::testRunOnAndroidMainThread()
}
}
+void setSystemUiVisibility(int visibility)
+{
+ QNativeInterface::QAndroidApplication::runOnAndroidMainThread([visibility] {
+ QJniObject::callStaticMethod<void>("org/qtproject/qt/android/QtNative",
+ "setSystemUiVisibility", "(I)V", visibility);
+ }).waitForFinished();
+}
+
+// QTBUG-107604
+void tst_Android::testFullScreenDimensions()
+{
+ static int SYSTEM_UI_VISIBILITY_NORMAL = 0;
+ static int SYSTEM_UI_VISIBILITY_FULLSCREEN = 1;
+ static int SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2;
+
+ // this will trigger new layout updates
+ setSystemUiVisibility(SYSTEM_UI_VISIBILITY_FULLSCREEN);
+ setSystemUiVisibility(SYSTEM_UI_VISIBILITY_NORMAL);
+
+ QJniObject activity = QNativeInterface::QAndroidApplication::context();
+ QVERIFY(activity.isValid());
+
+ QJniObject windowManager =
+ activity.callObjectMethod("getWindowManager", "()Landroid/view/WindowManager;");
+ QVERIFY(windowManager.isValid());
+
+ QJniObject display = windowManager.callObjectMethod("getDefaultDisplay", "()Landroid/view/Display;");
+ QVERIFY(display.isValid());
+
+ QJniObject appSize("android/graphics/Point");
+ QVERIFY(appSize.isValid());
+
+ display.callMethod<void>("getSize", "(Landroid/graphics/Point;)V", appSize.object());
+
+ QJniObject realSize("android/graphics/Point");
+ QVERIFY(realSize.isValid());
+
+ display.callMethod<void>("getRealSize", "(Landroid/graphics/Point;)V", realSize.object());
+
+ QPlatformScreen *screen = QGuiApplication::primaryScreen()->handle();
+
+ {
+ // Normal -
+ // available geometry == app size (system bars visible and removed from available geometry)
+ QCoreApplication::processEvents();
+ QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
+ QVERIFY(window.isValid());
+
+ QJniObject decorView = window.callObjectMethod("getDecorView", "()Landroid/view/View;");
+ QVERIFY(decorView.isValid());
+
+ QJniObject insets =
+ decorView.callObjectMethod("getRootWindowInsets", "()Landroid/view/WindowInsets;");
+ QVERIFY(insets.isValid());
+
+ int insetsWidth = insets.callMethod<jint>("getSystemWindowInsetRight")
+ + insets.callMethod<jint>("getSystemWindowInsetLeft");
+
+ int insetsHeight = insets.callMethod<jint>("getSystemWindowInsetTop")
+ + insets.callMethod<jint>("getSystemWindowInsetBottom");
+
+ QTRY_COMPARE(screen->availableGeometry().width(),
+ int(appSize.getField<jint>("x")) - insetsWidth);
+ QTRY_COMPARE(screen->availableGeometry().height(),
+ int(appSize.getField<jint>("y")) - insetsHeight);
+
+ QTRY_COMPARE(screen->geometry().width(), int(realSize.getField<jint>("x")));
+ QTRY_COMPARE(screen->geometry().height(), int(realSize.getField<jint>("y")));
+ }
+
+ {
+ setSystemUiVisibility(SYSTEM_UI_VISIBILITY_FULLSCREEN);
+
+ // Fullscreen
+ // available geometry == full display size (system bars hidden)
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(screen->availableGeometry().width(), int(realSize.getField<jint>("x")));
+ QTRY_COMPARE(screen->availableGeometry().height(), int(realSize.getField<jint>("y")));
+
+ QTRY_COMPARE(screen->geometry().width(), int(realSize.getField<jint>("x")));
+ QTRY_COMPARE(screen->geometry().height(), int(realSize.getField<jint>("y")));
+ }
+
+ {
+ setSystemUiVisibility(SYSTEM_UI_VISIBILITY_TRANSLUCENT);
+
+ // Translucent
+ // available geometry == full display size (system bars visible but drawable under)
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(screen->availableGeometry().width(), int(realSize.getField<jint>("x")));
+ QTRY_COMPARE(screen->availableGeometry().height(), int(realSize.getField<jint>("y")));
+
+ QTRY_COMPARE(screen->geometry().width(), int(realSize.getField<jint>("x")));
+ QTRY_COMPARE(screen->geometry().height(), int(realSize.getField<jint>("y")));
+ }
+}
+
QTEST_MAIN(tst_Android)
#include "tst_android.moc"
diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
index d36ca0f8d8..651dd34c01 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
@@ -81,6 +81,7 @@ enum QLibraryOperation {
QString directory;
private slots:
void initTestCase();
+ void cleanup();
void load();
void load_data();
@@ -124,6 +125,38 @@ void tst_QLibrary::initTestCase()
#endif
}
+void tst_QLibrary::cleanup()
+{
+ // unload the libraries, if they are still loaded after the test ended
+ // (probably in a failure)
+
+ static struct {
+ QString name;
+ int version = -1;
+ } libs[] = {
+ { directory + "/mylib" },
+ { directory + "/mylib", 1 },
+ { directory + "/mylib", 2 },
+ { sys_qualifiedLibraryName("mylib") },
+
+ // stuff that load_data() succeeds with
+ { directory + "/" PREFIX "mylib" },
+ { directory + "/" PREFIX "mylib" SUFFIX },
+#if defined(Q_OS_WIN32)
+ { directory + "/mylib.dl2" },
+ { directory + "/system.qt.test.mylib.dll" },
+#elif !defined(Q_OS_ANDROID)
+ // .so even on macOS
+ { directory + "/libmylib.so2" },
+ { directory + "/system.qt.test.mylib.so" },
+#endif
+
+ };
+ for (const auto &entry : libs) {
+ do {} while (QLibrary(entry.name, entry.version).unload());
+ }
+}
+
void tst_QLibrary::version_data()
{
#ifdef Q_OS_ANDROID
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
index 2c2b24acee..6d68bdf3e0 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
@@ -376,14 +376,14 @@ void tst_QPluginLoader::deleteinstanceOnUnload()
QVERIFY(spy2.isValid());
if (pass == 0) {
QCOMPARE(loader2.unload(), false); // refcount not reached 0, not really unloaded
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 0);
+ QCOMPARE(spy1.size(), 0);
+ QCOMPARE(spy2.size(), 0);
}
QCOMPARE(instance1->pluginName(), QLatin1String("Plugin ok"));
QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok"));
QVERIFY(loader1.unload()); // refcount reached 0, did really unload
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 1);
+ QCOMPARE(spy2.size(), 1);
}
}
@@ -969,7 +969,7 @@ void tst_QPluginLoader::reloadPlugin()
QSignalSpy spy(loader.instance(), &QObject::destroyed);
QVERIFY(spy.isValid());
QVERIFY(loader.unload()); // refcount reached 0, did really unload
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// reload plugin
QVERIFY(loader.load());
@@ -984,6 +984,10 @@ void tst_QPluginLoader::reloadPlugin()
void tst_QPluginLoader::loadSectionTableStrippedElf()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 24)
+ QSKIP("Android 7+ (API 24+) linker doesn't allow missing or bad section header");
+#endif
#if !defined(QT_SHARED)
QSKIP("This test requires a shared build of Qt, as QPluginLoader::setFileName is a no-op in static builds");
#elif !defined(Q_OF_ELF)
diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
index eb0ce46502..c3170dd354 100644
--- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
+++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
@@ -372,13 +372,13 @@ public:
void tst_QUuid::threadUniqueness()
{
QList<UuidThread *> threads(qMax(2, QThread::idealThreadCount()));
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i] = new UuidThread;
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->start();
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
QVERIFY(threads[i]->wait(1000));
- for (int i = 1; i < threads.count(); ++i)
+ for (int i = 1; i < threads.size(); ++i)
QVERIFY(threads[0]->uuid != threads[i]->uuid);
qDeleteAll(threads);
}
diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp
index 7e01ca3f98..374d0cf10d 100644
--- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp
@@ -940,7 +940,7 @@ void tst_QtJson::testValueRef()
QCOMPARE(object.value(QLatin1String("null")), QJsonValue());
object[QLatin1String("null")] = 100.;
QCOMPARE(object.value(QLatin1String("null")).type(), QJsonValue::Double);
- QJsonValue val = qAsConst(object)[QLatin1String("null")];
+ QJsonValue val = std::as_const(object)[QLatin1String("null")];
QCOMPARE(val.toDouble(), 100.);
QCOMPARE(object.size(), 2);
diff --git a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp
index 5651cc3987..898fb785e8 100644
--- a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp
+++ b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp
@@ -81,9 +81,9 @@ void encodeVariant(QCborStreamWriter &writer, const QVariant &v)
list = v.value<IndeterminateLengthArray>();
writer.startArray();
} else {
- writer.startArray(list.length());
+ writer.startArray(list.size());
}
- for (const QVariant &v2 : qAsConst(list))
+ for (const QVariant &v2 : std::as_const(list))
encodeVariant(writer, v2);
QVERIFY(writer.endArray());
return;
@@ -94,9 +94,9 @@ void encodeVariant(QCborStreamWriter &writer, const QVariant &v)
map = v.value<IndeterminateLengthMap>();
writer.startMap();
} else {
- writer.startMap(map.length());
+ writer.startMap(map.size());
}
- for (auto pair : qAsConst(map)) {
+ for (auto pair : std::as_const(map)) {
encodeVariant(writer, pair.first);
encodeVariant(writer, pair.second);
}
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 6c128016ba..80e0a21985 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -785,7 +785,7 @@ void tst_QCborValue::arrayInitializerList()
// range for
int i = 0;
- for (const QCborValue v : qAsConst(a)) {
+ for (const QCborValue v : std::as_const(a)) {
QVERIFY(!v.isInvalid());
QCOMPARE(v.isUndefined(), i == 5); // 6th element is Undefined
++i;
@@ -885,7 +885,7 @@ void tst_QCborValue::mapSimpleInitializerList()
// range for
int i = 0;
- for (auto pair : qAsConst(m)) {
+ for (auto pair : std::as_const(m)) {
QVERIFY(!pair.first.isUndefined());
QVERIFY(!pair.second.isUndefined());
++i;
@@ -1294,16 +1294,16 @@ void tst_QCborValue::arrayValueRefLargeKey()
a[LargeKey + 1] = 123;
QCborValue v(a);
- QCOMPARE(qAsConst(v)[LargeKey], QCborValue());
- QCOMPARE(qAsConst(v)[LargeKey + 1], 123);
+ QCOMPARE(std::as_const(v)[LargeKey], QCborValue());
+ QCOMPARE(std::as_const(v)[LargeKey + 1], 123);
QCOMPARE(v[LargeKey], QCborValue());
QCOMPARE(v[LargeKey + 1], 123);
QCOMPARE(v.type(), QCborValue::Array);
QCborArray outer = { QCborValue(a) };
QCborValueRef ref = outer[0];
- QCOMPARE(qAsConst(ref)[LargeKey], QCborValue());
- QCOMPARE(qAsConst(ref)[LargeKey + 1], 123);
+ QCOMPARE(std::as_const(ref)[LargeKey], QCborValue());
+ QCOMPARE(std::as_const(ref)[LargeKey + 1], 123);
QCOMPARE(ref[LargeKey], QCborValue());
QCOMPARE(ref[LargeKey + 1], 123);
QCOMPARE(ref.type(), QCborValue::Array);
@@ -1714,7 +1714,7 @@ void tst_QCborValue::arrayNested()
QCborArray a1 = { 42, 47 };
QCborArray a2 = { QCborValue(a1) };
QCOMPARE(a2.size(), 1);
- const QCborValue &first = qAsConst(a2).first();
+ const QCborValue &first = std::as_const(a2).first();
QVERIFY(first.isArray());
QCOMPARE(first.toArray(wrongArray).size(), 2);
QCOMPARE(first.toArray(wrongArray).first(), 42);
@@ -1735,7 +1735,7 @@ void tst_QCborValue::arrayNested()
QCborArray a1;
a1 = { QCborValue(a1) }; // insert it into itself
QCOMPARE(a1.size(), 1);
- const QCborValue &first = qAsConst(a1).first();
+ const QCborValue &first = std::as_const(a1).first();
QVERIFY(first.isArray());
QCOMPARE(first, QCborArray());
QCOMPARE(first.toArray(wrongArray), QCborArray());
@@ -1752,7 +1752,7 @@ void tst_QCborValue::arrayNested()
QCborArray a1;
a1.append(a1); // insert into itself
QCOMPARE(a1.size(), 1);
- const QCborValue &first = qAsConst(a1).first();
+ const QCborValue &first = std::as_const(a1).first();
QVERIFY(first.isArray());
QCOMPARE(first, QCborArray());
QCOMPARE(first.toArray(), QCborArray());
@@ -2695,9 +2695,9 @@ template <typename ValueRef> static void cborValueRef_template()
QCOMPARE(ref.toArray().isEmpty(), v.toArray().isEmpty());
QCOMPARE(ref.toMap().isEmpty(), v.toMap().isEmpty());
- QCOMPARE(ref[0], qAsConst(v)[0]);
- QCOMPARE(ref[QLatin1String("other")], qAsConst(v)[QLatin1String("other")]);
- QCOMPARE(ref[QString("other")], qAsConst(v)[QString("other")]);
+ QCOMPARE(ref[0], std::as_const(v)[0]);
+ QCOMPARE(ref[QLatin1String("other")], std::as_const(v)[QLatin1String("other")]);
+ QCOMPARE(ref[QString("other")], std::as_const(v)[QString("other")]);
if (qIsNaN(v.toDouble()))
QCOMPARE(qIsNaN(ref.toVariant().toDouble()), qIsNaN(v.toVariant().toDouble()));
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index 296f491724..a203861e30 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -960,10 +960,10 @@ static void QBitArrayData(QBitArray *b, int index)
case 18: filler = "1111111111111111111111111111111111111111111111111111111111111111"; break;
}
- b->resize(filler.length());
+ b->resize(filler.size());
b->fill(0); // reset all bits to zero
- for (int i = 0; i < filler.length(); ++i) {
+ for (int i = 0; i < filler.size(); ++i) {
if (filler.at(i) == '1')
b->setBit(i, true);
}
diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
index 6d80efe956..53b5810451 100644
--- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
@@ -12,6 +12,7 @@
#include <QDebug>
#include <QElapsedTimer>
#include <QFile>
+#include <QTemporaryFile>
#include <QStringConverter>
#include <QTcpSocket>
#include <QTemporaryDir>
@@ -202,6 +203,9 @@ private slots:
void textModeOnEmptyRead();
+ void autodetectUnicode_data();
+ void autodetectUnicode();
+
private:
void generateLineData(bool for_QString);
void generateAllData(bool for_QString);
@@ -1409,7 +1413,7 @@ void tst_QTextStream::pos3LargeFile()
// NOTE: The unusual spacing is to ensure non-1-character whitespace.
QString lineString = " 0 1 2\t3 4\t \t5 6 7 8 9 \n";
// Approximate 50kb text file
- const int NbLines = (50*1024) / lineString.length() + 1;
+ const int NbLines = (50*1024) / lineString.size() + 1;
for (int line = 0; line < NbLines; ++line)
out << lineString;
// File is automatically flushed and closed on destruction.
@@ -3043,6 +3047,57 @@ void tst_QTextStream::textModeOnEmptyRead()
QVERIFY(file.isTextModeEnabled());
}
+void tst_QTextStream::autodetectUnicode_data()
+{
+ QTest::addColumn<QStringConverter::Encoding>("encoding");
+ QTest::newRow("Utf8") << QStringConverter::Utf8;
+ QTest::newRow("Utf16BE") << QStringConverter::Utf16BE;
+ QTest::newRow("Utf16LE") << QStringConverter::Utf16LE;
+ QTest::newRow("Utf32BE") << QStringConverter::Utf32BE;
+ QTest::newRow("Utf32LE") << QStringConverter::Utf32LE;
+}
+
+void tst_QTextStream::autodetectUnicode()
+{
+ QFETCH(QStringConverter::Encoding, encoding);
+
+ QTemporaryFile file;
+ QVERIFY(file.open());
+
+ QString original("HelloWorld👋");
+
+ {
+ QTextStream out(&file);
+ out.setGenerateByteOrderMark(true);
+ out.setEncoding(encoding);
+ out << original;
+ }
+ file.seek(0);
+ {
+ QTextStream in(&file);
+ QString actual;
+ in >> actual;
+ QCOMPARE(actual, original);
+ QCOMPARE(in.encoding(), encoding);
+ }
+ file.seek(0);
+ // Again, but change order of calls to QTextStream...
+ {
+ QTextStream out(&file);
+ out.setEncoding(encoding);
+ out.setGenerateByteOrderMark(true);
+ out << original;
+ }
+ file.seek(0);
+ {
+ QTextStream in(&file);
+ QString actual;
+ in >> actual;
+ QCOMPARE(actual, original);
+ QCOMPARE(in.encoding(), encoding);
+ }
+}
+
// ------------------------------------------------------------------------------
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
index 2799e7a999..c64088d477 100644
--- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
@@ -1659,20 +1659,21 @@ static bool isValidSingleTextChar(const ushort c)
void tst_QXmlStream::readBack() const
{
+ QBuffer buffer;
+
for (ushort c = 0; c < std::numeric_limits<ushort>::max(); ++c) {
- QBuffer buffer;
- QVERIFY(buffer.open(QIODevice::WriteOnly));
+ QVERIFY(buffer.open(QIODevice::WriteOnly|QIODevice::Truncate));
QXmlStreamWriter writer(&buffer);
writer.writeStartDocument();
writer.writeTextElement("a", QString(QChar(c)));
writer.writeEndDocument();
buffer.close();
- if (writer.hasError()) {
- QVERIFY2(!isValidSingleTextChar(c), QByteArray::number(c));
+ if (!isValidSingleTextChar(c)) {
+ QVERIFY2(writer.hasError(), QByteArray::number(c));
} else {
- QVERIFY2(isValidSingleTextChar(c), QByteArray::number(c));
+ QVERIFY2(!writer.hasError(), QByteArray::number(c));
QVERIFY(buffer.open(QIODevice::ReadOnly));
QXmlStreamReader reader(&buffer);
do {
diff --git a/tests/auto/corelib/text/CMakeLists.txt b/tests/auto/corelib/text/CMakeLists.txt
index 5264c3e2fc..2562ca4f10 100644
--- a/tests/auto/corelib/text/CMakeLists.txt
+++ b/tests/auto/corelib/text/CMakeLists.txt
@@ -2,6 +2,7 @@
add_subdirectory(qanystringview)
add_subdirectory(qbytearray)
+add_subdirectory(qbytearray_large)
add_subdirectory(qbytearrayapisymmetry)
add_subdirectory(qbytearraylist)
add_subdirectory(qbytearraymatcher)
diff --git a/tests/auto/corelib/text/qbytearray/CMakeLists.txt b/tests/auto/corelib/text/qbytearray/CMakeLists.txt
index d1a65adcd8..54b29e70ee 100644
--- a/tests/auto/corelib/text/qbytearray/CMakeLists.txt
+++ b/tests/auto/corelib/text/qbytearray/CMakeLists.txt
@@ -4,15 +4,11 @@
## tst_qbytearray Test:
#####################################################################
-# Collect test data
-list(APPEND test_data "rfc3252.txt")
-
qt_internal_add_test(tst_qbytearray
SOURCES
tst_qbytearray.cpp
PUBLIC_LIBRARIES
Qt::CorePrivate
- TESTDATA ${test_data}
)
## Scopes:
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
index 823dd679e5..5566d64bc4 100644
--- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
@@ -12,9 +12,6 @@
#include "../shared/test_number_shared.h"
-#include <stdexcept>
-#include <string_view>
-
class tst_QByteArray : public QObject
{
Q_OBJECT
@@ -26,13 +23,6 @@ private slots:
void swap();
void qChecksum_data();
void qChecksum();
- void qCompress_data();
-#ifndef QT_NO_COMPRESS
- void qCompress();
- void qUncompressCorruptedData_data();
- void qUncompressCorruptedData();
- void qCompressionZeroTermination();
-#endif
void constByteArray();
void leftJustified();
void rightJustified();
@@ -43,7 +33,6 @@ private slots:
void split();
void base64_data();
void base64();
- void base64_2GiB();
void fromBase64_data();
void fromBase64();
void qvsnprintf();
@@ -235,79 +224,6 @@ void tst_QByteArray::qChecksum()
QCOMPARE(::qChecksum(QByteArrayView(data.constData(), len), standard), static_cast<quint16>(checksum));
}
-void tst_QByteArray::qCompress_data()
-{
- QTest::addColumn<QByteArray>("ba");
-
- const int size1 = 1024*1024;
- QByteArray ba1( size1, 0 );
-
- QTest::newRow( "00" ) << QByteArray();
-
- int i;
- for ( i=0; i<size1; i++ )
- ba1[i] = (char)( i / 1024 );
- QTest::newRow( "01" ) << ba1;
-
- for ( i=0; i<size1; i++ )
- ba1[i] = (char)( i % 256 );
- QTest::newRow( "02" ) << ba1;
-
- ba1.fill( 'A' );
- QTest::newRow( "03" ) << ba1;
-
- QFile file( QFINDTESTDATA("rfc3252.txt") );
- QVERIFY( file.open(QIODevice::ReadOnly) );
- QTest::newRow( "04" ) << file.readAll();
-}
-
-#ifndef QT_NO_COMPRESS
-void tst_QByteArray::qCompress()
-{
- QFETCH( QByteArray, ba );
- QByteArray compressed = ::qCompress( ba );
- QTEST( ::qUncompress( compressed ), "ba" );
-}
-
-void tst_QByteArray::qUncompressCorruptedData_data()
-{
- QTest::addColumn<QByteArray>("in");
-
- QTest::newRow("0x00000000") << QByteArray("\x00\x00\x00\x00", 4);
- QTest::newRow("0x000000ff") << QByteArray("\x00\x00\x00\xff", 4);
- QTest::newRow("0x3f000000") << QByteArray("\x3f\x00\x00\x00", 4);
- QTest::newRow("0x3fffffff") << QByteArray("\x3f\xff\xff\xff", 4);
- QTest::newRow("0x7fffff00") << QByteArray("\x7f\xff\xff\x00", 4);
- QTest::newRow("0x7fffffff") << QByteArray("\x7f\xff\xff\xff", 4);
- QTest::newRow("0x80000000") << QByteArray("\x80\x00\x00\x00", 4);
- QTest::newRow("0x800000ff") << QByteArray("\x80\x00\x00\xff", 4);
- QTest::newRow("0xcf000000") << QByteArray("\xcf\x00\x00\x00", 4);
- QTest::newRow("0xcfffffff") << QByteArray("\xcf\xff\xff\xff", 4);
- QTest::newRow("0xffffff00") << QByteArray("\xff\xff\xff\x00", 4);
- QTest::newRow("0xffffffff") << QByteArray("\xff\xff\xff\xff", 4);
-}
-
-// This test is expected to produce some warning messages in the test output.
-void tst_QByteArray::qUncompressCorruptedData()
-{
- QFETCH(QByteArray, in);
-
- QByteArray res;
- res = ::qUncompress(in);
- QCOMPARE(res, QByteArray());
-
- res = ::qUncompress(in + "blah");
- QCOMPARE(res, QByteArray());
-}
-
-void tst_QByteArray::qCompressionZeroTermination()
-{
- QByteArray s = "Hello, I'm a string.";
- QByteArray ba = ::qUncompress(::qCompress(s));
- QCOMPARE(ba.data()[ba.size()], '\0');
- QCOMPARE(ba, s);
-}
-#endif
void tst_QByteArray::constByteArray()
{
@@ -579,42 +495,6 @@ void tst_QByteArray::base64()
QCOMPARE(arr64, base64urlnoequals);
}
-void tst_QByteArray::base64_2GiB()
-{
- if constexpr (sizeof(qsizetype) > sizeof(int)) {
- try {
- constexpr qint64 GiB = 1024 * 1024 * 1024;
- static_assert((2 * GiB + 1) % 3 == 0);
- const char inputChar = '\0'; // all-NULs encode as
- const char outputChar = 'A'; // all-'A's
- const qint64 inputSize = 2 * GiB + 1;
- const qint64 outputSize = inputSize / 3 * 4;
- const auto sv = [](const QByteArray &ba) {
- return std::string_view{ba.data(), size_t(ba.size())};
- };
- QByteArray output;
- {
- const QByteArray input(inputSize, inputChar);
- output = input.toBase64();
- QCOMPARE(output.size(), outputSize);
- QCOMPARE(sv(output).find_first_not_of(outputChar),
- std::string_view::npos);
- }
- {
- auto r = QByteArray::fromBase64Encoding(output);
- QCOMPARE_EQ(r.decodingStatus, QByteArray::Base64DecodingStatus::Ok);
- QCOMPARE(r.decoded.size(), inputSize);
- QCOMPARE(sv(r.decoded).find_first_not_of(inputChar),
- std::string_view::npos);
- }
- } catch (const std::bad_alloc &) {
- QSKIP("Could not allocate enough RAM.");
- }
- } else {
- QSKIP("This is a 64-bit only test");
- }
-}
-
//different from the previous test as the input are invalid
void tst_QByteArray::fromBase64_data()
{
@@ -857,7 +737,10 @@ void tst_QByteArray::qstrncpy()
// src == nullptr
QCOMPARE(::qstrncpy(dst.data(), 0, 0), (char*)0);
+ QCOMPARE(*dst.data(), 'b'); // must not have written to dst
QCOMPARE(::qstrncpy(dst.data(), 0, 10), (char*)0);
+ QCOMPARE(*dst.data(), '\0'); // must have written to dst
+ *dst.data() = 'b'; // restore
// valid pointers, but len == 0
QCOMPARE(::qstrncpy(dst.data(), src.data(), 0), dst.data());
diff --git a/tests/auto/corelib/text/qbytearray/.gitattributes b/tests/auto/corelib/text/qbytearray_large/.gitattributes
index e04709aa2e..e04709aa2e 100644
--- a/tests/auto/corelib/text/qbytearray/.gitattributes
+++ b/tests/auto/corelib/text/qbytearray_large/.gitattributes
diff --git a/tests/auto/corelib/text/qbytearray_large/CMakeLists.txt b/tests/auto/corelib/text/qbytearray_large/CMakeLists.txt
new file mode 100644
index 0000000000..898c1662f0
--- /dev/null
+++ b/tests/auto/corelib/text/qbytearray_large/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_test(tst_qbytearray_large
+ SOURCES
+ tst_qbytearray_large.cpp
+ LIBRARIES
+ Qt::Core
+ TESTDATA "rfc3252.txt"
+)
+
diff --git a/tests/auto/corelib/text/qbytearray/rfc3252.txt b/tests/auto/corelib/text/qbytearray_large/rfc3252.txt
index b80c61bf0a..b80c61bf0a 100644
--- a/tests/auto/corelib/text/qbytearray/rfc3252.txt
+++ b/tests/auto/corelib/text/qbytearray_large/rfc3252.txt
diff --git a/tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp b/tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp
new file mode 100644
index 0000000000..65ba2f54ff
--- /dev/null
+++ b/tests/auto/corelib/text/qbytearray_large/tst_qbytearray_large.cpp
@@ -0,0 +1,216 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// Copyright (C) 2022 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <QTest>
+
+#include <qbytearray.h>
+
+#include <q20iterator.h>
+#include <stdexcept>
+#include <string_view>
+
+class tst_QByteArrayLarge : public QObject
+{
+ Q_OBJECT
+
+private slots:
+#ifndef QT_NO_COMPRESS
+ void qCompress_data();
+ void qCompress();
+ void qUncompressCorruptedData_data();
+ void qUncompressCorruptedData();
+ void qUncompress4GiBPlus();
+ void qCompressionZeroTermination();
+#endif
+ void base64_2GiB();
+};
+
+#ifndef QT_NO_COMPRESS
+void tst_QByteArrayLarge::qCompress_data()
+{
+ QTest::addColumn<QByteArray>("ba");
+
+ const int size1 = 1024*1024;
+ QByteArray ba1( size1, 0 );
+
+ QTest::newRow( "00" ) << QByteArray();
+
+ int i;
+ for ( i=0; i<size1; i++ )
+ ba1[i] = (char)( i / 1024 );
+ QTest::newRow( "01" ) << ba1;
+
+ for ( i=0; i<size1; i++ )
+ ba1[i] = (char)( i % 256 );
+ QTest::newRow( "02" ) << ba1;
+
+ ba1.fill( 'A' );
+ QTest::newRow( "03" ) << ba1;
+
+ QFile file( QFINDTESTDATA("rfc3252.txt") );
+ QVERIFY( file.open(QIODevice::ReadOnly) );
+ QTest::newRow( "04" ) << file.readAll();
+}
+
+void tst_QByteArrayLarge::qCompress()
+{
+ QFETCH( QByteArray, ba );
+ QByteArray compressed = ::qCompress( ba );
+ QTEST( ::qUncompress( compressed ), "ba" );
+}
+
+void tst_QByteArrayLarge::qUncompressCorruptedData_data()
+{
+ QTest::addColumn<QByteArray>("in");
+
+ QTest::newRow("0x00000000") << QByteArray("\x00\x00\x00\x00", 4);
+ QTest::newRow("0x000000ff") << QByteArray("\x00\x00\x00\xff", 4);
+ QTest::newRow("0x3f000000") << QByteArray("\x3f\x00\x00\x00", 4);
+ QTest::newRow("0x3fffffff") << QByteArray("\x3f\xff\xff\xff", 4);
+ QTest::newRow("0x7fffff00") << QByteArray("\x7f\xff\xff\x00", 4);
+ QTest::newRow("0x7fffffff") << QByteArray("\x7f\xff\xff\xff", 4);
+ QTest::newRow("0x80000000") << QByteArray("\x80\x00\x00\x00", 4);
+ QTest::newRow("0x800000ff") << QByteArray("\x80\x00\x00\xff", 4);
+ QTest::newRow("0xcf000000") << QByteArray("\xcf\x00\x00\x00", 4);
+ QTest::newRow("0xcfffffff") << QByteArray("\xcf\xff\xff\xff", 4);
+ QTest::newRow("0xffffff00") << QByteArray("\xff\xff\xff\x00", 4);
+ QTest::newRow("0xffffffff") << QByteArray("\xff\xff\xff\xff", 4);
+}
+
+// This test is expected to produce some warning messages in the test output.
+void tst_QByteArrayLarge::qUncompressCorruptedData()
+{
+ QFETCH(QByteArray, in);
+
+ QByteArray res;
+ res = ::qUncompress(in);
+ QCOMPARE(res, QByteArray());
+
+ res = ::qUncompress(in + "blah");
+ QCOMPARE(res, QByteArray());
+}
+
+void tst_QByteArrayLarge::qUncompress4GiBPlus()
+{
+ // after three rounds, this decompresses to 4GiB + 1 'X' bytes:
+ constexpr uchar compressed_3x[] = {
+ 0x00, 0x00, 0x1a, 0x76, 0x78, 0x9c, 0x63, 0xb0, 0xdf, 0xb4, 0xad, 0x62,
+ 0xce, 0xdb, 0x3b, 0x0b, 0xf3, 0x26, 0x27, 0x4a, 0xb4, 0x3d, 0x34, 0x5b,
+ 0xed, 0xb4, 0x41, 0xf1, 0xc0, 0x99, 0x2f, 0x02, 0x05, 0x67, 0x26, 0x88,
+ 0x6c, 0x66, 0x71, 0x34, 0x62, 0x9c, 0x75, 0x26, 0xb1, 0xa0, 0xe5, 0xcc,
+ 0xda, 0x94, 0x83, 0xc9, 0x05, 0x73, 0x0e, 0x3c, 0x39, 0xc2, 0xc7, 0xd0,
+ 0xae, 0x38, 0x53, 0x7b, 0x87, 0xdc, 0x01, 0x91, 0x45, 0x59, 0x4f, 0xda,
+ 0xbf, 0xca, 0xcc, 0x52, 0xdb, 0xbb, 0xde, 0xbb, 0xf6, 0xd3, 0x55, 0xff,
+ 0x7d, 0x77, 0x0e, 0x1b, 0xf0, 0xa4, 0xdf, 0xcf, 0xdb, 0x5f, 0x2f, 0xf5,
+ 0xd7, 0x7c, 0xfe, 0xbf, 0x3f, 0xbf, 0x3f, 0x9d, 0x7c, 0xda, 0x2c, 0xc8,
+ 0xc0, 0xc0, 0xb0, 0xe1, 0xf1, 0xb3, 0xfd, 0xfa, 0xdf, 0x8e, 0x7d, 0xef,
+ 0x7f, 0xb9, 0xc1, 0xc2, 0xae, 0x92, 0x19, 0x28, 0xf2, 0x66, 0xd7, 0xe5,
+ 0xbf, 0xed, 0x93, 0xbf, 0x6a, 0x14, 0x7c, 0xff, 0xf6, 0xe1, 0xe8, 0xb6,
+ 0x7e, 0x46, 0xa0, 0x90, 0xd9, 0xbb, 0xcf, 0x9f, 0x17, 0x37, 0x7f, 0xe5,
+ 0x6f, 0xb4, 0x7f, 0xfe, 0x5e, 0xfd, 0xb6, 0x1d, 0x1b, 0x50, 0xe8, 0xc6,
+ 0x8e, 0xe3, 0xab, 0x9f, 0xe6, 0xec, 0x65, 0xfd, 0x23, 0xb1, 0x4e, 0x7e,
+ 0xef, 0xbd, 0x6f, 0xa6, 0x40, 0xa1, 0x03, 0xc7, 0xfe, 0x0a, 0xf1, 0x00,
+ 0xe9, 0x06, 0x91, 0x83, 0x40, 0x92, 0x21, 0x43, 0x10, 0xcc, 0x11, 0x03,
+ 0x73, 0x3a, 0x90, 0x39, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32,
+ 0xa3, 0x32, 0xa3, 0x32, 0xa3, 0x32, 0x34, 0x90, 0x99, 0xb6, 0x7e, 0xf5,
+ 0xd3, 0xe9, 0xbf, 0x35, 0x13, 0xca, 0x8c, 0x75, 0xec, 0xec, 0xa4, 0x2f,
+ 0x7e, 0x2d, 0xf9, 0xf3, 0xf0, 0xee, 0xea, 0xd5, 0xf5, 0xd3, 0x14, 0x57,
+ 0x06, 0x00, 0x00, 0xb9, 0x1e, 0x35, 0xce
+ };
+
+ constexpr qint64 GiB = 1024LL * 1024 * 1024;
+
+ if constexpr (sizeof(qsizetype) == sizeof(int)) {
+ QSKIP("This is a 64-bit-only test.");
+ } else {
+
+ // 1st
+ auto c = ::qUncompress(std::data(compressed_3x), q20::ssize(compressed_3x));
+ QVERIFY(!c.isNull()); // check for decompression error
+
+ // 2nd
+ c = ::qUncompress(c);
+ QVERIFY(!c.isNull());
+
+ // 3rd
+ try {
+ c = ::qUncompress(c);
+ if (c.isNull()) // this step (~18MiB -> 4GiB) might have run out of memory
+ QSKIP("Failed to allocate enough memory.");
+ } catch (const std::bad_alloc &) {
+ QSKIP("Failed to allocate enough memory.");
+ }
+
+ QCOMPARE(c.size(), 4 * GiB + 1);
+ QCOMPARE(std::string_view{c}.find_first_not_of('X'),
+ std::string_view::npos);
+
+ // re-compress once
+ // (produces 18MiB, we shouldn't use much more than that in allocated capacity)
+ c = ::qCompress(c);
+ QVERIFY(!c.isNull());
+
+ // and un-compress again, to make sure compression worked (we
+ // can't compare with compressed_3x, because zlib may change):
+ c = ::qUncompress(c);
+
+ QCOMPARE(c.size(), 4 * GiB + 1);
+ QCOMPARE(std::string_view{c}.find_first_not_of('X'),
+ std::string_view::npos);
+ }
+}
+
+void tst_QByteArrayLarge::qCompressionZeroTermination()
+{
+ QByteArray s = "Hello, I'm a string.";
+ QByteArray ba = ::qUncompress(::qCompress(s));
+ QCOMPARE(ba.data()[ba.size()], '\0');
+ QCOMPARE(ba, s);
+}
+#endif
+
+void tst_QByteArrayLarge::base64_2GiB()
+{
+#ifdef Q_OS_ANDROID
+ QSKIP("Android kills the test when using too much memory");
+#endif
+ if constexpr (sizeof(qsizetype) > sizeof(int)) {
+ try {
+ constexpr qint64 GiB = 1024 * 1024 * 1024;
+ static_assert((2 * GiB + 1) % 3 == 0);
+ const char inputChar = '\0'; // all-NULs encode as
+ const char outputChar = 'A'; // all-'A's
+ const qint64 inputSize = 2 * GiB + 1;
+ const qint64 outputSize = inputSize / 3 * 4;
+ const auto sv = [](const QByteArray &ba) {
+ return std::string_view{ba.data(), size_t(ba.size())};
+ };
+ QByteArray output;
+ {
+ const QByteArray input(inputSize, inputChar);
+ output = input.toBase64();
+ QCOMPARE(output.size(), outputSize);
+ QCOMPARE(sv(output).find_first_not_of(outputChar),
+ std::string_view::npos);
+ }
+ {
+ auto r = QByteArray::fromBase64Encoding(output);
+ QCOMPARE_EQ(r.decodingStatus, QByteArray::Base64DecodingStatus::Ok);
+ QCOMPARE(r.decoded.size(), inputSize);
+ QCOMPARE(sv(r.decoded).find_first_not_of(inputChar),
+ std::string_view::npos);
+ }
+ } catch (const std::bad_alloc &) {
+ QSKIP("Could not allocate enough RAM.");
+ }
+ } else {
+ QSKIP("This is a 64-bit only test");
+ }
+}
+
+QTEST_MAIN(tst_QByteArrayLarge)
+#include "tst_qbytearray_large.moc"
diff --git a/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp b/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp
index a01b097576..3d3b724599 100644
--- a/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp
+++ b/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp
@@ -91,12 +91,12 @@ void tst_QByteArrayMatcher::interface()
QCOMPARE(matcher5.indexIn(haystack), 42);
QCOMPARE(matcher6.indexIn(haystack), 42);
- QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length()), 42);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size()), 42);
QCOMPARE(matcher1.indexIn(haystack, 43), 84);
- QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 43), 84);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size(), 43), 84);
QCOMPARE(matcher1.indexIn(haystack, 85), -1);
- QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 85), -1);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size(), 85), -1);
QByteArrayMatcher matcher7(QByteArray("123"));
QCOMPARE(matcher7.indexIn(haystack), 6);
diff --git a/tests/auto/corelib/text/qchar/tst_qchar.cpp b/tests/auto/corelib/text/qchar/tst_qchar.cpp
index 725a7e0d72..9f887bb59f 100644
--- a/tests/auto/corelib/text/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/text/qchar/tst_qchar.cpp
@@ -797,7 +797,7 @@ void tst_QChar::normalization_data()
line = line.trimmed();
if (line.endsWith(';'))
- line.truncate(line.length()-1);
+ line.truncate(line.size()-1);
QList<QByteArray> l = line.split(';');
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index 4dd2cf6aff..4897218fcc 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -13,7 +13,9 @@
# include <QProcess>
#endif
#include <QScopedArrayPointer>
+#if QT_CONFIG(timezone)
#include <QTimeZone>
+#endif
#include <private/qlocale_p.h>
#include <private/qlocale_tools_p.h>
@@ -1493,8 +1495,7 @@ void tst_QLocale::fpExceptions()
# define _EM_INEXACT 0x00000001
# endif
_clearfp();
- unsigned int oldbits = _controlfp(0, 0);
- _controlfp( 0 | _EM_INEXACT, _MCW_EM );
+ unsigned int oldbits = _controlfp(0 | _EM_INEXACT, _MCW_EM);
#endif
#ifdef QT_USE_FENV
@@ -1512,7 +1513,7 @@ void tst_QLocale::fpExceptions()
#ifdef Q_OS_WIN
_clearfp();
- _controlfp(oldbits, 0xFFFFF);
+ _controlfp(oldbits, _MCW_EM);
#endif
#ifdef QT_USE_FENV
@@ -2313,7 +2314,7 @@ void tst_QLocale::windowsDefaultLocale()
locale.toString(QDate(1974, 12, 1), QLocale::ShortFormat));
QCOMPARE(locale.toString(QDate(1974, 12, 1), QLocale::LongFormat),
QStringView(u"\u3021@\u3021\u3022@\u3021\u3029\u3027\u3024"));
- const QString expectedFormattedShortTime = QStringView(u"\u3021^\u3022").toString();
+ const QString expectedFormattedShortTime = QStringView(u"\u3021^\u3022^\u3023").toString();
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::ShortFormat), expectedFormattedShortTime);
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::NarrowFormat),
locale.toString(QTime(1,2,3), QLocale::ShortFormat));
@@ -3237,7 +3238,12 @@ public:
QVariant query(QueryType type, QVariant /*in*/) const override
{
- return type == UILanguages ? QVariant(QStringList{m_name}) : QVariant();
+ if (type == UILanguages) {
+ if (m_name == u"en-DE") // QTBUG-104930: simulate macOS's list not including m_name.
+ return QVariant(QStringList{QStringLiteral("en-GB"), QStringLiteral("de-DE")});
+ return QVariant(QStringList{m_name});
+ }
+ return QVariant();
}
QLocale fallbackLocale() const override
@@ -3266,6 +3272,12 @@ void tst_QLocale::systemLocale_data()
QTest::addRow("ukrainian")
<< QString("uk") << QLocale::Ukrainian
<< QStringList{QStringLiteral("uk"), QStringLiteral("uk-Cyrl-UA"), QStringLiteral("uk-UA")};
+ QTest::addRow("english-germany")
+ << QString("en-DE") << QLocale::English
+ // First two were missed out before fix to QTBUG-104930:
+ << QStringList{QStringLiteral("en-DE"), QStringLiteral("en-Latn-DE"),
+ QStringLiteral("en-GB"), QStringLiteral("en-Latn-GB"),
+ QStringLiteral("de-DE"), QStringLiteral("de-Latn-DE"), QStringLiteral("de")};
QTest::addRow("german")
<< QString("de") << QLocale::German
<< QStringList{QStringLiteral("de"), QStringLiteral("de-Latn-DE"), QStringLiteral("de-DE")};
@@ -3290,7 +3302,11 @@ void tst_QLocale::systemLocale()
MySystemLocale sLocale(name);
QCOMPARE(QLocale().language(), language);
QCOMPARE(QLocale::system().language(), language);
+ auto reporter = qScopeGuard([]() {
+ qDebug("\n\t%s", qPrintable(QLocale::system().uiLanguages().join(u"\n\t")));
+ });
QCOMPARE(QLocale::system().uiLanguages(), uiLanguages);
+ reporter.dismiss();
}
QCOMPARE(QLocale(), originalLocale);
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 239b3498a9..64e9d5623a 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -56,7 +56,7 @@ class ArgBase
protected:
QString pinned;
explicit ArgBase(const char *str)
- : pinned(QString::fromLatin1(str)) {}
+ : pinned(QString::fromUtf8(str)) {}
};
template <>
@@ -67,11 +67,11 @@ public:
template <typename MemFun>
void apply0(QString &s, MemFun mf) const
- { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(ch); }
+ { for (QChar ch : std::as_const(this->pinned)) (s.*mf)(ch); }
template <typename MemFun, typename A1>
void apply1(QString &s, MemFun mf, A1 a1) const
- { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(a1, ch); }
+ { for (QChar ch : std::as_const(this->pinned)) (s.*mf)(a1, ch); }
};
template <>
@@ -276,6 +276,13 @@ static void do_apply1(MemFun mf)
class tst_QString : public QObject
{
Q_OBJECT
+public:
+ enum DataOption {
+ EmptyIsNoop = 0x1,
+ Latin1Encoded = 0x2
+ };
+ Q_DECLARE_FLAGS(DataOptions, DataOption)
+private:
#if QT_CONFIG(regularexpression)
template<typename List, class RegExp>
@@ -288,22 +295,22 @@ class tst_QString : public QObject
void append_impl() const { do_apply0<ArgType>(MemFun(&QString::append)); }
template <typename ArgType>
void append_impl() const { append_impl<ArgType, QString &(QString::*)(const ArgType&)>(); }
- void append_data(bool emptyIsNoop = false);
+ void append_data(DataOptions options = {});
template <typename ArgType, typename MemFun>
void operator_pluseq_impl() const { do_apply0<ArgType>(MemFun(&QString::operator+=)); }
template <typename ArgType>
void operator_pluseq_impl() const { operator_pluseq_impl<ArgType, QString &(QString::*)(const ArgType&)>(); }
- void operator_pluseq_data(bool emptyIsNoop = false);
+ void operator_pluseq_data(DataOptions options = {});
template <typename ArgType, typename MemFun>
void prepend_impl() const { do_apply0<ArgType>(MemFun(&QString::prepend)); }
template <typename ArgType>
void prepend_impl() const { prepend_impl<ArgType, QString &(QString::*)(const ArgType&)>(); }
- void prepend_data(bool emptyIsNoop = false);
+ void prepend_data(DataOptions options = {});
template <typename ArgType, typename MemFun>
void insert_impl() const { do_apply1<ArgType, int>(MemFun(&QString::insert)); }
template <typename ArgType>
void insert_impl() const { insert_impl<ArgType, QString &(QString::*)(qsizetype, const ArgType&)>(); }
- void insert_data(bool emptyIsNoop = false);
+ void insert_data(DataOptions options = {});
class TransientDefaultLocale
{
@@ -369,38 +376,38 @@ private slots:
void swap();
void prepend_qstring() { prepend_impl<QString>(); }
- void prepend_qstring_data() { prepend_data(true); }
+ void prepend_qstring_data() { prepend_data(EmptyIsNoop); }
void prepend_qstringview() { prepend_impl<QStringView, QString &(QString::*)(QStringView)>(); }
- void prepend_qstringview_data() { prepend_data(true); }
+ void prepend_qstringview_data() { prepend_data(EmptyIsNoop); }
void prepend_qlatin1string() { prepend_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
- void prepend_qlatin1string_data() { prepend_data(true); }
+ void prepend_qlatin1string_data() { prepend_data({EmptyIsNoop, Latin1Encoded}); }
void prepend_qcharstar_int() { prepend_impl<QPair<const QChar *, int>, QString &(QString::*)(const QChar *, qsizetype)>(); }
- void prepend_qcharstar_int_data() { prepend_data(true); }
+ void prepend_qcharstar_int_data() { prepend_data(EmptyIsNoop); }
void prepend_qchar() { prepend_impl<Reversed<QChar>, QString &(QString::*)(QChar)>(); }
- void prepend_qchar_data() { prepend_data(true); }
+ void prepend_qchar_data() { prepend_data(EmptyIsNoop); }
void prepend_qbytearray() { prepend_impl<QByteArray>(); }
- void prepend_qbytearray_data() { prepend_data(true); }
+ void prepend_qbytearray_data() { prepend_data(EmptyIsNoop); }
void prepend_char() { prepend_impl<Reversed<char>, QString &(QString::*)(QChar)>(); }
- void prepend_char_data() { prepend_data(true); }
+ void prepend_char_data() { prepend_data({EmptyIsNoop, Latin1Encoded}); }
void prepend_charstar() { prepend_impl<const char *, QString &(QString::*)(const char *)>(); }
- void prepend_charstar_data() { prepend_data(true); }
+ void prepend_charstar_data() { prepend_data(EmptyIsNoop); }
void prepend_bytearray_special_cases_data();
void prepend_bytearray_special_cases();
void append_qstring() { append_impl<QString>(); }
void append_qstring_data() { append_data(); }
void append_qstringview() { append_impl<QStringView, QString &(QString::*)(QStringView)>(); }
- void append_qstringview_data() { append_data(true); }
+ void append_qstringview_data() { append_data(EmptyIsNoop); }
void append_qlatin1string() { append_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
- void append_qlatin1string_data() { append_data(); }
+ void append_qlatin1string_data() { append_data(Latin1Encoded); }
void append_qcharstar_int() { append_impl<QPair<const QChar *, int>, QString&(QString::*)(const QChar *, qsizetype)>(); }
- void append_qcharstar_int_data() { append_data(true); }
+ void append_qcharstar_int_data() { append_data(EmptyIsNoop); }
void append_qchar() { append_impl<QChar, QString &(QString::*)(QChar)>(); }
- void append_qchar_data() { append_data(true); }
+ void append_qchar_data() { append_data(EmptyIsNoop); }
void append_qbytearray() { append_impl<QByteArray>(); }
void append_qbytearray_data() { append_data(); }
void append_char() { append_impl<char, QString &(QString::*)(QChar)>(); }
- void append_char_data() { append_data(true); }
+ void append_char_data() { append_data({EmptyIsNoop, Latin1Encoded}); }
void append_charstar() { append_impl<const char *, QString &(QString::*)(const char *)>(); }
void append_charstar_data() { append_data(); }
void append_special_cases();
@@ -410,11 +417,11 @@ private slots:
void operator_pluseq_qstring() { operator_pluseq_impl<QString>(); }
void operator_pluseq_qstring_data() { operator_pluseq_data(); }
void operator_pluseq_qstringview() { operator_pluseq_impl<QStringView, QString &(QString::*)(QStringView)>(); }
- void operator_pluseq_qstringview_data() { operator_pluseq_data(true); }
+ void operator_pluseq_qstringview_data() { operator_pluseq_data(EmptyIsNoop); }
void operator_pluseq_qlatin1string() { operator_pluseq_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
- void operator_pluseq_qlatin1string_data() { operator_pluseq_data(); }
+ void operator_pluseq_qlatin1string_data() { operator_pluseq_data(Latin1Encoded); }
void operator_pluseq_qchar() { operator_pluseq_impl<QChar, QString &(QString::*)(QChar)>(); }
- void operator_pluseq_qchar_data() { operator_pluseq_data(true); }
+ void operator_pluseq_qchar_data() { operator_pluseq_data(EmptyIsNoop); }
void operator_pluseq_qbytearray() { operator_pluseq_impl<QByteArray>(); }
void operator_pluseq_qbytearray_data() { operator_pluseq_data(); }
void operator_pluseq_charstar() { operator_pluseq_impl<const char *, QString &(QString::*)(const char *)>(); }
@@ -429,21 +436,21 @@ private slots:
void operator_smaller();
void insert_qstring() { insert_impl<QString>(); }
- void insert_qstring_data() { insert_data(true); }
+ void insert_qstring_data() { insert_data(EmptyIsNoop); }
void insert_qstringview() { insert_impl<QStringView, QString &(QString::*)(qsizetype, QStringView)>(); }
- void insert_qstringview_data() { insert_data(true); }
+ void insert_qstringview_data() { insert_data(EmptyIsNoop); }
void insert_qlatin1string() { insert_impl<QLatin1String, QString &(QString::*)(qsizetype, QLatin1String)>(); }
- void insert_qlatin1string_data() { insert_data(true); }
+ void insert_qlatin1string_data() { insert_data({EmptyIsNoop, Latin1Encoded}); }
void insert_qcharstar_int() { insert_impl<QPair<const QChar *, int>, QString &(QString::*)(qsizetype, const QChar*, qsizetype) >(); }
- void insert_qcharstar_int_data() { insert_data(true); }
+ void insert_qcharstar_int_data() { insert_data(EmptyIsNoop); }
void insert_qchar() { insert_impl<Reversed<QChar>, QString &(QString::*)(qsizetype, QChar)>(); }
- void insert_qchar_data() { insert_data(true); }
+ void insert_qchar_data() { insert_data(EmptyIsNoop); }
void insert_qbytearray() { insert_impl<QByteArray>(); }
- void insert_qbytearray_data() { insert_data(true); }
+ void insert_qbytearray_data() { insert_data(EmptyIsNoop); }
void insert_char() { insert_impl<Reversed<char>, QString &(QString::*)(qsizetype, QChar)>(); }
- void insert_char_data() { insert_data(true); }
+ void insert_char_data() { insert_data({EmptyIsNoop, Latin1Encoded}); }
void insert_charstar() { insert_impl<const char *, QString &(QString::*)(qsizetype, const char*) >(); }
- void insert_charstar_data() { insert_data(true); }
+ void insert_charstar_data() { insert_data(EmptyIsNoop); }
void insert_special_cases();
void simplified_data();
@@ -587,6 +594,8 @@ private slots:
void chopped();
void removeIf();
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(tst_QString::DataOptions)
+
template <class T> const T &verifyZeroTermination(const T &t) { return t; }
@@ -600,7 +609,7 @@ QString verifyZeroTermination(const QString &str)
if (!strDataPtr->isMutable())
return str;
- int strSize = str.size();
+ qsizetype strSize = str.size();
QChar strTerminator = str.constData()[strSize];
if (QChar('\0') != strTerminator)
return QString::fromLatin1(
@@ -856,6 +865,9 @@ void tst_QString::replace_regexp_data()
// Columns (all QString): string, regexp, after, result; string.replace(regexp, after) == result
// Test-cases with empty after (replacement text, third column) go in remove_regexp_data()
+ QTest::newRow("empty-in-null") << QString() << "" << "after" << "after";
+ QTest::newRow("empty-in-empty") << "" << "" << "after" << "after";
+
QTest::newRow( "rep00" ) << QString("A <i>bon mot</i>.") << QString("<i>([^<]*)</i>") << QString("\\emph{\\1}") << QString("A \\emph{bon mot}.");
QTest::newRow( "rep01" ) << QString("banana") << QString("^.a()") << QString("\\1") << QString("nana");
QTest::newRow( "rep02" ) << QString("banana") << QString("(ba)") << QString("\\1X\\1") << QString("baXbanana");
@@ -1393,6 +1405,43 @@ void tst_QString::asprintf()
double d = -514.25683;
QCOMPARE(QString::asprintf("%f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%.f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%.0f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%1f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%1.f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%1.0f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%1.6f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%1.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%-1f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%-1.f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%-1.0f", d), QLatin1String("-514"));
+ QCOMPARE(QString::asprintf("%-1.6f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%-1.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%10f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%10.f", d), QLatin1String(" -514"));
+ QCOMPARE(QString::asprintf("%10.0f", d), QLatin1String(" -514"));
+ QCOMPARE(QString::asprintf("%-10f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%-10.f", d), QLatin1String("-514 "));
+ QCOMPARE(QString::asprintf("%-10.0f", d), QLatin1String("-514 "));
+ QCOMPARE(QString::asprintf("%010f", d), QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%010.f", d), QLatin1String("-000000514"));
+ QCOMPARE(QString::asprintf("%010.0f", d), QLatin1String("-000000514"));
+ QCOMPARE(QString::asprintf("%15f", d), QLatin1String(" -514.256830"));
+ QCOMPARE(QString::asprintf("%15.6f", d), QLatin1String(" -514.256830"));
+ QCOMPARE(QString::asprintf("%15.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%-15f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-15.6f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-15.10f", d), QLatin1String("-514.2568300000"));
+ QCOMPARE(QString::asprintf("%015f", d), QLatin1String("-0000514.256830"));
+ QCOMPARE(QString::asprintf("%015.6f", d), QLatin1String("-0000514.256830"));
+ QCOMPARE(QString::asprintf("%015.10f", d), QLatin1String("-514.2568300000"));
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wformat")
+QT_WARNING_DISABLE_CLANG("-Wformat") // Flag '0' ignored when flag '-' is present
+ QCOMPARE(QString::asprintf("%-015f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-015.6f", d), QLatin1String("-514.256830 "));
+ QCOMPARE(QString::asprintf("%-015.10f", d), QLatin1String("-514.2568300000"));
+QT_WARNING_POP
{
/* This code crashed. I don't know how to reduce it further. In other words,
@@ -1913,6 +1962,21 @@ void tst_QString::count()
QTest::ignoreMessage(QtWarningMsg, ignoreMessagePattern);
QCOMPARE(emptyStr.count(QRegularExpression("invalid regex\\")), 0);
#endif
+
+ QString nonBmpString = u8"\U00010000\U00010000abc\U00010000";
+ QCOMPARE(nonBmpString.count(u"\U00010000"), 3);
+#if QT_CONFIG(regularexpression)
+ QCOMPARE(nonBmpString.count(QRegularExpression(u8"\U00010000")), 3);
+ QCOMPARE(nonBmpString.count(QRegularExpression(u8"\U00010000a?")), 3);
+ QCOMPARE(nonBmpString.count(QRegularExpression(u8"\U00010000a")), 1);
+ QCOMPARE(nonBmpString.count(QRegularExpression(".")), 6);
+
+ // can't search for unpaired surrogates
+ QTest::ignoreMessage(QtWarningMsg, ignoreMessagePattern);
+ QCOMPARE(nonBmpString.count(QRegularExpression(QChar(0xd800))), 0);
+ QTest::ignoreMessage(QtWarningMsg, ignoreMessagePattern);
+ QCOMPARE(nonBmpString.count(QRegularExpression(QChar(0xdc00))), 0);
+#endif
}
void tst_QString::contains()
@@ -2587,19 +2651,22 @@ void tst_QString::simplified()
QCOMPARE(std::move(full).simplified(), simple);
}
-void tst_QString::insert_data(bool emptyIsNoop)
+void tst_QString::insert_data(DataOptions options)
{
QTest::addColumn<QString>("s");
QTest::addColumn<CharStarContainer>("arg");
QTest::addColumn<int>("a1");
QTest::addColumn<QString>("expected");
+ const bool emptyIsNoop = options.testFlag(EmptyIsNoop);
+
const CharStarContainer nullC;
const CharStarContainer emptyC("");
const CharStarContainer aC("a");
const CharStarContainer bC("b");
//const CharStarContainer abC("ab");
const CharStarContainer baC("ba");
+ const CharStarContainer yumlautC(options.testFlag(Latin1Encoded) ? "\xff" : "\xc3\xbf");
const QString null;
const QString empty("");
@@ -2608,6 +2675,10 @@ void tst_QString::insert_data(bool emptyIsNoop)
const QString ab("ab");
const QString ba("ba");
+ const QString yumlaut = QStringLiteral("\u00ff"); // LATIN LETTER SMALL Y WITH UMLAUT
+ const QString yumlautA = QStringLiteral("\u00ffa");
+ const QString aYumlaut = QStringLiteral("a\u00ff");
+
QTest::newRow("null.insert(0, null)") << null << nullC << 0 << null;
QTest::newRow("null.insert(0, empty)") << null << emptyC << 0 << (emptyIsNoop ? null : empty);
QTest::newRow("null.insert(0, a)") << null << aC << 0 << a;
@@ -2624,6 +2695,79 @@ void tst_QString::insert_data(bool emptyIsNoop)
QTest::newRow("a.insert(1, ba)") << a << baC << 1 << (a + ba);
QTest::newRow("ba.insert(1, a)") << ba << aC << 1 << (ba + a);
QTest::newRow("ba.insert(2, b)") << ba << bC << 2 << (ba + b);
+
+ QTest::newRow("null-insert-0-yumlaut") << null << yumlautC << 0 << yumlaut;
+ QTest::newRow("empty-insert-0-yumlaut") << empty << yumlautC << 0 << yumlaut;
+ QTest::newRow("yumlaut-insert-0-null") << yumlaut << nullC << 0 << yumlaut;
+ QTest::newRow("yumlaut-insert-0-empty") << yumlaut << emptyC << 0 << yumlaut;
+ QTest::newRow("a-insert-0-yumlaut") << a << yumlautC << 0 << yumlautA;
+ QTest::newRow("a-insert-1-yumlaut") << a << yumlautC << 1 << aYumlaut;
+
+ if (!options.testFlag(Latin1Encoded)) {
+ const auto smallTheta = QStringLiteral("\u03b8"); // GREEK LETTER SMALL THETA
+ const auto ssa = QStringLiteral("\u0937"); // DEVANAGARI LETTER SSA
+ const auto chakmaZero = QStringLiteral("\U00011136"); // CHAKMA DIGIT ZERO
+
+ const auto aSmallTheta = QStringLiteral("a\u03b8");
+ const auto aSsa = QStringLiteral("a\u0937");
+ const auto aChakmaZero = QStringLiteral("a\U00011136");
+
+ const auto smallThetaA = QStringLiteral("\u03b8a");
+ const auto ssaA = QStringLiteral("\u0937a");
+ const auto chakmaZeroA = QStringLiteral("\U00011136a");
+
+ const auto umlautTheta = QStringLiteral("\u00ff\u03b8");
+ const auto thetaUmlaut = QStringLiteral("\u03b8\u00ff");
+ const auto ssaChakma = QStringLiteral("\u0937\U00011136");
+ const auto chakmaSsa = QStringLiteral("\U00011136\u0937");
+
+ const CharStarContainer smallThetaC("\xce\xb8"); // non-Latin1
+ const CharStarContainer ssaC("\xe0\xa4\xb7"); // Higher BMP
+ const CharStarContainer chakmaZeroC("\xf0\x91\x84\xb6"); // Non-BMP
+
+ QTest::newRow("null-insert-0-theta") << null << smallThetaC << 0 << smallTheta;
+ QTest::newRow("null-insert-0-ssa") << null << ssaC << 0 << ssa;
+ QTest::newRow("null-insert-0-chakma") << null << chakmaZeroC << 0 << chakmaZero;
+
+ QTest::newRow("empty-insert-0-theta") << empty << smallThetaC << 0 << smallTheta;
+ QTest::newRow("empty-insert-0-ssa") << empty << ssaC << 0 << ssa;
+ QTest::newRow("empty-insert-0-chakma") << empty << chakmaZeroC << 0 << chakmaZero;
+
+ QTest::newRow("theta-insert-0-null") << smallTheta << nullC << 0 << smallTheta;
+ QTest::newRow("ssa-insert-0-null") << ssa << nullC << 0 << ssa;
+ QTest::newRow("chakma-insert-0-null") << chakmaZero << nullC << 0 << chakmaZero;
+
+ QTest::newRow("theta-insert-0-empty") << smallTheta << emptyC << 0 << smallTheta;
+ QTest::newRow("ssa-insert-0-empty") << ssa << emptyC << 0 << ssa;
+ QTest::newRow("chakma-insert-0-empty") << chakmaZero << emptyC << 0 << chakmaZero;
+
+ QTest::newRow("a-insert-0-theta") << a << smallThetaC << 0 << smallThetaA;
+ QTest::newRow("a-insert-0-ssa") << a << ssaC << 0 << ssaA;
+ QTest::newRow("a-insert-0-chakma") << a << chakmaZeroC << 0 << chakmaZeroA;
+ QTest::newRow("yumlaut-insert-0-theta") << yumlaut << smallThetaC << 0 << thetaUmlaut;
+ QTest::newRow("theta-insert-0-yumlaut") << smallTheta << yumlautC << 0 << umlautTheta;
+ QTest::newRow("ssa-insert-0-chakma") << ssa << chakmaZeroC << 0 << chakmaSsa;
+ QTest::newRow("chakma-insert-0-ssa") << chakmaZero << ssaC << 0 << ssaChakma;
+
+ QTest::newRow("theta-insert-1-null") << smallTheta << nullC << 1 << smallTheta;
+ QTest::newRow("ssa-insert-1-null") << ssa << nullC << 1 << ssa;
+ QTest::newRow("chakma-insert-1-null") << chakmaZero << nullC << 1 << chakmaZero;
+
+ QTest::newRow("theta-insert-1-empty") << smallTheta << emptyC << 1 << smallTheta;
+ QTest::newRow("ssa-insert-1-empty") << ssa << emptyC << 1 << ssa;
+ QTest::newRow("chakma-insert-1-empty") << chakmaZero << emptyC << 1 << chakmaZero;
+
+ QTest::newRow("a-insert-1-theta") << a << smallThetaC << 1 << aSmallTheta;
+ QTest::newRow("a-insert-1-ssa") << a << ssaC << 1 << aSsa;
+ QTest::newRow("a-insert-1-chakma") << a << chakmaZeroC << 1 << aChakmaZero;
+ QTest::newRow("yumlaut-insert-1-theta") << yumlaut << smallThetaC << 1 << umlautTheta;
+ QTest::newRow("theta-insert-1-yumlaut") << smallTheta << yumlautC << 1 << thetaUmlaut;
+ QTest::newRow("ssa-insert-1-chakma") << ssa << chakmaZeroC << 1 << ssaChakma;
+ // Beware, this will insert ssa right into the middle of the chakma:
+ // Actual (s) : "\uD804\u0937\uDD36"
+ // Expected (expected): "\uD804\uDD36\u0937"
+ // QTest::newRow("chakma.insert(1, ssa)") << chakmaZero << ssaC << 1 << chakmaSsa;
+ }
}
void tst_QString::insert_special_cases()
@@ -2698,17 +2842,20 @@ void tst_QString::insert_special_cases()
}
}
-void tst_QString::append_data(bool emptyIsNoop)
+void tst_QString::append_data(DataOptions options)
{
QTest::addColumn<QString>("s");
QTest::addColumn<CharStarContainer>("arg");
QTest::addColumn<QString>("expected");
+ const bool emptyIsNoop = options.testFlag(EmptyIsNoop);
+
const CharStarContainer nullC;
const CharStarContainer emptyC("");
const CharStarContainer aC("a");
const CharStarContainer bC("b");
//const CharStarContainer abC("ab");
+ const CharStarContainer yumlautC(options.testFlag(Latin1Encoded) ? "\xff" : "\xc3\xbf");
const QString null;
const QString empty("");
@@ -2716,6 +2863,9 @@ void tst_QString::append_data(bool emptyIsNoop)
//const QString b("b");
const QString ab("ab");
+ const QString yumlaut = QStringLiteral("\u00ff"); // LATIN LETTER SMALL Y WITH UMLAUT
+ const QString aYumlaut = QStringLiteral("a\u00ff");
+
QTest::newRow("null + null") << null << nullC << null;
QTest::newRow("null + empty") << null << emptyC << (emptyIsNoop ? null : empty);
QTest::newRow("null + a") << null << aC << a;
@@ -2725,6 +2875,64 @@ void tst_QString::append_data(bool emptyIsNoop)
QTest::newRow("a + null") << a << nullC << a;
QTest::newRow("a + empty") << a << emptyC << a;
QTest::newRow("a + b") << a << bC << ab;
+
+ QTest::newRow("null+yumlaut") << null << yumlautC << yumlaut;
+ QTest::newRow("empty+yumlaut") << empty << yumlautC << yumlaut;
+ QTest::newRow("a+yumlaut") << a << yumlautC << aYumlaut;
+
+ if (!options.testFlag(Latin1Encoded)) {
+ const auto smallTheta = QStringLiteral("\u03b8"); // GREEK LETTER SMALL THETA
+ const auto ssa = QStringLiteral("\u0937"); // DEVANAGARI LETTER SSA
+ const auto chakmaZero = QStringLiteral("\U00011136"); // CHAKMA DIGIT ZERO
+
+ const auto aSmallTheta = QStringLiteral("a\u03b8");
+ const auto aSsa = QStringLiteral("a\u0937");
+ const auto aChakmaZero = QStringLiteral("a\U00011136");
+
+ const auto thetaChakma = QStringLiteral("\u03b8\U00011136");
+ const auto chakmaTheta = QStringLiteral("\U00011136\u03b8");
+ const auto ssaTheta = QStringLiteral("\u0937\u03b8");
+ const auto thetaSsa = QStringLiteral("\u03b8\u0937");
+ const auto ssaChakma = QStringLiteral("\u0937\U00011136");
+ const auto chakmaSsa = QStringLiteral("\U00011136\u0937");
+ const auto thetaUmlaut = QStringLiteral("\u03b8\u00ff");
+ const auto umlautTheta = QStringLiteral("\u00ff\u03b8");
+ const auto ssaUmlaut = QStringLiteral("\u0937\u00ff");
+ const auto umlautSsa = QStringLiteral("\u00ff\u0937");
+ const auto chakmaUmlaut = QStringLiteral("\U00011136\u00ff");
+ const auto umlautChakma = QStringLiteral("\u00ff\U00011136");
+
+ const CharStarContainer smallThetaC("\xce\xb8"); // non-Latin1
+ const CharStarContainer ssaC("\xe0\xa4\xb7"); // Higher BMP
+ const CharStarContainer chakmaZeroC("\xf0\x91\x84\xb6"); // Non-BMP
+
+ QTest::newRow("null+smallTheta") << null << smallThetaC << smallTheta;
+ QTest::newRow("empty+smallTheta") << empty << smallThetaC << smallTheta;
+ QTest::newRow("a+smallTheta") << a << smallThetaC << aSmallTheta;
+
+ QTest::newRow("null+ssa") << null << ssaC << ssa;
+ QTest::newRow("empty+ssa") << empty << ssaC << ssa;
+ QTest::newRow("a+ssa") << a << ssaC << aSsa;
+
+ QTest::newRow("null+chakma") << null << chakmaZeroC << chakmaZero;
+ QTest::newRow("empty+chakma") << empty << chakmaZeroC << chakmaZero;
+ QTest::newRow("a+chakma") << a << chakmaZeroC << aChakmaZero;
+
+ QTest::newRow("smallTheta+chakma") << smallTheta << chakmaZeroC << thetaChakma;
+ QTest::newRow("chakma+smallTheta") << chakmaZero << smallThetaC << chakmaTheta;
+ QTest::newRow("smallTheta+ssa") << smallTheta << ssaC << thetaSsa;
+
+ QTest::newRow("ssa+smallTheta") << ssa << smallThetaC << ssaTheta;
+ QTest::newRow("ssa+chakma") << ssa << chakmaZeroC << ssaChakma;
+ QTest::newRow("chakma+ssa") << chakmaZero << ssaC << chakmaSsa;
+
+ QTest::newRow("smallTheta+yumlaut") << smallTheta << yumlautC << thetaUmlaut;
+ QTest::newRow("yumlaut+smallTheta") << yumlaut << smallThetaC << umlautTheta;
+ QTest::newRow("ssa+yumlaut") << ssa << yumlautC << ssaUmlaut;
+ QTest::newRow("yumlaut+ssa") << yumlaut << ssaC << umlautSsa;
+ QTest::newRow("chakma+yumlaut") << chakmaZero << yumlautC << chakmaUmlaut;
+ QTest::newRow("yumlaut+chakma") << yumlaut << chakmaZeroC << umlautChakma;
+ }
}
void tst_QString::append_special_cases()
@@ -2873,9 +3081,9 @@ void tst_QString::operator_pluseq_special_cases()
}
}
-void tst_QString::operator_pluseq_data(bool emptyIsNoop)
+void tst_QString::operator_pluseq_data(DataOptions options)
{
- append_data(emptyIsNoop);
+ append_data(options);
}
void tst_QString::operator_pluseq_bytearray_special_cases_data()
@@ -2940,17 +3148,20 @@ void tst_QString::swap()
QCOMPARE(s2,QLatin1String("s1"));
}
-void tst_QString::prepend_data(bool emptyIsNoop)
+void tst_QString::prepend_data(DataOptions options)
{
QTest::addColumn<QString>("s");
QTest::addColumn<CharStarContainer>("arg");
QTest::addColumn<QString>("expected");
+ const bool emptyIsNoop = options.testFlag(EmptyIsNoop);
+
const CharStarContainer nullC;
const CharStarContainer emptyC("");
const CharStarContainer aC("a");
const CharStarContainer bC("b");
const CharStarContainer baC("ba");
+ const CharStarContainer yumlautC(options.testFlag(Latin1Encoded) ? "\xff" : "\xc3\xbf");
const QString null;
const QString empty("");
@@ -2958,6 +3169,9 @@ void tst_QString::prepend_data(bool emptyIsNoop)
//const QString b("b");
const QString ba("ba");
+ const QString yumlaut = QStringLiteral("\u00ff"); // LATIN LETTER SMALL Y WITH UMLAUT
+ const QString yumlautA = QStringLiteral("\u00ffa");
+
QTest::newRow("null.prepend(null)") << null << nullC << null;
QTest::newRow("null.prepend(empty)") << null << emptyC << (emptyIsNoop ? null : empty);
QTest::newRow("null.prepend(a)") << null << aC << a;
@@ -2968,6 +3182,62 @@ void tst_QString::prepend_data(bool emptyIsNoop)
QTest::newRow("a.prepend(empty)") << a << emptyC << a;
QTest::newRow("a.prepend(b)") << a << bC << ba;
QTest::newRow("a.prepend(ba)") << a << baC << (ba + a);
+
+ QTest::newRow("null-prepend-yumlaut") << null << yumlautC << yumlaut;
+ QTest::newRow("empty-prepend-yumlaut") << empty << yumlautC << yumlaut;
+ QTest::newRow("a-prepend-yumlaut") << a << yumlautC << yumlautA;
+
+ if (!options.testFlag(Latin1Encoded)) {
+ const auto smallTheta = QStringLiteral("\u03b8"); // GREEK LETTER SMALL THETA
+ const auto ssa = QStringLiteral("\u0937"); // DEVANAGARI LETTER SSA
+ const auto chakmaZero = QStringLiteral("\U00011136"); // CHAKMA DIGIT ZERO
+
+ const auto smallThetaA = QStringLiteral("\u03b8a");
+ const auto ssaA = QStringLiteral("\u0937a");
+ const auto chakmaZeroA = QStringLiteral("\U00011136a");
+
+ const auto thetaChakma = QStringLiteral("\u03b8\U00011136");
+ const auto chakmaTheta = QStringLiteral("\U00011136\u03b8");
+ const auto ssaTheta = QStringLiteral("\u0937\u03b8");
+ const auto thetaSsa = QStringLiteral("\u03b8\u0937");
+ const auto ssaChakma = QStringLiteral("\u0937\U00011136");
+ const auto chakmaSsa = QStringLiteral("\U00011136\u0937");
+ const auto thetaUmlaut = QStringLiteral("\u03b8\u00ff");
+ const auto umlautTheta = QStringLiteral("\u00ff\u03b8");
+ const auto ssaUmlaut = QStringLiteral("\u0937\u00ff");
+ const auto umlautSsa = QStringLiteral("\u00ff\u0937");
+ const auto chakmaUmlaut = QStringLiteral("\U00011136\u00ff");
+ const auto umlautChakma = QStringLiteral("\u00ff\U00011136");
+
+ const CharStarContainer smallThetaC("\xce\xb8"); // non-Latin1
+ const CharStarContainer ssaC("\xe0\xa4\xb7"); // Higher BMP
+ const CharStarContainer chakmaZeroC("\xf0\x91\x84\xb6"); // Non-BMP
+
+ QTest::newRow("null-prepend-smallTheta") << null << smallThetaC << smallTheta;
+ QTest::newRow("empty-prepend-smallTheta") << empty << smallThetaC << smallTheta;
+ QTest::newRow("a-prepend-smallTheta") << a << smallThetaC << smallThetaA;
+
+ QTest::newRow("null-prepend-ssa") << null << ssaC << ssa;
+ QTest::newRow("empty-prepend-ssa") << empty << ssaC << ssa;
+ QTest::newRow("a-prepend-ssa") << a << ssaC << ssaA;
+
+ QTest::newRow("null-prepend-chakma") << null << chakmaZeroC << chakmaZero;
+ QTest::newRow("empty-prepend-chakma") << empty << chakmaZeroC << chakmaZero;
+ QTest::newRow("a-prepend-chakma") << a << chakmaZeroC << chakmaZeroA;
+
+ QTest::newRow("smallTheta-prepend-chakma") << smallTheta << chakmaZeroC << chakmaTheta;
+ QTest::newRow("chakma-prepend-smallTheta") << chakmaZero << smallThetaC << thetaChakma;
+ QTest::newRow("smallTheta-prepend-ssa") << smallTheta << ssaC << ssaTheta;
+ QTest::newRow("ssa-prepend-smallTheta") << ssa << smallThetaC << thetaSsa;
+ QTest::newRow("ssa-prepend-chakma") << ssa << chakmaZeroC << chakmaSsa;
+ QTest::newRow("chakma-prepend-ssa") << chakmaZero << ssaC << ssaChakma;
+ QTest::newRow("smallTheta-prepend-yumlaut") << smallTheta << yumlautC << umlautTheta;
+ QTest::newRow("yumlaut-prepend-smallTheta") << yumlaut << smallThetaC << thetaUmlaut;
+ QTest::newRow("ssa-prepend-yumlaut") << ssa << yumlautC << umlautSsa;
+ QTest::newRow("yumlaut-prepend-ssa") << yumlaut << ssaC << ssaUmlaut;
+ QTest::newRow("chakma-prepend-yumlaut") << chakmaZero << yumlautC << umlautChakma;
+ QTest::newRow("yumlaut-prepend-chakma") << yumlaut << chakmaZeroC << chakmaUmlaut;
+ }
}
void tst_QString::prepend_bytearray_special_cases_data()
diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
index e4f3759c6f..cf406293e4 100644
--- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -130,6 +130,7 @@ private Q_SLOTS:
void overload_QAnyStringView() { overload<QAnyStringView>(); }
void overload_QLatin1String() { overload<QLatin1String>(); }
void overload_QByteArray() { overload<QByteArray>(); }
+ void overload_QByteArrayView() { overload<QByteArrayView>(); }
void overload_const_char_star() { overload<const char*>(); }
void overload_const_char8_t_star() { IF_CHAR8T(overload<const char8_t*>()); }
void overload_const_char16_t_star() { overload<const char16_t*>(); }
@@ -160,7 +161,7 @@ private:
void compare_impl() const;
private Q_SLOTS:
- // test all combinations of {QChar, char16_t, QString, QStringView, QLatin1String, QByteArray, const char*}
+ // test all combinations of {QChar, char16_t, QString, QStringView, QLatin1String, QByteArray/View, const char*}
void compare_QChar_QChar_data() { compare_data(false); }
void compare_QChar_QChar() { compare_impl<QChar, QChar>(); }
void compare_QChar_char16_t_data() { compare_data(false); }
@@ -175,6 +176,8 @@ private Q_SLOTS:
void compare_QChar_QLatin1String() { compare_impl<QChar, QLatin1String>(); }
void compare_QChar_QByteArray_data() { compare_data(false); }
void compare_QChar_QByteArray() { compare_impl<QChar, QByteArray>(); }
+ void compare_QChar_QByteArrayView_data() { compare_data(false); }
+ void compare_QChar_QByteArrayView() { compare_impl<QChar, QByteArrayView>(); }
void compare_QChar_const_char_star_data() { compare_data(false); }
void compare_QChar_const_char_star() { compare_impl<QChar, const char *>(); }
@@ -192,6 +195,8 @@ private Q_SLOTS:
void compare_char16_t_QLatin1String() { compare_impl<char16_t, QLatin1String>(); }
void compare_char16_t_QByteArray_data() { compare_data(false); }
void compare_char16_t_QByteArray() { compare_impl<char16_t, QByteArray>(); }
+ void compare_char16_t_QByteArrayView_data() { compare_data(false); }
+ void compare_char16_t_QByteArrayView() { compare_impl<char16_t, QByteArrayView>(); }
//void compare_char16_t_const_char_star_data() { compare_data(false); }
//void compare_char16_t_const_char_star() { compare_impl<char16_t, const char *>(); }
@@ -209,6 +214,8 @@ private Q_SLOTS:
void compare_QString_QLatin1String() { compare_impl<QString, QLatin1String>(); }
void compare_QString_QByteArray_data() { compare_data(); }
void compare_QString_QByteArray() { compare_impl<QString, QByteArray>(); }
+ void compare_QString_QByteArrayView_data() { compare_data(); }
+ void compare_QString_QByteArrayView() { compare_impl<QString, QByteArrayView>(); }
void compare_QString_const_char_star_data() { compare_data(); }
void compare_QString_const_char_star() { compare_impl<QString, const char *>(); }
@@ -220,13 +227,17 @@ private Q_SLOTS:
void compare_QStringView_QString() { compare_impl<QStringView, QString>(); }
void compare_QStringView_QStringView_data() { compare_data(); }
void compare_QStringView_QStringView() { compare_impl<QStringView, QStringView>(); }
+#ifdef NOT_YET_IMPLEMENTED
void compare_QStringView_QUtf8StringView_data() { compare_data(); }
- void compare_QStringView_QUtf8StringView() { compare_impl<QStringView, QStringView>(); }
+ void compare_QStringView_QUtf8StringView() { compare_impl<QStringView, QUtf8StringView>(); }
+#endif
void compare_QStringView_QLatin1String_data() { compare_data(); }
void compare_QStringView_QLatin1String() { compare_impl<QStringView, QLatin1String>(); }
#ifdef NOT_YET_IMPLMENTED
void compare_QStringView_QByteArray_data() { compare_data(); }
void compare_QStringView_QByteArray() { compare_impl<QStringView, QByteArray>(); }
+ void compare_QStringView_QByteArrayView_data() { compare_data(); }
+ void compare_QStringView_QByteArrayView() { compare_impl<QStringView, QByteArrayView>(); }
void compare_QStringView_const_char_star_data() { compare_data(); }
void compare_QStringView_const_char_star() { compare_impl<QStringView, const char *>(); }
#endif
@@ -246,6 +257,8 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLMENTED
void compare_QUtf8StringView_QByteArray_data() { compare_data(); }
void compare_QUtf8StringView_QByteArray() { compare_impl<QUtf8StringView, QByteArray>(); }
+ void compare_QUtf8StringView_QByteArrayView_data() { compare_data(); }
+ void compare_QUtf8StringView_QByteArrayView() { compare_impl<QUtf8StringView, QByteArrayView>(); }
void compare_QUtf8StringView_const_char_star_data() { compare_data(); }
void compare_QUtf8StringView_const_char_star() { compare_impl<QUtf8StringView, const char *>(); }
#endif
@@ -264,6 +277,10 @@ private Q_SLOTS:
void compare_QLatin1String_QLatin1String() { compare_impl<QLatin1String, QLatin1String>(); }
void compare_QLatin1String_QByteArray_data() { compare_data(); }
void compare_QLatin1String_QByteArray() { compare_impl<QLatin1String, QByteArray>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_QLatin1String_QByteArrayView_data() { compare_data(); }
+ void compare_QLatin1String_QByteArrayView() { compare_impl<QLatin1String, QByteArrayView>(); }
+#endif
void compare_QLatin1String_const_char_star_data() { compare_data(); }
void compare_QLatin1String_const_char_star() { compare_impl<QLatin1String, const char *>(); }
@@ -283,9 +300,38 @@ private Q_SLOTS:
void compare_QByteArray_QLatin1String() { compare_impl<QByteArray, QLatin1String>(); }
void compare_QByteArray_QByteArray_data() { compare_data(); }
void compare_QByteArray_QByteArray() { compare_impl<QByteArray, QByteArray>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_QByteArray_QByteArrayView_data() { compare_data(); }
+ void compare_QByteArray_QByteArrayView() { compare_impl<QByteArray, QByteArrayView>(); }
+#endif
void compare_QByteArray_const_char_star_data() { compare_data(); }
void compare_QByteArray_const_char_star() { compare_impl<QByteArray, const char *>(); }
+ void compare_QByteArrayView_QChar_data() { compare_data(false); }
+ void compare_QByteArrayView_QChar() { compare_impl<QByteArrayView, QChar>(); }
+ void compare_QByteArrayView_char16_t_data() { compare_data(false); }
+ void compare_QByteArrayView_char16_t() { compare_impl<QByteArrayView, char16_t>(); }
+ void compare_QByteArrayView_QString_data() { compare_data(); }
+ void compare_QByteArrayView_QString() { compare_impl<QByteArrayView, QString>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void compare_QByteArrayView_QStringView_data() { compare_data(); }
+ void compare_QByteArrayView_QStringView() { compare_impl<QByteArrayView, QStringView>(); }
+#endif
+#ifdef AMBIGUOUS_CALL
+ void compare_QByteArrayView_QUtf8StringView_data() { compare_data(); }
+ void compare_QByteArrayView_QUtf8StringView() { compare_impl<QByteArrayView, QUtf8StringView>(); }
+ void compare_QByteArrayView_QLatin1String_data() { compare_data(); }
+ void compare_QByteArrayView_QLatin1String() { compare_impl<QByteArrayView, QLatin1String>(); }
+ void compare_QByteArrayView_QByteArray_data() { compare_data(); }
+ void compare_QByteArrayView_QByteArray() { compare_impl<QByteArrayView, QByteArray>(); }
+#endif
+ void compare_QByteArrayView_QByteArrayView_data() { compare_data(); }
+ void compare_QByteArrayView_QByteArrayView() { compare_impl<QByteArrayView, QByteArrayView>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_QByteArrayView_const_char_star_data() { compare_data(); }
+ void compare_QByteArrayView_const_char_star() { compare_impl<QByteArrayView, const char *>(); }
+#endif
+
void compare_const_char_star_QChar_data() { compare_data(false); }
void compare_const_char_star_QChar() { compare_impl<const char *, QChar>(); }
//void compare_const_char_star_char16_t_data() { compare_data(false); }
@@ -298,6 +344,10 @@ private Q_SLOTS:
void compare_const_char_star_QLatin1String() { compare_impl<const char *, QLatin1String>(); }
void compare_const_char_star_QByteArray_data() { compare_data(); }
void compare_const_char_star_QByteArray() { compare_impl<const char *, QByteArray>(); }
+#ifdef AMBIGUOUS_CALL
+ void compare_const_char_star_QByteArrayView_data() { compare_data(); }
+ void compare_const_char_star_QByteArrayView() { compare_impl<const char *, QByteArrayView>(); }
+#endif
//void compare_const_char_star_const_char_star_data() { compare_data(); }
//void compare_const_char_star_const_char_star() { compare_impl<const char *, const char *>(); }
@@ -321,6 +371,8 @@ private Q_SLOTS:
void member_compare_QChar_QLatin1String() { member_compare_impl<QChar, QLatin1String>(); }
void member_compare_QChar_QByteArray_data() { member_compare_data(false); }
void member_compare_QChar_QByteArray() { member_compare_impl<QChar, QByteArray>(); }
+ void member_compare_QChar_QByteArrayView_data() { member_compare_data(false); }
+ void member_compare_QChar_QByteArrayView() { member_compare_impl<QChar, QByteArrayView>(); }
void member_compare_QChar_const_char_star_data() { member_compare_data(false); }
void member_compare_QChar_const_char_star() { member_compare_impl<QChar, const char *>(); }
#endif
@@ -339,6 +391,10 @@ private Q_SLOTS:
void member_compare_QString_QLatin1String() { member_compare_impl<QString, QLatin1String>(); }
void member_compare_QString_QByteArray_data() { member_compare_data(); }
void member_compare_QString_QByteArray() { member_compare_impl<QString, QByteArray>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void member_compare_QString_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QString_QByteArrayView() { member_compare_impl<QString, QByteArrayView>(); }
+#endif
void member_compare_QString_const_char_star_data() { member_compare_data(); }
void member_compare_QString_const_char_star() { member_compare_impl<QString, const char *>(); }
@@ -355,6 +411,8 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QStringView_QByteArray_data() { member_compare_data(); }
void member_compare_QStringView_QByteArray() { member_compare_impl<QStringView, QByteArray>(); }
+ void member_compare_QStringView_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QStringView_QByteArrayView() { member_compare_impl<QStringView, QByteArrayView>(); }
void member_compare_QStringView_const_char_star_data() { member_compare_data(); }
void member_compare_QStringView_const_char_star() { member_compare_impl<QStringView, const char *>(); }
#endif
@@ -374,9 +432,13 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QLatin1String_QByteArray_data() { member_compare_data(); }
void member_compare_QLatin1String_QByteArray() { member_compare_impl<QLatin1String, QByteArray>(); }
+ void member_compare_QLatin1String_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QLatin1String_QByteArrayView() { member_compare_impl<QLatin1String, QByteArrayView>(); }
void member_compare_QLatin1String_const_char_star_data() { member_compare_data(); }
void member_compare_QLatin1String_const_char_star() { member_compare_impl<QLatin1String, const char *>(); }
+#endif
+#ifdef NOT_YET_IMPLEMENTED
void member_compare_QByteArray_QChar_data() { member_compare_data(false); }
void member_compare_QByteArray_QChar() { member_compare_impl<QByteArray, QChar>(); }
void member_compare_QByteArray_char16_t_data() { member_compare_data(false); }
@@ -388,9 +450,28 @@ private Q_SLOTS:
#endif
void member_compare_QByteArray_QByteArray_data() { member_compare_data(); }
void member_compare_QByteArray_QByteArray() { member_compare_impl<QByteArray, QByteArray>(); }
+ void member_compare_QByteArray_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QByteArray_QByteArrayView() { member_compare_impl<QByteArray, QByteArrayView>(); }
void member_compare_QByteArray_const_char_star_data() { member_compare_data(); }
void member_compare_QByteArray_const_char_star() { member_compare_impl<QByteArray, const char *>(); }
+#ifdef NOT_YET_IMPLEMENTED
+ void member_compare_QByteArrayView_QChar_data() { member_compare_data(false); }
+ void member_compare_QByteArrayView_QChar() { member_compare_impl<QByteArrayView, QChar>(); }
+ void member_compare_QByteArrayView_char16_t_data() { member_compare_data(false); }
+ void member_compare_QByteArrayView_char16_t() { member_compare_impl<QByteArrayView, char16_t>(); }
+ void member_compare_QByteArrayView_QString_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QString() { member_compare_impl<QByteArrayView, QString>(); }
+ void member_compare_QByteArrayView_QLatin1String_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QLatin1String() { member_compare_impl<QByteArrayView, QLatin1String>(); }
+#endif
+ void member_compare_QByteArrayView_QByteArray_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QByteArray() { member_compare_impl<QByteArrayView, QByteArray>(); }
+ void member_compare_QByteArrayView_QByteArrayView_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_QByteArrayView() { member_compare_impl<QByteArrayView, QByteArrayView>(); }
+ void member_compare_QByteArrayView_const_char_star_data() { member_compare_data(); }
+ void member_compare_QByteArrayView_const_char_star() { member_compare_impl<QByteArrayView, const char *>(); }
+
private:
void localeAwareCompare_data();
template<typename LHS, typename RHS>
@@ -667,6 +748,8 @@ private Q_SLOTS:
void sliced_QUtf8StringView() { sliced_impl<QUtf8StringView>(); }
void sliced_QByteArray_data() { sliced_data(); }
void sliced_QByteArray() { sliced_impl<QByteArray>(); }
+ void sliced_QByteArrayView_data() { sliced_data(); }
+ void sliced_QByteArrayView() { sliced_impl<QByteArrayView>(); }
void first_truncate_QString_data() { first_data(); }
void first_truncate_QString() { first_impl<QString>(); }
@@ -678,6 +761,8 @@ private Q_SLOTS:
void first_truncate_QUtf8StringView() { first_impl<QUtf8StringView>(); }
void first_truncate_QByteArray_data() { first_data(); }
void first_truncate_QByteArray() { first_impl<QByteArray>(); }
+ void first_truncate_QByteArrayView_data() { first_data(); }
+ void first_truncate_QByteArrayView() { first_impl<QByteArrayView>(); }
void last_QString_data() { last_data(); }
void last_QString() { last_impl<QString>(); }
@@ -689,6 +774,8 @@ private Q_SLOTS:
void last_QUtf8StringView() { last_impl<QUtf8StringView>(); }
void last_QByteArray_data() { last_data(); }
void last_QByteArray() { last_impl<QByteArray>(); }
+ void last_QByteArrayView_data() { last_data(); }
+ void last_QByteArrayView() { last_impl<QByteArrayView>(); }
void chop_QString_data() { chop_data(); }
void chop_QString() { chop_impl<QString>(); }
@@ -700,6 +787,8 @@ private Q_SLOTS:
void chop_QLatin1String() { chop_impl<QLatin1String>(); }
void chop_QByteArray_data() { chop_data(); }
void chop_QByteArray() { chop_impl<QByteArray>(); }
+ void chop_QByteArrayView_data() { chop_data(); }
+ void chop_QByteArrayView() { chop_impl<QByteArrayView>(); }
private:
void trimmed_data();
@@ -714,6 +803,8 @@ private Q_SLOTS:
void trim_trimmed_QLatin1String() { trimmed_impl<QLatin1String>(); }
void trim_trimmed_QByteArray_data() { trimmed_data(); }
void trim_trimmed_QByteArray() { trimmed_impl<QByteArray>(); }
+ void trim_trimmed_QByteArrayView_data() { trimmed_data(); }
+ void trim_trimmed_QByteArrayView() { trimmed_impl<QByteArrayView>(); }
private:
void toNumber_data();
@@ -726,19 +817,23 @@ private Q_SLOTS:
void toNumber_QString() { toNumber_impl<QString>(); }
void toNumber_QStringView_data() { toNumber_data(); }
void toNumber_QStringView() { toNumber_impl<QStringView>(); }
- void toNumber_QByteArray_data() { toNumber_data(); }
- void toNumber_QByteArray() { toNumber_impl<QByteArray>(); }
void toNumber_QLatin1String_data() { toNumber_data(); }
void toNumber_QLatin1String() { toNumber_impl<QLatin1String>(); }
+ void toNumber_QByteArray_data() { toNumber_data(); }
+ void toNumber_QByteArray() { toNumber_impl<QByteArray>(); }
+ void toNumber_QByteArrayView_data() { toNumber_data(); }
+ void toNumber_QByteArrayView() { toNumber_impl<QByteArrayView>(); }
void toNumberWithBases_QString_data() { toNumberWithBases_data(); }
void toNumberWithBases_QString() { toNumberWithBases_impl<QString>(); }
void toNumberWithBases_QStringView_data() { toNumberWithBases_data(); }
void toNumberWithBases_QStringView() { toNumberWithBases_impl<QStringView>(); }
- void toNumberWithBases_QByteArray_data() { toNumberWithBases_data(); }
- void toNumberWithBases_QByteArray() { toNumberWithBases_impl<QByteArray>(); }
void toNumberWithBases_QLatin1String_data() { toNumberWithBases_data(); }
void toNumberWithBases_QLatin1String() { toNumberWithBases_impl<QLatin1String>(); }
+ void toNumberWithBases_QByteArray_data() { toNumberWithBases_data(); }
+ void toNumberWithBases_QByteArray() { toNumberWithBases_impl<QByteArray>(); }
+ void toNumberWithBases_QByteArrayView_data() { toNumberWithBases_data(); }
+ void toNumberWithBases_QByteArrayView() { toNumberWithBases_impl<QByteArrayView>(); }
private:
void count_data();
@@ -1179,6 +1274,7 @@ MAKE(QString) { return sv.toString(); }
MAKE(QStringView) { return sv; }
MAKE(QLatin1String) { return l1; }
MAKE(QByteArray) { return u8; }
+MAKE(QByteArrayView) { return u8; }
MAKE(const char *) { return u8.data(); }
MAKE(const char16_t *) { return sv.utf16(); } // assumes `sv` doesn't represent a substring
MAKE(std::u16string) { return sv.toString().toStdU16String(); }
@@ -1193,6 +1289,7 @@ MAKE(QAnyStringViewUsingU16) { return {QAnyStringView{sv}}; }
template <typename> constexpr bool is_bytearray_like_v = false;
template <> constexpr bool is_bytearray_like_v<const char *> = true;
template <> constexpr bool is_bytearray_like_v<QByteArray> = true;
+template <> constexpr bool is_bytearray_like_v<QByteArrayView> = true;
template <typename LHS, typename RHS>
constexpr bool has_nothrow_member_compare_v = is_bytearray_like_v<LHS> == is_bytearray_like_v<RHS>;
diff --git a/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp
index 89e8ae89b1..58d2fab09f 100644
--- a/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp
+++ b/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp
@@ -174,12 +174,12 @@ void tst_QStringList::sort()
list4 << "alpha" << "beta" << "BETA" << "epsilon" << "Gamma" << "gAmma" << "gamma";
// with this list, case insensitive sorting can give more than one permutation for "equivalent"
// elements; so we check that the sort gave the formally correct result (list[i] <= list[i+1])
- for (int i = 0; i < list4.count() - 1; ++i)
+ for (int i = 0; i < list4.size() - 1; ++i)
QVERIFY2(QString::compare(list4.at(i), list4.at(i + 1), Qt::CaseInsensitive) <= 0, qPrintable(QString("index %1 failed").arg(i)));
// additional checks
QCOMPARE(list4.at(0), QString("alpha"));
QVERIFY(list4.indexOf("epsilon") > 0);
- QVERIFY(list4.indexOf("epsilon") < (list4.count() - 1));
+ QVERIFY(list4.indexOf("epsilon") < (list4.size() - 1));
}
void tst_QStringList::replaceInStrings()
diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
index ccb12488a7..9eab2f6966 100644
--- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
+++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp
@@ -854,7 +854,7 @@ void tst_QStringView::overloadResolution()
{
std::u16string string;
QStringViewOverloadResolution::test(string);
- QStringViewOverloadResolution::test(qAsConst(string));
+ QStringViewOverloadResolution::test(std::as_const(string));
QStringViewOverloadResolution::test(std::move(string));
}
}
diff --git a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
index 0b29740e53..ea7d2f6982 100644
--- a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
+++ b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
@@ -186,7 +186,7 @@ static void doTestData(const QString &testString, const QList<int> &expectedBrea
QVERIFY(boundaryFinder.boundaryReasons() == QTextBoundaryFinder::NotAtBoundary);
// test boundaryReasons()
- for (int i = 0; i <= testString.length(); ++i) {
+ for (int i = 0; i <= testString.size(); ++i) {
boundaryFinder.setPosition(i);
QCOMPARE(!!(boundaryFinder.boundaryReasons() & reasons), expectedBreakPositions.contains(i));
}
@@ -768,7 +768,7 @@ void tst_QTextBoundaryFinder::emptyText()
void tst_QTextBoundaryFinder::fastConstructor()
{
QString text("Hello World");
- QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text.constData(), text.length(), /*buffer*/0, /*buffer size*/0);
+ QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text.constData(), text.size(), /*buffer*/0, /*buffer size*/0);
QCOMPARE(finder.position(), 0);
QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::StartOfItem);
@@ -782,7 +782,7 @@ void tst_QTextBoundaryFinder::fastConstructor()
QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::StartOfItem);
finder.toNextBoundary();
- QCOMPARE(finder.position(), text.length());
+ QCOMPARE(finder.position(), text.size());
QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::EndOfItem);
finder.toNextBoundary();
diff --git a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
index 15aec7d63e..5232a62778 100644
--- a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
+++ b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp
@@ -47,7 +47,7 @@ static void verifyCharClassPattern(QString str, qulonglong pattern,
QCharAttributes cleared;
memset(&cleared, 0, sizeof(QCharAttributes));
QList<QCharAttributes> attributes(str.size() + 1, cleared);
- QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.count(),
+ QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.size(),
attributes.data(), type);
qulonglong bit = 1ull << str.size();
diff --git a/tests/auto/corelib/thread/CMakeLists.txt b/tests/auto/corelib/thread/CMakeLists.txt
index 356ae0346c..d51d108d83 100644
--- a/tests/auto/corelib/thread/CMakeLists.txt
+++ b/tests/auto/corelib/thread/CMakeLists.txt
@@ -5,7 +5,7 @@ if(QT_FEATURE_thread)
add_subdirectory(qatomicinteger)
add_subdirectory(qatomicpointer)
add_subdirectory(qresultstore)
- if(NOT INTEGRITY)
+ if(QT_FEATURE_concurrent AND NOT INTEGRITY)
add_subdirectory(qfuture)
endif()
add_subdirectory(qfuturesynchronizer)
diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
index 638dc380f7..21408095de 100644
--- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
+++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
@@ -221,6 +221,7 @@ private slots:
void whenAnyDifferentTypesWithFailed();
void continuationsDontLeak();
+ void cancelAfterFinishWithContinuations();
void unwrap();
@@ -1076,13 +1077,13 @@ void tst_QFuture::multipleResults()
QList<int> fasit = QList<int>() << 1 << 2 << 3 << 4;
{
QList<int> results;
- for (int result : qAsConst(f))
+ for (int result : std::as_const(f))
results.append(result);
QCOMPARE(results, fasit);
}
{
QList<int> results;
- for (int result : qAsConst(copy))
+ for (int result : std::as_const(copy))
results.append(result);
QCOMPARE(results, fasit);
}
@@ -2240,6 +2241,26 @@ void tst_QFuture::then()
QVERIFY(threadId1 != QThread::currentThreadId());
QVERIFY(threadId2 != QThread::currentThreadId());
}
+
+ // QTBUG-106083 & QTBUG-105182
+ {
+ QThread thread;
+ thread.start();
+
+ QObject context;
+ context.moveToThread(&thread);
+
+ auto future = QtConcurrent::run([] {
+ return 42;
+ }).then([] (int result) {
+ return result + 1;
+ }).then(&context, [] (int result) {
+ return result + 1;
+ });
+ QCOMPARE(future.result(), 44);
+ thread.quit();
+ thread.wait();
+ }
}
template<class Type, class Callable>
@@ -3116,6 +3137,66 @@ void tst_QFuture::cancelContinuations()
QCOMPARE(checkpoint, 3);
}
#endif // QT_NO_EXCEPTIONS
+
+ // Check notifications from QFutureWatcher
+ {
+ QPromise<void> p;
+ auto f = p.future();
+
+ auto f1 = f.then([] {});
+ auto f2 = f1.then([] {});
+
+ QFutureWatcher<void> watcher1, watcher2;
+ int state = 0;
+ QObject::connect(&watcher1, &QFutureWatcher<void>::started, [&] {
+ QCOMPARE(state, 0);
+ ++state;
+ });
+ QObject::connect(&watcher1, &QFutureWatcher<void>::canceled, [&] {
+ QCOMPARE(state, 1);
+ ++state;
+ });
+ QObject::connect(&watcher1, &QFutureWatcher<void>::finished, [&] {
+ QCOMPARE(state, 2);
+ ++state;
+ });
+ QObject::connect(&watcher2, &QFutureWatcher<void>::started, [&] {
+ QCOMPARE(state, 3);
+ ++state;
+ });
+ QObject::connect(&watcher2, &QFutureWatcher<void>::canceled, [&] {
+ QCOMPARE(state, 4);
+ ++state;
+ });
+ QObject::connect(&watcher2, &QFutureWatcher<int>::finished, [&] {
+ QCOMPARE(state, 5);
+ ++state;
+ });
+
+ watcher1.setFuture(f1);
+ watcher2.setFuture(f2);
+
+ p.start();
+ f.cancel();
+ p.finish();
+
+ qApp->processEvents();
+
+ QCOMPARE(state, 6);
+ QVERIFY(watcher1.isFinished());
+ QVERIFY(watcher1.isCanceled());
+ QVERIFY(watcher2.isFinished());
+ QVERIFY(watcher2.isCanceled());
+ }
+
+ // Cancel continuations with context (QTBUG-108790)
+ {
+ // This test should pass with ASan
+ auto future = QtConcurrent::run([] {});
+ future.then(this, [] {});
+ future.waitForFinished();
+ future.cancel();
+ }
}
void tst_QFuture::continuationsWithContext()
@@ -4641,6 +4722,31 @@ void tst_QFuture::continuationsDontLeak()
QCOMPARE(InstanceCounter::count, 0);
}
+// This test checks that we do not get use-after-free
+void tst_QFuture::cancelAfterFinishWithContinuations()
+{
+ QFuture<void> future;
+ bool continuationIsRun = false;
+ bool cancelCalled = false;
+ {
+ QPromise<void> promise;
+ future = promise.future();
+
+ future.then([&continuationIsRun]() {
+ continuationIsRun = true;
+ }).onCanceled([&cancelCalled]() {
+ cancelCalled = true;
+ });
+
+ promise.start();
+ promise.finish();
+ }
+
+ QVERIFY(continuationIsRun);
+ future.cancel();
+ QVERIFY(!cancelCalled);
+}
+
void tst_QFuture::unwrap()
{
// The nested future succeeds
diff --git a/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp b/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
index 5f1e26ad02..fe84ec1ae4 100644
--- a/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
+++ b/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp
@@ -82,7 +82,7 @@ void tst_QFutureSynchronizer::futures()
synchronizer.addFuture(future);
}
- QCOMPARE(futures.count(), synchronizer.futures().count());
+ QCOMPARE(futures.size(), synchronizer.futures().size());
}
void tst_QFutureSynchronizer::setFuture()
diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
index e9eb7b24b0..645e22602e 100644
--- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -238,8 +238,8 @@ void tst_QFutureWatcher::cancelAndFinish()
fi.cancelAndFinish();
// The signals should be emitted only once
- QTRY_COMPARE(canceledSpy.count(), 1);
- QTRY_COMPARE(finishedSpy.count(), 1);
+ QTRY_COMPARE(canceledSpy.size(), 1);
+ QTRY_COMPARE(finishedSpy.size(), 1);
}
class IntTask : public RunFunctionTaskBase<int>
@@ -349,21 +349,21 @@ void tst_QFutureWatcher::futureSignals()
const int progress = 1;
a.setProgressValue(progress);
- QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_COMPARE(progressSpy.size(), 2);
QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0);
QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1);
const int result = 10;
a.reportResult(&result);
QVERIFY(resultReadySpy.wait());
- QCOMPARE(resultReadySpy.count(), 1);
+ QCOMPARE(resultReadySpy.size(), 1);
a.reportFinished(&result);
- QTRY_COMPARE(resultReadySpy.count(), 2);
+ QTRY_COMPARE(resultReadySpy.size(), 2);
QCOMPARE(resultReadySpy.takeFirst().at(0).toInt(), 0); // check the index
QCOMPARE(resultReadySpy.takeFirst().at(0).toInt(), 1);
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(finishedSpy.size(), 1);
}
}
@@ -402,10 +402,10 @@ void tst_QFutureWatcher::watchFinishedFuture()
watcher.setFuture(f);
QVERIFY(finishedSpy.wait());
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(resultReadySpy.count(), 1);
- QCOMPARE(canceledSpy.count(), 0);
+ QCOMPARE(startedSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(resultReadySpy.size(), 1);
+ QCOMPARE(canceledSpy.size(), 0);
}
void tst_QFutureWatcher::watchCanceledFuture()
@@ -436,10 +436,10 @@ void tst_QFutureWatcher::watchCanceledFuture()
watcher.setFuture(f);
QVERIFY(finishedSpy.wait());
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(resultReadySpy.count(), 0);
- QCOMPARE(canceledSpy.count(), 1);
+ QCOMPARE(startedSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(resultReadySpy.size(), 0);
+ QCOMPARE(canceledSpy.size(), 1);
}
void tst_QFutureWatcher::disconnectRunningFuture()
@@ -462,17 +462,17 @@ void tst_QFutureWatcher::disconnectRunningFuture()
const int result = 10;
a.reportResult(&result);
QVERIFY(resultReadySpy.wait());
- QCOMPARE(resultReadySpy.count(), 1);
+ QCOMPARE(resultReadySpy.size(), 1);
delete watcher;
a.reportResult(&result);
QTest::qWait(10);
- QCOMPARE(resultReadySpy.count(), 1);
+ QCOMPARE(resultReadySpy.size(), 1);
a.reportFinished(&result);
QTest::qWait(10);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
}
const int maxProgress = 100000;
@@ -672,14 +672,14 @@ void tst_QFutureWatcher::changeFuture()
watcher.setFuture(b); // But oh no! we're switching to another future
QTest::qWait(10); // before the event gets delivered.
- QCOMPARE(resultReadySpy.count(), 0);
+ QCOMPARE(resultReadySpy.size(), 0);
watcher.setFuture(a);
watcher.setFuture(b);
watcher.setFuture(a); // setting it back gets us one event, not two.
QVERIFY(resultReadySpy.wait());
- QCOMPARE(resultReadySpy.count(), 1);
+ QCOMPARE(resultReadySpy.size(), 1);
}
// Test that events aren't delivered from canceled futures
@@ -707,7 +707,7 @@ void tst_QFutureWatcher::cancelEvents()
QVERIFY(finishedSpy.wait());
- QCOMPARE(resultReadySpy.count(), 0);
+ QCOMPARE(resultReadySpy.size(), 0);
}
#if QT_DEPRECATED_SINCE(6, 0)
@@ -734,14 +734,14 @@ void tst_QFutureWatcher::pauseEvents()
watcher.setFuture(iface.future());
watcher.pause();
- QTRY_COMPARE(pauseSpy.count(), 1);
+ QTRY_COMPARE(pauseSpy.size(), 1);
int value = 0;
iface.reportFinished(&value);
// A result is reported, although the watcher is paused.
// The corresponding event should be also reported.
- QTRY_COMPARE(resultReadySpy.count(), 1);
+ QTRY_COMPARE(resultReadySpy.size(), 1);
watcher.resume();
}
@@ -769,7 +769,7 @@ void tst_QFutureWatcher::pauseEvents()
a.resume(); // should give us no results.
QTest::qWait(10);
- QCOMPARE(resultReadySpy.count(), 0);
+ QCOMPARE(resultReadySpy.size(), 0);
}
}
@@ -789,23 +789,23 @@ void tst_QFutureWatcher::pausedSuspendedOrder()
bool pausedBeforeSuspended = false;
bool notSuspendedBeforePaused = false;
connect(&watcher, &QFutureWatcher<void>::paused,
- [&] { notSuspendedBeforePaused = (suspendedSpy.count() == 0); });
+ [&] { notSuspendedBeforePaused = (suspendedSpy.size() == 0); });
connect(&watcher, &QFutureWatcher<void>::suspended,
- [&] { pausedBeforeSuspended = (pausedSpy.count() == 1); });
+ [&] { pausedBeforeSuspended = (pausedSpy.size() == 1); });
watcher.setFuture(iface.future());
iface.reportSuspended();
// Make sure reportPaused() is ignored if the state is not paused
pausedSpy.wait(100);
- QCOMPARE(pausedSpy.count(), 0);
- QCOMPARE(suspendedSpy.count(), 0);
+ QCOMPARE(pausedSpy.size(), 0);
+ QCOMPARE(suspendedSpy.size(), 0);
iface.setPaused(true);
iface.reportSuspended();
- QTRY_COMPARE(suspendedSpy.count(), 1);
- QCOMPARE(pausedSpy.count(), 1);
+ QTRY_COMPARE(suspendedSpy.size(), 1);
+ QCOMPARE(pausedSpy.size(), 1);
QVERIFY(notSuspendedBeforePaused);
QVERIFY(pausedBeforeSuspended);
@@ -836,14 +836,14 @@ void tst_QFutureWatcher::suspendEvents()
watcher.setFuture(iface.future());
watcher.suspend();
- QTRY_COMPARE(suspendingSpy.count(), 1);
+ QTRY_COMPARE(suspendingSpy.size(), 1);
int value = 0;
iface.reportFinished(&value);
// A result is reported, although the watcher is paused.
// The corresponding event should be also reported.
- QTRY_COMPARE(resultReadySpy.count(), 1);
+ QTRY_COMPARE(resultReadySpy.size(), 1);
watcher.resume();
}
@@ -872,7 +872,7 @@ void tst_QFutureWatcher::suspendEvents()
a.resume(); // should give us no results.
QTest::qWait(10);
- QCOMPARE(resultReadySpy.count(), 0);
+ QCOMPARE(resultReadySpy.size(), 0);
}
}
@@ -910,29 +910,29 @@ QT_WARNING_POP
watcher.suspend();
watcher.suspend();
- QTRY_COMPARE(suspendedSpy.count(), 1); // suspended() should be emitted only once
- QCOMPARE(suspendingSpy.count(), 2); // suspending() is emitted as many times as requested
+ QTRY_COMPARE(suspendedSpy.size(), 1); // suspended() should be emitted only once
+ QCOMPARE(suspendingSpy.size(), 2); // suspending() is emitted as many times as requested
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(pausedSpy.count(), 2); // paused() is emitted as many times as requested
+ QCOMPARE(pausedSpy.size(), 2); // paused() is emitted as many times as requested
#endif
// Make sure QFutureWatcher::resultReadyAt() is emitted only for already started threads.
- const auto resultReadyAfterPaused = resultReadySpy.count();
+ const auto resultReadyAfterPaused = resultReadySpy.size();
QCOMPARE(resultReadyAfterPaused, count);
// Make sure no more results are reported before resuming.
QThread::msleep(200);
- QCOMPARE(resultReadyAfterPaused, resultReadySpy.count());
+ QCOMPARE(resultReadyAfterPaused, resultReadySpy.size());
resultReadySpy.clear();
watcher.resume();
- QTRY_COMPARE(finishedSpy.count(), 1);
+ QTRY_COMPARE(finishedSpy.size(), 1);
// Make sure that no more suspended() signals have been emitted.
- QCOMPARE(suspendedSpy.count(), 1);
+ QCOMPARE(suspendedSpy.size(), 1);
// Make sure the rest of results were reported after resume.
- QCOMPARE(resultReadySpy.count(), numValues - resultReadyAfterPaused);
+ QCOMPARE(resultReadySpy.size(), numValues - resultReadyAfterPaused);
}
void tst_QFutureWatcher::suspendedEventsOrder()
@@ -951,23 +951,23 @@ void tst_QFutureWatcher::suspendedEventsOrder()
bool suspendingBeforeSuspended = false;
bool notSuspendedBeforeSuspending = false;
connect(&watcher, &QFutureWatcher<void>::suspending,
- [&] { notSuspendedBeforeSuspending = (suspendedSpy.count() == 0); });
+ [&] { notSuspendedBeforeSuspending = (suspendedSpy.size() == 0); });
connect(&watcher, &QFutureWatcher<void>::suspended,
- [&] { suspendingBeforeSuspended = (suspendingSpy.count() == 1); });
+ [&] { suspendingBeforeSuspended = (suspendingSpy.size() == 1); });
watcher.setFuture(iface.future());
iface.reportSuspended();
// Make sure reportPaused() is ignored if the state is not paused
suspendingSpy.wait(100);
- QCOMPARE(suspendingSpy.count(), 0);
- QCOMPARE(suspendedSpy.count(), 0);
+ QCOMPARE(suspendingSpy.size(), 0);
+ QCOMPARE(suspendedSpy.size(), 0);
iface.setSuspended(true);
iface.reportSuspended();
- QTRY_COMPARE(suspendedSpy.count(), 1);
- QCOMPARE(suspendingSpy.count(), 1);
+ QTRY_COMPARE(suspendedSpy.size(), 1);
+ QCOMPARE(suspendingSpy.size(), 1);
QVERIFY(notSuspendedBeforeSuspending);
QVERIFY(suspendingBeforeSuspended);
@@ -997,7 +997,7 @@ void tst_QFutureWatcher::throttling()
QVERIFY(iface.isThrottled());
- QTRY_COMPARE(resultSpy.count(), resultCount); // Process the results
+ QTRY_COMPARE(resultSpy.size(), resultCount); // Process the results
QVERIFY(!iface.isThrottled());
diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
index e78ebbed2e..e4f98608ae 100644
--- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
@@ -67,9 +67,7 @@ enum {
waitTime = 100
};
-#if __has_include(<chrono>)
static constexpr std::chrono::milliseconds waitTimeAsDuration(waitTime);
-#endif
void tst_QMutex::convertToMilliseconds_data()
{
@@ -78,10 +76,6 @@ void tst_QMutex::convertToMilliseconds_data()
QTest::addColumn<qint64>("intValue");
QTest::addColumn<qint64>("expected");
-#if !__has_include(<chrono>)
- QSKIP("This test requires <chrono>");
-#endif
-
auto add = [](TimeUnit unit, double d, long long i, qint64 expected) {
const QScopedArrayPointer<char> enumName(QTest::toString(unit));
QTest::addRow("%s:%f:%lld", enumName.data(), d, i)
@@ -134,9 +128,6 @@ void tst_QMutex::convertToMilliseconds_data()
void tst_QMutex::convertToMilliseconds()
{
-#if !__has_include(<chrono>)
- QSKIP("This test requires <chrono>");
-#else
QFETCH(TimeUnit, unit);
QFETCH(double, doubleValue);
QFETCH(qint64, intValue);
@@ -174,7 +165,6 @@ void tst_QMutex::convertToMilliseconds()
#undef DO
#undef CASE
}
-#endif
}
void tst_QMutex::tryLock_non_recursive()
@@ -302,10 +292,8 @@ void tst_QMutex::tryLock_non_recursive()
thread.wait();
}
-void tst_QMutex::try_lock_for_non_recursive() {
-#if !__has_include(<chrono>)
- QSKIP("This test requires <chrono>");
-#else
+void tst_QMutex::try_lock_for_non_recursive()
+{
class Thread : public QThread
{
public:
@@ -427,14 +415,10 @@ void tst_QMutex::try_lock_for_non_recursive() {
testsTurn.acquire();
threadsTurn.release();
thread.wait();
-#endif
}
void tst_QMutex::try_lock_until_non_recursive()
{
-#if !__has_include(<chrono>)
- QSKIP("This test requires <chrono>");
-#else
class Thread : public QThread
{
public:
@@ -556,7 +540,6 @@ void tst_QMutex::try_lock_until_non_recursive()
testsTurn.acquire();
threadsTurn.release();
thread.wait();
-#endif
}
void tst_QMutex::tryLock_recursive()
@@ -685,9 +668,6 @@ void tst_QMutex::tryLock_recursive()
void tst_QMutex::try_lock_for_recursive()
{
-#if !__has_include(<chrono>)
- QSKIP("This test requires <chrono>");
-#else
class Thread : public QThread
{
public:
@@ -808,14 +788,10 @@ void tst_QMutex::try_lock_for_recursive()
testsTurn.acquire();
threadsTurn.release();
thread.wait();
-#endif
}
void tst_QMutex::try_lock_until_recursive()
{
-#if !__has_include(<chrono>)
- QSKIP("This test requires <chrono>");
-#else
class Thread : public QThread
{
public:
@@ -937,7 +913,6 @@ void tst_QMutex::try_lock_until_recursive()
testsTurn.acquire();
threadsTurn.release();
thread.wait();
-#endif
}
class mutex_Thread : public QThread
@@ -1063,8 +1038,8 @@ void tst_QMutex::lock_unlock_locked_tryLock()
}
}
-enum { one_minute = 6 * 1000, //not really one minute, but else it is too long.
- threadCount = 10 };
+constexpr int one_minute = 6 * 1000; // not really one minute, but else it is too long.
+constexpr int threadCount = 10;
class StressTestThread : public QThread
{
diff --git a/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp b/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp
index e87ba82309..a1c7da280e 100644
--- a/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp
+++ b/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp
@@ -53,9 +53,9 @@ void snippet_QPromise::multithreadExample()
QFuture<int> future = sharedPromise->future();
// ...
-//! [multithread_init]
sharedPromise->start();
+//! [multithread_init]
//! [multithread_main]
// here, QPromise is shared between threads via a smart pointer
@@ -88,7 +88,9 @@ void snippet_QPromise::multithreadExample()
for (auto& t : threads)
t->wait();
+//! [multithread_cleanup]
sharedPromise->finish();
+//! [multithread_cleanup]
#endif
}
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp
index b17054c240..50870244b5 100644
--- a/tests/auto/corelib/time/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp
@@ -4,7 +4,9 @@
#include <private/qglobal_p.h> // for the icu feature test
#include <QTest>
+#if QT_CONFIG(timezone)
#include <QTimeZone>
+#endif
#include <qdatetime.h>
#include <qlocale.h>
#include <QMap>
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index c12ae8b632..6204f3b34f 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -2506,11 +2506,13 @@ void tst_QDateTime::fromStringDateFormat_data()
// 24:00:00 Should be next day according to ISO 8601 section 4.2.3.
QTest::newRow("ISO 24:00") << QString::fromLatin1("2012-06-04T24:00:00")
<< Qt::ISODate << QDateTime(QDate(2012, 6, 5), QTime(0, 0), Qt::LocalTime);
+#if QT_CONFIG(timezone)
QTest::newRow("ISO 24:00 in DST") // Only special if TZ=America/Sao_Paulo
<< QString::fromLatin1("2008-10-18T24:00") << Qt::ISODate
<< QDateTime(QDate(2008, 10, 19),
QTime(QTimeZone::systemTimeZoneId() == "America/Sao_Paulo" ? 1 : 0, 0),
Qt::LocalTime);
+#endif
QTest::newRow("ISO 24:00 end of month") << QString::fromLatin1("2012-06-30T24:00:00")
<< Qt::ISODate << QDateTime(QDate(2012, 7, 1), QTime(0, 0), Qt::LocalTime);
QTest::newRow("ISO 24:00 end of year") << QString::fromLatin1("2012-12-31T24:00:00")
diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
index b98fc0dbc8..788d5441a3 100644
--- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
@@ -220,8 +220,8 @@ void tst_QTimeZone::createTest()
tran.daylightTimeOffset = 3600;
expected << tran;
QTimeZone::OffsetDataList result = tz.transitions(janPrev, jan);
- QCOMPARE(result.count(), expected.count());
- for (int i = 0; i < expected.count(); ++i) {
+ QCOMPARE(result.size(), expected.size());
+ for (int i = 0; i < expected.size(); ++i) {
QCOMPARE(result.at(i).atUtc, expected.at(i).atUtc);
QCOMPARE(result.at(i).offsetFromUtc, expected.at(i).offsetFromUtc);
QCOMPARE(result.at(i).standardTimeOffset, expected.at(i).standardTimeOffset);
@@ -559,7 +559,7 @@ void tst_QTimeZone::specificTransition()
QSKIP("Missing time-zone data");
QTimeZone::OffsetDataList transits =
timeZone.transitions(start.startOfDay(timeZone), stop.endOfDay(timeZone));
- QCOMPARE(transits.length(), count);
+ QCOMPARE(transits.size(), count);
if (count) {
const QTimeZone::OffsetData &transition = transits.at(0);
QCOMPARE(transition.offsetFromUtc, offset);
@@ -1538,8 +1538,8 @@ void tst_QTimeZone::testCetPrivate(const QTimeZonePrivate &tzp)
tran.daylightTimeOffset = 0;
expected << tran;
QTimeZonePrivate::DataList result = tzp.transitions(prev, std);
- QCOMPARE(result.count(), expected.count());
- for (int i = 0; i < expected.count(); ++i) {
+ QCOMPARE(result.size(), expected.size());
+ for (int i = 0; i < expected.size(); ++i) {
QCOMPARE(QDateTime::fromMSecsSinceEpoch(result.at(i).atMSecsSinceEpoch,
Qt::OffsetFromUTC, 3600),
QDateTime::fromMSecsSinceEpoch(expected.at(i).atMSecsSinceEpoch,
diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index 4b2d3b56b2..97f0c142f2 100644
--- a/tests/auto/corelib/tools/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -684,7 +684,7 @@ QT_WARNING_POP
list.insert(0, "atzero");
QCOMPARE(list.at(0), QString("atzero"));
- int listCount = list.count();
+ int listCount = list.size();
list.insert(listCount, "atcount");
QCOMPARE(list.at(listCount), QString("atcount"));
}
@@ -2018,8 +2018,8 @@ void tst_Collections::qstring()
s = "ascii";
s += QChar((uchar) 0xb0);
QVERIFY(s.toUtf8() != s.toLatin1());
- QCOMPARE(s[s.length()-1].unicode(), (ushort)0xb0);
- QCOMPARE(s.left(s.length()-1), QLatin1String("ascii"));
+ QCOMPARE(s[s.size()-1].unicode(), (ushort)0xb0);
+ QCOMPARE(s.left(s.size()-1), QLatin1String("ascii"));
QVERIFY(s == QString::fromUtf8(s.toUtf8().constData()));
@@ -2071,7 +2071,7 @@ void tst_Collections::qstring()
QString str = "Hello";
- QString cstr = QString::fromRawData(str.unicode(), str.length());
+ QString cstr = QString::fromRawData(str.unicode(), str.size());
QCOMPARE(str, QLatin1String("Hello"));
QCOMPARE(cstr, QLatin1String("Hello"));
cstr.clear();
@@ -2693,7 +2693,7 @@ void tst_Collections::vector_stl()
QFETCH(QStringList, elements);
QList<QString> vector;
- for (int i = 0; i < elements.count(); ++i)
+ for (int i = 0; i < elements.size(); ++i)
vector << elements.at(i);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
@@ -2728,7 +2728,7 @@ void tst_Collections::list_stl()
QFETCH(QStringList, elements);
QList<QString> list;
- for (int i = 0; i < elements.count(); ++i)
+ for (int i = 0; i < elements.size(); ++i)
list << elements.at(i);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
@@ -2821,7 +2821,7 @@ void instantiateContainer()
container.clear();
container.contains(value);
- container.count();
+ container.size();
container.empty();
container.isEmpty();
container.size();
@@ -3246,7 +3246,7 @@ template<template<class> class C> void QTBUG13079_collectionInsideCollectionImpl
QCOMPARE(nodeList.first().s, QString::fromLatin1("child"));
nodeList = nodeList.first().children;
- QCOMPARE(nodeList.count(), 0);
+ QCOMPARE(nodeList.size(), 0);
nodeList << QTBUG13079_Node<C>();
}
@@ -3271,7 +3271,7 @@ template<template<class, class> class C> void QTBUG13079_collectionInsideCollect
QCOMPARE(nodeMap[12].s, QString::fromLatin1("child"));
nodeMap = nodeMap[12].children;
- QCOMPARE(nodeMap.count(), 0);
+ QCOMPARE(nodeMap.size(), 0);
nodeMap[42] = QTBUG13079_NodeAssoc<C>();
}
@@ -3338,7 +3338,7 @@ void tst_Collections::QTBUG13079_collectionInsideCollection()
QSet<QTBUG13079_Node<QSet> > nodeSet;
nodeSet << QTBUG13079_Node<QSet>();
nodeSet = nodeSet.begin()->children;
- QCOMPARE(nodeSet.count(), 0);
+ QCOMPARE(nodeSet.size(), 0);
}
QTBUG13079_collectionInsideCollectionAssocImpl<QMap>();
@@ -3360,7 +3360,7 @@ template<class Container> void foreach_test_arrays(const Container &container)
set << val;
i++;
}
- QCOMPARE(set.count(), container.count());
+ QCOMPARE(set.size(), container.size());
//modify the container while iterating.
Container c2 = container;
@@ -3397,9 +3397,9 @@ void tst_Collections::foreach_2()
varl2 << i;
varl3 << i;
}
- QCOMPARE(varl1.count(), intlist.count());
- QCOMPARE(varl2.count(), intlist.count());
- QCOMPARE(varl3.count(), intlist.count());
+ QCOMPARE(varl1.size(), intlist.size());
+ QCOMPARE(varl2.size(), intlist.size());
+ QCOMPARE(varl3.size(), intlist.size());
QVarLengthArray<QString> varl4;
QVarLengthArray<QString, 3> varl5;
@@ -3409,9 +3409,9 @@ void tst_Collections::foreach_2()
varl5 << str;
varl6 << str;
}
- QCOMPARE(varl4.count(), strlist.count());
- QCOMPARE(varl5.count(), strlist.count());
- QCOMPARE(varl6.count(), strlist.count());
+ QCOMPARE(varl4.size(), strlist.size());
+ QCOMPARE(varl5.size(), strlist.size());
+ QCOMPARE(varl6.size(), strlist.size());
}
struct IntOrString
@@ -3441,8 +3441,8 @@ template<class Container> void insert_remove_loop_impl()
t.insert(t.begin() + 2, T(IntOrString(7)));
t.insert(t.begin() + 5, 3, T(IntOrString(8)));
int expect1[] = { 4 , 1 , 7, 5 , 5 , 8, 8, 8, 6, 5, 2 , 3 };
- QCOMPARE(size_t(t.count()), sizeof(expect1)/sizeof(int));
- for (int i = 0; i < t.count(); i++) {
+ QCOMPARE(size_t(t.size()), sizeof(expect1)/sizeof(int));
+ for (int i = 0; i < t.size(); i++) {
QCOMPARE(t[i], T(IntOrString(expect1[i])));
}
@@ -3456,8 +3456,8 @@ template<class Container> void insert_remove_loop_impl()
t.remove(7);
t.remove(2, 3);
int expect2[] = { 4 , 1 , 9, 8, 6, 5, 2 , 3 };
- QCOMPARE(size_t(t.count()), sizeof(expect2)/sizeof(int));
- for (int i = 0; i < t.count(); i++) {
+ QCOMPARE(size_t(t.size()), sizeof(expect2)/sizeof(int));
+ for (int i = 0; i < t.size(); i++) {
QCOMPARE(t[i], T(IntOrString(expect2[i])));
}
@@ -3469,16 +3469,16 @@ template<class Container> void insert_remove_loop_impl()
}
int expect3[] = { 1 , 9, 5, 3 };
- QCOMPARE(size_t(t.count()), sizeof(expect3)/sizeof(int));
- for (int i = 0; i < t.count(); i++) {
+ QCOMPARE(size_t(t.size()), sizeof(expect3)/sizeof(int));
+ for (int i = 0; i < t.size(); i++) {
QCOMPARE(t[i], T(IntOrString(expect3[i])));
}
t.erase(t.begin() + 1, t.end() - 1);
int expect4[] = { 1 , 3 };
- QCOMPARE(size_t(t.count()), sizeof(expect4)/sizeof(int));
- for (int i = 0; i < t.count(); i++) {
+ QCOMPARE(size_t(t.size()), sizeof(expect4)/sizeof(int));
+ for (int i = 0; i < t.size(); i++) {
QCOMPARE(t[i], T(IntOrString(expect4[i])));
}
@@ -3495,8 +3495,8 @@ template<class Container> void insert_remove_loop_impl()
int expect5[] = { 1, 1, 2, 3*3, 3, 3*3+1, 10, 11*11, 11, 11*11+1, 12 , 13*13, 13, 13*13+1, 14,
15*15, 15, 15*15+1, 16 , 17*17, 17, 17*17+1 ,18 , 19*19, 19, 19*19+1, 20, 21*21, 21, 21*21+1 };
- QCOMPARE(size_t(t.count()), sizeof(expect5)/sizeof(int));
- for (int i = 0; i < t.count(); i++) {
+ QCOMPARE(size_t(t.size()), sizeof(expect5)/sizeof(int));
+ for (int i = 0; i < t.size(); i++) {
QCOMPARE(t[i], T(IntOrString(expect5[i])));
}
@@ -3506,8 +3506,8 @@ template<class Container> void insert_remove_loop_impl()
t.insert(2, 4, T(IntOrString(7)));
int expect6[] = { 1, 2, 7, 7, 7, 7, 9, 9, 9, 9, 3, 4 };
- QCOMPARE(size_t(t.count()), sizeof(expect6)/sizeof(int));
- for (int i = 0; i < t.count(); i++) {
+ QCOMPARE(size_t(t.size()), sizeof(expect6)/sizeof(int));
+ for (int i = 0; i < t.size(); i++) {
QCOMPARE(t[i], T(IntOrString(expect6[i])));
}
diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
index 60023e1bf2..c3a56b68ec 100644
--- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
+++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
@@ -354,6 +354,15 @@ private:
template <typename Container>
void erase_if_associative_impl() const;
+ template <typename Container>
+ void member_erase_impl() const;
+
+ template <typename Container>
+ void member_erase_associative_impl() const;
+
+ template <typename Container>
+ void member_erase_set_impl() const;
+
private Q_SLOTS:
void erase_QList() { erase_impl<QList<int>>(); }
void erase_QVarLengthArray() { erase_impl<QVarLengthArray<int>>(); }
@@ -380,6 +389,17 @@ private Q_SLOTS:
void erase_if_QHash() { erase_if_associative_impl<QHash<int, int>>(); }
void erase_if_QMultiHash() { erase_if_associative_impl<QMultiHash<int, int>>(); }
+ void member_erase_QList() { member_erase_impl<QList<int>>(); }
+ void member_erase_QVarLengthArray() { member_erase_impl<QVarLengthArray<int>>(); }
+ void member_erase_QString() { member_erase_impl<QString>(); }
+ void member_erase_QByteArray() { member_erase_impl<QByteArray>(); }
+ void member_erase_QSet() { member_erase_set_impl<QSet<int>>(); }
+
+ void member_erase_QMap() { member_erase_associative_impl<QMap<int, int>>(); }
+ void member_erase_QMultiMap() {member_erase_associative_impl<QMultiMap<int, int>>(); }
+ void member_erase_QHash() { member_erase_associative_impl<QHash<int, int>>(); }
+ void member_erase_QMultiHash() { member_erase_associative_impl<QMultiHash<int, int>>(); }
+
private:
template <typename Container>
void keyValueRange_impl() const;
@@ -746,14 +766,14 @@ void tst_ContainerApiSymmetry::front_back_impl() const
auto c1 = make<Container>(1);
QCOMPARE(clean(c1.front()), V(1));
QCOMPARE(clean(c1.back()), V(1));
- QCOMPARE(clean(qAsConst(c1).front()), V(1));
- QCOMPARE(clean(qAsConst(c1).back()), V(1));
+ QCOMPARE(clean(std::as_const(c1).front()), V(1));
+ QCOMPARE(clean(std::as_const(c1).back()), V(1));
auto c2 = make<Container>(2);
QCOMPARE(clean(c2.front()), V(1));
QCOMPARE(clean(c2.back()), V(2));
- QCOMPARE(clean(qAsConst(c2).front()), V(1));
- QCOMPARE(clean(qAsConst(c2).back()), V(2));
+ QCOMPARE(clean(std::as_const(c2).front()), V(1));
+ QCOMPARE(clean(std::as_const(c2).back()), V(2));
}
namespace {
@@ -874,6 +894,65 @@ void tst_ContainerApiSymmetry::erase_if_associative_impl() const
}
template <typename Container>
+void tst_ContainerApiSymmetry::member_erase_impl() const
+{
+ using S = typename Container::size_type;
+ using V = typename Container::value_type;
+ const S size = 7;
+ auto c = make<Container>(size); // {1, 2, 3, 4, 5, 6, 7}
+ QCOMPARE(c.size(), size);
+
+ auto copy = c;
+ // Container::erase() returns an iterator, not const_iterator
+ auto it = c.erase(c.cbegin(), c.cbegin());
+ static_assert(std::is_same_v<decltype(it), typename Container::iterator>);
+ QCOMPARE(c.size(), size);
+ const V newVal{100};
+ QCOMPARE_NE(*it, newVal);
+ *it = newVal;
+ QCOMPARE(it, c.cbegin());
+ QCOMPARE(*c.cbegin(), newVal);
+
+ QCOMPARE(std::find(copy.cbegin(), copy.cend(), newVal), copy.cend());
+}
+
+template <typename Container>
+void tst_ContainerApiSymmetry::member_erase_associative_impl() const
+{
+ using S = typename Container::size_type;
+ using V = typename Container::mapped_type;
+
+ const S size = 20;
+ auto c = makeAssociative<Container>(size);
+ QCOMPARE(c.size(), size);
+
+ // Verify Container::erase() returns iterator, not const_iterator
+ auto it = c.erase(c.cbegin());
+ static_assert(std::is_same_v<decltype(it), typename Container::iterator>);
+ QCOMPARE(c.size(), size - 1);
+ QCOMPARE(it, c.cbegin());
+ const auto current = it.value();
+ it.value() = current + V(5);
+ QCOMPARE(c.cbegin().value(),current + V(5));
+}
+
+template <typename Container>
+void tst_ContainerApiSymmetry::member_erase_set_impl() const
+{
+ using S = typename Container::size_type;
+
+ const S size = 20;
+ auto c = make<Container>(size);
+ QCOMPARE(c.size(), size);
+
+ // Verify Container::erase() returns iterator, not const_iterator
+ auto it = c.erase(c.cbegin());
+ static_assert(std::is_same_v<decltype(it), typename Container::iterator>);
+ QCOMPARE(c.size(), size - 1);
+ QCOMPARE(it, c.cbegin());
+}
+
+template <typename Container>
void tst_ContainerApiSymmetry::keyValueRange_impl() const
{
constexpr int COUNT = 20;
diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
index 4a06306e31..8eb5392eb0 100644
--- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
@@ -70,6 +70,18 @@ private:
void countLeading_impl();
};
+template <typename T> struct PrintIfFailed
+{
+ T value;
+ PrintIfFailed(T v) : value(v) {}
+ ~PrintIfFailed()
+ {
+ if (!QTest::currentTestFailed())
+ return;
+ qWarning() << "Original value was" << Qt::hex << Qt::showbase << T(value);
+ }
+};
+
void tst_QAlgorithms::swap()
{
{
@@ -249,23 +261,26 @@ void tst_QAlgorithms::popCount_data_impl(size_t sizeof_T_Int)
const uint bits = bitsSetInByte(byte);
const quint64 value = static_cast<quint64>(byte);
const quint64 input = value << ((i % sizeof_T_Int) * 8U);
- QTest::addRow("0x%016llx", input) << input << bits;
+ QTest::addRow("%u-bits", i) << input << bits;
}
// and some random ones:
- if (sizeof_T_Int >= 8)
+ if (sizeof_T_Int >= 8) {
for (size_t i = 0; i < 1000; ++i) {
const quint64 input = QRandomGenerator::global()->generate64();
- QTest::addRow("0x%016llx", input) << input << bitsSetInInt64(input);
+ QTest::addRow("random-%zu", i) << input << bitsSetInInt64(input);
}
- else if (sizeof_T_Int >= 2)
- for (size_t i = 0; i < 1000 ; ++i) {
- const quint32 input = QRandomGenerator::global()->generate();
- if (sizeof_T_Int >= 4)
- QTest::addRow("0x%08x", input) << quint64(input) << bitsSetInInt(input);
- else
- QTest::addRow("0x%04x", quint16(input & 0xFFFF)) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF);
+ } else if (sizeof_T_Int >= 2) {
+ for (size_t i = 0; i < 1000 ; ++i) {
+ const quint32 input = QRandomGenerator::global()->generate();
+ if (sizeof_T_Int >= 4) {
+ QTest::addRow("random-%zu", i) << quint64(input) << bitsSetInInt(input);
+ } else {
+ QTest::addRow("random-%zu", i)
+ << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF);
}
+ }
+ }
}
template <typename T_Int>
@@ -275,22 +290,23 @@ void tst_QAlgorithms::popCount_impl()
QFETCH(uint, expected);
const T_Int value = static_cast<T_Int>(input);
-
+ PrintIfFailed pf(value);
QCOMPARE(qPopulationCount(value), expected);
}
+// Number of test-cases per offset into each size (arbitrary):
+static constexpr int casesPerOffset = 3;
+
void tst_QAlgorithms::countTrailing_data_impl(size_t sizeof_T_Int)
{
using namespace QTest;
addColumn<quint64>("input");
addColumn<uint>("expected");
- int nibs = sizeof_T_Int*2;
-
- newRow(("0x"+QByteArray::number(0,16).rightJustified(nibs,'0')).constData()) << Q_UINT64_C(0) << uint(sizeof_T_Int*8);
+ addRow("0") << Q_UINT64_C(0) << uint(sizeof_T_Int*8);
for (uint i = 0; i < sizeof_T_Int*8; ++i) {
const quint64 input = Q_UINT64_C(1) << i;
- newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << i;
+ addRow("bit-%u", i) << input << i;
}
quint64 type_mask;
@@ -301,12 +317,12 @@ void tst_QAlgorithms::countTrailing_data_impl(size_t sizeof_T_Int)
// and some random ones:
for (uint i = 0; i < sizeof_T_Int*8; ++i) {
- for (uint j = 0; j < sizeof_T_Int*3; ++j) { // 3 is arbitrary
+ const quint64 b = Q_UINT64_C(1) << i;
+ const quint64 mask = ((~(b - 1)) ^ b) & type_mask;
+ for (uint j = 0; j < sizeof_T_Int * casesPerOffset; ++j) {
const quint64 r = QRandomGenerator::global()->generate64();
- const quint64 b = Q_UINT64_C(1) << i;
- const quint64 mask = ((~(b-1)) ^ b) & type_mask;
const quint64 input = (r&mask) | b;
- newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << i;
+ addRow("%u-bits-random-%u", i, j) << input << i;
}
}
}
@@ -318,7 +334,7 @@ void tst_QAlgorithms::countTrailing_impl()
QFETCH(uint, expected);
const T_Int value = static_cast<T_Int>(input);
-
+ PrintIfFailed pf(value);
QCOMPARE(qCountTrailingZeroBits(value), expected);
}
@@ -328,22 +344,20 @@ void tst_QAlgorithms::countLeading_data_impl(size_t sizeof_T_Int)
addColumn<quint64>("input");
addColumn<uint>("expected");
- int nibs = sizeof_T_Int*2;
-
- newRow(("0x"+QByteArray::number(0,16).rightJustified(nibs,'0')).constData()) << Q_UINT64_C(0) << uint(sizeof_T_Int*8);
+ addRow("0") << Q_UINT64_C(0) << uint(sizeof_T_Int*8);
for (uint i = 0; i < sizeof_T_Int*8; ++i) {
const quint64 input = Q_UINT64_C(1) << i;
- newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << uint(sizeof_T_Int*8-i-1);
+ addRow("bit-%u", i) << input << uint(sizeof_T_Int*8-i-1);
}
// and some random ones:
for (uint i = 0; i < sizeof_T_Int*8; ++i) {
- for (uint j = 0; j < sizeof_T_Int*3; ++j) { // 3 is arbitrary
+ const quint64 b = Q_UINT64_C(1) << i;
+ const quint64 mask = b - 1;
+ for (uint j = 0; j < sizeof_T_Int * casesPerOffset; ++j) {
const quint64 r = QRandomGenerator::global()->generate64();
- const quint64 b = Q_UINT64_C(1) << i;
- const quint64 mask = b-1;
const quint64 input = (r&mask) | b;
- newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << uint(sizeof_T_Int*8-i-1);
+ addRow("%u-bits-random-%u", i, j) << input << uint(sizeof_T_Int*8-i-1);
}
}
}
@@ -355,7 +369,7 @@ void tst_QAlgorithms::countLeading_impl()
QFETCH(uint, expected);
const T_Int value = static_cast<T_Int>(input);
-
+ PrintIfFailed pf(value);
QCOMPARE(qCountLeadingZeroBits(value), expected);
}
diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
index 3e755e67da..2e6c94e8e0 100644
--- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
+++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
@@ -13,10 +13,10 @@
static QBitArray QStringToQBitArray(const QString &str)
{
QBitArray ba;
- ba.resize(str.length());
+ ba.resize(str.size());
int i;
QChar tru('1');
- for (i = 0; i < str.length(); i++)
+ for (i = 0; i < str.size(); i++)
{
if (str.at(i) == tru)
{
@@ -143,6 +143,8 @@ void tst_QBitArray::countBits()
bits.setBit(i);
}
+ QCOMPARE(bits.size(), numBits);
+ // NOLINTNEXTLINE(qt-port-to-std-compatible-api): : We want to test count() and size()
QCOMPARE(bits.count(), numBits);
QCOMPARE(bits.count(true), onBits);
QCOMPARE(bits.count(false), numBits - onBits);
@@ -494,7 +496,7 @@ void tst_QBitArray::datastream()
bits.setBit(i);
}
- QCOMPARE(bits.count(), numBits);
+ QCOMPARE(bits.size(), numBits);
QCOMPARE(bits.count(true), onBits);
QCOMPARE(bits.count(false), numBits - onBits);
@@ -509,7 +511,7 @@ void tst_QBitArray::datastream()
QBitArray array1, array2, array3;
stream2 >> array1 >> array2 >> array3;
- QCOMPARE(array1.count(), numBits);
+ QCOMPARE(array1.size(), numBits);
QCOMPARE(array1.count(true), onBits);
QCOMPARE(array1.count(false), numBits - onBits);
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index c2f6811d27..6252440232 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -503,7 +503,7 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes()
QVERIFY(parser.addOption(forceShort));
QVERIFY(parser.parse(commandLine));
QCOMPARE(parser.optionNames(), expectedOptionNames);
- for (int i = 0; i < expectedOptionValues.count(); ++i)
+ for (int i = 0; i < expectedOptionValues.size(); ++i)
QCOMPARE(parser.value(parser.optionNames().at(i)), expectedOptionValues.at(i));
QCOMPARE(parser.unknownOptionNames(), QStringList());
}
@@ -762,7 +762,7 @@ void tst_QCommandLineParser::testVeryLongOptionNames()
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
const QStringList lines = output.split('\n');
- const int last = lines.count() - 1;
+ const int last = lines.size() - 1;
// Let's not compare everything, just the final parts.
QCOMPARE(lines.at(last - 7), " cdefghijklmnopqrstuvwxyz");
QCOMPARE(lines.at(last - 6), " --looooooooooooong-option, --looooong-opt-alias <l Short description");
diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
index 22b44a027c..7a2cfffaea 100644
--- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
+++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
@@ -50,20 +50,24 @@ void tst_QContiguousCache::empty()
{
QContiguousCache<int> c(10);
QCOMPARE(c.capacity(), 10);
+ QCOMPARE(c.size(), 0);
+ // NOLINTNEXTLINE(qt-port-to-std-compatible-api): : We want to test count() and size()
QCOMPARE(c.count(), 0);
QVERIFY(c.isEmpty());
c.append(1);
+ QCOMPARE(c.size(), 1);
+ // NOLINTNEXTLINE(qt-port-to-std-compatible-api): : We want to test count() and size()
QCOMPARE(c.count(), 1);
QVERIFY(!c.isEmpty());
c.clear();
QCOMPARE(c.capacity(), 10);
- QCOMPARE(c.count(), 0);
+ QCOMPARE(c.size(), 0);
QVERIFY(c.isEmpty());
c.prepend(1);
- QCOMPARE(c.count(), 1);
+ QCOMPARE(c.size(), 1);
QVERIFY(!c.isEmpty());
c.clear();
- QCOMPARE(c.count(), 0);
+ QCOMPARE(c.size(), 0);
QVERIFY(c.isEmpty());
QCOMPARE(c.capacity(), 10);
}
@@ -74,9 +78,9 @@ void tst_QContiguousCache::swap()
c1.append(1);
c1.swap(c2);
QCOMPARE(c1.capacity(), 100);
- QCOMPARE(c1.count(), 0 );
+ QCOMPARE(c1.size(), 0 );
QCOMPARE(c2.capacity(), 10 );
- QCOMPARE(c2.count(), 1 );
+ QCOMPARE(c2.size(), 1 );
}
void tst_QContiguousCache::append_data()
@@ -112,7 +116,7 @@ void tst_QContiguousCache::append()
QCOMPARE(c.available(), qMax(qsizetype(0), cacheSize - i));
QCOMPARE(c.first(), qMax(qsizetype(1), i-cacheSize+1));
QCOMPARE(c.last(), i);
- QCOMPARE(c.count(), qMin(i, cacheSize));
+ QCOMPARE(c.size(), qMin(i, cacheSize));
QCOMPARE(c.isFull(), i >= cacheSize);
i++;
}
@@ -125,7 +129,7 @@ void tst_QContiguousCache::append()
// test taking from end until empty.
for (j = 0; j < cacheSize; j++, i--) {
QCOMPARE(c.takeLast(), i-1);
- QCOMPARE(c.count(), cacheSize-j-1);
+ QCOMPARE(c.size(), cacheSize-j-1);
QCOMPARE(c.available(), j+1);
QVERIFY(!c.isFull());
QCOMPARE(c.isEmpty(), j==cacheSize-1);
@@ -163,7 +167,7 @@ void tst_QContiguousCache::prepend()
QCOMPARE(c.available(), qMax(0, cacheSize - i));
QCOMPARE(c.last(), qMax(1, i-cacheSize+1));
QCOMPARE(c.first(), i);
- QCOMPARE(c.count(), qMin(i, cacheSize));
+ QCOMPARE(c.size(), qMin(i, cacheSize));
QCOMPARE(c.isFull(), i >= cacheSize);
i++;
}
@@ -176,7 +180,7 @@ void tst_QContiguousCache::prepend()
// test taking from start until empty.
for (j = 0; j < cacheSize; j++, i--) {
QCOMPARE(c.takeFirst(), i-1);
- QCOMPARE(c.count(), cacheSize-j-1);
+ QCOMPARE(c.size(), cacheSize-j-1);
QCOMPARE(c.available(), j+1);
QVERIFY(!c.isFull());
QCOMPARE(c.isEmpty(), j==cacheSize-1);
@@ -296,7 +300,7 @@ void tst_QContiguousCache::setCapacity()
for (i = 280; i < 310; ++i)
contiguousCache.insert(i, i);
QCOMPARE(contiguousCache.capacity(), 100);
- QCOMPARE(contiguousCache.count(), 30);
+ QCOMPARE(contiguousCache.size(), 30);
QCOMPARE(contiguousCache.firstIndex(), 280);
QCOMPARE(contiguousCache.lastIndex(), 309);
@@ -308,7 +312,7 @@ void tst_QContiguousCache::setCapacity()
contiguousCache.setCapacity(150);
QCOMPARE(contiguousCache.capacity(), 150);
- QCOMPARE(contiguousCache.count(), 30);
+ QCOMPARE(contiguousCache.size(), 30);
QCOMPARE(contiguousCache.firstIndex(), 280);
QCOMPARE(contiguousCache.lastIndex(), 309);
@@ -320,7 +324,7 @@ void tst_QContiguousCache::setCapacity()
contiguousCache.setCapacity(20);
QCOMPARE(contiguousCache.capacity(), 20);
- QCOMPARE(contiguousCache.count(), 20);
+ QCOMPARE(contiguousCache.size(), 20);
QCOMPARE(contiguousCache.firstIndex(), 290);
QCOMPARE(contiguousCache.lastIndex(), 309);
diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
index 5e2e854067..680749e10a 100644
--- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
+++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
@@ -34,7 +34,9 @@ private slots:
// keep last
void moreThan4GiBOfData_data();
void moreThan4GiBOfData();
+ void keccakBufferOverflow();
private:
+ void ensureLargeData();
std::vector<char> large;
};
@@ -401,12 +403,14 @@ void tst_QCryptographicHash::hashLength()
QCOMPARE(QCryptographicHash::hashLength(algorithm), output.length());
}
-void tst_QCryptographicHash::moreThan4GiBOfData_data()
+void tst_QCryptographicHash::ensureLargeData()
{
#if QT_POINTER_SIZE > 4
QElapsedTimer timer;
timer.start();
const size_t GiB = 1024 * 1024 * 1024;
+ if (large.size() == 4 * GiB + 1)
+ return;
try {
large.resize(4 * GiB + 1, '\0');
} catch (const std::bad_alloc &) {
@@ -415,7 +419,14 @@ void tst_QCryptographicHash::moreThan4GiBOfData_data()
QCOMPARE(large.size(), 4 * GiB + 1);
large.back() = '\1';
qDebug("created dataset in %lld ms", timer.elapsed());
+#endif
+}
+void tst_QCryptographicHash::moreThan4GiBOfData_data()
+{
+#if QT_POINTER_SIZE > 4
+ if (ensureLargeData(); large.empty())
+ return;
QTest::addColumn<QCryptographicHash::Algorithm>("algorithm");
auto me = QMetaEnum::fromType<QCryptographicHash::Algorithm>();
auto row = [me] (QCryptographicHash::Algorithm algo) {
@@ -478,5 +489,33 @@ void tst_QCryptographicHash::moreThan4GiBOfData()
QCOMPARE(single, chunked);
}
+void tst_QCryptographicHash::keccakBufferOverflow()
+{
+#if QT_POINTER_SIZE == 4
+ QSKIP("This is a 64-bit-only test");
+#else
+
+ if (ensureLargeData(); large.empty())
+ return;
+
+ QElapsedTimer timer;
+ timer.start();
+ const auto sg = qScopeGuard([&] {
+ qDebug() << "test finished in" << timer.restart() << "ms";
+ });
+
+ constexpr qsizetype magic = INT_MAX/4;
+ QCOMPARE_GE(large.size(), size_t(magic + 1));
+
+ QCryptographicHash hash(QCryptographicHash::Algorithm::Keccak_224);
+ const auto first = QByteArrayView{large}.first(1);
+ const auto second = QByteArrayView{large}.sliced(1, magic);
+ hash.addData(first);
+ hash.addData(second);
+ (void)hash.resultView();
+ QVERIFY(true); // didn't crash
+#endif
+}
+
QTEST_MAIN(tst_QCryptographicHash)
#include "tst_qcryptographichash.moc"
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
index 4d1d846eb8..4989de521f 100644
--- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
@@ -374,7 +374,7 @@ void tst_QEasingCurve::valueForProgress()
// in theory the baseline should't have an error of more than 0.00005 due to how its rounded,
// but due to FP imprecision, we have to adjust the error a bit more.
const qreal errorBound = 0.00006;
- for (int i = 0; i < at.count(); ++i) {
+ for (int i = 0; i < at.size(); ++i) {
const qreal ex = expected.at(i);
const qreal error = qAbs(ex - curve.valueForProgress(at.at(i)/qreal(100)));
QVERIFY(error <= errorBound);
@@ -583,9 +583,9 @@ static inline void setupBezierSpline(QEasingCurve *easingCurve, const QString &s
points.append(point);
}
- QVERIFY(points.count() % 3 == 0);
+ QVERIFY(points.size() % 3 == 0);
- for (int i = 0; i < points.count() / 3; i++) {
+ for (int i = 0; i < points.size() / 3; i++) {
QPointF c1 = points.at(i * 3);
QPointF c2 = points.at(i * 3 + 1);
QPointF p1 = points.at(i * 3 + 2);
@@ -603,7 +603,7 @@ void tst_QEasingCurve::bezierSpline()
setupBezierSpline(&bezierEasingCurve, definition);
const qreal errorBound = 0.002;
- for (int i = 0; i < at.count(); ++i) {
+ for (int i = 0; i < at.size(); ++i) {
const qreal ex = expected.at(i);
const qreal value = bezierEasingCurve.valueForProgress(at.at(i)/qreal(100));
const qreal error = qAbs(ex - value);
@@ -646,7 +646,7 @@ static inline void setupTCBSpline(QEasingCurve *easingCurve, const QString &stri
foreach (const QString &str, pointStr) {
QStringList coordStr = str.split(QLatin1Char(','));
- Q_ASSERT(coordStr.count() == 5);
+ Q_ASSERT(coordStr.size() == 5);
QPointF point(coordStr.first().toDouble(), coordStr.at(1).toDouble());
qreal t = coordStr.at(2).toDouble();
qreal c = coordStr.at(3).toDouble();
@@ -665,7 +665,7 @@ void tst_QEasingCurve::tcbSpline()
setupTCBSpline(&tcbEasingCurve, definition);
const qreal errorBound = 0.002;
- for (int i = 0; i < at.count(); ++i) {
+ for (int i = 0; i < at.size(); ++i) {
const qreal ex = expected.at(i);
const qreal value = tcbEasingCurve.valueForProgress(at.at(i)/qreal(100));
const qreal error = qAbs(ex - value);
diff --git a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp
index f57abbf156..112a393136 100644
--- a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp
+++ b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp
@@ -682,7 +682,7 @@ void tst_QFlatMap::viewIterators()
});
auto it = keys.begin();
QCOMPARE(*it, "kaksi");
- QCOMPARE(it->length(), 5);
+ QCOMPARE(it->size(), 5);
++it;
QCOMPARE(*it, "kolme");
it++;
@@ -703,7 +703,7 @@ void tst_QFlatMap::viewIterators()
});
auto it = values.begin();
QCOMPARE(*it, "twee");
- QCOMPARE(it->length(), 4);
+ QCOMPARE(it->size(), 4);
++it;
QCOMPARE(*it, "dree");
it++;
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 5b51d6888d..27f63e8778 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -168,13 +168,13 @@ void tst_QHash::count()
{
MyMap map;
MyMap map2( map );
- QCOMPARE( map.count(), 0 );
- QCOMPARE( map2.count(), 0 );
+ QCOMPARE( map.size(), 0 );
+ QCOMPARE( map2.size(), 0 );
QCOMPARE( MyClass::count, 0 );
// detach
map2["Hallo"] = MyClass( "Fritz" );
- QCOMPARE( map.count(), 0 );
- QCOMPARE( map2.count(), 1 );
+ QCOMPARE( map.size(), 0 );
+ QCOMPARE( map2.size(), 1 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 1 );
#endif
@@ -184,11 +184,11 @@ void tst_QHash::count()
{
typedef QHash<QString, MyClass> Map;
Map map;
- QCOMPARE( map.count(), 0);
+ QCOMPARE( map.size(), 0);
map.insert( "Torben", MyClass("Weis") );
- QCOMPARE( map.count(), 1 );
+ QCOMPARE( map.size(), 1 );
map.insert( "Claudia", MyClass("Sorg") );
- QCOMPARE( map.count(), 2 );
+ QCOMPARE( map.size(), 2 );
map.insert( "Lars", MyClass("Linzbach") );
map.insert( "Matthias", MyClass("Ettrich") );
map.insert( "Sue", MyClass("Paludo") );
@@ -196,7 +196,7 @@ void tst_QHash::count()
map.insert( "Haavard", MyClass("Nord") );
map.insert( "Arnt", MyClass("Gulbrandsen") );
map.insert( "Paul", MyClass("Tvete") );
- QCOMPARE( map.count(), 9 );
+ QCOMPARE( map.size(), 9 );
map.insert( "Paul", MyClass("Tvete 1") );
map.insert( "Paul", MyClass("Tvete 2") );
map.insert( "Paul", MyClass("Tvete 3") );
@@ -204,68 +204,68 @@ void tst_QHash::count()
map.insert( "Paul", MyClass("Tvete 5") );
map.insert( "Paul", MyClass("Tvete 6") );
- QCOMPARE( map.count(), 9 );
+ QCOMPARE( map.size(), 9 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 );
#endif
Map map2( map );
- QVERIFY( map2.count() == 9 );
+ QVERIFY( map2.size() == 9 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 );
#endif
map2.insert( "Kay", MyClass("Roemer") );
- QVERIFY( map2.count() == 10 );
- QVERIFY( map.count() == 9 );
+ QVERIFY( map2.size() == 10 );
+ QVERIFY( map.size() == 9 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 19 );
#endif
map2 = map;
- QVERIFY( map.count() == 9 );
- QVERIFY( map2.count() == 9 );
+ QVERIFY( map.size() == 9 );
+ QVERIFY( map2.size() == 9 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 );
#endif
map2.insert( "Kay", MyClass("Roemer") );
- QVERIFY( map2.count() == 10 );
+ QVERIFY( map2.size() == 10 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 19 );
#endif
map2.clear();
- QVERIFY( map.count() == 9 );
- QVERIFY( map2.count() == 0 );
+ QVERIFY( map.size() == 9 );
+ QVERIFY( map2.size() == 0 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 );
#endif
map2 = map;
- QVERIFY( map.count() == 9 );
- QVERIFY( map2.count() == 9 );
+ QVERIFY( map.size() == 9 );
+ QVERIFY( map2.size() == 9 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 );
#endif
map2.clear();
- QVERIFY( map.count() == 9 );
- QVERIFY( map2.count() == 0 );
+ QVERIFY( map.size() == 9 );
+ QVERIFY( map2.size() == 0 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 );
#endif
map.remove( "Lars" );
- QVERIFY( map.count() == 8 );
- QVERIFY( map2.count() == 0 );
+ QVERIFY( map.size() == 8 );
+ QVERIFY( map2.size() == 0 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 8 );
#endif
map.remove( "Mist" );
- QVERIFY( map.count() == 8 );
- QVERIFY( map2.count() == 0 );
+ QVERIFY( map.size() == 8 );
+ QVERIFY( map2.size() == 0 );
#ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 8 );
#endif
@@ -279,22 +279,22 @@ void tst_QHash::count()
#ifndef Q_CC_SUN
QVERIFY( MyClass::count == 1 );
#endif
- QVERIFY( map.count() == 1 );
+ QVERIFY( map.size() == 1 );
(void)map["Torben"].str;
(void)map["Lars"].str;
#ifndef Q_CC_SUN
QVERIFY( MyClass::count == 2 );
#endif
- QVERIFY( map.count() == 2 );
+ QVERIFY( map.size() == 2 );
const Map& cmap = map;
(void)cmap["Depp"].str;
#ifndef Q_CC_SUN
QVERIFY( MyClass::count == 2 );
#endif
- QVERIFY( map.count() == 2 );
- QVERIFY( cmap.count() == 2 );
+ QVERIFY( map.size() == 2 );
+ QVERIFY( cmap.size() == 2 );
}
QCOMPARE( MyClass::count, 0 );
{
@@ -1629,9 +1629,9 @@ void tst_QHash::rehash_isnt_quadratic()
{
// this test should be incredibly slow if rehash() is quadratic
for (int j = 0; j < 5; ++j) {
- QMultiHash<int, int> testHash;
+ QHash<int, int> testHash;
for (int i = 0; i < 500000; ++i)
- testHash.insert(1, 1);
+ testHash.insert(i, 1);
}
}
@@ -1688,26 +1688,26 @@ void tst_QHash::qmultihash_specific()
}
QVERIFY(hash1.contains(9, 99));
- QCOMPARE(hash1.count(), 45);
+ QCOMPARE(hash1.size(), 45);
hash1.remove(9, 99);
QVERIFY(!hash1.contains(9, 99));
- QCOMPARE(hash1.count(), 44);
+ QCOMPARE(hash1.size(), 44);
hash1.remove(9, 99);
QVERIFY(!hash1.contains(9, 99));
- QCOMPARE(hash1.count(), 44);
+ QCOMPARE(hash1.size(), 44);
hash1.remove(1, 99);
- QCOMPARE(hash1.count(), 44);
+ QCOMPARE(hash1.size(), 44);
hash1.insert(1, 99);
hash1.insert(1, 99);
- QCOMPARE(hash1.count(), 46);
+ QCOMPARE(hash1.size(), 46);
hash1.remove(1, 99);
- QCOMPARE(hash1.count(), 44);
+ QCOMPARE(hash1.size(), 44);
hash1.remove(1, 99);
- QCOMPARE(hash1.count(), 44);
+ QCOMPARE(hash1.size(), 44);
{
QMultiHash<int, int>::const_iterator i = hash1.constFind(1, 11);
@@ -1753,10 +1753,10 @@ void tst_QHash::qmultihash_specific()
}
QCOMPARE(hash1.count(9), 8);
- QCOMPARE(hash1.count(), 44);
+ QCOMPARE(hash1.size(), 44);
hash1.remove(9);
QCOMPARE(hash1.count(9), 0);
- QCOMPARE(hash1.count(), 36);
+ QCOMPARE(hash1.size(), 36);
{
QMultiHash<int, int> map1;
@@ -1772,7 +1772,7 @@ void tst_QHash::qmultihash_specific()
map2.insert(42, 1);
map2.insert(10, 2);
map2.insert(48, 3);
- QCOMPARE(map1.count(), map2.count());
+ QCOMPARE(map1.size(), map2.size());
QVERIFY(map1.remove(42,5));
QVERIFY(map1 != map2);
QVERIFY(map2.remove(42,5));
@@ -1781,7 +1781,7 @@ void tst_QHash::qmultihash_specific()
QHash<int, int> hash;
hash.insert(-1, -1);
map2.unite(hash);
- QCOMPARE(map2.count(), 6);
+ QCOMPARE(map2.size(), 6);
QCOMPARE(map2[-1], -1);
}
}
@@ -2168,7 +2168,7 @@ void tst_QHash::twoArguments_qHash()
void tst_QHash::initializerList()
{
QHash<int, QString> hash = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}};
- QCOMPARE(hash.count(), 2);
+ QCOMPARE(hash.size(), 2);
QCOMPARE(hash[1], QString("hello"));
QCOMPARE(hash[2], QString("initializer_list"));
@@ -2178,9 +2178,9 @@ void tst_QHash::initializerList()
// QCOMPARE(stdh[1], QString("bar"));
QMultiHash<QString, int> multiHash{{"il", 1}, {"il", 2}, {"il", 3}};
- QCOMPARE(multiHash.count(), 3);
+ QCOMPARE(multiHash.size(), 3);
QList<int> values = multiHash.values("il");
- QCOMPARE(values.count(), 3);
+ QCOMPARE(values.size(), 3);
QHash<int, int> emptyHash{};
QVERIFY(emptyHash.isEmpty());
@@ -2352,7 +2352,7 @@ void tst_QHash::insert_hash()
hash.insert(hash2);
- QCOMPARE(hash.count(), 5);
+ QCOMPARE(hash.size(), 5);
for (int i = 0; i < 5; ++i)
QCOMPARE(hash[i], i);
}
@@ -2364,7 +2364,7 @@ void tst_QHash::insert_hash()
hash.insert(hash2);
- QCOMPARE(hash.count(), 1);
+ QCOMPARE(hash.size(), 1);
QCOMPARE(hash[0], 5);
}
{
@@ -2374,7 +2374,7 @@ void tst_QHash::insert_hash()
hash.insert(hash2);
- QCOMPARE(hash.count(), 1);
+ QCOMPARE(hash.size(), 1);
QCOMPARE(hash[0], 5);
QCOMPARE(hash, hash2);
}
@@ -2387,7 +2387,7 @@ void tst_QHash::insert_hash()
// insert into ourself, nothing should happen
hash.insert(hash);
- QCOMPARE(hash.count(), 3);
+ QCOMPARE(hash.size(), 3);
QCOMPARE(hash[0], 7);
QCOMPARE(hash[2], 5);
QCOMPARE(hash[7], 55);
@@ -2561,13 +2561,13 @@ void tst_QHash::countInEmptyHash()
{
{
QHash<int, int> hash;
- QCOMPARE(hash.count(), 0);
+ QCOMPARE(hash.size(), 0);
QCOMPARE(hash.count(42), 0);
}
{
QMultiHash<int, int> hash;
- QCOMPARE(hash.count(), 0);
+ QCOMPARE(hash.size(), 0);
QCOMPARE(hash.count(42), 0);
QCOMPARE(hash.count(42, 1), 0);
}
diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
index d060f50609..058525f0ae 100644
--- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
+++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
@@ -53,6 +53,8 @@ private Q_SLOTS:
void stdPair_string_pairIntInt() { stdPair_template(QString("Hello"), std::make_pair(42, -47)); } // QTBUG-92910
void stdPair_int_pairIntPairIntInt() { stdPair_template(1, std::make_pair(2, std::make_pair(3, 4))); }
+ void enum_int_consistent_hash_qtbug108032();
+
void setGlobalQHashSeed();
};
@@ -370,6 +372,17 @@ void tst_QHashFunctions::stdPair_template(const T1 &t1, const T2 &t2)
QCOMPARE(qHash(vpair, seed), qHash(vpair, seed));
}
+void tst_QHashFunctions::enum_int_consistent_hash_qtbug108032()
+{
+ enum E { E1, E2, E3 };
+
+ static_assert(QHashPrivate::HasQHashSingleArgOverload<E>);
+
+ QCOMPARE(qHash(E1, seed), qHash(int(E1), seed));
+ QCOMPARE(qHash(E2, seed), qHash(int(E2), seed));
+ QCOMPARE(qHash(E3, seed), qHash(int(E3), seed));
+}
+
void tst_QHashFunctions::setGlobalQHashSeed()
{
// Setter works as advertised
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index e797b76f69..482079b0fe 100644
--- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -1078,20 +1078,20 @@ void tst_QList::count() const
{
// zero size
QList<T> myvec;
- QVERIFY(myvec.count() == 0);
+ QVERIFY(myvec.size() == 0);
QVERIFY(!myvec.isDetached());
// grow
myvec.append(SimpleValue<T>::at(0));
- QVERIFY(myvec.count() == 1);
+ QVERIFY(myvec.size() == 1);
myvec.append(SimpleValue<T>::at(1));
- QVERIFY(myvec.count() == 2);
+ QVERIFY(myvec.size() == 2);
// shrink
myvec.remove(0);
- QVERIFY(myvec.count() == 1);
+ QVERIFY(myvec.size() == 1);
myvec.remove(0);
- QVERIFY(myvec.count() == 0);
+ QVERIFY(myvec.size() == 0);
}
// count of items
@@ -1905,11 +1905,11 @@ void tst_QList::move() const
list << T_FOO << T_BAR << T_BAZ;
// move an item
- list.move(0, list.count() - 1);
+ list.move(0, list.size() - 1);
QCOMPARE(list, QList<T>() << T_BAR << T_BAZ << T_FOO);
// move it back
- list.move(list.count() - 1, 0);
+ list.move(list.size() - 1, 0);
QCOMPARE(list, QList<T>() << T_FOO << T_BAR << T_BAZ);
// move an item in the middle
@@ -2673,24 +2673,24 @@ void tst_QList::size() const
// zero size
QList<T> myvec;
QVERIFY(myvec.size() == 0);
- QCOMPARE(myvec.length(), myvec.size());
+ QCOMPARE(myvec.size(), myvec.size());
QVERIFY(!myvec.isDetached());
// grow
myvec.append(SimpleValue<T>::at(0));
QVERIFY(myvec.size() == 1);
- QCOMPARE(myvec.length(), myvec.size());
+ QCOMPARE(myvec.size(), myvec.size());
myvec.append(SimpleValue<T>::at(1));
QVERIFY(myvec.size() == 2);
- QCOMPARE(myvec.length(), myvec.size());
+ QCOMPARE(myvec.size(), myvec.size());
// shrink
myvec.remove(0);
QVERIFY(myvec.size() == 1);
- QCOMPARE(myvec.length(), myvec.size());
+ QCOMPARE(myvec.size(), myvec.size());
myvec.remove(0);
QVERIFY(myvec.size() == 0);
- QCOMPARE(myvec.length(), myvec.size());
+ QCOMPARE(myvec.size(), myvec.size());
}
// ::squeeze() is tested in ::capacity().
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index 589b98ce49..bae3e6eed6 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -422,7 +422,12 @@ void tst_QMap::beginEnd()
// detach
map2.insert( "2", "c" );
QVERIFY( map.constBegin() == map.constBegin() );
- QVERIFY( map.constBegin() != map2.constBegin() );
+
+ // comparing iterators between two different std::map is UB (and raises an
+ // assertion failure with MSVC debug-mode iterators), so we compare the
+ // elements' addresses.
+ QVERIFY(&map.constBegin().key() != &map2.constBegin().key());
+ QVERIFY(&map.constBegin().value() != &map2.constBegin().value());
}
void tst_QMap::firstLast()
@@ -1836,12 +1841,6 @@ void tst_QMap::equal_range()
QCOMPARE(map.count(1), 2);
}
-template <class T>
-const T &const_(const T &t)
-{
- return t;
-}
-
void tst_QMap::insert()
{
QMap<QString, float> map;
diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp
index 08b7afae04..12fc2f8e43 100644
--- a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp
+++ b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp
@@ -122,7 +122,7 @@ void tst_QMessageAuthenticationCode::result_incremental()
QFETCH(QByteArray, message);
QFETCH(QByteArray, code);
- int index = message.length() / 2;
+ int index = message.size() / 2;
QByteArray leftPart(message.mid(0, index));
QByteArray rightPart(message.mid(index));
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp
index e72bf34581..97c5ea1f57 100644
--- a/tests/auto/corelib/tools/qset/tst_qset.cpp
+++ b/tests/auto/corelib/tools/qset/tst_qset.cpp
@@ -8,7 +8,7 @@
int toNumber(const QString &str)
{
int res = 0;
- for (int i = 0; i < str.length(); ++i)
+ for (int i = 0; i < str.size(); ++i)
res = (res * 10) + str[i].digitValue();
return res;
}
@@ -139,44 +139,44 @@ void tst_QSet::size()
QSet<int> set;
QVERIFY(set.size() == 0);
QVERIFY(set.isEmpty());
- QVERIFY(set.count() == set.size());
+ QVERIFY(set.size() == set.size());
QVERIFY(set.isEmpty() == set.empty());
QVERIFY(!set.isDetached());
set.insert(1);
QVERIFY(set.size() == 1);
QVERIFY(!set.isEmpty());
- QVERIFY(set.count() == set.size());
+ QVERIFY(set.size() == set.size());
QVERIFY(set.isEmpty() == set.empty());
set.insert(1);
QVERIFY(set.size() == 1);
QVERIFY(!set.isEmpty());
- QVERIFY(set.count() == set.size());
+ QVERIFY(set.size() == set.size());
QVERIFY(set.isEmpty() == set.empty());
set.insert(2);
QVERIFY(set.size() == 2);
QVERIFY(!set.isEmpty());
- QVERIFY(set.count() == set.size());
+ QVERIFY(set.size() == set.size());
QVERIFY(set.isEmpty() == set.empty());
set.remove(1);
QVERIFY(set.size() == 1);
QVERIFY(!set.isEmpty());
- QVERIFY(set.count() == set.size());
+ QVERIFY(set.size() == set.size());
QVERIFY(set.isEmpty() == set.empty());
set.remove(1);
QVERIFY(set.size() == 1);
QVERIFY(!set.isEmpty());
- QVERIFY(set.count() == set.size());
+ QVERIFY(set.size() == set.size());
QVERIFY(set.isEmpty() == set.empty());
set.remove(2);
QVERIFY(set.size() == 0);
QVERIFY(set.isEmpty());
- QVERIFY(set.count() == set.size());
+ QVERIFY(set.size() == set.size());
QVERIFY(set.isEmpty() == set.empty());
}
@@ -1011,7 +1011,7 @@ void tst_QSet::makeSureTheComfortFunctionsCompile()
void tst_QSet::initializerList()
{
QSet<int> set = {1, 1, 2, 3, 4, 5};
- QCOMPARE(set.count(), 5);
+ QCOMPARE(set.size(), 5);
QVERIFY(set.contains(1));
QVERIFY(set.contains(2));
QVERIFY(set.contains(3));
@@ -1020,7 +1020,7 @@ void tst_QSet::initializerList()
// check _which_ of the equal elements gets inserted (in the QHash/QMap case, it's the last):
const QSet<IdentityTracker> set2 = {{1, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}};
- QCOMPARE(set2.count(), 5);
+ QCOMPARE(set2.size(), 5);
const int dummy = -1;
const IdentityTracker searchKey = {1, dummy};
QCOMPARE(set2.find(searchKey)->id, 0);
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index 90609eb998..f455d7647e 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -2058,11 +2058,11 @@ void tst_QSharedPointer::threadStressTest()
base.clear();
// start threads
- for (int i = 0; i < allThreads.count(); ++i)
+ for (int i = 0; i < allThreads.size(); ++i)
if (allThreads[i]) allThreads[i]->start();
// wait for them to finish
- for (int i = 0; i < allThreads.count(); ++i)
+ for (int i = 0; i < allThreads.size(); ++i)
if (allThreads[i]) allThreads[i]->wait();
qDeleteAll(allThreads);
diff --git a/tests/auto/corelib/tools/qtaggedpointer/tst_qtaggedpointer.cpp b/tests/auto/corelib/tools/qtaggedpointer/tst_qtaggedpointer.cpp
index 752bf48d93..5cb82329d0 100644
--- a/tests/auto/corelib/tools/qtaggedpointer/tst_qtaggedpointer.cpp
+++ b/tests/auto/corelib/tools/qtaggedpointer/tst_qtaggedpointer.cpp
@@ -11,6 +11,7 @@ class tst_QTaggedPointer : public QObject
private Q_SLOTS:
void constExpr();
void construction();
+ void assignment();
void dereferenceOperator();
void pointerOperator();
void negationOperator();
@@ -80,6 +81,47 @@ void tst_QTaggedPointer::construction()
}
}
+void tst_QTaggedPointer::assignment()
+{
+ QScopedPointer<int> rawPointer(new int(5));
+ QTaggedPointer<int> p(rawPointer.data(), 0x1);
+ QTaggedPointer<int> p2(rawPointer.data(), 0x2);
+
+ QCOMPARE(p.data(), rawPointer.data());
+ QCOMPARE(p.tag(), quintptr(0x1));
+
+ QCOMPARE(p2.data(), rawPointer.data());
+ QCOMPARE(p2.tag(), quintptr(0x2));
+
+ p = nullptr;
+ QCOMPARE(p.data(), nullptr);
+ QCOMPARE(p.tag(), quintptr(0x1));
+
+ p = rawPointer.data();
+ QCOMPARE(p.data(), rawPointer.data());
+ QCOMPARE(p.tag(), quintptr(0x1));
+
+ p = {};
+ QCOMPARE(p.data(), nullptr);
+ QCOMPARE(p.tag(), quintptr(0x0));
+
+ p = p2;
+ QCOMPARE(p.data(), rawPointer.data());
+ QCOMPARE(p.tag(), quintptr(0x2));
+
+ p = nullptr;
+ QCOMPARE(p.data(), nullptr);
+ QCOMPARE(p.tag(), quintptr(0x2));
+
+ p = {};
+ QCOMPARE(p.data(), nullptr);
+ QCOMPARE(p.tag(), quintptr(0x0));
+
+ p = rawPointer.data();
+ QCOMPARE(p.data(), rawPointer.data());
+ QCOMPARE(p.tag(), quintptr(0x0));
+}
+
class AbstractClass
{
public:
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index d1a1d2c169..7d0e121b30 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -80,7 +80,7 @@ void tst_QTimeLine::range()
timeLine.setStartFrame(5000);
QVERIFY(timeLine.currentFrame() > oldValue);
timeLine.setFrameRange(0, 500);
- QTRY_VERIFY(spy.count() > 1);
+ QTRY_VERIFY(spy.size() > 1);
QVERIFY(timeLine.currentFrame() < oldValue);
}
@@ -102,7 +102,7 @@ void tst_QTimeLine::currentTime()
spy.clear();
timeLine.setCurrentTime(timeLine.duration()/2);
timeLine.setCurrentTime(timeLine.duration()/2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QCOMPARE(timeLine.currentTime(), timeLine.duration()/2);
timeLine.resume();
@@ -153,10 +153,10 @@ void tst_QTimeLine::bindableCurrentTime()
spy.clear();
QProperty<int> referenceCurrentTime(timeLine.duration() / 2);
timeLine.bindableCurrentTime().setBinding([&]() { return referenceCurrentTime.value(); });
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// setting it a second time to check that valueChanged() is emitted only once
referenceCurrentTime = timeLine.duration() / 2;
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QCOMPARE(timeLine.currentTime(), timeLine.duration() / 2);
@@ -172,7 +172,7 @@ void tst_QTimeLine::bindableCurrentTime()
spy.clear();
referenceCurrentTime = 0;
QCOMPARE(currentTimeObserver.value(), timeLine.duration());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTimeLine::duration()
@@ -236,7 +236,7 @@ void tst_QTimeLine::frameRate()
timeLine.start();
QTest::qWait(timeLine.duration()*2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- int slowCount = spy.count();
+ int slowCount = spy.size();
// Faster!!
timeLine.setUpdateInterval(1000 / 100);
@@ -245,7 +245,7 @@ void tst_QTimeLine::frameRate()
timeLine.start();
QTest::qWait(timeLine.duration()*2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count()));
+ QVERIFY2(slowCount < spy.size(), QByteArray::number(spy.size()));
}
void tst_QTimeLine::bindableUpdateInterval()
@@ -270,7 +270,7 @@ void tst_QTimeLine::bindableUpdateInterval()
timeLine.start();
QTest::qWait(timeLine.duration() * 2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- int slowCount = spy.count();
+ int slowCount = spy.size();
// Faster!!
updateIntervalReference = 1000 / 100;
@@ -279,7 +279,7 @@ void tst_QTimeLine::bindableUpdateInterval()
timeLine.start();
QTest::qWait(timeLine.duration() * 2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count()));
+ QVERIFY2(slowCount < spy.size(), QByteArray::number(spy.size()));
}
void tst_QTimeLine::value()
@@ -294,7 +294,7 @@ void tst_QTimeLine::value()
QTRY_VERIFY(timeLine.currentValue() > 0);
QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning);
QCOMPARE(timeLine.currentValue(), 1.0);
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
// Reverse should decrease the value
timeLine.setCurrentTime(100);
@@ -380,8 +380,8 @@ void tst_QTimeLine::loopCount()
loop.exec();
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(frameChangedSpy.count(), 11);
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(frameChangedSpy.size(), 11);
for (int i = 0; i < 11; ++i)
QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), (i+1) % 3);
}
@@ -390,8 +390,8 @@ void tst_QTimeLine::loopCount()
timeLine.start();
loop.exec();
- QCOMPARE(finishedSpy.count(), 2);
- QCOMPARE(frameChangedSpy.count(), 22);
+ QCOMPARE(finishedSpy.size(), 2);
+ QCOMPARE(frameChangedSpy.size(), 22);
for (int i = 11; i < 22; ++i) {
QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i+2) % 3);
}
@@ -456,8 +456,8 @@ void tst_QTimeLine::bindableLoopCount()
loop.exec();
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(frameChangedSpy.count(), 11);
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(frameChangedSpy.size(), 11);
for (int i = 0; i < 11; ++i)
QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), (i + 1) % 3);
}
@@ -466,8 +466,8 @@ void tst_QTimeLine::bindableLoopCount()
timeLine.start();
loop.exec();
- QCOMPARE(finishedSpy.count(), 2);
- QCOMPARE(frameChangedSpy.count(), 22);
+ QCOMPARE(finishedSpy.size(), 2);
+ QCOMPARE(frameChangedSpy.size(), 22);
for (int i = 11; i < 22; ++i)
QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i + 2) % 3);
}
@@ -636,14 +636,14 @@ void tst_QTimeLine::frameChanged()
timeLine.start();
QTest::qWait(timeLine.duration()/2);
QCOMPARE(timeLine.state(), QTimeLine::Running);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QTest::qWait(timeLine.duration());
if (timeLine.state() != QTimeLine::NotRunning)
QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- if (spy.count() != 1)
+ if (spy.size() != 1)
QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// Test what happens when the frames are all emitted well before duration expires.
timeLine.setUpdateInterval(5);
@@ -652,7 +652,7 @@ void tst_QTimeLine::frameChanged()
timeLine.start();
QTest::qWait(timeLine.duration()*2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- QCOMPARE(spy.count(), 10);
+ QCOMPARE(spy.size(), 10);
}
void tst_QTimeLine::stopped()
@@ -665,11 +665,11 @@ void tst_QTimeLine::stopped()
timeLine.start();
QTest::qWait(timeLine.duration()*2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
spy.clear();
timeLine.start();
timeLine.stop();
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
timeLine.setDirection(QTimeLine::Backward);
QCOMPARE(timeLine.loopCount(), 1);
}
@@ -681,13 +681,13 @@ void tst_QTimeLine::finished()
QSignalSpy spy(&timeLine, &QTimeLine::finished);
QVERIFY(spy.isValid());
timeLine.start();
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
spy.clear();
timeLine.start();
timeLine.stop();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTimeLine::isRunning()
@@ -720,7 +720,7 @@ void tst_QTimeLine::multipleTimeLines()
timeLine.start();
timeLineKiller.stop();
QTest::qWait(timeLine.duration()*2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QTimeLine::sineCurve()
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 508f709533..1ae18ca171 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -7,6 +7,8 @@
#include <qscopeguard.h>
#include <qscopedvaluerollback.h>
+#include <algorithm>
+#include <q20iterator.h>
#include <memory>
struct Tracker
@@ -40,12 +42,29 @@ public:
{ return !operator==(lhs, rhs); }
};
+class NonCopyable
+{
+ Q_DISABLE_COPY(NonCopyable)
+ int n;
+public:
+ NonCopyable() : n(0) {}
+ explicit NonCopyable(int n) : n(n) {}
+
+ friend bool operator==(const NonCopyable &lhs, const NonCopyable &rhs) noexcept
+ { return lhs.n == rhs.n; }
+ friend bool operator!=(const NonCopyable &lhs, const NonCopyable &rhs) noexcept
+ { return !operator==(lhs, rhs); }
+};
+
class tst_QVarLengthArray : public QObject
{
Q_OBJECT
private slots:
void defaultConstructor_int() { defaultConstructor<int>(); }
void defaultConstructor_QString() { defaultConstructor<QString>(); }
+ void sizeConstructor_int() { sizeConstructor<int>(); }
+ void sizeConstructor_QString() { sizeConstructor<QString>(); }
+ void sizeConstructor_NonCopyable() { sizeConstructor<NonCopyable>(); }
void append();
#if QT_DEPRECATED_SINCE(6, 3)
void prepend();
@@ -92,9 +111,13 @@ private slots:
void remove();
void erase();
+ // special cases:
+ void copesWithCopyabilityOfMoveOnlyVector(); // QTBUG-109745
private:
template <typename T>
void defaultConstructor();
+ template <typename T>
+ void sizeConstructor();
template <qsizetype N, typename T>
void move(T t1, T t2);
template <qsizetype N>
@@ -124,6 +147,31 @@ void tst_QVarLengthArray::defaultConstructor()
}
}
+template <typename T>
+void tst_QVarLengthArray::sizeConstructor()
+{
+ {
+ QVarLengthArray<T, 123> vla(0);
+ QCOMPARE(vla.size(), 0);
+ QVERIFY(vla.empty());
+ QVERIFY(vla.isEmpty());
+ QCOMPARE(vla.begin(), vla.end());
+ QCOMPARE(vla.capacity(), 123);
+ }
+ {
+ QVarLengthArray<T, 124> vla(124);
+ QCOMPARE(vla.size(), 124);
+ QVERIFY(!vla.empty());
+ QCOMPARE(vla.capacity(), 124);
+ }
+ {
+ QVarLengthArray<T, 124> vla(125);
+ QCOMPARE(vla.size(), 125);
+ QVERIFY(!vla.empty());
+ QCOMPARE_GE(vla.capacity(), 125);
+ }
+}
+
void tst_QVarLengthArray::append()
{
QVarLengthArray<QString, 2> v;
@@ -384,6 +432,17 @@ void tst_QVarLengthArray::appendCausingRealloc()
QVarLengthArray<float, 1> d(1);
for (int i=0; i<30; i++)
d.append(i);
+
+ // Regression test for QTBUG-110412:
+ constexpr qsizetype InitialCapacity = 10;
+ QVarLengthArray<float, InitialCapacity> d2(InitialCapacity);
+ std::iota(d2.begin(), d2.end(), 0.0f);
+ QCOMPARE_EQ(d2.size(), d2.capacity()); // by construction
+ float floats[1000];
+ std::iota(std::begin(floats), std::end(floats), InitialCapacity + 0.0f);
+ d2.append(floats, q20::ssize(floats));
+ QCOMPARE_EQ(d2.size(), q20::ssize(floats) + InitialCapacity);
+ QCOMPARE_GE(d2.capacity(), d2.size());
}
void tst_QVarLengthArray::appendIsStronglyExceptionSafe()
@@ -575,6 +634,12 @@ struct MyBase
bool hasMoved() const { return !wasConstructedAt(this); }
protected:
+ void swap(MyBase &other) {
+ using std::swap;
+ swap(data, other.data);
+ swap(isCopy, other.isCopy);
+ }
+
MyBase(const MyBase *data, bool isCopy)
: data(data), isCopy(isCopy) {}
@@ -649,6 +714,14 @@ struct MyMovable
return *this;
}
+ void swap(MyMovable &other) noexcept
+ {
+ MyBase::swap(other);
+ std::swap(i, other.i);
+ }
+
+ friend void swap(MyMovable &lhs, MyMovable &rhs) noexcept { lhs.swap(rhs); }
+
bool operator==(const MyMovable &other) const
{
return i == other.i;
@@ -664,6 +737,15 @@ struct MyComplex
{
return i == other.i;
}
+
+ void swap(MyComplex &other) noexcept
+ {
+ MyBase::swap(other);
+ std::swap(i, other.i);
+ }
+
+ friend void swap(MyComplex &lhs, MyComplex &rhs) noexcept { lhs.swap(rhs); }
+
char i;
};
@@ -936,8 +1018,8 @@ void tst_QVarLengthArray::count()
// tests size(), count() and length(), since they're the same thing
{
const QVarLengthArray<int> list;
- QCOMPARE(list.length(), 0);
- QCOMPARE(list.count(), 0);
+ QCOMPARE(list.size(), 0);
+ QCOMPARE(list.size(), 0);
QCOMPARE(list.size(), 0);
QVERIFY(list.isEmpty());
}
@@ -945,8 +1027,8 @@ void tst_QVarLengthArray::count()
{
QVarLengthArray<int> list;
list.append(0);
- QCOMPARE(list.length(), 1);
- QCOMPARE(list.count(), 1);
+ QCOMPARE(list.size(), 1);
+ QCOMPARE(list.size(), 1);
QCOMPARE(list.size(), 1);
QVERIFY(!list.isEmpty());
}
@@ -955,8 +1037,8 @@ void tst_QVarLengthArray::count()
QVarLengthArray<int> list;
list.append(0);
list.append(1);
- QCOMPARE(list.length(), 2);
- QCOMPARE(list.count(), 2);
+ QCOMPARE(list.size(), 2);
+ QCOMPARE(list.size(), 2);
QCOMPARE(list.size(), 2);
QVERIFY(!list.isEmpty());
}
@@ -966,8 +1048,8 @@ void tst_QVarLengthArray::count()
list.append(0);
list.append(0);
list.append(0);
- QCOMPARE(list.length(), 3);
- QCOMPARE(list.count(), 3);
+ QCOMPARE(list.size(), 3);
+ QCOMPARE(list.size(), 3);
QCOMPARE(list.size(), 3);
QVERIFY(!list.isEmpty());
}
@@ -978,23 +1060,23 @@ void tst_QVarLengthArray::count()
list.append(0);
list.append(0);
list.append(0);
- QCOMPARE(list.length(), 3);
- QCOMPARE(list.count(), 3);
+ QCOMPARE(list.size(), 3);
+ QCOMPARE(list.size(), 3);
QCOMPARE(list.size(), 3);
QVERIFY(!list.isEmpty());
list.removeLast();
- QCOMPARE(list.length(), 2);
- QCOMPARE(list.count(), 2);
+ QCOMPARE(list.size(), 2);
+ QCOMPARE(list.size(), 2);
QCOMPARE(list.size(), 2);
QVERIFY(!list.isEmpty());
list.removeLast();
- QCOMPARE(list.length(), 1);
- QCOMPARE(list.count(), 1);
+ QCOMPARE(list.size(), 1);
+ QCOMPARE(list.size(), 1);
QCOMPARE(list.size(), 1);
QVERIFY(!list.isEmpty());
list.removeLast();
- QCOMPARE(list.length(), 0);
- QCOMPARE(list.count(), 0);
+ QCOMPARE(list.size(), 0);
+ QCOMPARE(list.size(), 0);
QCOMPARE(list.size(), 0);
QVERIFY(list.isEmpty());
}
@@ -1033,16 +1115,16 @@ void tst_QVarLengthArray::first()
QCOMPARE(list.first(), 27);
list.append(1987);
QCOMPARE(list.first(), 27);
- QCOMPARE(list.length(), 3);
+ QCOMPARE(list.size(), 3);
// remove some, make sure it stays sane
list.removeLast();
QCOMPARE(list.first(), 27);
- QCOMPARE(list.length(), 2);
+ QCOMPARE(list.size(), 2);
list.removeLast();
QCOMPARE(list.first(), 27);
- QCOMPARE(list.length(), 1);
+ QCOMPARE(list.size(), 1);
}
void tst_QVarLengthArray::last()
@@ -1055,16 +1137,16 @@ void tst_QVarLengthArray::last()
QCOMPARE(list.last(), 4);
list.append(1987);
QCOMPARE(list.last(), 1987);
- QCOMPARE(list.length(), 3);
+ QCOMPARE(list.size(), 3);
// remove some, make sure it stays sane
list.removeLast();
QCOMPARE(list.last(), 4);
- QCOMPARE(list.length(), 2);
+ QCOMPARE(list.size(), 2);
list.removeLast();
QCOMPARE(list.last(), 27);
- QCOMPARE(list.length(), 1);
+ QCOMPARE(list.size(), 1);
}
void tst_QVarLengthArray::squeeze()
@@ -1108,7 +1190,7 @@ void tst_QVarLengthArray::operators()
// +=: not provided, emulate
//myvla += myvlatwo;
- for (const QString &s : qAsConst(myvlatwo))
+ for (const QString &s : std::as_const(myvlatwo))
myvla.push_back(s);
QCOMPARE(myvla, combined);
@@ -1296,6 +1378,17 @@ void tst_QVarLengthArray::insertMove()
QCOMPARE(MyBase::copyCount, 0);
{
+ MyMovable m1, m2;
+ QCOMPARE(MyBase::liveCount, 2);
+ QCOMPARE(MyBase::copyCount, 0);
+ using std::swap;
+ swap(m1, m2);
+ QCOMPARE(MyBase::liveCount, 2);
+ QCOMPARE(MyBase::movedCount, 0);
+ QCOMPARE(MyBase::copyCount, 0);
+ }
+
+ {
QVarLengthArray<MyMovable, 6> vec;
MyMovable m1;
MyMovable m2;
@@ -1640,5 +1733,26 @@ void tst_QVarLengthArray::erase()
QCOMPARE(arr, QVarLengthArray<QString>({ "val0" }));
}
+void tst_QVarLengthArray::copesWithCopyabilityOfMoveOnlyVector()
+{
+ // std::vector<move-only-type> is_copyable
+ // (https://quuxplusone.github.io/blog/2020/02/05/vector-is-copyable-except-when-its-not/)
+
+ QVarLengthArray<std::vector<std::unique_ptr<int>>, 2> vla;
+ vla.emplace_back(42);
+ vla.emplace_back(43);
+ vla.emplace_back(44); // goes to the heap
+ QCOMPARE_EQ(vla.size(), 3);
+ QCOMPARE_EQ(vla.front().size(), 42U);
+ QCOMPARE_EQ(vla.front().front(), nullptr);
+ QCOMPARE_EQ(vla.back().size(), 44U);
+
+ auto moved = std::move(vla);
+ QCOMPARE_EQ(moved.size(), 3);
+ QCOMPARE_EQ(moved.front().size(), 42U);
+ QCOMPARE_EQ(moved.front().front(), nullptr);
+ QCOMPARE_EQ(moved.back().size(), 44U);
+}
+
QTEST_APPLESS_MAIN(tst_QVarLengthArray)
#include "tst_qvarlengtharray.moc"
diff --git a/tests/auto/dbus/qdbusabstractadaptor/myobject.h b/tests/auto/dbus/qdbusabstractadaptor/myobject.h
index 3bb211c1ad..d2c4b14805 100644
--- a/tests/auto/dbus/qdbusabstractadaptor/myobject.h
+++ b/tests/auto/dbus/qdbusabstractadaptor/myobject.h
@@ -26,7 +26,7 @@ public slots:
signature = msg.signature();
path = msg.path();
value.clear();
- if (msg.arguments().count())
+ if (msg.arguments().size())
value = msg.arguments().at(0);
}
diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
index 7242e6c353..4a5e6c9d7e 100644
--- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
+++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
@@ -1840,7 +1840,7 @@ void tst_QDBusAbstractAdaptor::typeMatching()
reply = iface.call(QDBus::BlockWithGui, "retrieve" + basename);
QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
- QCOMPARE(reply.arguments().count(), 1);
+ QCOMPARE(reply.arguments().size(), 1);
const QVariant &retval = reply.arguments().at(0);
QVERIFY(compare(retval, value));
@@ -1858,7 +1858,7 @@ void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValue()
QDBusInterface remote(con.baseService(), "/", "local.Interface3", con);
QDBusMessage reply = remote.call(QDBus::BlockWithGui, "methodStringString", testString);
- QCOMPARE(reply.arguments().count(), 2);
+ QCOMPARE(reply.arguments().size(), 2);
QDBusReply<int> intreply = reply;
QVERIFY(intreply.isValid());
@@ -1881,7 +1881,7 @@ void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValuePeer()
QDBusInterface remote(QString(), "/", "local.Interface3", con);
QDBusMessage reply = remote.call(QDBus::BlockWithGui, "methodStringString", testString);
- QCOMPARE(reply.arguments().count(), 2);
+ QCOMPARE(reply.arguments().size(), 2);
QDBusReply<int> intreply = reply;
QVERIFY(intreply.isValid());
diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
index c42ec5de9d..09ce947ccc 100644
--- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
+++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
@@ -114,7 +114,7 @@ void tst_QDBusConnection::sendSignalToName()
QVERIFY(con.send(msg));
- QTRY_COMPARE(spy.args.count(), 1);
+ QTRY_COMPARE(spy.args.size(), 1);
QCOMPARE(spy.args.at(0).toString(), QString("ping"));
}
@@ -139,7 +139,7 @@ void tst_QDBusConnection::sendSignalToOtherName()
QTest::qWait(1000);
- QCOMPARE(spy.args.count(), 0);
+ QCOMPARE(spy.args.size(), 0);
}
void tst_QDBusConnection::send()
@@ -153,7 +153,7 @@ void tst_QDBusConnection::send()
QDBusMessage reply = con.call(msg);
- QCOMPARE(reply.arguments().count(), 1);
+ QCOMPARE(reply.arguments().size(), 1);
QCOMPARE(reply.arguments().at(0).typeName(), "QStringList");
QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService()));
}
@@ -172,7 +172,7 @@ void tst_QDBusConnection::sendWithGui()
QDBusMessage reply = con.call(msg, QDBus::BlockWithGui);
- QCOMPARE(reply.arguments().count(), 1);
+ QCOMPARE(reply.arguments().size(), 1);
QCOMPARE(reply.arguments().at(0).typeName(), "QStringList");
QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService()));
}
@@ -191,7 +191,7 @@ void tst_QDBusConnection::sendAsync()
"/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames");
QVERIFY(con.callWithCallback(msg, &spy, SLOT(asyncReply(QDBusMessage))));
- QTRY_COMPARE(spy.args.count(), 1);
+ QTRY_COMPARE(spy.args.size(), 1);
QCOMPARE(spy.args.value(0).typeName(), "QStringList");
QVERIFY(spy.args.at(0).toStringList().contains(con.baseService()));
}
@@ -214,7 +214,7 @@ void tst_QDBusConnection::connect()
QVERIFY(con.send(msg));
- QTRY_COMPARE(spy.args.count(), 1);
+ QTRY_COMPARE(spy.args.size(), 1);
QCOMPARE(spy.args.at(0).toString(), QString("ping"));
}
@@ -1026,7 +1026,7 @@ void tst_QDBusConnection::multipleInterfacesInQObject()
"local.BaseObject", "anotherMethod");
QDBusMessage reply = con.call(msg, QDBus::Block);
QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
- QCOMPARE(reply.arguments().count(), 0);
+ QCOMPARE(reply.arguments().size(), 0);
QVERIFY_HOOKCALLED();
}
diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
index 10edc0e322..ecaf9b33cb 100644
--- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
@@ -468,14 +468,14 @@ void tst_QDBusInterface::callMethod()
QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// verify reply
- QCOMPARE(reply.arguments().count(), 1);
+ QCOMPARE(reply.arguments().size(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -487,14 +487,14 @@ void tst_QDBusInterface::callMethod()
QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
// verify reply
- QCOMPARE(reply.arguments().count(), 1);
+ QCOMPARE(reply.arguments().size(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -515,7 +515,7 @@ void tst_QDBusInterface::invokeMethod()
QCOMPARE(MyObject::callCount, 1);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -527,7 +527,7 @@ void tst_QDBusInterface::invokeMethod()
QCOMPARE(MyObject::callCount, 2);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -549,7 +549,7 @@ void tst_QDBusInterface::invokeMethodWithReturn()
QCOMPARE(MyObject::callCount, 1);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -564,7 +564,7 @@ void tst_QDBusInterface::invokeMethodWithReturn()
QCOMPARE(MyObject::callCount, 2);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -593,7 +593,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn()
QCOMPARE(MyObject::callCount, 1);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 2);
+ QCOMPARE(MyObject::callArgs.size(), 2);
QVariant v = MyObject::callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -618,7 +618,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn()
QCOMPARE(MyObject::callCount, 2);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 2);
+ QCOMPARE(MyObject::callArgs.size(), 2);
v = MyObject::callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -649,7 +649,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn()
QCOMPARE(MyObject::callCount, 1);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
QVariant v = MyObject::callArgs.at(0);
QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>());
QCOMPARE(qdbus_cast<QList<int> >(v), arg);
@@ -663,7 +663,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn()
QCOMPARE(MyObject::callCount, 2);
// verify what the callee received
- QCOMPARE(MyObject::callArgs.count(), 1);
+ QCOMPARE(MyObject::callArgs.size(), 1);
v = MyObject::callArgs.at(0);
QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>());
QCOMPARE(qdbus_cast<QList<int> >(v), arg2);
@@ -703,14 +703,14 @@ void tst_QDBusInterface::callMethodPeer()
// verify what the callee received
QVariantList callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("foo"));
// verify reply
- QCOMPARE(reply.arguments().count(), 1);
+ QCOMPARE(reply.arguments().size(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -723,14 +723,14 @@ void tst_QDBusInterface::callMethodPeer()
// verify what the callee received
callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
QCOMPARE(dv.variant().toString(), QString("bar"));
// verify reply
- QCOMPARE(reply.arguments().count(), 1);
+ QCOMPARE(reply.arguments().size(), 1);
v = reply.arguments().at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -752,7 +752,7 @@ void tst_QDBusInterface::invokeMethodPeer()
// verify what the callee received
QVariantList callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -765,7 +765,7 @@ void tst_QDBusInterface::invokeMethodPeer()
// verify what the callee received
callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -788,7 +788,7 @@ void tst_QDBusInterface::invokeMethodWithReturnPeer()
// verify what the callee received
QVariantList callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -804,7 +804,7 @@ void tst_QDBusInterface::invokeMethodWithReturnPeer()
// verify what the callee received
callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -834,7 +834,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturnPeer()
// verify what the callee received
QVariantList callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 2);
+ QCOMPARE(callArgs.size(), 2);
QVariant v = callArgs.at(0);
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -860,7 +860,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturnPeer()
// verify what the callee received
callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 2);
+ QCOMPARE(callArgs.size(), 2);
v = callArgs.at(0);
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().userType(), QMetaType::QString);
@@ -892,7 +892,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturnPeer()
// verify what the callee received
QVariantList callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
QVariant v = callArgs.at(0);
QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>());
QCOMPARE(qdbus_cast<QList<int> >(v), arg);
@@ -907,7 +907,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturnPeer()
// verify what the callee received
callArgs = callArgsPeer();
- QCOMPARE(callArgs.count(), 1);
+ QCOMPARE(callArgs.size(), 1);
v = callArgs.at(0);
QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>());
QCOMPARE(qdbus_cast<QList<int> >(v), arg2);
diff --git a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp
index f5f72de07a..7ea5958805 100644
--- a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp
+++ b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp
@@ -137,7 +137,7 @@ void tst_QDBusLocalCalls::makeCalls()
QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage));
QVariantList replyArgs = replyMsg.arguments();
- QCOMPARE(replyArgs.count(), 1);
+ QCOMPARE(replyArgs.size(), 1);
QCOMPARE(replyArgs.at(0), value);
}
@@ -152,7 +152,7 @@ void tst_QDBusLocalCalls::makeCallsVariant()
QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage));
QVariantList replyArgs = replyMsg.arguments();
- QCOMPARE(replyArgs.count(), 1);
+ QCOMPARE(replyArgs.size(), 1);
const QVariant &reply = replyArgs.at(0);
QCOMPARE(reply.userType(), qMetaTypeId<QDBusVariant>());
@@ -169,7 +169,7 @@ void tst_QDBusLocalCalls::makeCallsTwoRets()
QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage));
QVariantList replyArgs = replyMsg.arguments();
- QCOMPARE(replyArgs.count(), 2);
+ QCOMPARE(replyArgs.size(), 2);
QCOMPARE(replyArgs.at(0).toString(), QString::fromLatin1("One"));
QCOMPARE(replyArgs.at(1).toString(), QString::fromLatin1("Two"));
}
@@ -189,7 +189,7 @@ void tst_QDBusLocalCalls::makeCallsComplex()
QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage));
QVariantList replyArgs = replyMsg.arguments();
- QCOMPARE(replyArgs.count(), 1);
+ QCOMPARE(replyArgs.size(), 1);
const QVariant &reply = replyArgs.at(0);
QCOMPARE(reply.userType(), qMetaTypeId<QDBusArgument>());
QCOMPARE(qdbus_cast<QList<int> >(reply), value);
diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h
index 71dca905c7..e0e82af706 100644
--- a/tests/auto/dbus/qdbusmarshall/common.h
+++ b/tests/auto/dbus/qdbusmarshall/common.h
@@ -334,7 +334,7 @@ bool compare(const QDBusVariant &s1, const QDBusVariant &s2)
template<typename T>
bool compare(const QList<T> &l1, const QList<T> &l2)
{
- if (l1.count() != l2.count())
+ if (l1.size() != l2.size())
return false;
typename QList<T>::ConstIterator it1 = l1.constBegin();
@@ -349,7 +349,7 @@ bool compare(const QList<T> &l1, const QList<T> &l2)
template<typename Key, typename T>
bool compare(const QMap<Key, T> &m1, const QMap<Key, T> &m2)
{
- if (m1.count() != m2.size())
+ if (m1.size() != m2.size())
return false;
typename QMap<Key, T>::ConstIterator i1 = m1.constBegin();
typename QMap<Key, T>::ConstIterator end = m1.constEnd();
diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
index d3d4292563..fe9ff866f3 100644
--- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -757,9 +757,9 @@ void tst_QDBusMarshall::sendBasic()
qPrintable(reply.errorName() + ": " + reply.errorMessage()));
//qDebug() << reply;
- QCOMPARE(reply.arguments().count(), msg.arguments().count());
+ QCOMPARE(reply.arguments().size(), msg.arguments().size());
QTEST(reply.signature(), "sig");
- for (int i = 0; i < reply.arguments().count(); ++i) {
+ for (int i = 0; i < reply.arguments().size(); ++i) {
QVERIFY(compare(reply.arguments().at(i), msg.arguments().at(i)));
//printf("\n! %s\n* %s\n", qPrintable(qDBusArgumentToString(reply.arguments().at(i))), qPrintable(stringResult));
QCOMPARE(QDBusUtil::argumentToString(reply.arguments().at(i)), stringResult);
@@ -781,9 +781,9 @@ void tst_QDBusMarshall::sendVariant()
QDBusMessage reply = con.call(msg);
// qDebug() << reply;
- QCOMPARE(reply.arguments().count(), msg.arguments().count());
+ QCOMPARE(reply.arguments().size(), msg.arguments().size());
QCOMPARE(reply.signature(), QString("v"));
- for (int i = 0; i < reply.arguments().count(); ++i)
+ for (int i = 0; i < reply.arguments().size(); ++i)
QVERIFY(compare(reply.arguments().at(i), msg.arguments().at(i)));
}
@@ -1205,7 +1205,7 @@ void tst_QDBusMarshall::receiveUnknownType()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(spy.list.size(), 1);
- QCOMPARE(spy.list.at(0).arguments().count(), 1);
+ QCOMPARE(spy.list.at(0).arguments().size(), 1);
QFETCH(int, receivedTypeId);
//qDebug() << spy.list.at(0).arguments().at(0).typeName();
QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId);
diff --git a/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
index c2df3bc678..609e7f1c6f 100644
--- a/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
+++ b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
@@ -245,7 +245,14 @@ void tst_QDBusMetaType::initTestCase()
qDBusRegisterMetaType<QList<Struct3> >();
qDBusRegisterMetaType<QList<Struct4> >();
+#ifdef Q_CC_GNU_ONLY
+ // GCC has a defect/extension (depending on your point of view) that allows
+ // a template class with defaulted template parameters to match a Template
+ // Template Parameter (TTP) with fewer template arguments. The call below
+ // tries to use the template<template <typename> class Container, ...>
+ // template functions qdbusargument.h
qDBusRegisterMetaType<std::vector<Struct1> >();
+#endif
qDBusRegisterMetaType<Invalid0>();
qDBusRegisterMetaType<Invalid1>();
@@ -307,7 +314,9 @@ void tst_QDBusMetaType::dynamicTypes_data()
QTest::newRow("Struct1") << qMetaTypeId<Struct1>() << "(s)";
QTest::newRow("QList<Struct1>") << qMetaTypeId<QList<Struct1> >() << "a(s)";
+#ifdef Q_CC_GNU_ONLY
QTest::newRow("std::vector<Struct1>") << qMetaTypeId<std::vector<Struct1> >() << "a(s)";
+#endif
QTest::newRow("Struct2") << qMetaTypeId<Struct2>() << "(sos)";
QTest::newRow("QList<Struct2>") << qMetaTypeId<QList<Struct2>>() << "a(sos)";
diff --git a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
index f8f272ab08..4bcee5cada 100644
--- a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
+++ b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
@@ -157,7 +157,7 @@ void tst_QDBusPendingCall::waitForFinished()
QCOMPARE(reply.signature(), QString("as"));
const QVariantList args = ac.reply().arguments();
- QCOMPARE(args.count(), 1);
+ QCOMPARE(args.size(), 1);
const QVariant &arg = args.at(0);
QCOMPARE(arg.userType(), QMetaType::QStringList);
diff --git a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
index 6c80334a5c..7ac2c6690e 100644
--- a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
+++ b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
@@ -99,12 +99,12 @@ void tst_QDBusServiceWatcher::watchForCreation()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.size(), 1);
QCOMPARE(spyR.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyU.count(), 0);
+ QCOMPARE(spyU.size(), 0);
- QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.size(), 1);
QCOMPARE(spyO.at(0).at(0).toString(), registeredName);
QVERIFY(spyO.at(0).at(1).toString().isEmpty());
QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
@@ -122,12 +122,12 @@ void tst_QDBusServiceWatcher::watchForCreation()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.size(), 1);
QCOMPARE(spyR.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyU.count(), 0);
+ QCOMPARE(spyU.size(), 0);
- QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.size(), 1);
QCOMPARE(spyO.at(0).at(0).toString(), registeredName);
QVERIFY(spyO.at(0).at(1).toString().isEmpty());
QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
@@ -163,12 +163,12 @@ void tst_QDBusServiceWatcher::watchForDisappearance()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 0);
+ QCOMPARE(spyR.size(), 0);
- QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.size(), 1);
QCOMPARE(spyU.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.size(), 1);
QCOMPARE(spyO.at(0).at(0).toString(), registeredName);
QCOMPARE(spyO.at(0).at(1).toString(), con.baseService());
QVERIFY(spyO.at(0).at(2).toString().isEmpty());
@@ -197,12 +197,12 @@ void tst_QDBusServiceWatcher::watchForDisappearanceUniqueConnection()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 0);
+ QCOMPARE(spyR.size(), 0);
- QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.size(), 1);
QCOMPARE(spyU.at(0).at(0).toString(), watchedName);
- QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.size(), 1);
QCOMPARE(spyO.at(0).at(0).toString(), watchedName);
QCOMPARE(spyO.at(0).at(1).toString(), watchedName);
QVERIFY(spyO.at(0).at(2).toString().isEmpty());
@@ -234,12 +234,12 @@ void tst_QDBusServiceWatcher::watchForOwnerChange()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.size(), 1);
QCOMPARE(spyR.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyU.count(), 0);
+ QCOMPARE(spyU.size(), 0);
- QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.size(), 1);
QCOMPARE(spyO.at(0).at(0).toString(), registeredName);
QVERIFY(spyO.at(0).at(1).toString().isEmpty());
QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
@@ -257,13 +257,13 @@ void tst_QDBusServiceWatcher::watchForOwnerChange()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.size(), 1);
QCOMPARE(spyR.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.size(), 1);
QCOMPARE(spyU.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyO.count(), 2);
+ QCOMPARE(spyO.size(), 2);
QCOMPARE(spyO.at(0).at(0).toString(), registeredName);
QCOMPARE(spyO.at(0).at(1).toString(), con.baseService());
QVERIFY(spyO.at(0).at(2).toString().isEmpty());
@@ -298,12 +298,12 @@ void tst_QDBusServiceWatcher::modeChange()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.size(), 1);
QCOMPARE(spyR.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyU.count(), 0);
+ QCOMPARE(spyU.size(), 0);
- QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.size(), 1);
QCOMPARE(spyO.at(0).at(0).toString(), registeredName);
QVERIFY(spyO.at(0).at(1).toString().isEmpty());
QCOMPARE(spyO.at(0).at(2).toString(), con.baseService());
@@ -321,12 +321,12 @@ void tst_QDBusServiceWatcher::modeChange()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 0);
+ QCOMPARE(spyR.size(), 0);
- QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.size(), 1);
QCOMPARE(spyU.at(0).at(0).toString(), registeredName);
- QCOMPARE(spyO.count(), 1);
+ QCOMPARE(spyO.size(), 1);
QCOMPARE(spyO.at(0).at(0).toString(), registeredName);
QCOMPARE(spyO.at(0).at(1).toString(), con.baseService());
QVERIFY(spyO.at(0).at(2).toString().isEmpty());
@@ -377,9 +377,9 @@ void tst_QDBusServiceWatcher::setConnection()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.size(), 1);
QCOMPARE(spyR.at(0).at(0).toString(), serviceName);
- QCOMPARE(spyU.count(), 0);
+ QCOMPARE(spyU.size(), 0);
// is the system bus available?
if (!QDBusConnection::systemBus().isConnected())
@@ -400,9 +400,9 @@ void tst_QDBusServiceWatcher::setConnection()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spyR.count(), 0);
+ QCOMPARE(spyR.size(), 0);
- QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.size(), 1);
QCOMPARE(spyU.at(0).at(0).toString(), watchedName);
}
diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
index 2c53c4a403..536520ea0d 100644
--- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
+++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
@@ -173,7 +173,7 @@ void tst_QDBusType::isValidFixedType()
QFETCH(QString, data);
QFETCH(bool, result);
QFETCH(bool, isValid);
- QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types");
+ QVERIFY2(data.size() == 1, "Test is malformed, this function must test only one-letter types");
QVERIFY(isValid || (!isValid && !result));
int type = data.at(0).unicode();
@@ -195,7 +195,7 @@ void tst_QDBusType::isValidBasicType()
QFETCH(QString, data);
QFETCH(bool, result);
QFETCH(bool, isValid);
- QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types");
+ QVERIFY2(data.size() == 1, "Test is malformed, this function must test only one-letter types");
QVERIFY(isValid || (!isValid && !result));
int type = data.at(0).unicode();
diff --git a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp
index 3e01d18ffd..512eb35f45 100644
--- a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp
+++ b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp
@@ -106,9 +106,9 @@ void tst_QDBusXmlParser::parsing_common(const QString &xmlData)
QFETCH(int, objectCount);
QFETCH(int, annotationCount);
QFETCH(QStringList, introspection);
- QCOMPARE(obj.interfaces.count(), interfaceCount);
- QCOMPARE(obj.childObjects.count(), objectCount);
- QCOMPARE(QDBusIntrospection::parseInterface(xmlData).annotations.count(), annotationCount);
+ QCOMPARE(obj.interfaces.size(), interfaceCount);
+ QCOMPARE(obj.childObjects.size(), objectCount);
+ QCOMPARE(QDBusIntrospection::parseInterface(xmlData).annotations.size(), annotationCount);
QDBusIntrospection::Interfaces ifaces = QDBusIntrospection::parseInterfaces(xmlData);
@@ -327,7 +327,7 @@ void tst_QDBusXmlParser::methods()
QFETCH(MethodMap, methodMap);
MethodMap parsedMap = iface.methods;
- QCOMPARE(parsedMap.count(), methodMap.count());
+ QCOMPARE(parsedMap.size(), methodMap.size());
QCOMPARE(parsedMap, methodMap);
}
@@ -441,7 +441,7 @@ void tst_QDBusXmlParser::signals_()
QFETCH(SignalMap, signalMap);
SignalMap parsedMap = iface.signals_;
- QCOMPARE(signalMap.count(), parsedMap.count());
+ QCOMPARE(signalMap.size(), parsedMap.size());
QCOMPARE(signalMap, parsedMap);
}
@@ -531,7 +531,7 @@ void tst_QDBusXmlParser::properties()
QFETCH(PropertyMap, propertyMap);
PropertyMap parsedMap = iface.properties;
- QCOMPARE(propertyMap.count(), parsedMap.count());
+ QCOMPARE(propertyMap.size(), parsedMap.size());
QCOMPARE(propertyMap, parsedMap);
}
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index d04d42e0b2..898345e44a 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -3435,6 +3435,9 @@ void tst_QImage::exifInvalidData()
void tst_QImage::exifReadComments()
{
+#ifdef QT_NO_IMAGEIO_TEXT_LOADING
+ QSKIP("Reading text from image file is configured off");
+#endif
QImage image;
QVERIFY(image.load(m_prefix + "jpeg_exif_utf8_comment.jpg"));
QVERIFY(!image.isNull());
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index b01eb83089..42a2efe5a8 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -487,8 +487,11 @@ void tst_QImageReader::setScaledClipRect()
QImageReader originalReader(prefix + fileName);
originalReader.setScaledSize(QSize(300, 300));
QImage originalImage = originalReader.read();
- if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive) && format.contains("svg"))
- QEXPECT_FAIL("", "This fails on Wayland, see QTBUG-100917.", Abort);
+ if (format.contains("svg")) {
+ // rendering of subrect may yield slight rounding differences, truncate them away
+ image.convertTo(QImage::Format_RGB444);
+ originalImage.convertTo(QImage::Format_RGB444);
+ }
QCOMPARE(originalImage.copy(newRect), image);
}
diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
index b2f9c038aa..1cf13f6f9c 100644
--- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp
+++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
@@ -156,7 +156,7 @@ void tst_QMovie::playMovie()
movie.start();
QCOMPARE(movie.state(), QMovie::Running);
QTestEventLoop::instance().enterLoop(2);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
QCOMPARE(movie.state(), QMovie::Running);
QCOMPARE(movie.currentFrameNumber(), 0);
}
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index ec724c284f..3802f8afc6 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -173,7 +173,7 @@ void tst_QFileSystemModel::rootPath()
QSignalSpy rootChanged(model.data(), &QFileSystemModel::rootPathChanged);
QModelIndex root = model->setRootPath(model->rootPath());
root = model->setRootPath("this directory shouldn't exist");
- QCOMPARE(rootChanged.count(), 0);
+ QCOMPARE(rootChanged.size(), 0);
QString oldRootPath = model->rootPath();
const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
@@ -190,26 +190,26 @@ void tst_QFileSystemModel::rootPath()
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), QString(documentPath));
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? 0 : 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? 0 : 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
model->setRootPath(QDir::rootPath());
- int oldCount = rootChanged.count();
+ int oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), documentPath);
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
QDir newdir = documentPath;
if (newdir.cdUp()) {
- oldCount = rootChanged.count();
+ oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/.."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), newdir.path());
- QCOMPARE(rootChanged.count(), oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), newdir.path());
}
@@ -403,8 +403,8 @@ void tst_QFileSystemModel::rowCount()
QModelIndex root = prepareTestModelRoot(model.data(), flatDirTestPath, &spy2, &spy3);
QVERIFY(root.isValid());
- QVERIFY(spy2 && spy2->count() > 0);
- QVERIFY(spy3 && spy3->count() > 0);
+ QVERIFY(spy2 && spy2->size() > 0);
+ QVERIFY(spy3 && spy3->size() > 0);
}
void tst_QFileSystemModel::rowsInserted_data()
@@ -446,7 +446,7 @@ void tst_QFileSystemModel::rowsInserted()
QVERIFY(createFiles(model.data(), tmp, files, 5));
QTRY_COMPARE(model->rowCount(root), oldCount + count);
int totalRowsInserted = 0;
- for (int i = 0; i < spy0.count(); ++i) {
+ for (int i = 0; i < spy0.size(); ++i) {
int start = spy0[i].value(1).toInt();
int end = spy0[i].value(2).toInt();
totalRowsInserted += end - start + 1;
@@ -455,24 +455,24 @@ void tst_QFileSystemModel::rowsInserted()
const QString expected = ascending == Qt::AscendingOrder ? QStringLiteral("j") : QStringLiteral("b");
QTRY_COMPARE(lastEntry(root), expected);
- if (spy0.count() > 0) {
+ if (spy0.size() > 0) {
if (count == 0)
- QCOMPARE(spy0.count(), 0);
+ QCOMPARE(spy0.size(), 0);
else
- QVERIFY(spy0.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
}
- if (count == 0) QCOMPARE(spy1.count(), 0); else QVERIFY(spy1.count() >= 1);
+ if (count == 0) QCOMPARE(spy1.size(), 0); else QVERIFY(spy1.size() >= 1);
QVERIFY(createFiles(model.data(), tmp, QStringList(".hidden_file"), 5 + count));
if (count != 0)
- QTRY_VERIFY(spy0.count() >= 1);
+ QTRY_VERIFY(spy0.size() >= 1);
else
- QTRY_COMPARE(spy0.count(), 0);
+ QTRY_COMPARE(spy0.size(), 0);
if (count != 0)
- QTRY_VERIFY(spy1.count() >= 1);
+ QTRY_VERIFY(spy1.size() >= 1);
else
- QTRY_COMPARE(spy1.count(), 0);
+ QTRY_COMPARE(spy1.size(), 0);
}
void tst_QFileSystemModel::rowsRemoved_data()
@@ -503,14 +503,14 @@ void tst_QFileSystemModel::rowsRemoved()
}
for (int i = 0 ; i < 10; ++i) {
if (count != 0) {
- if (i == 10 || spy0.count() != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ if (i == 10 || spy0.size() != 0) {
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
}
} else {
- if (i == 10 || spy0.count() == 0) {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ if (i == 10 || spy0.size() == 0) {
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
QStringList lst;
@@ -529,11 +529,11 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + QLatin1String("/.c")));
if (count != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
} else {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
@@ -565,7 +565,7 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
+ if (count != 0) QVERIFY(spy.size() >= 1); else QCOMPARE(spy.size(), 0);
}
void tst_QFileSystemModel::filters_data()
@@ -620,7 +620,7 @@ void tst_QFileSystemModel::filters()
QFETCH(QStringList, nameFilters);
QFETCH(int, rowCount);
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
model->setNameFilters(nameFilters);
model->setNameFilterDisables(false);
model->setFilter(dirFilters);
@@ -632,12 +632,12 @@ void tst_QFileSystemModel::filters()
QDir xFactor(tmp);
QStringList dirEntries;
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
dirEntries = xFactor.entryList(nameFilters, dirFilters);
else
dirEntries = xFactor.entryList(dirFilters);
- QCOMPARE(dirEntries.count(), rowCount);
+ QCOMPARE(dirEntries.size(), rowCount);
QStringList modelEntries;
@@ -649,7 +649,7 @@ void tst_QFileSystemModel::filters()
QCOMPARE(dirEntries, modelEntries);
#ifdef Q_OS_LINUX
- if (files.count() >= 3 && rowCount >= 3 && rowCount != 5) {
+ if (files.size() >= 3 && rowCount >= 3 && rowCount != 5) {
QString fileName1 = (tmp + '/' + files.at(0));
QString fileName2 = (tmp + '/' + files.at(1));
QString fileName3 = (tmp + '/' + files.at(2));
@@ -748,7 +748,7 @@ void tst_QFileSystemModel::setData()
tmpIdx = model->index(tmp);
model->fetchMore(tmpIdx);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
QModelIndex idx = model->index(tmp + '/' + oldFileName);
QCOMPARE(idx.isValid(), true);
@@ -758,7 +758,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(model->setData(idx, newFileName), success);
model->setReadOnly(true);
if (success) {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName);
QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName);
@@ -767,7 +767,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(arguments.at(2).toString(), newFileName);
QCOMPARE(QFile::rename(tmp + '/' + newFileName, tmp + '/' + oldFileName), true);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
// cleanup
if (!subdirName.isEmpty())
QVERIFY(QDir(tmp).removeRecursively());
@@ -862,7 +862,7 @@ void tst_QFileSystemModel::sort()
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
if (fileDialogMode) {
- QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count());
+ QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.size());
// File dialog Mode means sub trees are not sorted, only the current root.
// There's no way we can check that the sub tree is "not sorted"; just check if it
// has the same contents of the expected list
@@ -997,7 +997,7 @@ void tst_QFileSystemModel::caseSensitivity()
QStringList paths;
QModelIndexList indexes;
QCOMPARE(model->rowCount(root), 0);
- for (int i = 0; i < files.count(); ++i) {
+ for (int i = 0; i < files.size(); ++i) {
const QString path = tmp + '/' + files.at(i);
const QModelIndex index = model->index(path);
QVERIFY(index.isValid());
@@ -1007,7 +1007,7 @@ void tst_QFileSystemModel::caseSensitivity()
if (!QFileSystemEngine::isCaseSensitive()) {
// QTBUG-31103, QTBUG-64147: Verify that files can be accessed by paths with fLipPeD case.
- for (int i = 0; i < paths.count(); ++i) {
+ for (int i = 0; i < paths.size(); ++i) {
const QModelIndex flippedCaseIndex = model->index(flipCase(paths.at(i)));
QCOMPARE(indexes.at(i), flippedCaseIndex);
}
diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
index 40834459e5..6f42c45821 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
@@ -757,10 +757,10 @@ void tst_QStandardItem::takeColumn()
QList<QStandardItem *> taken = item.takeColumn(column);
if (expectSuccess) {
- QCOMPARE(taken.count(), item.rowCount());
+ QCOMPARE(taken.size(), item.rowCount());
QCOMPARE(item.columnCount(), columns - 1);
int index = column;
- for (int i = 0; i < taken.count(); ++i) {
+ for (int i = 0; i < taken.size(); ++i) {
QCOMPARE(taken.at(i), originalChildren.takeAt(index));
index += item.columnCount();
}
@@ -818,10 +818,10 @@ void tst_QStandardItem::takeRow()
QList<QStandardItem *> taken = item.takeRow(row);
if (expectSuccess) {
- QCOMPARE(taken.count(), item.columnCount());
+ QCOMPARE(taken.size(), item.columnCount());
QCOMPARE(item.rowCount(), rows - 1);
int index = row * columns;
- for (int i = 0; i < taken.count(); ++i) {
+ for (int i = 0; i < taken.size(); ++i) {
QCOMPARE(taken.at(i), originalChildren.takeAt(index));
}
index = 0;
@@ -984,8 +984,8 @@ void tst_QStandardItem::sortChildren()
QCOMPARE(two->child(1)->text(), QLatin1String("e"));
QCOMPARE(two->child(2)->text(), QLatin1String("f"));
- QCOMPARE(layoutAboutToBeChangedSpy.count(), (x == 0) ? 0 : 3);
- QCOMPARE(layoutChangedSpy.count(), (x == 0) ? 0 : 3);
+ QCOMPARE(layoutAboutToBeChangedSpy.size(), (x == 0) ? 0 : 3);
+ QCOMPARE(layoutChangedSpy.size(), (x == 0) ? 0 : 3);
if (x == 0)
delete item;
@@ -1001,7 +1001,7 @@ public:
int type() const override { return QStandardItem::UserType + 1; }
bool operator<(const QStandardItem &other) const override {
- return text().length() < other.text().length();
+ return text().size() < other.text().size();
}
using QStandardItem::clone;
@@ -1027,8 +1027,8 @@ void tst_QStandardItem::subclassing()
QSignalSpy itemChangedSpy(&model, &QStandardItemModel::itemChanged);
item->emitDataChanged();
- QCOMPARE(itemChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.at(0).count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QStandardItem*>(itemChangedSpy.at(0).at(0)), item);
CustomItem *child0 = new CustomItem("cc");
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
index ea9077e2a0..07fc074577 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -448,16 +448,16 @@ void tst_QStandardItemModel::setHeaderData()
for (int i = 0; i < count; ++i) {
QString customString = QString("custom") + QString::number(i);
QCOMPARE(m_model->setHeaderData(i, orient, customString), true);
- QCOMPARE(headerDataChangedSpy.count(), 1);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
+ QCOMPARE(dataChangedSpy.size(), 0);
QVariantList args = headerDataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<Qt::Orientation>(args.at(0)), orient);
QCOMPARE(args.at(1).toInt(), i);
QCOMPARE(args.at(2).toInt(), i);
QCOMPARE(m_model->headerData(i, orient).toString(), customString);
QCOMPARE(m_model->setHeaderData(i, orient, customString), true);
- QCOMPARE(headerDataChangedSpy.count(), 0);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(headerDataChangedSpy.size(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
}
//check read from invalid sections
@@ -761,9 +761,9 @@ void tst_QStandardItemModel::clear()
model.clear();
- QCOMPARE(modelResetSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), 0);
- QCOMPARE(rowsRemovedSpy.count(), 0);
+ QCOMPARE(modelResetSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 0);
+ QCOMPARE(rowsRemovedSpy.size(), 0);
QCOMPARE(model.index(0, 0), QModelIndex());
QCOMPARE(model.columnCount(), 0);
QCOMPARE(model.rowCount(), 0);
@@ -805,8 +805,8 @@ void tst_QStandardItemModel::sort()
QFETCH(QStringList, expected);
// prepare model
QStandardItemModel model;
- QVERIFY(model.insertRows(0, initial.count(), QModelIndex()));
- QCOMPARE(model.rowCount(QModelIndex()), initial.count());
+ QVERIFY(model.insertRows(0, initial.size(), QModelIndex()));
+ QCOMPARE(model.rowCount(QModelIndex()), initial.size());
model.insertColumns(0, 1, QModelIndex());
QCOMPARE(model.columnCount(QModelIndex()), 1);
for (int row = 0; row < model.rowCount(QModelIndex()); ++row) {
@@ -822,8 +822,8 @@ void tst_QStandardItemModel::sort()
// sort
model.sort(0, sortOrder);
- QCOMPARE(layoutAboutToBeChangedSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), 1);
+ QCOMPARE(layoutAboutToBeChangedSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 1);
// make sure the model is sorted
for (int row = 0; row < model.rowCount(QModelIndex()); ++row) {
@@ -867,7 +867,7 @@ void tst_QStandardItemModel::sortRole()
QFETCH(QVariantList, expectedData);
QStandardItemModel model;
- for (int i = 0; i < initialText.count(); ++i) {
+ for (int i = 0; i < initialText.size(); ++i) {
QStandardItem *item = new QStandardItem;
item->setText(initialText.at(i));
item->setData(initialData.at(i), Qt::UserRole);
@@ -875,7 +875,7 @@ void tst_QStandardItemModel::sortRole()
}
model.setSortRole(sortRole);
model.sort(0, sortOrder);
- for (int i = 0; i < expectedText.count(); ++i) {
+ for (int i = 0; i < expectedText.size(); ++i) {
QStandardItem *item = model.item(i);
QCOMPARE(item->text(), expectedText.at(i));
QCOMPARE(item->data(Qt::UserRole), expectedData.at(i));
@@ -906,15 +906,15 @@ void tst_QStandardItemModel::findItems()
model.item(1)->appendRow(new QStandardItem(QLatin1String("foo")));
QList<QStandardItem*> matches;
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, 0);
- QCOMPARE(matches.count(), 2);
+ QCOMPARE(matches.size(), 2);
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly, 0);
- QCOMPARE(matches.count(), 1);
+ QCOMPARE(matches.size(), 1);
matches = model.findItems(QLatin1String("food"), Qt::MatchExactly|Qt::MatchRecursive, 0);
- QCOMPARE(matches.count(), 0);
+ QCOMPARE(matches.size(), 0);
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, -1);
- QCOMPARE(matches.count(), 0);
+ QCOMPARE(matches.size(), 0);
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, 1);
- QCOMPARE(matches.count(), 0);
+ QCOMPARE(matches.size(), 0);
}
void tst_QStandardItemModel::getSetHeaderItem()
@@ -1061,9 +1061,9 @@ void tst_QStandardItemModel::getSetItemData()
QSignalSpy modelDataChangedSpy(
&model, &QStandardItemModel::dataChanged);
QVERIFY(model.setItemData(idx, roles));
- QCOMPARE(modelDataChangedSpy.count(), 1);
+ QCOMPARE(modelDataChangedSpy.size(), 1);
QVERIFY(model.setItemData(idx, roles));
- QCOMPARE(modelDataChangedSpy.count(), 1); //it was already changed once
+ QCOMPARE(modelDataChangedSpy.size(), 1); //it was already changed once
QCOMPARE(model.itemData(idx), roles);
}
@@ -1127,12 +1127,12 @@ void tst_QStandardItemModel::setHeaderLabels()
model.setHorizontalHeaderLabels(labels);
else
model.setVerticalHeaderLabels(labels);
- for (int i = 0; i < expectedLabels.count(); ++i)
+ for (int i = 0; i < expectedLabels.size(); ++i)
QCOMPARE(model.headerData(i, orientation).toString(), expectedLabels.at(i));
- QCOMPARE(columnsInsertedSpy.count(),
- (orientation == Qt::Vertical) ? 0 : labels.count() > columns);
- QCOMPARE(rowsInsertedSpy.count(),
- (orientation == Qt::Horizontal) ? 0 : labels.count() > rows);
+ QCOMPARE(columnsInsertedSpy.size(),
+ (orientation == Qt::Vertical) ? 0 : labels.size() > columns);
+ QCOMPARE(rowsInsertedSpy.size(),
+ (orientation == Qt::Horizontal) ? 0 : labels.size() > rows);
}
void tst_QStandardItemModel::itemDataChanged()
@@ -1143,8 +1143,8 @@ void tst_QStandardItemModel::itemDataChanged()
QSignalSpy itemChangedSpy(&model, &QStandardItemModel::itemChanged);
model.setItem(0, &item);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
QModelIndex index = model.indexFromItem(&item);
QList<QVariant> args;
args = dataChangedSpy.takeFirst();
@@ -1154,8 +1154,8 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setData(QLatin1String("foo"), Qt::DisplayRole);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = dataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), index);
QCOMPARE(qvariant_cast<QModelIndex>(args.at(1)), index);
@@ -1163,12 +1163,12 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setData(item.data(Qt::DisplayRole), Qt::DisplayRole);
- QCOMPARE(dataChangedSpy.count(), 0);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
item.setFlags(Qt::ItemIsEnabled);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = dataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), index);
QCOMPARE(qvariant_cast<QModelIndex>(args.at(1)), index);
@@ -1176,8 +1176,8 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setFlags(item.flags());
- QCOMPARE(dataChangedSpy.count(), 0);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
}
void tst_QStandardItemModel::takeHeaderItem()
@@ -1305,7 +1305,7 @@ void tst_QStandardItemModel::setNullChild()
QSignalSpy spy(&model, &QAbstractItemModel::dataChanged);
item->setChild(0, nullptr);
QCOMPARE(item->child(0), nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QStandardItemModel::deleteChild()
@@ -1317,7 +1317,7 @@ void tst_QStandardItemModel::deleteChild()
QSignalSpy spy(&model, &QAbstractItemModel::dataChanged);
delete item->child(0);
QCOMPARE(item->child(0), nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QStandardItemModel::rootItemFlags()
@@ -1558,8 +1558,8 @@ void tst_QStandardItemModel::removeRowsAndColumns()
QStringList row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',');
QStringList col_list = row_list;
QStandardItemModel model;
- for (int c = 0; c < col_list.count(); c++)
- for (int r = 0; r < row_list.count(); r++)
+ for (int c = 0; c < col_list.size(); c++)
+ for (int r = 0; r < row_list.size(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
@@ -1580,15 +1580,15 @@ void tst_QStandardItemModel::removeRowsAndColumns()
VERIFY_MODEL
QList<QStandardItem *> row_taken = model.takeRow(6);
- QCOMPARE(row_taken.count(), col_list.count());
- for (int c = 0; c < col_list.count(); c++)
+ QCOMPARE(row_taken.size(), col_list.size());
+ for (int c = 0; c < col_list.size(); c++)
QCOMPARE(row_taken[c]->text() , row_list[6] + QLatin1Char('x') + col_list[c]);
row_list.remove(6);
VERIFY_MODEL
QList<QStandardItem *> col_taken = model.takeColumn(10);
- QCOMPARE(col_taken.count(), row_list.count());
- for (int r = 0; r < row_list.count(); r++)
+ QCOMPARE(col_taken.size(), row_list.size());
+ for (int r = 0; r < row_list.size(); r++)
QCOMPARE(col_taken[r]->text() , row_list[r] + QLatin1Char('x') + col_list[10]);
col_list.remove(10);
VERIFY_MODEL
@@ -1605,8 +1605,8 @@ void tst_QStandardItemModel::itemRoleNames()
QStringList row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',');
QStringList col_list = row_list;
QStandardItemModel model;
- for (int c = 0; c < col_list.count(); c++)
- for (int r = 0; r < row_list.count(); r++)
+ for (int c = 0; c < col_list.size(); c++)
+ for (int r = 0; r < row_list.size(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
@@ -1646,7 +1646,7 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
QModelIndex index = item->index();
QCOMPARE(model.itemData(index).size(), 3);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QMap<int, QVariant> roles;
@@ -1654,21 +1654,21 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
roles.insert(Qt::UserRole + 2, 2);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
roles.insert(Qt::UserRole + 1, 1);
roles.insert(Qt::UserRole + 2, 2);
roles.insert(Qt::UserRole + 3, QVariant());
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
roles.clear();
roles.insert(Qt::UserRole + 1, 10);
roles.insert(Qt::UserRole + 3, 12);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QMap<int, QVariant> itemRoles = model.itemData(index);
QCOMPARE(itemRoles.size(), 4);
@@ -1680,13 +1680,13 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
roles.insert(Qt::UserRole + 3, 1);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
roles.clear();
roles.insert(Qt::UserRole + 3, QVariant());
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
itemRoles = model.itemData(index);
QCOMPARE(itemRoles.size(), 3);
@@ -1739,13 +1739,13 @@ void tst_QStandardItemModel::signalsOnTakeItem() // QTBUG-89145
QSignalSpy dataChangedSpy(&m, &QAbstractItemModel::dataChanged);
QStandardItem *const takenItem = m.takeItem(1, 0);
for (auto &&spy : removeSpies) {
- QCOMPARE(spy->count(), 1);
+ QCOMPARE(spy->size(), 1);
const auto spyArgs = spy->takeFirst();
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), parentIndex);
QCOMPARE(spyArgs.at(1).toInt(), 0);
QCOMPARE(spyArgs.at(2).toInt(), 1);
}
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
const auto dataChangedSpyArgs = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedSpyArgs.at(0).value<QModelIndex>(), m.index(1, 0));
QCOMPARE(dataChangedSpyArgs.at(1).value<QModelIndex>(), m.index(1, 0));
diff --git a/tests/auto/gui/kernel/qaction/tst_qaction.cpp b/tests/auto/gui/kernel/qaction/tst_qaction.cpp
index cebcf9ca5a..930cee26b8 100644
--- a/tests/auto/gui/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/gui/kernel/qaction/tst_qaction.cpp
@@ -209,11 +209,11 @@ void tst_QAction::setToolTip()
QFETCH(QStringList, values);
QFETCH(QStringList, expectedToolTips);
- QCOMPARE(properties.count(), values.count());
- QCOMPARE(properties.count(), expectedToolTips.count());
+ QCOMPARE(properties.size(), values.size());
+ QCOMPARE(properties.size(), expectedToolTips.size());
QAction action(nullptr);
- for (int i = 0; i < properties.count(); ++i) {
+ for (int i = 0; i < properties.size(); ++i) {
const auto property = properties.at(i);
const auto value = values.at(i);
const auto expectedToolTip = expectedToolTips.at(i);
@@ -272,19 +272,19 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
// test without a group
const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr));
QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered));
- QCOMPARE(spyWithoutGroup.count(), 0);
+ QCOMPARE(spyWithoutGroup.size(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
- QCOMPARE(spyWithoutGroup.count(), 1);
+ QCOMPARE(spyWithoutGroup.size(), 1);
// it is now a checkable checked action
actionWithoutGroup->setCheckable(true);
actionWithoutGroup->setChecked(true);
spyWithoutGroup.clear();
- QCOMPARE(spyWithoutGroup.count(), 0);
+ QCOMPARE(spyWithoutGroup.size(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
- QCOMPARE(spyWithoutGroup.count(), 1);
+ QCOMPARE(spyWithoutGroup.size(), 1);
}
void tst_QAction::setData() // QTBUG-62006
@@ -292,14 +292,14 @@ void tst_QAction::setData() // QTBUG-62006
QAction act(nullptr);
QSignalSpy spy(&act, &QAction::changed);
QCOMPARE(act.data(), QVariant());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
act.setData(QVariant());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
act.setData(-1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
act.setData(-1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QAction::setEnabledSetVisible()
@@ -308,22 +308,22 @@ void tst_QAction::setEnabledSetVisible()
QSignalSpy spy(&action, &QAction::enabledChanged);
QVERIFY(action.isEnabled());
QVERIFY(action.isVisible());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
action.setVisible(false);
QVERIFY(!action.isEnabled());
QVERIFY(!action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.setEnabled(false);
QVERIFY(!action.isEnabled());
QVERIFY(!action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.setVisible(true);
QVERIFY(!action.isEnabled());
QVERIFY(action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.resetEnabled();
QVERIFY(action.isEnabled());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QAction::setCheckabledSetChecked()
@@ -334,37 +334,37 @@ void tst_QAction::setCheckabledSetChecked()
QSignalSpy checkableSpy(&action, &QAction::checkableChanged);
QVERIFY(!action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 0);
- QCOMPARE(checkedSpy.count(), 0);
- QCOMPARE(checkableSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
+ QCOMPARE(checkedSpy.size(), 0);
+ QCOMPARE(checkableSpy.size(), 0);
action.setCheckable(true);
QVERIFY(action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(checkedSpy.count(), 0);
- QCOMPARE(checkableSpy.count(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(checkedSpy.size(), 0);
+ QCOMPARE(checkableSpy.size(), 1);
action.setChecked(true);
QVERIFY(action.isCheckable());
QVERIFY(action.isChecked());
- QCOMPARE(changedSpy.count(), 2);
- QCOMPARE(checkedSpy.count(), 1);
- QCOMPARE(checkableSpy.count(), 1);
+ QCOMPARE(changedSpy.size(), 2);
+ QCOMPARE(checkedSpy.size(), 1);
+ QCOMPARE(checkableSpy.size(), 1);
action.setCheckable(false);
QVERIFY(!action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 3);
- QCOMPARE(checkedSpy.count(), 2);
- QCOMPARE(checkableSpy.count(), 2);
+ QCOMPARE(changedSpy.size(), 3);
+ QCOMPARE(checkedSpy.size(), 2);
+ QCOMPARE(checkableSpy.size(), 2);
action.setCheckable(true);
QVERIFY(action.isCheckable());
QVERIFY(action.isChecked());
- QCOMPARE(changedSpy.count(), 4);
- QCOMPARE(checkedSpy.count(), 3);
- QCOMPARE(checkableSpy.count(), 3);
+ QCOMPARE(changedSpy.size(), 4);
+ QCOMPARE(checkedSpy.size(), 3);
+ QCOMPARE(checkableSpy.size(), 3);
}
QTEST_MAIN(tst_QAction)
diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
index 4163d072e0..d5150d97b1 100644
--- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
@@ -124,7 +124,7 @@ public:
operator bool() const
{
- if (m_timer.elapsed() && !m_spy.count())
+ if (m_timer.elapsed() && !m_spy.size())
return true;
m_spy.clear();
return false;
@@ -166,11 +166,11 @@ void tst_QClipboard::testSignals()
// Test the default mode signal.
clipboard->setText(text);
- QTRY_COMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(searchChangedSpy.count(), 0);
- QCOMPARE(selectionChangedSpy.count(), 0);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QTRY_COMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(searchChangedSpy.size(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Clipboard);
changedSpy.clear();
@@ -178,29 +178,29 @@ void tst_QClipboard::testSignals()
// Test the selection mode signal.
if (clipboard->supportsSelection()) {
clipboard->setText(text, QClipboard::Selection);
- QCOMPARE(selectionChangedSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QCOMPARE(selectionChangedSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Selection);
} else {
- QCOMPARE(selectionChangedSpy.count(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
}
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(searchChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(searchChangedSpy.size(), 0);
changedSpy.clear();
// Test the search mode signal.
if (clipboard->supportsFindBuffer()) {
clipboard->setText(text, QClipboard::FindBuffer);
- QCOMPARE(searchChangedSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QCOMPARE(searchChangedSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::FindBuffer);
} else {
- QCOMPARE(searchChangedSpy.count(), 0);
+ QCOMPARE(searchChangedSpy.size(), 0);
}
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
}
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX)
@@ -340,16 +340,16 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->clear(QClipboard::FindBuffer);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(spySelection.count(), 1);
+ QCOMPARE(spySelection.size(), 1);
else
- QCOMPARE(spySelection.count(), 0);
+ QCOMPARE(spySelection.size(), 0);
if (QGuiApplication::clipboard()->supportsFindBuffer())
- QCOMPARE(spyFindBuffer.count(), 1);
+ QCOMPARE(spyFindBuffer.size(), 1);
else
- QCOMPARE(spyFindBuffer.count(), 0);
+ QCOMPARE(spyFindBuffer.size(), 0);
- QTRY_COMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.size(), 1);
// an other crash test
data = new QMimeData;
@@ -376,16 +376,16 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(spySelection.count(), 1);
+ QCOMPARE(spySelection.size(), 1);
else
- QCOMPARE(spySelection.count(), 0);
+ QCOMPARE(spySelection.size(), 0);
if (QGuiApplication::clipboard()->supportsFindBuffer())
- QCOMPARE(spyFindBuffer.count(), 1);
+ QCOMPARE(spyFindBuffer.size(), 1);
else
- QCOMPARE(spyFindBuffer.count(), 0);
+ QCOMPARE(spyFindBuffer.size(), 0);
- QTRY_COMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.size(), 1);
}
void tst_QClipboard::clearBeforeSetText()
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index e8c283252e..b3e50ea562 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -98,20 +98,20 @@ void tst_QGuiApplication::displayName()
QGuiApplication::setApplicationName("The Core Application");
QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application"));
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The Core Application"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QGuiApplication::setApplicationDisplayName("The GUI Application");
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QGuiApplication::setApplicationName("The Core Application 2");
QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application 2"));
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QGuiApplication::setApplicationDisplayName("The GUI Application 2");
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application 2"));
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QGuiApplication::desktopFileName()
@@ -222,12 +222,12 @@ void tst_QGuiApplication::focusObject()
window1.setFocusObject(&obj1);
QCOMPARE(app.focusObject(), &obj1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window1.setFocusObject(&obj2);
QCOMPARE(app.focusObject(), &obj2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window2.setFocusObject(&obj3);
@@ -236,12 +236,12 @@ void tst_QGuiApplication::focusObject()
QVERIFY(QTest::qWaitForWindowExposed(&window2));
QTRY_COMPARE(app.focusWindow(), &window2);
QCOMPARE(app.focusObject(), &obj3);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// focus change on unfocused window does not show
spy.clear();
window1.setFocusObject(&obj1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(app.focusObject(), &obj3);
}
@@ -253,13 +253,13 @@ void tst_QGuiApplication::allWindows()
QWindow *window2 = new QWindow(window1);
QVERIFY(app.allWindows().contains(window1));
QVERIFY(app.allWindows().contains(window2));
- QCOMPARE(app.allWindows().count(), 2);
+ QCOMPARE(app.allWindows().size(), 2);
delete window1;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.allWindows().contains(window2));
QVERIFY(!app.allWindows().contains(window1));
- QCOMPARE(app.allWindows().count(), 0);
+ QCOMPARE(app.allWindows().size(), 0);
}
void tst_QGuiApplication::topLevelWindows()
@@ -270,13 +270,13 @@ void tst_QGuiApplication::topLevelWindows()
QWindow *window2 = new QWindow(window1);
QVERIFY(app.topLevelWindows().contains(window1));
QVERIFY(!app.topLevelWindows().contains(window2));
- QCOMPARE(app.topLevelWindows().count(), 1);
+ QCOMPARE(app.topLevelWindows().size(), 1);
delete window1;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.topLevelWindows().contains(window2));
QVERIFY(!app.topLevelWindows().contains(window1));
- QCOMPARE(app.topLevelWindows().count(), 0);
+ QCOMPARE(app.topLevelWindows().size(), 0);
}
class ShowCloseShowWindow : public QWindow
@@ -531,7 +531,7 @@ void tst_QGuiApplication::palette()
QGuiApplication::setPalette(newPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), newPalette));
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
#endif
QVERIFY(palettesMatch(signalSpy.at(0).at(0).value<QPalette>(), newPalette));
QCOMPARE(QGuiApplication::palette(), QPalette());
@@ -539,7 +539,7 @@ void tst_QGuiApplication::palette()
QGuiApplication::setPalette(oldPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette));
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
#endif
QVERIFY(palettesMatch(signalSpy.at(1).at(0).value<QPalette>(), oldPalette));
QCOMPARE(QGuiApplication::palette(), QPalette());
@@ -547,7 +547,7 @@ void tst_QGuiApplication::palette()
QGuiApplication::setPalette(oldPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette));
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
}
@@ -564,17 +564,17 @@ void tst_QGuiApplication::font()
QGuiApplication::setFont(newFont);
QCOMPARE(QGuiApplication::font(), newFont);
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
QCOMPARE(signalSpy.at(0).at(0), QVariant(newFont));
QGuiApplication::setFont(oldFont);
QCOMPARE(QGuiApplication::font(), oldFont);
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
QCOMPARE(signalSpy.at(1).at(0), QVariant(oldFont));
QGuiApplication::setFont(oldFont);
QCOMPARE(QGuiApplication::font(), oldFont);
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
}
class BlockableWindow : public QWindow
@@ -879,9 +879,9 @@ void tst_QGuiApplication::quitOnLastWindowClosed()
app.exec();
- QCOMPARE(spyAboutToQuit.count(), 1);
+ QCOMPARE(spyAboutToQuit.size(), 1);
// Should be around 10 if closing caused the quit
- QVERIFY2(spyTimeout.count() < 15, QByteArray::number(spyTimeout.count()).constData());
+ QVERIFY2(spyTimeout.size() < 15, QByteArray::number(spyTimeout.size()).constData());
}
void tst_QGuiApplication::quitOnLastWindowClosedMulti()
@@ -922,7 +922,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti()
app.exec();
QVERIFY(!prematureQuit);
- QCOMPARE(spyAboutToQuit.count(), 1); // fired only once
+ QCOMPARE(spyAboutToQuit.size(), 1); // fired only once
}
void tst_QGuiApplication::dontQuitOnLastWindowClosed()
@@ -950,8 +950,8 @@ void tst_QGuiApplication::dontQuitOnLastWindowClosed()
app.setQuitOnLastWindowClosed(true); // restore underlying static to default value
- QCOMPARE(spyTimeout.count(), 1); // quit timer fired
- QCOMPARE(spyLastWindowClosed.count(), 1); // lastWindowClosed emitted
+ QCOMPARE(spyTimeout.size(), 1); // quit timer fired
+ QCOMPARE(spyLastWindowClosed.size(), 1); // lastWindowClosed emitted
}
class QuitSpy : public QObject
@@ -1130,8 +1130,6 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents()
QVERIFY(QGuiApplication::primaryScreen());
QCOMPARE(QGuiApplication::primaryScreen()->orientation(), testOrientationToSend);
- if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
- QEXPECT_FAIL("", "Wayland: This fails. See QTBUG-100891.", Abort);
QCOMPARE(testReceiver.customEvents, 0);
QCoreApplication::sendPostedEvents(&testReceiver);
QCOMPARE(testReceiver.customEvents, 1);
@@ -1155,12 +1153,12 @@ void tst_QGuiApplication::layoutDirection()
QGuiApplication::setLayoutDirection(oldDirection);
QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
QCOMPARE(signalSpy.at(0).at(0).toInt(), static_cast<int>(oldDirection));
QGuiApplication::setLayoutDirection(oldDirection);
QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
// with QGuiApplication instantiated, install a translator that gives us control
class LayoutDirectionTranslator : public QTranslator
@@ -1191,31 +1189,31 @@ void tst_QGuiApplication::layoutDirection()
LayoutDirectionTranslator translator(oldDirection);
QGuiApplication::installTranslator(&translator);
QCOMPARE(QGuiApplication::layoutDirection(), translator.direction);
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
}
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount); // ltrTranslator removed, no change
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount); // ltrTranslator removed, no change
// install a new translator that changes the direction
{
LayoutDirectionTranslator translator(newDirection);
QGuiApplication::installTranslator(&translator);
QCOMPARE(QGuiApplication::layoutDirection(), translator.direction);
- QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
}
// rtlTranslator removed
- QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
// override translation
QGuiApplication::setLayoutDirection(newDirection);
- QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
{
// this translator will be ignored
LayoutDirectionTranslator translator(oldDirection);
QGuiApplication::installTranslator(&translator);
QCOMPARE(QGuiApplication::layoutDirection(), newDirection);
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
}
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
}
diff --git a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
index 67c65f1160..ac42f0da30 100644
--- a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
+++ b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
@@ -78,7 +78,7 @@ void tst_QInputDevice::multiSeatDevices()
QWindowSystemInterface::registerInputDevice(new QPointingDevice("seat 2 mouse", 2010, QInputDevice::DeviceType::Mouse, QPointingDevice::PointerType::Generic,
QInputDevice::Capability::Position | QInputDevice::Capability::Hover,
1, 2, "seat 2", QPointingDeviceUniqueId(), this));
- QVERIFY(QInputDevice::devices().count() >= 4);
+ QVERIFY(QInputDevice::devices().size() >= 4);
QVERIFY(QInputDevicePrivate::fromId(1010));
QVERIFY(QInputDevicePrivate::fromId(1010)->hasCapability(QInputDevice::Capability::Scroll));
QVERIFY(QInputDevicePrivate::fromId(2010));
diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
index 86669fde62..c562a5c362 100644
--- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
+++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
@@ -125,7 +125,7 @@ void tst_qinputmethod::animating()
QSignalSpy spy(qApp->inputMethod(), SIGNAL(animatingChanged()));
m_platformInputContext.emitAnimatingChanged();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_qinputmethod::keyboarRectangle()
@@ -137,7 +137,7 @@ void tst_qinputmethod::keyboarRectangle()
QSignalSpy spy(qApp->inputMethod(), SIGNAL(keyboardRectangleChanged()));
m_platformInputContext.emitKeyboardRectChanged();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_qinputmethod::inputItemTransform()
@@ -152,7 +152,7 @@ void tst_qinputmethod::inputItemTransform()
qApp->inputMethod()->setInputItemTransform(transform);
QCOMPARE(qApp->inputMethod()->inputItemTransform(), transform);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// reset
qApp->inputMethod()->setInputItemTransform(QTransform());
diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
index 5420adca14..d7cc8a572c 100644
--- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
+++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
@@ -263,14 +263,14 @@ void tst_QMouseEvent::grabbers()
auto firstEPD = devPriv->pointById(0);
QCOMPARE(firstEPD->eventPoint.pressTimestamp(), testMouseWidget->pressTimestamp);
QCOMPARE(firstEPD->exclusiveGrabber, grabExclusive ? testMouseWidget : nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), grabPassive ? 1 : 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), grabPassive ? 1 : 0);
if (grabPassive)
QCOMPARE(firstEPD->passiveGrabbers.first(), testMouseWidget);
// Ensure that grabbers are forgotten after release delivery
QTest::mouseRelease(testMouseWidget, Qt::LeftButton, Qt::KeyboardModifiers(), {10, 10});
QTRY_COMPARE(firstEPD->exclusiveGrabber, nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), 0);
}
void tst_QMouseEvent::velocity()
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index 150d58e6f4..897511300b 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
@@ -22,6 +22,7 @@ private Q_SLOTS:
void noBrushesSetForDefaultPalette();
void cannotCheckIfInvalidBrushSet();
void checkIfBrushForCurrentGroupSet();
+ void cacheKey();
};
void tst_QPalette::roleValues_data()
@@ -264,5 +265,69 @@ void tst_QPalette::checkIfBrushForCurrentGroupSet()
QVERIFY(p.isBrushSet(QPalette::Current, QPalette::Link));
}
+void tst_QPalette::cacheKey()
+{
+ const QPalette defaultPalette;
+ // precondition: all palettes are expected to have contrasting text on base
+ QVERIFY(defaultPalette.base() != defaultPalette.text());
+ const auto defaultCacheKey = defaultPalette.cacheKey();
+ const auto defaultSerNo = defaultCacheKey >> 32;
+ const auto defaultDetachNo = defaultCacheKey & 0xffffffff;
+
+ QPalette changeTwicePalette(defaultPalette);
+ changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::red);
+ const auto firstChangeCacheKey = changeTwicePalette.cacheKey();
+ QCOMPARE_NE(firstChangeCacheKey, defaultCacheKey);
+ changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::green);
+ const auto secondChangeCacheKey = changeTwicePalette.cacheKey();
+ QCOMPARE_NE(firstChangeCacheKey, secondChangeCacheKey);
+
+ QPalette copyDifferentData(defaultPalette);
+ QPalette copyDifferentMask(defaultPalette);
+ QPalette copyDifferentMaskAndData(defaultPalette);
+
+ QCOMPARE(defaultPalette.cacheKey(), copyDifferentData.cacheKey());
+
+ // deep detach of both private and data
+ copyDifferentData.setBrush(QPalette::Base, defaultPalette.text());
+ const auto differentDataKey = copyDifferentData.cacheKey();
+ const auto differentDataSerNo = differentDataKey >> 32;
+ const auto differentDataDetachNo = differentDataKey & 0xffffffff;
+
+ QCOMPARE_NE(copyDifferentData.cacheKey(), defaultCacheKey);
+ QCOMPARE(defaultPalette.cacheKey(), defaultCacheKey);
+
+ // shallow detach, both privates reference the same data
+ copyDifferentMask.setResolveMask(0xffffffffffffffff);
+ const auto differentMaskKey = copyDifferentMask.cacheKey();
+ const auto differentMaskSerNo = differentMaskKey >> 32;
+ const auto differentMaskDetachNo = differentMaskKey & 0xffffffff;
+ QCOMPARE(differentMaskSerNo, defaultSerNo);
+ QCOMPARE_NE(differentMaskSerNo, defaultDetachNo);
+ QCOMPARE_NE(differentMaskKey, defaultCacheKey);
+ QCOMPARE_NE(differentMaskKey, differentDataKey);
+
+ // shallow detach, both privates reference the same data
+ copyDifferentMaskAndData.setResolveMask(0xeeeeeeeeeeeeeeee);
+ const auto modifiedCacheKey = copyDifferentMaskAndData.cacheKey();
+ QCOMPARE_NE(modifiedCacheKey, copyDifferentMask.cacheKey());
+ QCOMPARE_NE(modifiedCacheKey, defaultCacheKey);
+ QCOMPARE_NE(modifiedCacheKey, copyDifferentData.cacheKey());
+ QCOMPARE_NE(copyDifferentMask.cacheKey(), defaultCacheKey);
+
+ // full detach - both key elements are different
+ copyDifferentMaskAndData.setBrush(QPalette::Base, defaultPalette.text());
+ const auto modifiedAllKey = copyDifferentMaskAndData.cacheKey();
+ const auto modifiedAllSerNo = modifiedAllKey >> 32;
+ const auto modifiedAllDetachNo = modifiedAllKey & 0xffffffff;
+ QCOMPARE_NE(modifiedAllSerNo, defaultSerNo);
+ QCOMPARE_NE(modifiedAllDetachNo, defaultDetachNo);
+
+ QCOMPARE_NE(modifiedAllKey, copyDifferentMask.cacheKey());
+ QCOMPARE_NE(modifiedAllKey, defaultCacheKey);
+ QCOMPARE_NE(modifiedAllKey, differentDataKey);
+ QCOMPARE_NE(modifiedAllKey, modifiedCacheKey);
+}
+
QTEST_MAIN(tst_QPalette)
#include "tst_qpalette.moc"
diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
index 9d85a31d5a..b537b211c1 100644
--- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
+++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
@@ -158,27 +158,27 @@ void tst_QScreen::orientationChange()
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::InvertedLandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedPortraitOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::InvertedPortraitOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
}
void tst_QScreen::grabWindow_data()
diff --git a/tests/auto/gui/kernel/qtouchevent/BLACKLIST b/tests/auto/gui/kernel/qtouchevent/BLACKLIST
index 3ae3f6d30d..c4e4b2291d 100644
--- a/tests/auto/gui/kernel/qtouchevent/BLACKLIST
+++ b/tests/auto/gui/kernel/qtouchevent/BLACKLIST
@@ -1,7 +1,3 @@
-[multiPointRawEventTranslationOnTouchScreen]
-ubuntu-16.04
-[multiPointRawEventTranslationOnTouchScreen]
-android
[multiPointRawEventTranslationOnTouchPad]
# QTBUG-101519
windows-11
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index 2f0863fc54..3fc6a0c1a2 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -17,6 +17,8 @@
#include <QtGui/private/qeventpoint_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qpointingdevice_p.h>
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
@@ -46,6 +48,24 @@ public:
deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false;
}
+ void paintEvent(QPaintEvent *) override
+ {
+ QPainter painter(this);
+ painter.drawRect(rect());
+ painter.setPen(Qt::darkGray);
+ painter.drawText(rect(), Qt::AlignHCenter | Qt::AlignCenter, objectName());
+ static const QString pointFormat = QString::fromUtf8("\360\237\226\227 %1, %2");
+ painter.setPen(Qt::darkGreen);
+ for (const auto &pt : std::as_const(touchBeginPoints))
+ painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
+ painter.setPen(Qt::darkYellow);
+ for (const auto &pt : std::as_const(touchUpdatePoints))
+ painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
+ painter.setPen(Qt::darkRed);
+ for (const auto &pt : std::as_const(touchEndPoints))
+ painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
+ }
+
bool event(QEvent *event) override
{
lastNormalizedPositions.clear();
@@ -59,13 +79,15 @@ public:
auto touchEvent = static_cast<QTouchEvent *>(event);
touchBeginPoints = touchEvent->points();
Q_ASSERT(touchBeginPoints.first().device() == touchEvent->pointingDevice());
- for (const QEventPoint &pt : qAsConst(touchBeginPoints))
+ for (const QEventPoint &pt : std::as_const(touchBeginPoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
event->setAccepted(acceptTouchBegin);
if (deleteInTouchBegin)
delete this;
+ else
+ update();
break;
}
case QEvent::TouchUpdate: {
@@ -75,13 +97,15 @@ public:
seenTouchUpdate = seenTouchBegin && !seenTouchEnd;
auto touchEvent = static_cast<QTouchEvent *>(event);
touchUpdatePoints = touchEvent->points();
- for (const QEventPoint &pt : qAsConst(touchUpdatePoints))
+ for (const QEventPoint &pt : std::as_const(touchUpdatePoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
event->setAccepted(acceptTouchUpdate);
if (deleteInTouchUpdate)
delete this;
+ else
+ update();
break;
}
case QEvent::TouchEnd: {
@@ -91,13 +115,15 @@ public:
seenTouchEnd = seenTouchBegin && !seenTouchEnd;
auto touchEvent = static_cast<QTouchEvent *>(event);
touchEndPoints = touchEvent->points();
- for (const QEventPoint &pt : qAsConst(touchEndPoints))
+ for (const QEventPoint &pt : std::as_const(touchEndPoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
event->setAccepted(acceptTouchEnd);
if (deleteInTouchEnd)
delete this;
+ else
+ update();
break;
}
default:
@@ -706,7 +732,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
QCOMPARE(touchBeginPoint.id(), 0);
@@ -736,7 +762,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 1);
QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), 0);
QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state());
@@ -764,7 +790,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
QEventPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 0);
QCOMPARE(touchEndPoint.state(), rawTouchPoint.state());
@@ -787,9 +813,11 @@ void tst_QTouchEvent::basicRawEventTranslation()
void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
{
tst_QTouchEventWidget touchWidget;
+ touchWidget.setObjectName("parent touch widget");
touchWidget.setWindowTitle(QTest::currentTestFunction());
touchWidget.setAttribute(Qt::WA_AcceptTouchEvents);
- touchWidget.setGeometry(100, 100, 400, 300);
+ const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(100, 100);
+ touchWidget.setGeometry({topLeft, QSize(400, 300)});
tst_QTouchEventWidget leftWidget(&touchWidget);
leftWidget.setObjectName("leftWidget");
@@ -803,24 +831,25 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
touchWidget.show();
QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
+ if (touchWidget.geometry().topLeft() != topLeft) {
+ qCDebug(lcTests) << "tried to set position 100, 100 on screen; got geometry"
+ << touchWidget.geometry() << "frame" << touchWidget.frameGeometry();
+ QSKIP("failed to position the widget window on this platform");
+ }
- QPointF leftPos = leftWidget.rect().center();
- QPointF rightPos = rightWidget.rect().center();
- QPointF centerPos = touchWidget.rect().center();
- QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
- QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
- QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
+ QPoint leftPos = leftWidget.rect().center();
+ QPoint rightPos = rightWidget.rect().center();
+ QPoint centerPos = touchWidget.rect().center();
+ QPoint leftScenePos = leftWidget.mapToParent(leftPos);
+ QPoint rightScenePos = rightWidget.mapToParent(rightPos);
+ QPoint leftScreenPos = leftWidget.mapToGlobal(leftPos);
+ QPoint rightScreenPos = rightWidget.mapToGlobal(rightPos);
+ QPoint centerScreenPos = touchWidget.mapToGlobal(centerPos);
// generate TouchBegins on both leftWidget and rightWidget
- ulong timestamp = 0;
- auto rawTouchPoints = QList<QEventPoint>()
- << QEventPoint(0, QEventPoint::State::Pressed, QPointF(), leftScreenPos)
- << QEventPoint(1, QEventPoint::State::Pressed, QPointF(), rightScreenPos);
- QWindow *window = touchWidget.windowHandle();
- QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
- QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
- QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
- QCoreApplication::processEvents();
+ auto touchSequence = QTest::touchEvent(touchWidget.windowHandle(), touchScreenDevice);
+ touchSequence.press(0, leftScenePos).press(1, rightScenePos);
+ QVERIFY(touchSequence.commit()); // verify acceptance
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
@@ -830,14 +859,14 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchBeginPoints.count(), 1);
- QCOMPARE(rightWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(leftWidget.touchBeginPoints.size(), 1);
+ QCOMPARE(rightWidget.touchBeginPoints.size(), 1);
const int touchPointId0 = 0;
const int touchPointId1 = touchPointId0 + 1;
{
- QEventPoint leftTouchPoint = leftWidget.touchBeginPoints.first();
+ const QEventPoint &leftTouchPoint = leftWidget.touchBeginPoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
- QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
+ QCOMPARE(leftTouchPoint.state(), QEventPoint::Pressed);
QCOMPARE(leftTouchPoint.position(), leftPos);
QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPosition(), leftPos);
@@ -847,15 +876,12 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.position(), leftPos);
- QCOMPARE(leftTouchPoint.scenePosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
- QEventPoint rightTouchPoint = rightWidget.touchBeginPoints.first();
+ const QEventPoint &rightTouchPoint = rightWidget.touchBeginPoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1);
- QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
+ QCOMPARE(rightTouchPoint.state(), QEventPoint::Pressed);
QCOMPARE(rightTouchPoint.position(), rightPos);
QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPosition(), rightPos);
@@ -865,20 +891,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.position(), rightPos);
- QCOMPARE(rightTouchPoint.scenePosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
}
- rawTouchPoints.clear();
- rawTouchPoints << QEventPoint(0, QEventPoint::State::Updated, QPointF(), centerScreenPos)
- << QEventPoint(1, QEventPoint::State::Updated, QPointF(), centerScreenPos);
- nativeTouchPoints =
- QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
- QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
- QCoreApplication::processEvents();
+ // an unlikely event with the two touchpoints moving exactly on top of each other
+ touchSequence.move(0, centerPos).move(1, centerPos);
+ QVERIFY(touchSequence.commit()); // verify acceptance
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
@@ -888,13 +907,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchUpdatePoints.count(), 1);
- QCOMPARE(rightWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(leftWidget.touchUpdatePoints.size(), 1);
+ QCOMPARE(rightWidget.touchUpdatePoints.size(), 1);
{
- QEventPoint leftTouchPoint = leftWidget.touchUpdatePoints.first();
+ const QEventPoint &leftTouchPoint = leftWidget.touchUpdatePoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
- QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
- QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(leftTouchPoint.state(), QEventPoint::Updated);
+ QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos)));
QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPosition(), leftPos);
QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
@@ -903,16 +922,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
- QEventPoint rightTouchPoint = rightWidget.touchUpdatePoints.first();
+ const QEventPoint &rightTouchPoint = rightWidget.touchUpdatePoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1);
- QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
- QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(rightTouchPoint.state(), QEventPoint::Updated);
+ QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos)));
QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPosition(), rightPos);
QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
@@ -921,21 +937,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.position(), rightWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
}
// generate TouchEnds on both leftWidget and rightWidget
- rawTouchPoints.clear();
- rawTouchPoints << QEventPoint(0, QEventPoint::State::Released, QPointF(), centerScreenPos)
- << QEventPoint(1, QEventPoint::State::Released, QPointF(), centerScreenPos);
- nativeTouchPoints =
- QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
- QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
- QCoreApplication::processEvents();
+ touchSequence.release(0, centerPos).release(1, centerPos);
+ QVERIFY(touchSequence.commit()); // verify acceptance
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
@@ -945,13 +953,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(rightWidget.seenTouchUpdate);
QVERIFY(rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchEndPoints.count(), 1);
- QCOMPARE(rightWidget.touchEndPoints.count(), 1);
+ QCOMPARE(leftWidget.touchEndPoints.size(), 1);
+ QCOMPARE(rightWidget.touchEndPoints.size(), 1);
{
- QEventPoint leftTouchPoint = leftWidget.touchEndPoints.first();
+ const QEventPoint &leftTouchPoint = leftWidget.touchEndPoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
- QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
- QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(leftTouchPoint.state(), QEventPoint::Released);
+ QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos)));
QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPosition(), leftPos);
QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
@@ -960,16 +968,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(0.));
- QEventPoint rightTouchPoint = rightWidget.touchEndPoints.first();
+ const QEventPoint &rightTouchPoint = rightWidget.touchEndPoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1);
- QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
- QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(rightTouchPoint.state(), QEventPoint::Released);
+ QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos)));
QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPosition(), rightPos);
QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
@@ -978,9 +983,6 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.position(), rightWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(0.));
}
@@ -1010,7 +1012,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
QCOMPARE(touchBeginPoint.id(), 1);
@@ -1025,7 +1027,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), 10);
@@ -1040,7 +1042,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), 11);
@@ -1056,7 +1058,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 1);
QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), 1);
QCOMPARE(touchUpdatePoint.state(), QEventPoint::State::Updated);
@@ -1071,7 +1073,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
QEventPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 1);
QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released);
@@ -1096,7 +1098,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 10);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 11);
@@ -1111,7 +1113,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 11);
QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released);
@@ -1127,6 +1129,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QSKIP("The macOS mouse cursor interferes with this test can cannot be moved away");
#endif
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
tst_QTouchEventWidget touchWidget;
touchWidget.setObjectName("touchWidget");
touchWidget.setWindowTitle(QTest::currentTestFunction());
@@ -1183,8 +1188,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchBeginPoints.count(), 2);
- QCOMPARE(rightWidget.touchBeginPoints.count(), 0);
+ QCOMPARE(leftWidget.touchBeginPoints.size(), 2);
+ QCOMPARE(rightWidget.touchBeginPoints.size(), 0);
{
QEventPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after press" << leftWidget.lastNormalizedPositions;
@@ -1245,8 +1250,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchUpdatePoints.count(), 2);
- QCOMPARE(rightWidget.touchUpdatePoints.count(), 0);
+ QCOMPARE(leftWidget.touchUpdatePoints.size(), 2);
+ QCOMPARE(rightWidget.touchUpdatePoints.size(), 0);
{
QEventPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after update" << leftWidget.lastNormalizedPositions;
@@ -1307,8 +1312,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchEndPoints.count(), 2);
- QCOMPARE(rightWidget.touchEndPoints.count(), 0);
+ QCOMPARE(leftWidget.touchEndPoints.size(), 2);
+ QCOMPARE(rightWidget.touchEndPoints.size(), 0);
{
QEventPoint leftTouchPoint = leftWidget.touchEndPoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after release" << leftWidget.lastNormalizedPositions;
@@ -1391,16 +1396,16 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 2);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 2);
- for (int i = 0; i < touchWidget.touchBeginPoints.count(); ++i) {
+ for (int i = 0; i < touchWidget.touchBeginPoints.size(); ++i) {
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.at(i);
QCOMPARE(touchBeginPoint.id(), i);
QCOMPARE(touchBeginPoint.state(), rawTouchPoints[i].state());
}
// moving the point should translate to TouchUpdate
- for (int i = 0; i < rawTouchPoints.count(); ++i) {
+ for (int i = 0; i < rawTouchPoints.size(); ++i) {
auto &p = rawTouchPoints[i];
QMutableEventPoint::setState(p, QEventPoint::State::Updated);
QMutableEventPoint::setGlobalPosition(p, p.globalPosition() + delta);
@@ -1412,7 +1417,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), 1);
@@ -1427,7 +1432,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QCOMPARE(touchWidget.seenTouchEnd, false);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 1);
@@ -1441,7 +1446,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42);
@@ -1455,7 +1460,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42);
}
@@ -1819,25 +1824,25 @@ void tst_QTouchEvent::testQGuiAppDelivery()
// Now the real thing.
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchBegin
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin);
points[0].state = QEventPoint::State::Updated;
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchUpdate
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 2);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 2);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchUpdate);
points[0].state = QEventPoint::State::Released;
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchEnd
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 3);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 3);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchEnd);
}
@@ -1880,8 +1885,8 @@ void tst_QTouchEvent::testMultiDevice()
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin);
QCOMPARE(filter.d.value(deviceTwo).lastSeenType, QEvent::TouchBegin);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1);
- QCOMPARE(filter.d.value(deviceTwo).points.count(), 2);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1);
+ QCOMPARE(filter.d.value(deviceTwo).points.size(), 2);
QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).globalPosition(), area0.center());
// This fails because QGuiApplicationPrivate::processTouchEvent() sends synth-mouse events
@@ -1936,7 +1941,7 @@ void tst_QTouchEvent::grabbers()
// Ensure that grabbers are persistent between events, within the stored touchpoints
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, grabExclusive ? &w : nullptr);
- QCOMPARE(devPriv->pointById(0)->passiveGrabbers.count(), grabPassive ? 1 : 0);
+ QCOMPARE(devPriv->pointById(0)->passiveGrabbers.size(), grabPassive ? 1 : 0);
if (grabPassive)
QCOMPARE(devPriv->pointById(0)->passiveGrabbers.first(), &w);
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 91cdc969c0..e298603ca4 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -70,6 +70,7 @@ private slots:
void modalWithChildWindow();
void modalWindowModallity();
void modalWindowPosition();
+ void modalCloseWhileBlocked();
#ifndef QT_NO_CURSOR
void modalWindowEnterEventOnHide_QTBUG35109();
void spuriousMouseMove();
@@ -710,7 +711,7 @@ void tst_QWindow::stateChange()
// explicitly use non-fullscreen show. show() can be fullscreen on some platforms
window.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- for (Qt::WindowState state : qAsConst(stateSequence)) {
+ for (Qt::WindowState state : std::as_const(stateSequence)) {
window.setWindowState(state);
QCoreApplication::processEvents();
}
@@ -987,7 +988,7 @@ public:
}
touchEventType = event->type();
QList<QTouchEvent::TouchPoint> points = event->points();
- for (int i = 0; i < points.count(); ++i) {
+ for (int i = 0; i < points.size(); ++i) {
const auto &point = points.at(i);
switch (point.state()) {
case QEventPoint::State::Pressed:
@@ -1504,7 +1505,7 @@ void tst_QWindow::orientation()
QSignalSpy spy(&window, SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)));
window.reportContentOrientationChange(Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QWindow::sizes()
@@ -1523,40 +1524,40 @@ void tst_QWindow::sizes()
QCOMPARE(window.minimumHeight(), 0);
QCOMPARE(window.minimumSize(), QSize(10, 0));
QCOMPARE(window.maximumSize(), oldMaximum);
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 0);
- QCOMPARE(maximumWidthSpy.count(), 0);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 0);
+ QCOMPARE(maximumWidthSpy.size(), 0);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMinimumHeight(10);
QCOMPARE(window.minimumWidth(), 10);
QCOMPARE(window.minimumHeight(), 10);
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), oldMaximum);
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 0);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 0);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMaximumWidth(100);
QCOMPARE(window.maximumWidth(), 100);
QCOMPARE(window.maximumHeight(), oldMaximum.height());
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), QSize(100, oldMaximum.height()));
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 1);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 1);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMaximumHeight(100);
QCOMPARE(window.maximumWidth(), 100);
QCOMPARE(window.maximumHeight(), 100);
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), QSize(100, 100));
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 1);
- QCOMPARE(maximumHeightSpy.count(), 1);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 1);
+ QCOMPARE(maximumHeightSpy.size(), 1);
}
class CloseOnCloseEventWindow : public QWindow
@@ -1788,25 +1789,25 @@ void tst_QWindow::windowModality()
QCOMPARE(window.modality(), Qt::NonModal);
window.setModality(Qt::NonModal);
QCOMPARE(window.modality(), Qt::NonModal);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
window.setModality(Qt::WindowModal);
QCOMPARE(window.modality(), Qt::WindowModal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
window.setModality(Qt::WindowModal);
QCOMPARE(window.modality(), Qt::WindowModal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
window.setModality(Qt::ApplicationModal);
QCOMPARE(window.modality(), Qt::ApplicationModal);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
window.setModality(Qt::ApplicationModal);
QCOMPARE(window.modality(), Qt::ApplicationModal);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
window.setModality(Qt::NonModal);
QCOMPARE(window.modality(), Qt::NonModal);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QWindow::inputReentrancy()
@@ -1989,32 +1990,32 @@ void tst_QWindow::visibility()
QVERIFY(window.isVisible());
QVERIFY(window.visibility() != QWindow::Hidden);
QVERIFY(window.visibility() != QWindow::AutomaticVisibility);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window.setVisibility(QWindow::Hidden);
QVERIFY(!window.isVisible());
QCOMPARE(window.visibility(), QWindow::Hidden);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window.setVisibility(QWindow::FullScreen);
QVERIFY(window.isVisible());
QCOMPARE(window.windowState(), Qt::WindowFullScreen);
QCOMPARE(window.visibility(), QWindow::FullScreen);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowFullScreen);
spy.clear();
window.setWindowState(Qt::WindowNoState);
QCOMPARE(window.visibility(), QWindow::Windowed);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowNoState);
spy.clear();
window.setVisible(false);
QCOMPARE(window.visibility(), QWindow::Hidden);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
@@ -2061,8 +2062,6 @@ void tst_QWindow::initialSize()
w.setTitle(QLatin1String(QTest::currentTestFunction()));
w.setWidth(m_testWindowSize.width());
w.showNormal();
- if (isPlatformWayland())
- QEXPECT_FAIL("", "Wayland: This fails. See QTBUG-66818.", Abort);
QTRY_COMPARE(w.width(), m_testWindowSize.width());
QTRY_VERIFY(w.height() > 0);
}
@@ -2238,6 +2237,9 @@ void tst_QWindow::modalWindowModallity()
void tst_QWindow::modalWindowPosition()
{
+ if (isPlatformWayland())
+ QSKIP("Window position not queryable on Wayland");
+
QWindow window;
window.setTitle(QLatin1String(QTest::currentTestFunction()));
window.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWindowSize));
@@ -2246,11 +2248,25 @@ void tst_QWindow::modalWindowPosition()
window.setModality(Qt::WindowModal);
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- if (isPlatformWayland())
- QEXPECT_FAIL("", "Wayland: This fails. See QTBUG-100888.", Abort);
QCOMPARE(window.geometry(), origGeo);
}
+void tst_QWindow::modalCloseWhileBlocked()
+{
+ QWindow first;
+ first.setModality(Qt::ApplicationModal);
+ first.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&first));
+
+ QWindow second;
+ second.setModality(Qt::ApplicationModal);
+ second.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&first));
+
+ first.close();
+ QTRY_VERIFY(!first.isVisible());
+}
+
#ifndef QT_NO_CURSOR
void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
{
diff --git a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
index 00975906ed..4677399b3f 100644
--- a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
+++ b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
@@ -70,7 +70,7 @@ void tst_QPageRanges::addPage()
QFETCH(PageRangeList, expected);
QPageRanges result;
- for (int pageNumber : qAsConst(pageNumbers)) {
+ for (int pageNumber : std::as_const(pageNumbers)) {
if (QByteArrayView(QTest::currentDataTag()) == "invalid")
QTest::ignoreMessage(QtWarningMsg, "QPageRanges::addPage: 'pageNumber' must be greater than 0");
result.addPage(pageNumber);
@@ -112,7 +112,7 @@ void tst_QPageRanges::addRange()
QFETCH(PageRangeList, expected);
QPageRanges result;
- for (const auto &range : qAsConst(ranges)) {
+ for (const auto &range : std::as_const(ranges)) {
const QByteArrayView testdata(QTest::currentDataTag());
if (testdata.startsWith("invalid"))
QTest::ignoreMessage(QtWarningMsg, "QPageRanges::addRange: 'from' and 'to' must be greater than 0");
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 041169c775..eb705a0219 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -5181,7 +5181,7 @@ void tst_QPainter::drawPolyline()
p.setPen(pen);
QVERIFY(p.pen().isCosmetic());
if (r) {
- for (int i = 0; i < points.count()-1; i++) {
+ for (int i = 0; i < points.size()-1; i++) {
p.drawLine(points.at(i), points.at(i+1));
}
} else {
@@ -5506,6 +5506,7 @@ void tst_QPainter::hdrColors()
QCOMPARE(img.pixelColor(4, 4), color);
QImage img2(10, 10, QImage::Format_RGBX32FPx4);
+ img2.fill(Qt::black); // fill to avoid random FP values like Inf which can break SourceOver composition
{
QPainter p(&img2);
p.drawImage(0, 0, img);
diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
index 87dda161d2..512381ab95 100644
--- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
+++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
@@ -168,8 +168,8 @@ void tst_QPolygon::swap()
QPolygon p2(QList<QPoint>() << QPoint(0, 0) << QPoint(0, 10) << QPoint(10, 10)
<< QPoint(10, 0));
p1.swap(p2);
- QCOMPARE(p1.count(),4);
- QCOMPARE(p2.count(),3);
+ QCOMPARE(p1.size(),4);
+ QCOMPARE(p2.size(),3);
}
void tst_QPolygon::intersections_data()
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 4e81af6cf3..3603d7d662 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -618,6 +618,10 @@ static bool supportsInternalFboFormat(QOpenGLContext *ctx, int glFormat)
void tst_QOpenGL::fboRenderingRGB30()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
+ QSKIP("Fails on Android 12 (QTBUG-105738)");
+#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
QSKIP("QTBUG-22617");
#endif
@@ -1623,8 +1627,6 @@ void tst_QOpenGL::bufferMapRange()
buf.unmap();
p = (char *) buf.mapRange(0, sizeof(data), QOpenGLBuffer::RangeRead);
- if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
- QEXPECT_FAIL("", "This fails on Wayland, see QTBUG-100918.", Abort);
QVERIFY(!strcmp(p, "sOMe data"));
buf.unmap();
diff --git a/tests/auto/gui/qvulkan/tst_qvulkan.cpp b/tests/auto/gui/qvulkan/tst_qvulkan.cpp
index 88171a80c6..95f85e48dc 100644
--- a/tests/auto/gui/qvulkan/tst_qvulkan.cpp
+++ b/tests/auto/gui/qvulkan/tst_qvulkan.cpp
@@ -88,6 +88,10 @@ void tst_QVulkan::vulkanCheckSupported()
void tst_QVulkan::vulkan11()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
+ QSKIP("Fails on Android 12 (QTBUG-105739)");
+#endif
#if VK_VERSION_1_1
QVulkanInstance inst;
if (inst.supportedApiVersion() < QVersionNumber(1, 1))
@@ -449,6 +453,10 @@ void tst_QVulkan::vulkanWindowRenderer()
void tst_QVulkan::vulkanWindowGrab()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
+ QSKIP("Fails on Android 12 (QTBUG-105739)");
+#endif
QVulkanInstance inst;
inst.setLayers(QByteArrayList() << "VK_LAYER_KHRONOS_validation");
if (!inst.create())
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index 193a8e80e9..caf34085fc 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -17,6 +17,8 @@
# include <QOpenGLContext>
# include <QOpenGLFunctions>
# include <QtGui/private/qrhigles2_p.h>
+# include <QtGui/private/qguiapplication_p.h>
+# include <qpa/qplatformintegration.h>
# define TST_GL
#endif
@@ -49,7 +51,6 @@ private slots:
void cleanupTestCase();
void rhiTestData();
- void rhiTestDataOpenGL();
void create_data();
void create();
void nativeHandles_data();
@@ -121,9 +122,7 @@ private slots:
void pipelineCache_data();
void pipelineCache();
- void textureImportOpenGL_data();
void textureImportOpenGL();
- void renderbufferImportOpenGL_data();
void renderbufferImportOpenGL();
void threeDimTexture_data();
void threeDimTexture();
@@ -178,7 +177,7 @@ void tst_QRhi::initTestCase()
if (supportedVersion >= QVersionNumber(1, 2))
vulkanInstance.setApiVersion(QVersionNumber(1, 2));
else if (supportedVersion >= QVersionNumber(1, 1))
- vulkanInstance.setApiVersion(QVersionNumber(1, 2));
+ vulkanInstance.setApiVersion(QVersionNumber(1, 1));
vulkanInstance.setLayers({ "VK_LAYER_KHRONOS_validation" });
vulkanInstance.setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions());
vulkanInstance.create();
@@ -209,7 +208,8 @@ void tst_QRhi::rhiTestData()
QTest::newRow("Null") << QRhi::Null << static_cast<QRhiInitParams *>(&initParams.null);
#endif
#ifdef TST_GL
- QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
#endif
#ifdef TST_VK
if (vulkanInstance.isValid())
@@ -223,16 +223,6 @@ void tst_QRhi::rhiTestData()
#endif
}
-void tst_QRhi::rhiTestDataOpenGL()
-{
- QTest::addColumn<QRhi::Implementation>("impl");
- QTest::addColumn<QRhiInitParams *>("initParams");
-
-#ifdef TST_GL
- QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
-#endif
-}
-
void tst_QRhi::create_data()
{
rhiTestData();
@@ -4383,21 +4373,13 @@ void tst_QRhi::pipelineCache()
}
}
-void tst_QRhi::textureImportOpenGL_data()
-{
- rhiTestDataOpenGL();
-}
-
void tst_QRhi::textureImportOpenGL()
{
- QFETCH(QRhi::Implementation, impl);
- if (impl != QRhi::OpenGLES2)
- QSKIP("Skipping OpenGL-dependent test");
-
#ifdef TST_GL
- QFETCH(QRhiInitParams *, initParams);
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QSKIP("Skipping OpenGL-dependent test");
- QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ QScopedPointer<QRhi> rhi(QRhi::create(QRhi::OpenGLES2, &initParams.gl, QRhi::Flags(), nullptr));
if (!rhi)
QSKIP("QRhi could not be created, skipping testing native texture");
@@ -4437,21 +4419,13 @@ void tst_QRhi::textureImportOpenGL()
#endif
}
-void tst_QRhi::renderbufferImportOpenGL_data()
-{
- rhiTestDataOpenGL();
-}
-
void tst_QRhi::renderbufferImportOpenGL()
{
- QFETCH(QRhi::Implementation, impl);
- if (impl != QRhi::OpenGLES2)
- QSKIP("Skipping OpenGL-dependent test");
-
#ifdef TST_GL
- QFETCH(QRhiInitParams *, initParams);
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QSKIP("Skipping OpenGL-dependent test");
- QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ QScopedPointer<QRhi> rhi(QRhi::create(QRhi::OpenGLES2, &initParams.gl, QRhi::Flags(), nullptr));
if (!rhi)
QSKIP("QRhi could not be created, skipping testing native texture");
diff --git a/tests/auto/gui/text/CMakeLists.txt b/tests/auto/gui/text/CMakeLists.txt
index 5040060a33..536870bada 100644
--- a/tests/auto/gui/text/CMakeLists.txt
+++ b/tests/auto/gui/text/CMakeLists.txt
@@ -13,6 +13,7 @@ add_subdirectory(qtextcursor)
add_subdirectory(qtextdocumentfragment)
add_subdirectory(qtextdocumentlayout)
add_subdirectory(qtextformat)
+add_subdirectory(qtextimagehandler)
add_subdirectory(qtextlist)
add_subdirectory(qtextobject)
# add_subdirectory(qtextscriptengine) # disable until system_harfbuzz feature is available # special case
diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp
index 4ab2d1adb3..037964f42b 100644
--- a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp
+++ b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp
@@ -126,7 +126,7 @@ void tst_QAbstractTextDocumentLayout::anchorAt()
QAbstractTextDocumentLayout *documentLayout = doc.documentLayout();
QTextBlock firstBlock = doc.begin();
QTextLayout *layout = firstBlock.layout();
- layout->setPreeditArea(doc.toPlainText().length(), "xxx");
+ layout->setPreeditArea(doc.toPlainText().size(), "xxx");
doc.setPageSize(QSizeF(1000, 1000));
QFontMetrics metrics(layout->font());
@@ -156,7 +156,7 @@ void tst_QAbstractTextDocumentLayout::imageAt()
QAbstractTextDocumentLayout *documentLayout = doc.documentLayout();
QTextBlock firstBlock = doc.begin();
QTextLayout *layout = firstBlock.layout();
- layout->setPreeditArea(doc.toPlainText().length(), "xxx");
+ layout->setPreeditArea(doc.toPlainText().size(), "xxx");
doc.setPageSize(QSizeF(1000, 1000));
QFontMetrics metrics(layout->font());
@@ -181,7 +181,7 @@ void tst_QAbstractTextDocumentLayout::formatAt()
QAbstractTextDocumentLayout *documentLayout = doc.documentLayout();
QTextBlock firstBlock = doc.begin();
QTextLayout *layout = firstBlock.layout();
- layout->setPreeditArea(doc.toPlainText().length(), "xxx");
+ layout->setPreeditArea(doc.toPlainText().size(), "xxx");
doc.setPageSize(QSizeF(1000, 1000));
QFontMetrics metrics(layout->font());
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 3b20068f17..f5d544d1e7 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -126,7 +126,7 @@ static const char *tokenName(QCss::TokenType t)
static void debug(const QList<QCss::Symbol> &symbols, int index = -1)
{
qDebug() << "all symbols:";
- for (int i = 0; i < symbols.count(); ++i)
+ for (int i = 0; i < symbols.size(); ++i)
qDebug() << '(' << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
if (index != -1)
qDebug() << "failure at index" << index;
@@ -144,10 +144,10 @@ void tst_QCssParser::scanner()
QList<QCss::Symbol> symbols;
QCss::Scanner::scan(QCss::Scanner::preprocess(QString::fromUtf8(inputFile.readAll())), &symbols);
- QVERIFY(symbols.count() > 1);
+ QVERIFY(symbols.size() > 1);
QCOMPARE(symbols.last().token, QCss::S);
QCOMPARE(symbols.last().lexem(), QLatin1String("\n"));
- symbols.remove(symbols.count() - 1, 1);
+ symbols.remove(symbols.size() - 1, 1);
QFile outputFile(output);
QVERIFY(outputFile.open(QIODevice::ReadOnly|QIODevice::Text));
@@ -159,14 +159,14 @@ void tst_QCssParser::scanner()
lines.append(line);
}
- if (lines.count() != symbols.count()) {
+ if (lines.size() != symbols.size()) {
debug(symbols);
- QCOMPARE(lines.count(), symbols.count());
+ QCOMPARE(lines.size(), symbols.size());
}
- for (int i = 0; i < lines.count(); ++i) {
+ for (int i = 0; i < lines.size(); ++i) {
QStringList l = lines.at(i).split(QChar::fromLatin1('|'));
- QCOMPARE(l.count(), 2);
+ QCOMPARE(l.size(), 2);
const QString expectedToken = l.at(0);
const QString expectedLexem = l.at(1);
QString actualToken = QString::fromLatin1(tokenName(symbols.at(i).token));
@@ -350,9 +350,9 @@ void tst_QCssParser::expr()
QVERIFY(parser.testExpr());
QCOMPARE(parser.parseExpr(&values), parseSuccess);
if (parseSuccess) {
- QCOMPARE(values.count(), expectedValues.count());
+ QCOMPARE(values.size(), expectedValues.size());
- for (int i = 0; i < values.count(); ++i) {
+ for (int i = 0; i < values.size(); ++i) {
QCOMPARE(int(values.at(i).type), int(expectedValues.at(i).type));
QCOMPARE(values.at(i).variant, expectedValues.at(i).variant);
}
@@ -371,7 +371,7 @@ void tst_QCssParser::import()
QVERIFY(parser.testImport());
QVERIFY(parser.parseImport(&rule));
QCOMPARE(rule.href, QString("www.kde.org"));
- QCOMPARE(rule.media.count(), 2);
+ QCOMPARE(rule.media.size(), 2);
QCOMPARE(rule.media.at(0), QString("print"));
QCOMPARE(rule.media.at(1), QString("screen"));
}
@@ -382,7 +382,7 @@ void tst_QCssParser::media()
QVERIFY(parser.testMedia());
QCss::MediaRule rule;
QVERIFY(parser.parseMedia(&rule));
- QCOMPARE(rule.media.count(), 2);
+ QCOMPARE(rule.media.size(), 2);
QCOMPARE(rule.media.at(0), QString("print"));
QCOMPARE(rule.media.at(1), QString("screen"));
QVERIFY(rule.styleRules.isEmpty());
@@ -405,8 +405,8 @@ void tst_QCssParser::ruleset()
QVERIFY(parser.testRuleset());
QCss::StyleRule rule;
QVERIFY(parser.parseRuleset(&rule));
- QCOMPARE(rule.selectors.count(), 1);
- QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+ QCOMPARE(rule.selectors.size(), 1);
+ QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1);
QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
QVERIFY(rule.declarations.isEmpty());
}
@@ -416,10 +416,10 @@ void tst_QCssParser::ruleset()
QVERIFY(parser.testRuleset());
QCss::StyleRule rule;
QVERIFY(parser.parseRuleset(&rule));
- QCOMPARE(rule.selectors.count(), 2);
- QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+ QCOMPARE(rule.selectors.size(), 2);
+ QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1);
QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
- QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1);
+ QCOMPARE(rule.selectors.at(1).basicSelectors.size(), 1);
QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).elementName, QString("div"));
QVERIFY(rule.declarations.isEmpty());
}
@@ -429,14 +429,14 @@ void tst_QCssParser::ruleset()
QVERIFY(parser.testRuleset());
QCss::StyleRule rule;
QVERIFY(parser.parseRuleset(&rule));
- QCOMPARE(rule.selectors.count(), 2);
+ QCOMPARE(rule.selectors.size(), 2);
- QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
- QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.count(), 1);
+ QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1);
+ QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.size(), 1);
QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.at(0).name, QString("before"));
- QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1);
- QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.count(), 1);
+ QCOMPARE(rule.selectors.at(1).basicSelectors.size(), 1);
+ QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.size(), 1);
QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.at(0).name, QString("after"));
QVERIFY(rule.declarations.isEmpty());
@@ -688,21 +688,21 @@ void tst_QCssParser::selector()
QCss::Selector selector;
QVERIFY(parser.parseSelector(&selector));
- QCOMPARE(selector.basicSelectors.count(), expectedSelector.basicSelectors.count());
- for (int i = 0; i < selector.basicSelectors.count(); ++i) {
+ QCOMPARE(selector.basicSelectors.size(), expectedSelector.basicSelectors.size());
+ for (int i = 0; i < selector.basicSelectors.size(); ++i) {
const QCss::BasicSelector sel = selector.basicSelectors.at(i);
const QCss::BasicSelector expectedSel = expectedSelector.basicSelectors.at(i);
QCOMPARE(sel.elementName, expectedSel.elementName);
QCOMPARE(int(sel.relationToNext), int(expectedSel.relationToNext));
- QCOMPARE(sel.pseudos.count(), expectedSel.pseudos.count());
- for (int i = 0; i < sel.pseudos.count(); ++i) {
+ QCOMPARE(sel.pseudos.size(), expectedSel.pseudos.size());
+ for (int i = 0; i < sel.pseudos.size(); ++i) {
QCOMPARE(sel.pseudos.at(i).name, expectedSel.pseudos.at(i).name);
QCOMPARE(sel.pseudos.at(i).function, expectedSel.pseudos.at(i).function);
}
- QCOMPARE(sel.attributeSelectors.count(), expectedSel.attributeSelectors.count());
- for (int i = 0; i < sel.attributeSelectors.count(); ++i) {
+ QCOMPARE(sel.attributeSelectors.size(), expectedSel.attributeSelectors.size());
+ for (int i = 0; i < sel.attributeSelectors.size(); ++i) {
QCOMPARE(sel.attributeSelectors.at(i).name, expectedSel.attributeSelectors.at(i).name);
QCOMPARE(sel.attributeSelectors.at(i).value, expectedSel.attributeSelectors.at(i).value);
QCOMPARE(int(sel.attributeSelectors.at(i).valueMatchCriterium), int(expectedSel.attributeSelectors.at(i).valueMatchCriterium));
@@ -760,13 +760,13 @@ void tst_QCssParser::malformedDeclarations()
QCss::StyleRule rule;
QVERIFY(parser.parseRuleset(&rule));
- QCOMPARE(rule.selectors.count(), 1);
- QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+ QCOMPARE(rule.selectors.size(), 1);
+ QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1);
QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
- QVERIFY(rule.declarations.count() >= 1);
+ QVERIFY(rule.declarations.size() >= 1);
QCOMPARE(int(rule.declarations.last().d->propertyId), int(QCss::Color));
- QCOMPARE(rule.declarations.last().d->values.count(), 1);
+ QCOMPARE(rule.declarations.last().d->values.size(), 1);
QCOMPARE(int(rule.declarations.last().d->values.at(0).type), int(QCss::Value::Identifier));
QCOMPARE(rule.declarations.last().d->values.at(0).variant.toString(), QString("green"));
}
@@ -786,17 +786,17 @@ void tst_QCssParser::invalidAtKeywords()
QCss::StyleSheet sheet;
QVERIFY(parser.parse(&sheet));
- QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+ QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1);
QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
sheet.styleRules.at(0) : *sheet.nameIndex.begin();
- QCOMPARE(rule.selectors.count(), 1);
- QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+ QCOMPARE(rule.selectors.size(), 1);
+ QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1);
QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("h1"));
- QCOMPARE(rule.declarations.count(), 1);
+ QCOMPARE(rule.declarations.size(), 1);
QCOMPARE(int(rule.declarations.at(0).d->propertyId), int(QCss::Color));
- QCOMPARE(rule.declarations.at(0).d->values.count(), 1);
+ QCOMPARE(rule.declarations.at(0).d->values.size(), 1);
QCOMPARE(int(rule.declarations.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
QCOMPARE(rule.declarations.at(0).d->values.at(0).variant.toString(), QString("blue"));
}
@@ -1141,9 +1141,9 @@ void tst_QCssParser::styleSelector()
QList<QCss::Declaration> decls = testSelector.declarationsForNode(n);
if (match) {
- QCOMPARE(decls.count(), 1);
+ QCOMPARE(decls.size(), 1);
QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::BackgroundColor));
- QCOMPARE(decls.at(0).d->values.count(), 1);
+ QCOMPARE(decls.at(0).d->values.size(), 1);
QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green"));
} else {
@@ -1183,11 +1183,11 @@ void tst_QCssParser::specificity()
QCss::StyleSheet sheet;
QVERIFY(parser.parse(&sheet));
- QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count() + sheet.idIndex.count() , 1);
+ QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size() + sheet.idIndex.size() , 1);
QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0)
: (!sheet.nameIndex.isEmpty()) ? *sheet.nameIndex.begin()
: *sheet.idIndex.begin();
- QCOMPARE(rule.selectors.count(), 1);
+ QCOMPARE(rule.selectors.size(), 1);
QTEST(rule.selectors.at(0).specificity(), "specificity");
}
@@ -1236,15 +1236,15 @@ void tst_QCssParser::specificitySort()
n.ptr = &e;
QList<QCss::Declaration> decls = testSelector.declarationsForNode(n);
- QCOMPARE(decls.count(), 2);
+ QCOMPARE(decls.size(), 2);
QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::Color));
- QCOMPARE(decls.at(0).d->values.count(), 1);
+ QCOMPARE(decls.at(0).d->values.size(), 1);
QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green"));
QCOMPARE(int(decls.at(1).d->propertyId), int(QCss::Color));
- QCOMPARE(decls.at(1).d->values.count(), 1);
+ QCOMPARE(decls.at(1).d->values.size(), 1);
QCOMPARE(int(decls.at(1).d->values.at(0).type), int(QCss::Value::Identifier));
QCOMPARE(decls.at(1).d->values.at(0).variant.toString(), QString("red"));
}
@@ -1319,7 +1319,7 @@ void tst_QCssParser::rulesForNode()
QList<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
QList<QCss::Declaration> decls;
- for (int i = 0; i < rules.count(); i++) {
+ for (int i = 0; i < rules.size(); i++) {
const QCss::Selector &selector = rules.at(i).selectors.at(0);
quint64 negated = 0;
quint64 cssClass = selector.pseudoClass(&negated);
@@ -1328,7 +1328,7 @@ void tst_QCssParser::rulesForNode()
decls += rules.at(i).declarations;
}
- QCOMPARE(decls.count(), declCount);
+ QCOMPARE(decls.size(), declCount);
if (declCount > 0)
QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), value0);
@@ -1455,14 +1455,14 @@ void tst_QCssParser::pseudoElement()
n.ptr = &e;
QList<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
QList<QCss::Declaration> decls;
- for (int i = 0; i < rules.count(); i++) {
+ for (int i = 0; i < rules.size(); i++) {
const QCss::Selector& selector = rules.at(i).selectors.at(0);
if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0)
continue;
decls += rules.at(i).declarations;
}
- QCOMPARE(decls.count(), declCount);
+ QCOMPARE(decls.size(), declCount);
}
void tst_QCssParser::gradient_data()
@@ -1596,7 +1596,7 @@ void tst_QCssParser::extractFontFamily()
QCss::StyleSheet sheet;
QVERIFY(parser.parse(&sheet));
- QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+ QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1);
QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
sheet.styleRules.at(0) : *sheet.nameIndex.begin();
@@ -1654,7 +1654,7 @@ void tst_QCssParser::extractBorder()
QCss::StyleSheet sheet;
QVERIFY(parser.parse(&sheet));
- QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+ QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1);
QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
sheet.styleRules.at(0) : *sheet.nameIndex.begin();
const QList<QCss::Declaration> decls = rule.declarations;
@@ -1684,7 +1684,7 @@ void tst_QCssParser::noTextDecoration()
QCss::StyleSheet sheet;
QVERIFY(parser.parse(&sheet));
- QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+ QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1);
QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
sheet.styleRules.at(0) : *sheet.nameIndex.begin();
const QList<QCss::Declaration> decls = rule.declarations;
@@ -1709,7 +1709,7 @@ void tst_QCssParser::quotedAndUnquotedIdentifiers()
QCss::StyleSheet sheet;
QVERIFY(parser.parse(&sheet));
- QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+ QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1);
QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
sheet.styleRules.at(0) : *sheet.nameIndex.begin();
const QList<QCss::Declaration> decls = rule.declarations;
diff --git a/tests/auto/gui/text/qfont/BLACKLIST b/tests/auto/gui/text/qfont/BLACKLIST
index e914a7e533..f85d8ceebb 100644
--- a/tests/auto/gui/text/qfont/BLACKLIST
+++ b/tests/auto/gui/text/qfont/BLACKLIST
@@ -1,12 +1,8 @@
[defaultFamily:cursive]
-ubuntu-20.04
-ubuntu-22.04
centos
b2qt
rhel
[defaultFamily:fantasy]
-ubuntu-20.04
-ubuntu-22.04
centos
b2qt
rhel
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index a663468d0f..6d86eb32fe 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -357,15 +357,15 @@ void tst_QFont::insertAndRemoveSubstitutions()
// inserting Foo
QFont::insertSubstitution("BogusFontFamily", "Foo");
- QCOMPARE(QFont::substitutes("BogusFontFamily").count(), 1);
- QCOMPARE(QFont::substitutes("bogusfontfamily").count(), 1);
+ QCOMPARE(QFont::substitutes("BogusFontFamily").size(), 1);
+ QCOMPARE(QFont::substitutes("bogusfontfamily").size(), 1);
// inserting Bar and Baz
QStringList moreFonts;
moreFonts << "Bar" << "Baz";
QFont::insertSubstitutions("BogusFontFamily", moreFonts);
- QCOMPARE(QFont::substitutes("BogusFontFamily").count(), 3);
- QCOMPARE(QFont::substitutes("bogusfontfamily").count(), 3);
+ QCOMPARE(QFont::substitutes("BogusFontFamily").size(), 3);
+ QCOMPARE(QFont::substitutes("bogusfontfamily").size(), 3);
QFont::removeSubstitutions("BogusFontFamily");
// make sure it is empty again
@@ -589,6 +589,11 @@ void tst_QFont::defaultFamily()
break;
}
}
+
+#if defined(Q_OS_UNIX) && defined(QT_NO_FONTCONFIG)
+ QSKIP("This platform does not support checking for default font acceptability");
+#endif
+
#ifdef Q_PROCESSOR_ARM_32
if (QTestPrivate::isRunningArmOnX86())
QEXPECT_FAIL("", "Fails on ARMv7 QEMU (QTQAINFRA-4127)", Continue);
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 9c56d9b2d2..665ee75a35 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -236,7 +236,7 @@ void tst_QFontDatabase::addAppFont()
QCOMPARE(id, -1);
return;
#endif
- QCOMPARE(fontDbChangedSpy.count(), 1);
+ QCOMPARE(fontDbChangedSpy.size(), 1);
if (id == -1)
QSKIP("Skip the test since app fonts are not supported on this system");
@@ -245,9 +245,9 @@ void tst_QFontDatabase::addAppFont()
const QStringList newFamilies = QFontDatabase::families();
QVERIFY(!newFamilies.isEmpty());
- QVERIFY(newFamilies.count() >= oldFamilies.count());
+ QVERIFY(newFamilies.size() >= oldFamilies.size());
- for (int i = 0; i < addedFamilies.count(); ++i) {
+ for (int i = 0; i < addedFamilies.size(); ++i) {
QString family = addedFamilies.at(i);
QVERIFY(newFamilies.contains(family));
QFont qfont(family);
@@ -256,9 +256,9 @@ void tst_QFontDatabase::addAppFont()
}
QVERIFY(QFontDatabase::removeApplicationFont(id));
- QCOMPARE(fontDbChangedSpy.count(), 2);
+ QCOMPARE(fontDbChangedSpy.size(), 2);
- QVERIFY(QFontDatabase::families().count() <= oldFamilies.count());
+ QVERIFY(QFontDatabase::families().size() <= oldFamilies.size());
}
void tst_QFontDatabase::addTwoAppFontsFromFamily()
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
index 1569a4bf84..2f57ec47b3 100644
--- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
+++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
@@ -605,17 +605,39 @@ void tst_QGlyphRun::multiLineBoundingRect()
void tst_QGlyphRun::defaultIgnorables()
{
- QTextLayout layout;
- layout.setFont(QFont("QtsSpecialTestFont"));
- layout.setText(QChar(0x200D));
- layout.beginLayout();
- layout.createLine();
- layout.endLayout();
+ {
+ QTextLayout layout;
+ layout.setFont(QFont("QtsSpecialTestFont"));
+ layout.setText(QChar(0x200D));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> runs = layout.glyphRuns();
+ QCOMPARE(runs.size(), 0);
+ }
- QList<QGlyphRun> runs = layout.glyphRuns();
- QCOMPARE(runs.size(), 1);
- QCOMPARE(runs.at(0).glyphIndexes().size(), 1);
- QCOMPARE(runs.at(0).glyphIndexes()[0], uint(0));
+ {
+ QTextLayout layout;
+ layout.setFont(QFont("QtsSpecialTestFont"));
+ layout.setText(QStringLiteral("AAA") + QChar(0xFE0F) + QStringLiteral("111"));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> runs = layout.glyphRuns();
+ QVERIFY(!runs.isEmpty());
+
+ bool hasFullMainFontRun = false;
+ for (const QGlyphRun &run : runs) {
+ if (run.rawFont().familyName() == QStringLiteral("QtsSpecialTestFont")
+ && run.glyphIndexes().size() == 6) {
+ hasFullMainFontRun = true;
+ break;
+ }
+ }
+ QVERIFY(hasFullMainFontRun);
+ }
}
#endif // QT_NO_RAWFONT
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
index 0e90572709..8b203f439e 100644
--- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
@@ -96,7 +96,7 @@ void tst_QRawFont::initTestCase()
if (testFont.isEmpty() || testFontBoldItalic.isEmpty())
QFAIL("qrawfont unittest font files not found!");
- if (QFontDatabase::families().count() == 0)
+ if (QFontDatabase::families().size() == 0)
QSKIP("No fonts available!!!");
}
diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
index 202d07ea1e..2d92d49f4f 100644
--- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
+++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
@@ -100,7 +100,7 @@ public:
virtual void highlightBlock(const QString &text) override
{
- for (int i = 0; i < formats.count(); ++i) {
+ for (int i = 0; i < formats.size(); ++i) {
const QTextLayout::FormatRange &range = formats.at(i);
setFormat(range.start, range.length, range.format);
}
@@ -161,7 +161,7 @@ public:
commentFormat.setForeground(Qt::darkGreen);
commentFormat.setFontWeight(QFont::StyleItalic);
commentFormat.setFontFixedPitch(true);
- int textLength = text.length();
+ int textLength = text.size();
if (text.startsWith(QLatin1Char(';'))){
// The entire line is a comment
@@ -414,7 +414,7 @@ void tst_QSyntaxHighlighter::preservePreeditArea()
QCOMPARE(hl->callCount, 1);
formats = layout->formats();
- QCOMPARE(formats.count(), 3);
+ QCOMPARE(formats.size(), 3);
range = formats.at(0);
@@ -493,7 +493,7 @@ void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight()
QSignalSpy contentsChangedSpy(doc, SIGNAL(contentsChanged()));
cursor.insertText("Hello World");
- QCOMPARE(contentsChangedSpy.count(), 1);
+ QCOMPARE(contentsChangedSpy.size(), 1);
QVERIFY(hl->highlighted);
QVERIFY(lout->documentChangedCalled);
}
diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
index cc6722af40..639e2e277f 100644
--- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
@@ -1754,26 +1754,26 @@ void tst_QTextCursor::update_data()
QTest::newRow("removeInsideSelection")
<< text
<< /*position*/ 0
- << /*anchor*/ int(text.length())
+ << /*anchor*/ int(text.size())
// delete 'big'
<< 6
<< 6 + charsToDelete
<< QString() // don't insert anything, just remove
<< /*expectedPosition*/ 0
- << /*expectedAnchor*/ int(text.length() - charsToDelete)
+ << /*expectedAnchor*/ int(text.size() - charsToDelete)
;
text = "Hello big world";
charsToDelete = 3;
QTest::newRow("removeInsideSelectionWithSwappedAnchorAndPosition")
<< text
- << /*position*/ int(text.length())
+ << /*position*/ int(text.size())
<< /*anchor*/ 0
// delete 'big'
<< 6
<< 6 + charsToDelete
<< QString() // don't insert anything, just remove
- << /*expectedPosition*/ int(text.length() - charsToDelete)
+ << /*expectedPosition*/ int(text.size() - charsToDelete)
<< /*expectedAnchor*/ 0
;
@@ -1784,13 +1784,13 @@ void tst_QTextCursor::update_data()
QTest::newRow("replaceInsideSelection")
<< text
<< /*position*/ 0
- << /*anchor*/ int(text.length())
+ << /*anchor*/ int(text.size())
// delete 'big' ...
<< 6
<< 6 + charsToDelete
<< textToInsert // ... and replace 'big' with 'small'
<< /*expectedPosition*/ 0
- << /*expectedAnchor*/ int(text.length() - charsToDelete + textToInsert.length())
+ << /*expectedAnchor*/ int(text.size() - charsToDelete + textToInsert.size())
;
text = "Hello big world";
@@ -1798,13 +1798,13 @@ void tst_QTextCursor::update_data()
textToInsert = "small";
QTest::newRow("replaceInsideSelectionWithSwappedAnchorAndPosition")
<< text
- << /*position*/ int(text.length())
+ << /*position*/ int(text.size())
<< /*anchor*/ 0
// delete 'big' ...
<< 6
<< 6 + charsToDelete
<< textToInsert // ... and replace 'big' with 'small'
- << /*expectedPosition*/ int(text.length() - charsToDelete + textToInsert.length())
+ << /*expectedPosition*/ int(text.size() - charsToDelete + textToInsert.size())
<< /*expectedAnchor*/ 0
;
@@ -1813,14 +1813,14 @@ void tst_QTextCursor::update_data()
charsToDelete = 3;
QTest::newRow("removeBeforeSelection")
<< text
- << /*position*/ int(text.length() - 5)
- << /*anchor*/ int(text.length())
+ << /*position*/ int(text.size() - 5)
+ << /*anchor*/ int(text.size())
// delete 'big'
<< 6
<< 6 + charsToDelete
<< QString() // don't insert anything, just remove
- << /*expectedPosition*/ int(text.length() - 5 - charsToDelete)
- << /*expectedAnchor*/ int(text.length() - charsToDelete)
+ << /*expectedPosition*/ int(text.size() - 5 - charsToDelete)
+ << /*expectedAnchor*/ int(text.size() - charsToDelete)
;
text = "Hello big world";
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index d10027b7a0..dc93c86829 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -465,17 +465,17 @@ void tst_QTextDocument::basicIsModifiedChecks()
QVERIFY(!doc->isModified());
cursor.insertText("Hello World");
QVERIFY(doc->isModified());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(spy.takeFirst().at(0).toBool());
doc->undo();
QVERIFY(!doc->isModified());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!spy.takeFirst().at(0).toBool());
doc->redo();
QVERIFY(doc->isModified());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(spy.takeFirst().at(0).toBool());
}
@@ -566,16 +566,16 @@ void tst_QTextDocument::noundo_basicIsModifiedChecks()
QVERIFY(!doc->isModified());
cursor.insertText("Hello World");
QVERIFY(doc->isModified());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(spy.takeFirst().at(0).toBool());
doc->undo();
QVERIFY(doc->isModified());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
doc->redo();
QVERIFY(doc->isModified());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTextDocument::task240325()
@@ -1945,7 +1945,7 @@ void tst_QTextDocument::toHtmlBodyBgColor()
doc.rootFrame()->setFrameFormat(fmt);
QString expectedHtml = htmlHead;
- expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"#0000ff\"");
+ expectedHtml.insert(htmlHead.size() - 2, " bgcolor=\"#0000ff\"");
expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
+ htmlTail;
@@ -1965,7 +1965,7 @@ void tst_QTextDocument::toHtmlBodyBgColorRgba()
doc.rootFrame()->setFrameFormat(fmt);
QString expectedHtml = htmlHead;
- expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"rgba(255,0,0,0.2)\"");
+ expectedHtml.insert(htmlHead.size() - 2, " bgcolor=\"rgba(255,0,0,0.2)\"");
expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
+ htmlTail;
@@ -1985,7 +1985,7 @@ void tst_QTextDocument::toHtmlBodyBgColorTransparent()
doc.rootFrame()->setFrameFormat(fmt);
QString expectedHtml = htmlHead;
- expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"transparent\"");
+ expectedHtml.insert(htmlHead.size() - 2, " bgcolor=\"transparent\"");
expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
+ htmlTail;
@@ -2051,7 +2051,7 @@ void tst_QTextDocument::toHtmlDefaultFontSpacingProperties()
doc.setDefaultFont(fnt);
QString expectedOutput = htmlHead;
- expectedOutput.insert(htmlHead.length() - 3, " letter-spacing:13px; word-spacing:15px;");
+ expectedOutput.insert(htmlHead.size() - 3, " letter-spacing:13px; word-spacing:15px;");
expectedOutput +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
+ htmlTail;
@@ -2071,7 +2071,7 @@ void tst_QTextDocument::toHtmlTextDecorationUnderline()
doc.setDefaultFont(fnt);
QString expectedOutput = htmlHead;
- expectedOutput.insert(htmlHead.length() - 3, " text-decoration: underline;");
+ expectedOutput.insert(htmlHead.size() - 3, " text-decoration: underline;");
expectedOutput +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Some text</p>"
+ htmlTail;
@@ -2086,7 +2086,7 @@ void tst_QTextDocument::toHtmlTextDecorationUnderline()
cursor.mergeCharFormat(format);
expectedOutput = htmlHead;
- expectedOutput.insert(htmlHead.length() - 3, " text-decoration: underline;");
+ expectedOutput.insert(htmlHead.size() - 3, " text-decoration: underline;");
expectedOutput +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
@@ -2740,11 +2740,11 @@ void tst_QTextDocument::defaultTableStyle()
brushes << sideProperty.value<QBrush>();
}
auto errorDetails = qScopeGuard([&]{
- if (brushes.count() != borderBrushes.count()) {
- qWarning("Different count: %lld vs %lld", brushes.count(), borderBrushes.count());
+ if (brushes.size() != borderBrushes.size()) {
+ qWarning("Different count: %lld vs %lld", brushes.size(), borderBrushes.size());
return;
}
- for (int i = 0; i < brushes.count(); ++i) {
+ for (int i = 0; i < brushes.size(); ++i) {
QString side;
QDebug(&side) << QTextFormat::Property(QTextFormat::TableCellTopBorderBrush + i);
QString actual;
@@ -2868,13 +2868,13 @@ void tst_QTextDocument::blockCountChanged()
doc->setPlainText("Foo");
QCOMPARE(doc->blockCount(), 1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
doc->setPlainText("Foo\nBar");
QCOMPARE(doc->blockCount(), 2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).value(0).toInt(), 2);
spy.clear();
@@ -2882,16 +2882,16 @@ void tst_QTextDocument::blockCountChanged()
cursor.movePosition(QTextCursor::End);
cursor.insertText("Blahblah");
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
cursor.insertBlock();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).value(0).toInt(), 3);
spy.clear();
doc->undo();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).value(0).toInt(), 2);
}
@@ -3070,12 +3070,12 @@ void tst_QTextDocument::characterAt()
QString text("12345\n67890");
cursor.insertText(text);
int length = doc.characterCount();
- QCOMPARE(length, text.length() + 1);
+ QCOMPARE(length, text.size() + 1);
QCOMPARE(doc.characterAt(length-1), QChar(QChar::ParagraphSeparator));
QCOMPARE(doc.characterAt(-1), QChar());
QCOMPARE(doc.characterAt(length), QChar());
QCOMPARE(doc.characterAt(length + 1), QChar());
- for (int i = 0; i < text.length(); ++i) {
+ for (int i = 0; i < text.size(); ++i) {
QChar c = text.at(i);
if (c == QLatin1Char('\n'))
c = QChar(QChar::ParagraphSeparator);
@@ -3155,11 +3155,11 @@ void tst_QTextDocument::testUndoCommandAdded()
QVERIFY(spy.isEmpty());
cursor.insertText("a");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
cursor.insertText("b"); // should be merged
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
cursor.insertText("c"); // should be merged
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(doc->toPlainText(), QString("abc"));
doc->undo();
QCOMPARE(doc->toPlainText(), QString(""));
@@ -3167,11 +3167,11 @@ void tst_QTextDocument::testUndoCommandAdded()
doc->clear();
spy.clear();
cursor.insertText("aaa");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
cursor.insertText("aaaa\nbcd");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
cursor.beginEditBlock();
@@ -3181,11 +3181,11 @@ void tst_QTextDocument::testUndoCommandAdded()
cursor.insertText("\nccc");
QVERIFY(spy.isEmpty());
cursor.endEditBlock();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
cursor.insertBlock();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
cursor.setPosition(5);
@@ -3197,18 +3197,18 @@ void tst_QTextDocument::testUndoCommandAdded()
QTextCharFormat cf;
cf.setFontItalic(true);
cursor.mergeCharFormat(cf);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
doc->undo();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
doc->undo();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
doc->redo();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
doc->redo();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTextDocument::testUndoBlocks()
@@ -3788,7 +3788,7 @@ void tst_QTextDocument::mergeFontFamilies()
QTextCursor cursor = QTextCursor(&td);
cursor.setPosition(0);
- cursor.setPosition(QByteArray("Hello World").length(), QTextCursor::KeepAnchor);
+ cursor.setPosition(QByteArray("Hello World").size(), QTextCursor::KeepAnchor);
cursor.mergeCharFormat(newFormat);
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Jokerman';")));
@@ -3934,7 +3934,7 @@ void tst_QTextDocument::insertHtmlWithComments()
QTextDocument doc;
doc.setHtml(html);
- QCOMPARE(doc.blockCount(), expectedBlocks.count());
+ QCOMPARE(doc.blockCount(), expectedBlocks.size());
QStringList blockContent;
auto currentBlock = doc.begin();
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 52708e1b14..4cc4a253ee 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -1175,7 +1175,7 @@ void tst_QTextDocumentFragment::copySubTable()
table->cellAt(row, col).firstCursorPosition().insertText(rowS + QString::number(col));
}
- QCOMPARE(table->format().columnWidthConstraints().count(), table->columns());
+ QCOMPARE(table->format().columnWidthConstraints().size(), table->columns());
// select 2x2 subtable
cursor = table->cellAt(1, 1).firstCursorPosition();
@@ -2235,7 +2235,7 @@ void tst_QTextDocumentFragment::html_frameImport()
cursor.insertFragment(frag);
QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames();
- QCOMPARE(childFrames.count(), 1);
+ QCOMPARE(childFrames.size(), 1);
QTextFrame *frame = childFrames.first();
QCOMPARE(frame->frameFormat().margin(), ffmt.margin());
QCOMPARE(frame->frameFormat().border(), ffmt.border());
@@ -2263,7 +2263,7 @@ void tst_QTextDocumentFragment::html_frameImport2()
cursor.insertFragment(frag);
QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames();
- QCOMPARE(childFrames.count(), 1);
+ QCOMPARE(childFrames.size(), 1);
QTextFrame *frame = childFrames.first();
QCOMPARE(frame->frameFormat().topMargin(), ffmt.topMargin());
QCOMPARE(frame->frameFormat().bottomMargin(), ffmt.bottomMargin());
@@ -2278,7 +2278,7 @@ void tst_QTextDocumentFragment::html_dontAddMarginsAcrossTableCells()
cursor.insertFragment(QTextDocumentFragment::fromHtml(QString::fromLatin1(html)));
QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames();
- QCOMPARE(childFrames.count(), 1);
+ QCOMPARE(childFrames.size(), 1);
QTextFrame *frame = childFrames.first();
cursor = frame->firstCursorPosition();
QCOMPARE(cursor.blockFormat().leftMargin(), qreal(50.0));
@@ -2760,7 +2760,7 @@ void tst_QTextDocumentFragment::html_columnWidths()
QTextTableFormat fmt = table->format();
const QList<QTextLength> columnWidths = fmt.columnWidthConstraints();
- QCOMPARE(columnWidths.count(), 2);
+ QCOMPARE(columnWidths.size(), 2);
QCOMPARE(columnWidths.at(0).type(), QTextLength::VariableLength);
QCOMPARE(columnWidths.at(1).type(), QTextLength::PercentageLength);
QCOMPARE(columnWidths.at(1).rawValue(), qreal(1));
@@ -4168,7 +4168,7 @@ void tst_QTextDocumentFragment::html_entities()
setHtml(html);
QCOMPARE(doc->blockCount(), 1);
QString txt = doc->begin().text();
- QCOMPARE(txt.length(), 1);
+ QCOMPARE(txt.size(), 1);
QCOMPARE(txt.at(0).unicode(), code);
}
diff --git a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
index 01c4005bfe..010fe002d4 100644
--- a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
+++ b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
@@ -33,6 +33,7 @@ private slots:
void floatingTablePageBreak();
void imageAtRightAlignedTab();
void blockVisibility();
+ void testHitTest();
void largeImage();
@@ -380,5 +381,41 @@ void tst_QTextDocumentLayout::largeImage()
}
}
+void tst_QTextDocumentLayout::testHitTest()
+{
+ QTextDocument document;
+ QTextCursor cur(&document);
+ int topMargin = 20;
+
+ //insert 500 blocks into textedit
+ for (int i = 0; i < 500; i++) {
+ cur.insertBlock();
+ cur.insertHtml(QString("block %1").arg(i));
+ }
+
+ //randomly set half the blocks invisible
+ QTextBlock blk=document.begin();
+ for (int i = 0; i < 500; i++) {
+ if (i % 7)
+ blk.setVisible(0);
+ blk = blk.next();
+ }
+
+ //set margin for all blocks (not strictly necessary, but makes easier to click in between blocks)
+ QTextBlockFormat blkfmt;
+ blkfmt.setTopMargin(topMargin);
+ cur.movePosition(QTextCursor::Start);
+ cur.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ cur.mergeBlockFormat(blkfmt);
+
+ for (int y = cur.selectionStart(); y < cur.selectionEnd(); y += 10) {
+ QPoint mousePoint(1, y);
+ int cursorPos = document.documentLayout()->hitTest(mousePoint, Qt::FuzzyHit);
+ int positionY = document.findBlock(cursorPos).layout()->position().toPoint().y();
+ //mousePoint is in the rect of the current Block
+ QVERIFY(positionY - topMargin <= y);
+ }
+}
+
QTEST_MAIN(tst_QTextDocumentLayout)
#include "tst_qtextdocumentlayout.moc"
diff --git a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
index 9ef5842803..1b28274748 100644
--- a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
+++ b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
@@ -187,7 +187,7 @@ void tst_QTextFormat::resolveFont()
QTextCursor(&doc).insertText("Test", fmt);
QList<QTextFormat> formats = doc.allFormats();
- QCOMPARE(formats.count(), 3);
+ QCOMPARE(formats.size(), 3);
QCOMPARE(formats.at(2).type(), int(QTextFormat::CharFormat));
fmt = formats.at(2).toCharFormat();
@@ -312,8 +312,8 @@ void tst_QTextFormat::getSetTabs()
public:
Comparator(const QList<QTextOption::Tab> &tabs, const QList<QTextOption::Tab> &tabs2)
{
- QCOMPARE(tabs.count(), tabs2.count());
- for(int i=0; i < tabs.count(); i++) {
+ QCOMPARE(tabs.size(), tabs2.size());
+ for(int i=0; i < tabs.size(); i++) {
QTextOption::Tab t1 = tabs[i];
QTextOption::Tab t2 = tabs2[i];
QCOMPARE(t1.position, t2.position);
@@ -364,7 +364,7 @@ void tst_QTextFormat::testTabsUsed()
QCOMPARE(line.cursorToX(4), 100.);
QTextOption option = layout->textOption();
- QCOMPARE(option.tabs().count(), tabs.count());
+ QCOMPARE(option.tabs().size(), tabs.size());
}
@@ -648,16 +648,16 @@ void tst_QTextFormat::clearCollection()
charFormat2.setUnderlineStyle(QTextCharFormat::SingleUnderline);
int formatIndex2 = collection.indexForFormat(charFormat2);
QCOMPARE(formatIndex2, 1);
- QCOMPARE(collection.formats.count(), 2);
- QCOMPARE(collection.hashes.count(), 2);
+ QCOMPARE(collection.formats.size(), 2);
+ QCOMPARE(collection.hashes.size(), 2);
QCOMPARE(collection.defaultFont(), f);
collection.clear();
- QCOMPARE(collection.formats.count(), 0);
- QCOMPARE(collection.hashes.count(), 0);
+ QCOMPARE(collection.formats.size(), 0);
+ QCOMPARE(collection.hashes.size(), 0);
QCOMPARE(collection.indexForFormat(charFormat2), 0);
- QCOMPARE(collection.formats.count(), 1);
- QCOMPARE(collection.hashes.count(), 1);
+ QCOMPARE(collection.formats.size(), 1);
+ QCOMPARE(collection.hashes.size(), 1);
QCOMPARE(collection.defaultFont(), f); // kept, QTextDocument::clear or setPlainText should not reset the font set by setDefaultFont
}
diff --git a/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt b/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt
new file mode 100644
index 0000000000..45feab12f1
--- /dev/null
+++ b/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+list(APPEND test_data "data/image.png")
+list(APPEND test_data "data/image@2x.png")
+
+qt_internal_add_test(tst_qtextimagehandler
+ SOURCES
+ tst_qtextimagehandler.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ TESTDATA
+ ${test_data}
+)
+
+qt_internal_add_resource(tst_qtextimagehandler "qtextimagehandler"
+ PREFIX
+ "/"
+ FILES
+ ${test_data}
+)
diff --git a/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp b/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp
index a1d9b2c6cf..b640efc8e4 100644
--- a/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp
+++ b/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 The Qt Company Ltd.
+// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
@@ -17,6 +17,7 @@ private slots:
void init();
void cleanup();
void cleanupTestCase();
+ void loadAtNImages_data();
void loadAtNImages();
};
@@ -36,24 +37,40 @@ void tst_QTextImageHandler::cleanupTestCase()
{
}
+void tst_QTextImageHandler::loadAtNImages_data()
+{
+ QTest::addColumn<QString>("imageFile");
+
+ QTest::addRow("file") << QFINDTESTDATA("data/image.png");
+ QTest::addRow("file_url") << QString("file:/") + QFINDTESTDATA("data/image.png");
+ QTest::addRow("resource") << ":/data/image.png";
+ QTest::addRow("qrc_url") << "qrc:/data/image.png";
+}
+
void tst_QTextImageHandler::loadAtNImages()
{
+ QFETCH(QString, imageFile);
+
QTextDocument doc;
QTextCursor c(&doc);
- c.insertHtml("<img src=\"data/image.png\">");
+ c.insertHtml("<img src=\"" + imageFile + "\">");
+ const auto formats = doc.allFormats();
+ const auto it = std::find_if(formats.begin(), formats.end(), [](const auto &format){
+ return format.objectType() == QTextFormat::ImageObject;
+ });
+ QVERIFY(it != formats.end());
+ const QTextImageFormat format = (*it).toImageFormat();
QTextImageHandler handler;
- QTextImageFormat fmt;
- fmt.setName("data/image.png");
- for (int i = 1; i < 3; ++i) {
+ for (const auto &dpr : {1, 2}) {
QImage img(20, 20, QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::white);
- img.setDevicePixelRatio(i);
+ img.setDevicePixelRatio(dpr);
QPainter p(&img);
- handler.drawObject(&p, QRect(0, 0, 20, 20), &doc, 0, fmt);
+ handler.drawObject(&p, QRect(0, 0, 20, 20), &doc, 0, format);
p.end();
QVERIFY(!img.isNull());
- const auto expectedColor = i == 1 ? Qt::red : Qt::green;
+ const auto expectedColor = dpr == 1 ? Qt::red : Qt::green;
QCOMPARE(img.pixelColor(0, 0), expectedColor);
}
}
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index def7c88593..a8b42b8869 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -720,29 +720,29 @@ void tst_QTextLayout::cursorToXForBidiBoundaries_data()
QTest::addColumn<Qt::LayoutDirection>("textDirection");
QTest::addColumn<QString>("text");
QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("expectedX");
+ QTest::addColumn<int>("runsToInclude");
QTest::addRow("LTR, abcشزذabc, 0") << Qt::LeftToRight << "abcشزذabc"
<< 0 << 0;
QTest::addRow("RTL, abcشزذabc, 9") << Qt::RightToLeft << "abcشزذabc"
- << 9 << TESTFONT_SIZE * 3;
+ << 9 << 1;
QTest::addRow("LTR, abcشزذabc, 3") << Qt::LeftToRight << "abcشزذabc"
<< 0 << 0;
QTest::addRow("RTL, abcشزذabc, 6") << Qt::RightToLeft << "abcشزذabc"
- << 9 << TESTFONT_SIZE * 3;
+ << 9 << 1;
QTest::addRow("LTR, شزذabcشزذ, 0") << Qt::LeftToRight << "شزذabcشزذ"
- << 0 << TESTFONT_SIZE * 2;
+ << 0 << 1;
QTest::addRow("RTL, شزذabcشزذ, 9") << Qt::RightToLeft << "شزذabcشزذ"
<< 9 << 0;
QTest::addRow("LTR, شزذabcشزذ, 3") << Qt::LeftToRight << "شزذabcشزذ"
- << 3 << TESTFONT_SIZE * 2;
+ << 3 << 1;
QTest::addRow("RTL, شزذabcشزذ, 3") << Qt::RightToLeft << "شزذabcشزذ"
- << 3 << TESTFONT_SIZE * 5;
+ << 3 << 2;
QTest::addRow("LTR, شزذabcشزذ, 6") << Qt::LeftToRight << "شزذabcشزذ"
- << 6 << TESTFONT_SIZE * 5;
+ << 6 << 2;
QTest::addRow("RTL, شزذabcشزذ, 6") << Qt::RightToLeft << "شزذabcشزذ"
- << 6 << TESTFONT_SIZE * 2;
+ << 6 << 1;
}
void tst_QTextLayout::cursorToXForBidiBoundaries()
@@ -750,7 +750,7 @@ void tst_QTextLayout::cursorToXForBidiBoundaries()
QFETCH(Qt::LayoutDirection, textDirection);
QFETCH(QString, text);
QFETCH(int, cursorPosition);
- QFETCH(int, expectedX);
+ QFETCH(int, runsToInclude);
QTextOption option;
option.setTextDirection(textDirection);
@@ -759,12 +759,27 @@ void tst_QTextLayout::cursorToXForBidiBoundaries()
layout.setTextOption(option);
layout.beginLayout();
- QTextLine line = layout.createLine();
- line.setLineWidth(0x10000);
+ {
+ QTextLine line = layout.createLine();
+ line.setLineWidth(0x10000);
+ }
+ layout.endLayout();
- QCOMPARE(line.cursorToX(cursorPosition), expectedX);
+ QTextLine line = layout.lineAt(0);
+ QList<QGlyphRun> glyphRuns = line.glyphRuns();
+ QVERIFY(runsToInclude <= glyphRuns.size());
- layout.endLayout();
+ std::sort(glyphRuns.begin(), glyphRuns.end(),
+ [](const QGlyphRun &first, const QGlyphRun &second) {
+ return first.positions().first().x() < second.positions().first().x();
+ });
+
+ qreal expectedX = 0.0;
+ for (int i = 0; i < runsToInclude; ++i) {
+ expectedX += glyphRuns.at(i).boundingRect().width();
+ }
+
+ QCOMPARE(line.cursorToX(cursorPosition), expectedX);
}
void tst_QTextLayout::horizontalAlignment_data()
diff --git a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp
index 30185e83b9..3ae6046bdb 100644
--- a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp
+++ b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp
@@ -79,7 +79,7 @@ QString tst_QTextOdfWriter::getContentFromXml()
if (index > 0) {
index = stringContent.indexOf('>', index);
if (index > 0)
- ret = stringContent.mid(index+1, stringContent.length() - index - 10);
+ ret = stringContent.mid(index+1, stringContent.size() - index - 10);
}
return ret;
}
@@ -279,7 +279,7 @@ file.open(QIODevice::WriteOnly);
file.write(buffer->data());
file.close();
*/
- QVERIFY(buffer->data().length() > 80);
+ QVERIFY(buffer->data().size() > 80);
QCOMPARE(buffer->data()[0], 'P'); // its a zip :)
QCOMPARE(buffer->data()[1], 'K');
QString mimetype(buffer->data().mid(38, 39));
diff --git a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
index 71afd31574..cac84de7e2 100644
--- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
+++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
@@ -971,7 +971,7 @@ void tst_QTextPieceTable::checkFrames1()
QVERIFY(root);
QVERIFY(!root->parentFrame());
- QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().size(), 1);
QVERIFY(frame->format() == ffmt);
QCOMPARE(frame->firstPosition(), 2);
QCOMPARE(frame->lastPosition(), 4);
@@ -979,10 +979,10 @@ void tst_QTextPieceTable::checkFrames1()
QPointer<QTextFrame> frame2 = table->insertFrame(2, 3, ffmt);
- QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().size(), 1);
QCOMPARE(root->childFrames().at(0), frame.data());
- QCOMPARE(frame->childFrames().count(), 1);
- QCOMPARE(frame2->childFrames().count(), 0);
+ QCOMPARE(frame->childFrames().size(), 1);
+ QCOMPARE(frame2->childFrames().size(), 0);
QCOMPARE(frame2->parentFrame(), frame.data());
QCOMPARE(frame2->firstPosition(), 3);
QCOMPARE(frame2->lastPosition(), 4);
@@ -993,10 +993,10 @@ void tst_QTextPieceTable::checkFrames1()
table->removeFrame(frame);
- QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().size(), 1);
QCOMPARE(root->childFrames().at(0), frame2.data());
QVERIFY(!frame);
- QCOMPARE(frame2->childFrames().count(), 0);
+ QCOMPARE(frame2->childFrames().size(), 0);
QCOMPARE(frame2->parentFrame(), root);
QCOMPARE(frame2->firstPosition(), 2);
QCOMPARE(frame2->lastPosition(), 3);
@@ -1005,11 +1005,11 @@ void tst_QTextPieceTable::checkFrames1()
frame = table->frameAt(2);
- QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().size(), 1);
QCOMPARE(root->childFrames().at(0), frame.data());
- QCOMPARE(frame->childFrames().count(), 1);
+ QCOMPARE(frame->childFrames().size(), 1);
QCOMPARE(frame->childFrames().at(0), frame2.data());
- QCOMPARE(frame2->childFrames().count(), 0);
+ QCOMPARE(frame2->childFrames().size(), 0);
QCOMPARE(frame2->parentFrame(), frame.data());
QCOMPARE(frame2->firstPosition(), 3);
QCOMPARE(frame2->lastPosition(), 4);
@@ -1019,9 +1019,9 @@ void tst_QTextPieceTable::checkFrames1()
table->undo();
- QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().size(), 1);
QCOMPARE(root->childFrames().at(0), frame.data());
- QCOMPARE(frame->childFrames().count(), 0);
+ QCOMPARE(frame->childFrames().size(), 0);
QVERIFY(!frame2);
QCOMPARE(frame->firstPosition(), 2);
diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
index bfead23d4d..ae5502852c 100644
--- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
@@ -121,7 +121,7 @@ void tst_QTextTable::variousTableModifications()
QTextTableFormat tableFmt;
QTextTable *tab = cursor.insertTable(2, 2, tableFmt);
- QCOMPARE(doc->toPlainText().length(), 5);
+ QCOMPARE(doc->toPlainText().size(), 5);
QCOMPARE(tab, cursor.currentTable());
QCOMPARE(tab->columns(), 2);
QCOMPARE(tab->rows(), 2);
@@ -176,14 +176,14 @@ void tst_QTextTable::variousTableModifications()
cursor.movePosition(QTextCursor::NextBlock);
QCOMPARE(cursor.position(), 1);
cursor.deleteChar();
- QCOMPARE(doc->toPlainText().length(), 5);
+ QCOMPARE(doc->toPlainText().size(), 5);
cursor.movePosition(QTextCursor::NextBlock);
QCOMPARE(cursor.position(), 2);
cursor.deleteChar();
- QCOMPARE(doc->toPlainText().length(), 5);
+ QCOMPARE(doc->toPlainText().size(), 5);
cursor.deletePreviousChar();
QCOMPARE(cursor.position(), 2);
- QCOMPARE(doc->toPlainText().length(), 5);
+ QCOMPARE(doc->toPlainText().size(), 5);
QTextTable *table = cursor.currentTable();
QCOMPARE(table->rows(), 2);
@@ -192,16 +192,16 @@ void tst_QTextTable::variousTableModifications()
table->insertRows(2, 1);
QCOMPARE(table->rows(), 3);
QCOMPARE(table->columns(), 2);
- QCOMPARE(doc->toPlainText().length(), 7);
+ QCOMPARE(doc->toPlainText().size(), 7);
table->insertColumns(2, 2);
QCOMPARE(table->rows(), 3);
QCOMPARE(table->columns(), 4);
- QCOMPARE(doc->toPlainText().length(), 13);
+ QCOMPARE(doc->toPlainText().size(), 13);
table->resize(4, 5);
QCOMPARE(table->rows(), 4);
QCOMPARE(table->columns(), 5);
- QCOMPARE(doc->toPlainText().length(), 21);
+ QCOMPARE(doc->toPlainText().size(), 21);
}
void tst_QTextTable::tableShrinking()
@@ -209,7 +209,7 @@ void tst_QTextTable::tableShrinking()
QTextTableFormat tableFmt;
cursor.insertTable(3, 4, tableFmt);
- QCOMPARE(doc->toPlainText().length(), 13);
+ QCOMPARE(doc->toPlainText().size(), 13);
QTextTable *table = cursor.currentTable();
QCOMPARE(table->rows(), 3);
@@ -218,16 +218,16 @@ void tst_QTextTable::tableShrinking()
table->removeRows(1, 1);
QCOMPARE(table->rows(), 2);
QCOMPARE(table->columns(), 4);
- QCOMPARE(doc->toPlainText().length(), 9);
+ QCOMPARE(doc->toPlainText().size(), 9);
table->removeColumns(1, 2);
QCOMPARE(table->rows(), 2);
QCOMPARE(table->columns(), 2);
- QCOMPARE(doc->toPlainText().length(), 5);
+ QCOMPARE(doc->toPlainText().size(), 5);
table->resize(1, 1);
QCOMPARE(table->rows(), 1);
QCOMPARE(table->columns(), 1);
- QCOMPARE(doc->toPlainText().length(), 2);
+ QCOMPARE(doc->toPlainText().size(), 2);
}
void tst_QTextTable::spans()
@@ -252,7 +252,7 @@ void tst_QTextTable::variousModifications2()
QTextTableFormat tableFmt;
cursor.insertTable(2, 5, tableFmt);
- QCOMPARE(doc->toPlainText().length(), 11);
+ QCOMPARE(doc->toPlainText().size(), 11);
QTextTable *table = cursor.currentTable();
QCOMPARE(cursor.position(), 1);
QCOMPARE(table->rows(), 2);
@@ -1148,8 +1148,8 @@ void tst_QTextTable::QTBUG31330_renderBackground()
doc.print(&paintDevice);
QVERIFY(paintDevice.pages >= 2);
- QCOMPARE(engine.rects.count(), paintDevice.pages);
- for (int i = 0; i < engine.rects.count(); ++i) {
+ QCOMPARE(engine.rects.size(), paintDevice.pages);
+ for (int i = 0; i < engine.rects.size(); ++i) {
QRectF rect = engine.rects[i];
QVERIFY(rect.top() > 0);
QVERIFY(rect.bottom() < 1000);
diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/gui/text/qzip/tst_qzip.cpp
index 128f0b3200..3e2dc39983 100644
--- a/tests/auto/gui/text/qzip/tst_qzip.cpp
+++ b/tests/auto/gui/text/qzip/tst_qzip.cpp
@@ -23,7 +23,7 @@ void tst_QZip::basicUnpack()
{
QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly);
QList<QZipReader::FileInfo> files = zip.fileInfoList();
- QCOMPARE(files.count(), 2);
+ QCOMPARE(files.size(), 2);
QZipReader::FileInfo fi = files.at(0);
QVERIFY(fi.isValid());
@@ -59,7 +59,7 @@ void tst_QZip::symlinks()
{
QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly);
QList<QZipReader::FileInfo> files = zip.fileInfoList();
- QCOMPARE(files.count(), 2);
+ QCOMPARE(files.size(), 2);
QZipReader::FileInfo fi = files.at(0);
QVERIFY(fi.isValid());
@@ -82,7 +82,7 @@ void tst_QZip::readTest()
{
QZipReader zip("foobar.zip", QIODevice::ReadOnly); // non existing file.
QList<QZipReader::FileInfo> files = zip.fileInfoList();
- QCOMPARE(files.count(), 0);
+ QCOMPARE(files.size(), 0);
QByteArray b = zip.fileData("foobar");
QCOMPARE(b.size(), 0);
}
@@ -101,7 +101,7 @@ void tst_QZip::createArchive()
QBuffer buffer2(&zipFile);
QZipReader zip2(&buffer2);
QList<QZipReader::FileInfo> files = zip2.fileInfoList();
- QCOMPARE(files.count(), 1);
+ QCOMPARE(files.size(), 1);
QZipReader::FileInfo file = files.at(0);
QCOMPARE(file.filePath, QString("My Filename"));
QCOMPARE(uint(file.isDir), (uint) 0);
diff --git a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
index 7818e83f09..a29de07183 100644
--- a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
+++ b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
@@ -143,6 +143,7 @@ void tst_QDoubleValidator::validate_data()
QTest::newRow("data56") << "C" << 1229.0 << 1231.0 << -1 << QString("123E+") << ITM << INV;
QTest::newRow("data57") << "C" << 1229.0 << 1231.0 << -1 << QString("123E+1") << ACC << INV;
QTest::newRow("data58") << "C" << 0.0 << 100.0 << -1 << QString("0.0") << ACC << ACC;
+ QTest::newRow("overlong") << "C" << 0.0 << 99.9 << 2 << QString("1234.0") << ITM << INV;
QTest::newRow("data_de0") << "de" << 0.0 << 100.0 << 1 << QString("50,0") << ACC << ACC;
QTest::newRow("data_de1") << "de" << 00.0 << 100.0 << 1 << QString("500,0") << ITM << ITM;
@@ -310,74 +311,74 @@ void tst_QDoubleValidator::notifySignals()
QCOMPARE(dv.decimals(), 10);
dv.setTop(0.8);
- QCOMPARE(topSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
+ QCOMPARE(topSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
QCOMPARE(dv.top(), 0.8);
dv.setBottom(0.2);
- QCOMPARE(bottomSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 2);
+ QCOMPARE(bottomSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 2);
QCOMPARE(dv.bottom(), 0.2);
dv.setRange(0.2, 0.7);
- QCOMPARE(topSpy.count(), 2);
- QCOMPARE(bottomSpy.count(), 1);
- QCOMPARE(decSpy.count(), 0);
- QCOMPARE(changedSpy.count(), 3);
+ QCOMPARE(topSpy.size(), 2);
+ QCOMPARE(bottomSpy.size(), 1);
+ QCOMPARE(decSpy.size(), 0);
+ QCOMPARE(changedSpy.size(), 3);
QCOMPARE(dv.bottom(), 0.2);
QCOMPARE(dv.top(), 0.7);
QCOMPARE(dv.decimals(), 10);
dv.setRange(0.3, 0.7);
- QCOMPARE(topSpy.count(), 2);
- QCOMPARE(bottomSpy.count(), 2);
- QCOMPARE(changedSpy.count(), 4);
+ QCOMPARE(topSpy.size(), 2);
+ QCOMPARE(bottomSpy.size(), 2);
+ QCOMPARE(changedSpy.size(), 4);
QCOMPARE(dv.bottom(), 0.3);
QCOMPARE(dv.top(), 0.7);
QCOMPARE(dv.decimals(), 10);
dv.setRange(0.4, 0.6);
- QCOMPARE(topSpy.count(), 3);
- QCOMPARE(bottomSpy.count(), 3);
- QCOMPARE(changedSpy.count(), 5);
+ QCOMPARE(topSpy.size(), 3);
+ QCOMPARE(bottomSpy.size(), 3);
+ QCOMPARE(changedSpy.size(), 5);
QCOMPARE(dv.bottom(), 0.4);
QCOMPARE(dv.top(), 0.6);
QCOMPARE(dv.decimals(), 10);
dv.setDecimals(5);
- QCOMPARE(decSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 6);
+ QCOMPARE(decSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 6);
QCOMPARE(dv.decimals(), 5);
dv.setRange(0.4, 0.6, 100);
- QCOMPARE(topSpy.count(), 3);
- QCOMPARE(bottomSpy.count(), 3);
- QCOMPARE(decSpy.count(), 2);
- QCOMPARE(changedSpy.count(), 7);
+ QCOMPARE(topSpy.size(), 3);
+ QCOMPARE(bottomSpy.size(), 3);
+ QCOMPARE(decSpy.size(), 2);
+ QCOMPARE(changedSpy.size(), 7);
QCOMPARE(dv.bottom(), 0.4);
QCOMPARE(dv.top(), 0.6);
QCOMPARE(dv.decimals(), 100);
dv.setNotation(QDoubleValidator::StandardNotation);
- QCOMPARE(notSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 8);
+ QCOMPARE(notSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 8);
QCOMPARE(dv.notation(), QDoubleValidator::StandardNotation);
dv.setRange(dv.bottom(), dv.top(), dv.decimals());
- QCOMPARE(topSpy.count(), 3);
- QCOMPARE(bottomSpy.count(), 3);
- QCOMPARE(decSpy.count(), 2);
- QCOMPARE(changedSpy.count(), 8);
+ QCOMPARE(topSpy.size(), 3);
+ QCOMPARE(bottomSpy.size(), 3);
+ QCOMPARE(decSpy.size(), 2);
+ QCOMPARE(changedSpy.size(), 8);
dv.setNotation(dv.notation());
- QCOMPARE(notSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 8);
+ QCOMPARE(notSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 8);
dv.setLocale(QLocale("C"));
- QCOMPARE(changedSpy.count(), 8);
+ QCOMPARE(changedSpy.size(), 8);
dv.setLocale(QLocale("en"));
- QCOMPARE(changedSpy.count(), 9);
+ QCOMPARE(changedSpy.size(), 9);
}
void tst_QDoubleValidator::fixup()
diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
index 6e380bdcaa..ec4e3930ec 100644
--- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
+++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
@@ -211,45 +211,45 @@ void tst_QIntValidator::notifySignals()
QSignalSpy changedSpy(&iv, SIGNAL(changed()));
iv.setTop(9);
- QCOMPARE(topSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
+ QCOMPARE(topSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
QCOMPARE(iv.top(), 9);
iv.setBottom(1);
- QCOMPARE(bottomSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 2);
+ QCOMPARE(bottomSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 2);
QCOMPARE(iv.bottom(), 1);
iv.setRange(1, 8);
- QCOMPARE(topSpy.count(), 2);
- QCOMPARE(bottomSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 3);
+ QCOMPARE(topSpy.size(), 2);
+ QCOMPARE(bottomSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 3);
QCOMPARE(iv.top(), 8);
QCOMPARE(iv.bottom(), 1);
iv.setRange(2, 8);
- QCOMPARE(topSpy.count(), 2);
- QCOMPARE(bottomSpy.count(), 2);
- QCOMPARE(changedSpy.count(), 4);
+ QCOMPARE(topSpy.size(), 2);
+ QCOMPARE(bottomSpy.size(), 2);
+ QCOMPARE(changedSpy.size(), 4);
QCOMPARE(iv.top(), 8);
QCOMPARE(iv.bottom(), 2);
iv.setRange(3, 7);
- QCOMPARE(topSpy.count(), 3);
- QCOMPARE(bottomSpy.count(), 3);
- QCOMPARE(changedSpy.count(), 5);
+ QCOMPARE(topSpy.size(), 3);
+ QCOMPARE(bottomSpy.size(), 3);
+ QCOMPARE(changedSpy.size(), 5);
QCOMPARE(iv.top(), 7);
QCOMPARE(iv.bottom(), 3);
iv.setRange(3, 7);
- QCOMPARE(topSpy.count(), 3);
- QCOMPARE(bottomSpy.count(), 3);
- QCOMPARE(changedSpy.count(), 5);
+ QCOMPARE(topSpy.size(), 3);
+ QCOMPARE(bottomSpy.size(), 3);
+ QCOMPARE(changedSpy.size(), 5);
iv.setLocale(QLocale("C"));
- QCOMPARE(changedSpy.count(), 5);
+ QCOMPARE(changedSpy.size(), 5);
iv.setLocale(QLocale("en"));
- QCOMPARE(changedSpy.count(), 6);
+ QCOMPARE(changedSpy.size(), 6);
}
void tst_QIntValidator::fixup()
diff --git a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
index d78ee31864..c2ddafa2c6 100644
--- a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
+++ b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
@@ -73,12 +73,12 @@ void tst_QRegularExpressionValidator::validate()
QTEST(result, "state");
if (result == QValidator::Invalid)
- QCOMPARE(pos, value.length());
+ QCOMPARE(pos, value.size());
else
QCOMPARE(pos, -1); // ensure pos is not modified if validate returned Acceptable or Intermediate
- QCOMPARE(spy.count(), signalCount);
- QCOMPARE(changedSpy.count(), signalCount);
+ QCOMPARE(spy.size(), signalCount);
+ QCOMPARE(changedSpy.size(), signalCount);
}
QTEST_GUILESS_MAIN(tst_QRegularExpressionValidator)
diff --git a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
index bcecfc26b9..f554e94a98 100644
--- a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
@@ -65,7 +65,7 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
QUndoCommand *parent)
: QUndoCommand(parent)
{
- QVERIFY(str->length() >= idx);
+ QVERIFY(str->size() >= idx);
setText("insert");
@@ -76,22 +76,22 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
void InsertCommand::redo()
{
- QVERIFY(m_str->length() >= m_idx);
+ QVERIFY(m_str->size() >= m_idx);
m_str->insert(m_idx, m_text);
}
void InsertCommand::undo()
{
- QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text);
- m_str->remove(m_idx, m_text.length());
+ m_str->remove(m_idx, m_text.size());
}
RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent)
: QUndoCommand(parent)
{
- QVERIFY(str->length() >= idx + len);
+ QVERIFY(str->size() >= idx + len);
setText("remove");
@@ -102,14 +102,14 @@ RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *paren
void RemoveCommand::redo()
{
- QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text);
- m_str->remove(m_idx, m_text.length());
+ m_str->remove(m_idx, m_text.size());
}
void RemoveCommand::undo()
{
- QVERIFY(m_str->length() >= m_idx);
+ QVERIFY(m_str->size() >= m_idx);
m_str->insert(m_idx, m_text);
}
@@ -131,9 +131,9 @@ void AppendCommand::redo()
void AppendCommand::undo()
{
- QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_str->size() - m_text.size()), m_text);
- m_str->truncate(m_str->length() - m_text.length());
+ m_str->truncate(m_str->size() - m_text.size());
}
int AppendCommand::id() const
diff --git a/tests/auto/gui/util/qundostack/tst_qundostack.cpp b/tests/auto/gui/util/qundostack/tst_qundostack.cpp
index bdb664ad7e..b47a4ee1a9 100644
--- a/tests/auto/gui/util/qundostack/tst_qundostack.cpp
+++ b/tests/auto/gui/util/qundostack/tst_qundostack.cpp
@@ -97,7 +97,7 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
QUndoCommand *parent)
: QUndoCommand(parent)
{
- QVERIFY(str->length() >= idx);
+ QVERIFY(str->size() >= idx);
setText("insert");
@@ -108,22 +108,22 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
void InsertCommand::redo()
{
- QVERIFY(m_str->length() >= m_idx);
+ QVERIFY(m_str->size() >= m_idx);
m_str->insert(m_idx, m_text);
}
void InsertCommand::undo()
{
- QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text);
- m_str->remove(m_idx, m_text.length());
+ m_str->remove(m_idx, m_text.size());
}
RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent)
: QUndoCommand(parent)
{
- QVERIFY(str->length() >= idx + len);
+ QVERIFY(str->size() >= idx + len);
setText("remove");
@@ -134,14 +134,14 @@ RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *paren
void RemoveCommand::redo()
{
- QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text);
- m_str->remove(m_idx, m_text.length());
+ m_str->remove(m_idx, m_text.size());
}
void RemoveCommand::undo()
{
- QVERIFY(m_str->length() >= m_idx);
+ QVERIFY(m_str->size() >= m_idx);
m_str->insert(m_idx, m_text);
}
@@ -172,9 +172,9 @@ void AppendCommand::redo()
void AppendCommand::undo()
{
- QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text);
+ QCOMPARE(m_str->mid(m_str->size() - m_text.size()), m_text);
- m_str->truncate(m_str->length() - m_text.length());
+ m_str->truncate(m_str->size() - m_text.size());
}
int AppendCommand::id() const
@@ -324,44 +324,44 @@ static void checkState(QSignalSpy &redoTextChangedSpy,
QCOMPARE(stack.canRedo(), _canRedo);
QCOMPARE(stack.redoText(), QString(_redoText));
if (_indexChanged) {
- QCOMPARE(indexChangedSpy.count(), 1);
+ QCOMPARE(indexChangedSpy.size(), 1);
QCOMPARE(indexChangedSpy.at(0).at(0).toInt(), _index);
indexChangedSpy.clear();
} else {
- QCOMPARE(indexChangedSpy.count(), 0);
+ QCOMPARE(indexChangedSpy.size(), 0);
}
if (_cleanChanged) {
- QCOMPARE(cleanChangedSpy.count(), 1);
+ QCOMPARE(cleanChangedSpy.size(), 1);
QCOMPARE(cleanChangedSpy.at(0).at(0).toBool(), _clean);
cleanChangedSpy.clear();
} else {
- QCOMPARE(cleanChangedSpy.count(), 0);
+ QCOMPARE(cleanChangedSpy.size(), 0);
}
if (_undoChanged) {
- QCOMPARE(canUndoChangedSpy.count(), 1);
+ QCOMPARE(canUndoChangedSpy.size(), 1);
QCOMPARE(canUndoChangedSpy.at(0).at(0).toBool(), _canUndo);
QCOMPARE(undoAction->isEnabled(), _canUndo);
- QCOMPARE(undoTextChangedSpy.count(), 1);
+ QCOMPARE(undoTextChangedSpy.size(), 1);
QCOMPARE(undoTextChangedSpy.at(0).at(0).toString(), QString(_undoText));
QCOMPARE(undoAction->text(), glue("foo", _undoText));
canUndoChangedSpy.clear();
undoTextChangedSpy.clear();
} else {
- QCOMPARE(canUndoChangedSpy.count(), 0);
- QCOMPARE(undoTextChangedSpy.count(), 0);
+ QCOMPARE(canUndoChangedSpy.size(), 0);
+ QCOMPARE(undoTextChangedSpy.size(), 0);
}
if (_redoChanged) {
- QCOMPARE(canRedoChangedSpy.count(), 1);
+ QCOMPARE(canRedoChangedSpy.size(), 1);
QCOMPARE(canRedoChangedSpy.at(0).at(0).toBool(), _canRedo);
QCOMPARE(redoAction->isEnabled(), _canRedo);
- QCOMPARE(redoTextChangedSpy.count(), 1);
+ QCOMPARE(redoTextChangedSpy.size(), 1);
QCOMPARE(redoTextChangedSpy.at(0).at(0).toString(), QString(_redoText));
QCOMPARE(redoAction->text(), glue("bar", _redoText));
canRedoChangedSpy.clear();
redoTextChangedSpy.clear();
} else {
- QCOMPARE(canRedoChangedSpy.count(), 0);
- QCOMPARE(redoTextChangedSpy.count(), 0);
+ QCOMPARE(canRedoChangedSpy.size(), 0);
+ QCOMPARE(redoTextChangedSpy.size(), 0);
}
}
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index 8207f65dcd..9c1a63bae1 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -69,6 +69,7 @@ public slots:
void init();
private slots:
// Tests:
+ void defaultQnamHttp2Configuration();
void singleRequest_data();
void singleRequest();
void multipleRequests();
@@ -208,6 +209,12 @@ void tst_Http2::init()
manager.reset(new QNetworkAccessManager);
}
+void tst_Http2::defaultQnamHttp2Configuration()
+{
+ // The configuration we also implicitly use in QNAM.
+ QCOMPARE(qt_defaultH2Configuration(), QNetworkRequest().http2Configuration());
+}
+
void tst_Http2::singleRequest_data()
{
QTest::addColumn<QNetworkRequest::Attribute>("h2Attribute");
@@ -285,7 +292,7 @@ void tst_Http2::singleRequest()
#if QT_CONFIG(ssl)
if (connectionType == H2Type::h2Alpn || connectionType == H2Type::h2Direct)
- QCOMPARE(encSpy.count(), 1);
+ QCOMPARE(encSpy.size(), 1);
#endif // QT_CONFIG(ssl)
}
@@ -773,7 +780,7 @@ void tst_Http2::maxFrameSize()
// Normally, with a 16kb limit, our server would split such
// a response into 3 'DATA' frames (16kb + 16kb + 0|END_STREAM).
- QCOMPARE(frameCounter.count(), 1);
+ QCOMPARE(frameCounter.size(), 1);
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
index d40411ba3d..28bbf5459a 100644
--- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
+++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
@@ -265,7 +265,7 @@ void tst_QAbstractNetworkCache::runTest()
// prime the cache
QNetworkReply *reply = manager.get(request);
QSignalSpy downloaded1(reply, SIGNAL(finished()));
- QTRY_COMPARE(downloaded1.count(), 1);
+ QTRY_COMPARE(downloaded1.size(), 1);
QCOMPARE(diskCache->gotData, false);
QByteArray goodData = reply->readAll();
@@ -274,7 +274,7 @@ void tst_QAbstractNetworkCache::runTest()
// should be in the cache now
QNetworkReply *reply2 = manager.get(request);
QSignalSpy downloaded2(reply2, SIGNAL(finished()));
- QTRY_COMPARE(downloaded2.count(), 1);
+ QTRY_COMPARE(downloaded2.size(), 1);
QByteArray secondData = reply2->readAll();
if (!fetchFromCache && cacheLoadControl == QNetworkRequest::AlwaysCache) {
@@ -363,7 +363,7 @@ void tst_QAbstractNetworkCache::deleteCache()
QNetworkReply *reply = manager.get(request);
QSignalSpy downloaded1(reply, SIGNAL(finished()));
manager.setCache(0);
- QTRY_COMPARE(downloaded1.count(), 1);
+ QTRY_COMPARE(downloaded1.size(), 1);
}
diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index b1f3966285..6833eb5bc9 100644
--- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -666,7 +666,7 @@ void tst_QHttpNetworkConnection::getMultiple_data()
static bool allRepliesFinished(const QList<QHttpNetworkReply*> *_replies)
{
const QList<QHttpNetworkReply*> &replies = *_replies;
- for (int i = 0; i < replies.length(); i++)
+ for (int i = 0; i < replies.size(); i++)
if (!replies.at(i)->isFinished())
return false;
return true;
@@ -735,7 +735,7 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities(
QTRY_VERIFY_WITH_TIMEOUT(allRepliesFinished(&replies), 60000);
int pipelinedCount = 0;
- for (int i = 0; i < replies.length(); i++) {
+ for (int i = 0; i < replies.size(); i++) {
QVERIFY (!(replies.at(i)->request().isPipeliningAllowed() == false
&& replies.at(i)->isPipeliningUsed()));
diff --git a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp
index e36acc81da..0780ae1f0e 100644
--- a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp
+++ b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp
@@ -77,7 +77,7 @@ void tst_QHttpNetworkReply::parseHeader()
QHttpNetworkReply reply;
reply.parseHeader(headers);
- for (int i = 0; i < fields.count(); ++i) {
+ for (int i = 0; i < fields.size(); ++i) {
//qDebug() << "field" << fields.at(i) << "value" << reply.headerField(fields.at(i)) << "expected" << values.at(i);
QString field = reply.headerField(fields.at(i).toLatin1());
QCOMPARE(field, values.at(i));
diff --git a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
index d6709a614c..18fd0f01ab 100644
--- a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -553,11 +553,11 @@ void tst_QNetworkCookie::parseSingleCookie()
QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toUtf8());
//QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort);
- QCOMPARE(result.count(), 1);
+ QCOMPARE(result.size(), 1);
QCOMPARE(result.at(0), expectedCookie);
result = QNetworkCookie::parseCookies(result.at(0).toRawForm());
- QCOMPARE(result.count(), 1);
+ QCOMPARE(result.size(), 1);
// Drop any millisecond information, if there's any
QDateTime dt = expectedCookie.expirationDate();
diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index ddce612684..301bb633b8 100644
--- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -546,9 +546,9 @@ void tst_QNetworkCookieJar::rfc6265()
QList<QNetworkCookie> cookiesToSend = jar.cookiesForUrl(sentUrl);
//compare cookies only using name/value, as the metadata isn't sent over the network
- QCOMPARE(cookiesToSend.count(), sent.count());
+ QCOMPARE(cookiesToSend.size(), sent.size());
bool ok = true;
- for (int i = 0; i < cookiesToSend.count(); i++) {
+ for (int i = 0; i < cookiesToSend.size(); i++) {
if (cookiesToSend.at(i).name() != sent.at(i).name()) {
ok = false;
break;
diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index fec66ebbd0..f4458ee235 100644
--- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -12,7 +12,7 @@
#define EXAMPLE_URL "http://user:pass@localhost:4/#foo"
#define EXAMPLE_URL2 "http://user:pass@localhost:4/bar"
//cached objects are organized into these many subdirs
-#define NUM_SUBDIRECTORIES 16
+#define NUM_SUBDIRECTORIES 15
class tst_QNetworkDiskCache : public QObject
{
@@ -278,17 +278,17 @@ void tst_QNetworkDiskCache::clear()
QVERIFY(cache.cacheSize() > qint64(0));
QString cacheDirectory = cache.cacheDirectory();
- QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
+ QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3);
cache.clear();
- QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2);
+ QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 2);
// don't delete files that it didn't create
QTemporaryFile file(cacheDirectory + "/XXXXXX");
if (file.open()) {
file.fileName(); // make sure it exists with a name
- QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
+ QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3);
cache.clear();
- QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
+ QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3);
}
}
@@ -355,9 +355,9 @@ void tst_QNetworkDiskCache::remove()
QUrl url(EXAMPLE_URL);
cache.setupWithOne(tempDir.path(), url);
QString cacheDirectory = cache.cacheDirectory();
- QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
+ QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3);
cache.remove(url);
- QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2);
+ QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 2);
}
void tst_QNetworkDiskCache::accessAfterRemove() // QTBUG-17400
@@ -477,7 +477,7 @@ void tst_QNetworkDiskCache::fileMetaData()
QString cacheDirectory = cache.cacheDirectory();
QStringList list = countFiles(cacheDirectory);
- QCOMPARE(list.count(), NUM_SUBDIRECTORIES + 3);
+ QCOMPARE(list.size(), NUM_SUBDIRECTORIES + 3);
foreach(QString fileName, list) {
QFileInfo info(fileName);
if (info.isFile()) {
@@ -531,7 +531,7 @@ void tst_QNetworkDiskCache::expire()
}
}
std::sort(cacheList.begin(), cacheList.end());
- for (int i = 0; i < cacheList.count(); ++i) {
+ for (int i = 0; i < cacheList.size(); ++i) {
QString fileName = cacheList[i];
QCOMPARE(fileName, QLatin1String("http://localhost:4/") + QString::number(i + 6));
}
@@ -570,7 +570,7 @@ void tst_QNetworkDiskCache::oldCacheVersionFile()
QVERIFY(!QFile::exists(name));
} else {
QStringList files = countFiles(cache.cacheDirectory());
- QCOMPARE(files.count(), NUM_SUBDIRECTORIES + 3);
+ QCOMPARE(files.size(), NUM_SUBDIRECTORIES + 3);
// find the file
QString cacheFile;
foreach (QString file, files) {
@@ -736,7 +736,7 @@ public:
if (d) {
QByteArray x = d->readAll();
if (x != longString && x != longString2) {
- qDebug() << x.length() << QString(x);
+ qDebug() << x.size() << QString(x);
gotMetaData = cache.metaData(url);
qDebug() << (gotMetaData.url().toString())
<< gotMetaData.lastModified()
diff --git a/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt b/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt
index d54fb40c56..857ad693e9 100644
--- a/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt
+++ b/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt
@@ -29,6 +29,7 @@ qt_internal_add_test(tst_qnetworkreply
TESTDATA ${test_data}
QT_TEST_SERVER_LIST "vsftpd" "apache2" "ftp-proxy" "danted" "squid" # special case
)
+add_dependencies(tst_qnetworkreply echo)
# Resources:
set(qnetworkreply_resource_files
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index f97fe88fdd..4c67317e9c 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -64,6 +64,8 @@
Q_DECLARE_METATYPE(QSharedPointer<char>)
#endif
+#include <memory>
+
#ifdef Q_OS_UNIX
# include <sys/types.h>
# include <unistd.h> // for getuid()
@@ -260,6 +262,7 @@ private Q_SLOTS:
void ioGetFromFileSpecial();
void ioGetFromFile_data();
void ioGetFromFile();
+ void ioGetFromFileUrl();
void ioGetFromFtp_data();
void ioGetFromFtp();
void ioGetFromFtpWithReuse();
@@ -442,6 +445,8 @@ private Q_SLOTS:
void varyingCacheExpiry_data();
void varyingCacheExpiry();
+ void amountOfHttp1ConnectionsQtbug25280();
+
void dontInsertPartialContentIntoTheCache();
void httpUserAgent();
@@ -511,6 +516,9 @@ private Q_SLOTS:
void downloadProgressWithContentEncoding();
void contentEncodingError_data();
void contentEncodingError();
+ void compressedReadyRead();
+ void notFoundWithCompression_data();
+ void notFoundWithCompression();
// NOTE: This test must be last!
void parentingRepliesToTheApp();
@@ -729,7 +737,7 @@ public slots:
|| receivedData.startsWith("CUSTOM_WITH_PAYLOAD");
if (hasContent && contentLength == 0)
parseContentLength();
- contentRead = receivedData.length() - endOfHeader;
+ contentRead = receivedData.size() - endOfHeader;
if (hasContent && contentRead < contentLength)
return;
@@ -1456,11 +1464,11 @@ QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op,
while (!reply->isFinished()) {
QTimer::singleShot(20000, loop, SLOT(quit()));
code = loop->exec();
- if (count == spy.count() && !reply->isFinished()) {
+ if (count == spy.size() && !reply->isFinished()) {
code = Timeout;
break;
}
- count = spy.count();
+ count = spy.size();
}
delete loop;
loop = 0;
@@ -1526,11 +1534,11 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply)
QSignalSpy spy(reply.data(), SIGNAL(downloadProgress(qint64,qint64)));
while (!reply->isFinished()) {
QTimer::singleShot(5000, loop, SLOT(quit()));
- if (loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) {
+ if (loop->exec() == Timeout && count == spy.size() && !reply->isFinished()) {
returnCode = Timeout;
break;
}
- count = spy.count();
+ count = spy.size();
}
delete loop;
loop = 0;
@@ -1991,7 +1999,7 @@ void tst_QNetworkReply::headFromHttp_data()
QString httpServer = QtNetworkSettings::httpServerName();
//testing proxies, mainly for the 407 response from http proxy
- for (int i = 0; i < proxies.count(); ++i) {
+ for (int i = 0; i < proxies.size(); ++i) {
QTest::newRow("rfc" + proxies.at(i).tag)
<< rfcsize
<< QUrl("http://" + httpServer + "/qtest/rfc3252.txt")
@@ -2273,9 +2281,9 @@ void tst_QNetworkReply::putToFtp()
QSignalSpy spy(r, SIGNAL(downloadProgress(qint64,qint64)));
while (!r->isFinished()) {
QTestEventLoop::instance().enterLoop(10);
- if (count == spy.count() && !r->isFinished())
+ if (count == spy.size() && !r->isFinished())
break;
- count = spy.count();
+ count = spy.size();
}
QObject::disconnect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -3327,6 +3335,18 @@ void tst_QNetworkReply::ioGetFromFile()
QCOMPARE(reader.data, data);
}
+void tst_QNetworkReply::ioGetFromFileUrl()
+{
+ // This immediately fails on non-windows platforms:
+ QNetworkRequest request(QUrl("file://unc-server/some/path"));
+ QNetworkReplyPtr reply(manager.get(request));
+ QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
+ // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
+ // was emitted before the constructor finished, leaving no chance at all to connect to the
+ // signal
+ QVERIFY(finishedSpy.wait());
+}
+
void tst_QNetworkReply::ioGetFromFtp_data()
{
if (!ftpSupported)
@@ -3573,7 +3593,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
QCOMPARE(reader1.data, expectedData);
QCOMPARE(reader2.data, expectedData);
- QCOMPARE(authspy.count(), (expectedAuth ? 1 : 0));
+ QCOMPARE(authspy.size(), (expectedAuth ? 1 : 0));
expectedAuth = qMax(0, expectedAuth - 1);
}
@@ -3594,7 +3614,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reader.data, expectedData);
- QCOMPARE(authspy.count(), (expectedAuth ? 1 : 0));
+ QCOMPARE(authspy.size(), (expectedAuth ? 1 : 0));
expectedAuth = qMax(0, expectedAuth - 1);
}
@@ -3611,7 +3631,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
// bad credentials in a synchronous request should just fail
QCOMPARE(replySync->error(), QNetworkReply::AuthenticationRequiredError);
} else {
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
// we cannot use a data reader here, since that connects to the readyRead signal,
// just use readAll()
@@ -3637,7 +3657,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
// bad credentials in a synchronous request should just fail
QCOMPARE(replySync->error(), QNetworkReply::AuthenticationRequiredError);
} else {
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
// we cannot use a data reader here, since that connects to the readyRead signal,
// just use readAll()
@@ -3663,7 +3683,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuthSynchronous()
QNetworkReplyPtr replySync(manager.get(request));
QVERIFY(replySync->isFinished()); // synchronous
QCOMPARE(replySync->error(), QNetworkReply::AuthenticationRequiredError);
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 401);
}
@@ -3704,7 +3724,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
QCOMPARE(reader1.data, referenceData);
QCOMPARE(reader2.data, referenceData);
- QCOMPARE(authspy.count(), 1);
+ QCOMPARE(authspy.size(), 1);
}
reference.seek(0);
@@ -3727,7 +3747,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reader.data, reference.readAll());
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
}
// now check with synchronous calls:
@@ -3740,7 +3760,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
QSignalSpy authspy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
QNetworkReplyPtr replySync(manager.get(request));
QVERIFY(replySync->isFinished()); // synchronous
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
// we cannot use a data reader here, since that connects to the readyRead signal,
// just use readAll()
@@ -3768,7 +3788,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuthSynchronous()
manager.setProxy(QNetworkProxy()); // reset
QVERIFY(replySync->isFinished()); // synchronous
QCOMPARE(replySync->error(), QNetworkReply::ProxyAuthenticationRequiredError);
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 407);
}
@@ -3800,7 +3820,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reader.data, reference.readAll());
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
}
// set an invalid proxy just to make sure that we can't load
@@ -3827,7 +3847,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
QEXPECT_FAIL("", "QTcpSocket doesn't return enough information yet", Continue);
QCOMPARE(int(reply->error()), int(QNetworkReply::ProxyConnectionRefusedError));
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
}
}
#endif // QT_CONFIG(networkproxy)
@@ -3855,7 +3875,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslErrors()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reader.data, reference.readAll());
- QCOMPARE(sslspy.count(), 1);
+ QCOMPARE(sslspy.size(), 1);
QVERIFY(!storedSslConfiguration.isNull());
QVERIFY(!reply->sslConfiguration().isNull());
@@ -3883,7 +3903,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithIgnoreSslErrors()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reader.data, reference.readAll());
- QCOMPARE(sslspy.count(), 1);
+ QCOMPARE(sslspy.size(), 1);
QVERIFY(!storedSslConfiguration.isNull());
QVERIFY(!reply->sslConfiguration().isNull());
@@ -3906,7 +3926,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError()
QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError);
- QCOMPARE(sslspy.count(), 0);
+ QCOMPARE(sslspy.size(), 0);
}
#endif
@@ -3964,7 +3984,7 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer()
QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->url(), request.url());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(reply->error() != QNetworkReply::NoError);
}
@@ -4482,16 +4502,16 @@ void tst_QNetworkReply::ioGetWithManyProxies()
// now verify that the proxies worked:
QFETCH(QNetworkProxy, proxyUsed);
if (proxyUsed.type() == QNetworkProxy::NoProxy) {
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
} else {
if (QByteArray(QTest::currentDataTag()).startsWith("ftp-"))
return; // No authentication with current FTP or with FTP proxies
- QCOMPARE(authspy.count(), 1);
+ QCOMPARE(authspy.size(), 1);
QCOMPARE(qvariant_cast<QNetworkProxy>(authspy.at(0).at(0)), proxyUsed);
}
} else {
// request failed
- QCOMPARE(authspy.count(), 0);
+ QCOMPARE(authspy.size(), 0);
}
}
#endif // QT_CONFIG(networkproxy)
@@ -4797,7 +4817,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket_data()
QTest::addColumn<int>("authenticationRequiredCount");
QTest::addColumn<int>("proxyAuthenticationRequiredCount");
- for (int i = 0; i < proxies.count(); ++i)
+ for (int i = 0; i < proxies.size(); ++i)
for (int auth = 0; auth < 2; ++auth) {
QUrl url;
if (auth)
@@ -4875,8 +4895,8 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
QCOMPARE(reply->readAll().trimmed(), md5sum(data).toHex());
- QTEST(int(authenticationRequiredSpy.count()), "authenticationRequiredCount");
- QTEST(int(proxyAuthenticationRequiredSpy.count()), "proxyAuthenticationRequiredCount");
+ QTEST(int(authenticationRequiredSpy.size()), "authenticationRequiredCount");
+ QTEST(int(proxyAuthenticationRequiredSpy.size()), "proxyAuthenticationRequiredCount");
}
void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous_data()
@@ -5375,7 +5395,7 @@ void tst_QNetworkReply::emitAllUploadProgressSignals()
QVERIFY(!QTestEventLoop::instance().timeout());
incomingSocket->close();
- signalCount.append(spy.count());
+ signalCount.append(spy.size());
reply->deleteLater();
}
server.close();
@@ -5421,7 +5441,7 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress()
QVERIFY(!QTestEventLoop::instance().timeout());
// final check: only 1 uploadProgress has been emitted
- QCOMPARE(spy.length(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> args = spy.last();
QVERIFY(!args.isEmpty());
QCOMPARE(args.at(0).toLongLong(), buffer.size());
@@ -5592,7 +5612,7 @@ void tst_QNetworkReply::downloadProgress()
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(reply->isFinished());
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
//final progress should have equal current & total
QList<QVariant> args = spy.takeLast();
@@ -5638,14 +5658,14 @@ void tst_QNetworkReply::uploadProgress()
QVERIFY(server.hasPendingConnections());
QTcpSocket *receiver = server.nextPendingConnection();
- if (finished.count() == 0) {
+ if (finished.size() == 0) {
// it's not finished yet, so wait for it to be
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
}
delete receiver;
- QVERIFY(finished.count() > 0);
- QVERIFY(spy.count() > 0);
+ QVERIFY(finished.size() > 0);
+ QVERIFY(spy.size() > 0);
QList<QVariant> args = spy.last();
QCOMPARE(args.at(0).toInt(), data.size());
@@ -5927,8 +5947,8 @@ void tst_QNetworkReply::nestedEventLoops()
QTestEventLoop::instance().enterLoop(20);
QVERIFY2(!QTestEventLoop::instance().timeout(), "Network timeout");
- QCOMPARE(finishedspy.count(), 1);
- QCOMPARE(errorspy.count(), 0);
+ QCOMPARE(finishedspy.size(), 1);
+ QCOMPARE(errorspy.size(), 0);
}
#if QT_CONFIG(networkproxy)
@@ -5974,7 +5994,7 @@ void tst_QNetworkReply::httpProxyCommands()
// especially since it won't succeed in the HTTPS case
// so just check that the command was correct
- QString receivedHeader = proxyServer.receivedData.left(expectedCommand.length());
+ QString receivedHeader = proxyServer.receivedData.left(expectedCommand.size());
QCOMPARE(receivedHeader, expectedCommand);
//QTBUG-17223 - make sure the user agent from the request is sent to proxy server even for CONNECT
@@ -6058,7 +6078,7 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous()
// especially since it won't succeed in the HTTPS case
// so just check that the command was correct
- QString receivedHeader = proxyServer->receivedData.left(expectedCommand.length());
+ QString receivedHeader = proxyServer->receivedData.left(expectedCommand.size());
QCOMPARE(receivedHeader, expectedCommand);
}
@@ -6155,9 +6175,9 @@ void tst_QNetworkReply::authorizationError()
QCOMPARE(waitForFinish(reply), int(Failure));
QFETCH(int, errorSignalCount);
- QCOMPARE(errorSpy.count(), errorSignalCount);
+ QCOMPARE(errorSpy.size(), errorSignalCount);
QFETCH(int, finishedSignalCount);
- QCOMPARE(finishedSpy.count(), finishedSignalCount);
+ QCOMPARE(finishedSpy.size(), finishedSignalCount);
QFETCH(int, error);
QCOMPARE(reply->error(), QNetworkReply::NetworkError(error));
@@ -6516,7 +6536,7 @@ void tst_QNetworkReply::encrypted()
QTestEventLoop::instance().enterLoop(20);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
reply->deleteLater();
}
@@ -6545,7 +6565,7 @@ void tst_QNetworkReply::abortOnEncrypted()
});
QSignalSpy spyEncrypted(reply, &QNetworkReply::encrypted);
- QTRY_COMPARE(spyEncrypted.count(), 1);
+ QTRY_COMPARE(spyEncrypted.size(), 1);
// Wait for the socket to be closed again in order to be sure QTcpSocket::readyRead would have been emitted.
QTRY_VERIFY(server.socket != nullptr);
@@ -7128,9 +7148,9 @@ void tst_QNetworkReply::qtbug4121unknownAuthentication()
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(authSpy.count(), 0);
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(authSpy.size(), 0);
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
}
@@ -7141,7 +7161,7 @@ void tst_QNetworkReply::authenticationCacheAfterCancel_data()
QTest::addColumn<QNetworkProxy>("proxy");
QTest::addColumn<bool>("proxyAuth");
QTest::addColumn<QUrl>("url");
- for (int i = 0; i < proxies.count(); ++i) {
+ for (int i = 0; i < proxies.size(); ++i) {
QTest::newRow("http" + proxies.at(i).tag)
<< proxies.at(i).proxy
<< proxies.at(i).requiresAuthentication
@@ -7224,8 +7244,8 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->error(), QNetworkReply::ProxyAuthenticationRequiredError);
- QCOMPARE(authSpy.count(), 0);
- QCOMPARE(proxyAuthSpy.count(), 1);
+ QCOMPARE(authSpy.size(), 0);
+ QCOMPARE(proxyAuthSpy.size(), 1);
proxyAuthSpy.clear();
//should fail due to bad credentials
@@ -7239,8 +7259,8 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
// Work round known quirk in the old test server (danted -v < v1.1.19):
if (reply->error() != QNetworkReply::HostNotFoundError)
QCOMPARE(reply->error(), QNetworkReply::ProxyAuthenticationRequiredError);
- QCOMPARE(authSpy.count(), 0);
- QVERIFY(proxyAuthSpy.count() > 0);
+ QCOMPARE(authSpy.size(), 0);
+ QVERIFY(proxyAuthSpy.size() > 0);
proxyAuthSpy.clear();
// QTBUG-23136 workaround (needed even with danted v1.1.19):
@@ -7265,10 +7285,10 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
- QVERIFY(authSpy.count() > 0);
+ QVERIFY(authSpy.size() > 0);
authSpy.clear();
if (proxyAuth) {
- QVERIFY(proxyAuthSpy.count() > 0);
+ QVERIFY(proxyAuthSpy.size() > 0);
proxyAuthSpy.clear();
}
@@ -7281,11 +7301,11 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
- QVERIFY(authSpy.count() > 0);
+ QVERIFY(authSpy.size() > 0);
authSpy.clear();
if (proxyAuth) {
//should be supplied from cache
- QCOMPARE(proxyAuthSpy.count(), 0);
+ QCOMPARE(proxyAuthSpy.size(), 0);
proxyAuthSpy.clear();
}
@@ -7299,11 +7319,11 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->error(), QNetworkReply::NoError);
- QVERIFY(authSpy.count() > 0);
+ QVERIFY(authSpy.size() > 0);
authSpy.clear();
if (proxyAuth) {
//should be supplied from cache
- QCOMPARE(proxyAuthSpy.count(), 0);
+ QCOMPARE(proxyAuthSpy.size(), 0);
proxyAuthSpy.clear();
}
@@ -7315,11 +7335,11 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
QCOMPARE(reply->error(), QNetworkReply::NoError);
//should be supplied from cache
- QCOMPARE(authSpy.count(), 0);
+ QCOMPARE(authSpy.size(), 0);
authSpy.clear();
if (proxyAuth) {
//should be supplied from cache
- QCOMPARE(proxyAuthSpy.count(), 0);
+ QCOMPARE(proxyAuthSpy.size(), 0);
proxyAuthSpy.clear();
}
@@ -7421,8 +7441,8 @@ void tst_QNetworkReply::httpWithNoCredentialUsage()
QNetworkReplyPtr reply(manager.get(request));
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
// credentials in URL, so don't expect authentication signal
- QCOMPARE(authSpy.count(), 0);
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(authSpy.size(), 0);
+ QCOMPARE(finishedSpy.size(), 1);
finishedSpy.clear();
}
@@ -7432,8 +7452,8 @@ void tst_QNetworkReply::httpWithNoCredentialUsage()
QNetworkReplyPtr reply(manager.get(request));
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
// credentials in cache, so don't expect authentication signal
- QCOMPARE(authSpy.count(), 0);
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(authSpy.size(), 0);
+ QCOMPARE(finishedSpy.size(), 1);
finishedSpy.clear();
}
@@ -7450,9 +7470,9 @@ void tst_QNetworkReply::httpWithNoCredentialUsage()
QVERIFY(!QTestEventLoop::instance().timeout());
// We check if authenticationRequired was emitted, however we do not anything in it so it should be 401
- QCOMPARE(authSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(authSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
}
@@ -7737,8 +7757,8 @@ void tst_QNetworkReply::qtbug45581WrongReplyStatusCode()
QCOMPARE(reply->readAll(), expectedContent);
- QCOMPARE(finishedSpy.count(), 0);
- QCOMPARE(sslErrorsSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 0);
QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), expectedContent.size());
@@ -7827,8 +7847,8 @@ void tst_QNetworkReply::synchronousRequest()
QSignalSpy sslErrorsSpy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply, 0));
QVERIFY(reply->isFinished());
- QCOMPARE(finishedSpy.count(), 0);
- QCOMPARE(sslErrorsSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 0);
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader).toString(), mimeType);
@@ -7867,7 +7887,7 @@ void tst_QNetworkReply::synchronousRequestSslFailure()
runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply, 0);
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError);
- QCOMPARE(sslErrorsSpy.count(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 0);
}
#endif
@@ -8086,6 +8106,48 @@ void tst_QNetworkReply::varyingCacheExpiry()
QVERIFY(success);
}
+class Qtbug25280Server : public MiniHttpServer
+{
+public:
+ Qtbug25280Server(QByteArray qba) : MiniHttpServer(qba, false) {}
+ QSet<QTcpSocket*> receivedSockets;
+ virtual void reply()
+ {
+ // Save sockets in a list
+ receivedSockets.insert((QTcpSocket*)sender());
+ qobject_cast<QTcpSocket*>(sender())->write(dataToTransmit);
+ //qDebug() << "count=" << receivedSockets.count();
+ }
+};
+
+// Also kind of QTBUG-8468
+void tst_QNetworkReply::amountOfHttp1ConnectionsQtbug25280()
+{
+ const int amount = 6;
+ QNetworkAccessManager manager; // function local instance
+ Qtbug25280Server server(tst_QNetworkReply::httpEmpty200Response);
+ server.doClose = false;
+ server.multiple = true;
+ QUrl url(QLatin1String("http://127.0.0.1")); // not "localhost" to prevent "Happy Eyeballs"
+ // from skewing the counting
+ url.setPort(server.serverPort());
+ constexpr int NumRequests = 200; // send a lot more than we have sockets
+ int finished = 0;
+ std::array<std::unique_ptr<QNetworkReply>, NumRequests> replies;
+ for (auto &reply : replies) {
+ QNetworkRequest request(url);
+ reply.reset(manager.get(request));
+ QObject::connect(reply.get(), &QNetworkReply::finished,
+ [&finished] { ++finished; });
+ }
+ QTRY_COMPARE_WITH_TIMEOUT(finished, NumRequests, 60'000);
+ for (const auto &reply : replies) {
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+ }
+ QCOMPARE(server.receivedSockets.size(), amount);
+}
+
void tst_QNetworkReply::dontInsertPartialContentIntoTheCache()
{
QByteArray reply206 =
@@ -8114,7 +8176,7 @@ void tst_QNetworkReply::dontInsertPartialContentIntoTheCache()
QVERIFY(server.totalConnections > 0);
QCOMPARE(reply->readAll().constData(), "load");
- QCOMPARE(memoryCache->m_insertedUrls.count(), 0);
+ QCOMPARE(memoryCache->m_insertedUrls.size(), 0);
}
void tst_QNetworkReply::httpUserAgent()
@@ -8317,7 +8379,7 @@ void tst_QNetworkReply::emitErrorForAllReplies() // QTBUG-36890
QList<QNetworkReply *> replies;
QList<QSignalSpy *> errorSpies;
QList<QSignalSpy *> finishedSpies;
- for (int a = 0; a < urls.count(); ++a) {
+ for (int a = 0; a < urls.size(); ++a) {
QNetworkRequest request(urls.at(a));
QNetworkReply *reply = manager.get(request);
replies.append(reply);
@@ -8329,11 +8391,11 @@ void tst_QNetworkReply::emitErrorForAllReplies() // QTBUG-36890
}
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
- for (int a = 0; a < urls.count(); ++a) {
+ for (int a = 0; a < urls.size(); ++a) {
QVERIFY(replies.at(a)->isFinished());
- QCOMPARE(errorSpies.at(a)->count(), 1);
+ QCOMPARE(errorSpies.at(a)->size(), 1);
errorSpies.at(a)->deleteLater();
- QCOMPARE(finishedSpies.at(a)->count(), 1);
+ QCOMPARE(finishedSpies.at(a)->size(), 1);
finishedSpies.at(a)->deleteLater();
replies.at(a)->deleteLater();
}
@@ -8383,7 +8445,7 @@ public:
return ret;
}
virtual bool atEnd() const override { return buffer.atEnd(); }
- virtual qint64 size() const override { return data.length(); }
+ virtual qint64 size() const override { return data.size(); }
qint64 bytesAvailable() const override
{
return buffer.bytesAvailable() + QIODevice::bytesAvailable();
@@ -8406,7 +8468,7 @@ void tst_QNetworkReply::putWithRateLimiting()
QFile reference(testDataDir + "/rfc3252.txt");
reference.open(QIODevice::ReadOnly);
QByteArray data = reference.readAll();
- QVERIFY(data.length() > 0);
+ QVERIFY(data.size() > 0);
QUrl url = QUrl::fromUserInput("http://" + QtNetworkSettings::httpServerName()+ "/qtest/cgi-bin/echo.cgi?");
@@ -8421,7 +8483,7 @@ void tst_QNetworkReply::putWithRateLimiting()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QByteArray uploadedData = reply->readAll();
- QCOMPARE(uploadedData.length(), data.length());
+ QCOMPARE(uploadedData.size(), data.size());
QCOMPARE(uploadedData, data);
}
@@ -8453,8 +8515,8 @@ void tst_QNetworkReply::ioHttpSingleRedirect()
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
// Redirected and finished should be emitted exactly once
- QCOMPARE(redSpy.count(), 1);
- QCOMPARE(finSpy.count(), 1);
+ QCOMPARE(redSpy.size(), 1);
+ QCOMPARE(finSpy.size(), 1);
// Original URL should not be changed after redirect
QCOMPARE(request.url(), localhost);
@@ -8500,8 +8562,8 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects()
QCOMPARE(waitForFinish(reply), int(Failure));
- QCOMPARE(redSpy.count(), request.maximumRedirectsAllowed());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(redSpy.size(), request.maximumRedirectsAllowed());
+ QCOMPARE(spy.size(), 1);
QCOMPARE(reply->error(), QNetworkReply::TooManyRedirectsError);
// Increase max redirects to allow successful completion
@@ -8512,7 +8574,7 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects()
QVERIFY2(waitForFinish(reply2) == Success, msgWaitForFinished(reply2));
- QCOMPARE(redSpy2.count(), 2);
+ QCOMPARE(redSpy2.size(), 2);
QCOMPARE(reply2->url(), server3Url);
QCOMPARE(reply2->error(), QNetworkReply::NoError);
QVERIFY(validateRedirectedResponseHeaders(reply2));
@@ -8645,8 +8707,8 @@ void tst_QNetworkReply::ioHttpRedirectPolicy()
QSignalSpy redirectSpy(reply.data(), SIGNAL(redirected(QUrl)));
QSignalSpy finishedSpy(reply.data(), SIGNAL(finished()));
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
- QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(redirectSpy.count(), redirectCount);
+ QCOMPARE(finishedSpy.size(), 1);
+ QCOMPARE(redirectSpy.size(), redirectCount);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
QVERIFY(validateRedirectedResponseHeaders(reply) || statusCode != 200);
}
@@ -8729,7 +8791,7 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors()
QSignalSpy spy(reply.data(), SIGNAL(errorOccurred(QNetworkReply::NetworkError)));
QCOMPARE(waitForFinish(reply), int(Failure));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(reply->error(), expectedError);
}
@@ -8779,7 +8841,7 @@ void tst_QNetworkReply::ioHttpUserVerifiedRedirect()
QSignalSpy finishedSpy(reply.data(), SIGNAL(finished()));
waitForFinish(reply);
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(finishedSpy.size(), 1);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
QVERIFY(validateRedirectedResponseHeaders(reply) || statusCode != 200);
}
@@ -8791,7 +8853,7 @@ void tst_QNetworkReply::ioHttpCookiesDuringRedirect()
const QString cookieHeader = QStringLiteral("Set-Cookie: hello=world; Path=/;\r\n");
QString redirect = tempRedirectReplyStr();
// Insert 'cookieHeader' before the final \r\n
- redirect.insert(redirect.length() - 2, cookieHeader);
+ redirect.insert(redirect.size() - 2, cookieHeader);
QUrl url("http://localhost/");
url.setPort(target.serverPort());
@@ -9218,7 +9280,7 @@ public slots:
//qDebug() << m_receivedData.left(m_receivedData.indexOf("\r\n\r\n"));
m_receivedData = m_receivedData.mid(m_receivedData.indexOf("\r\n\r\n")+4); // check only actual data
}
- if (m_receivedData.length() > 0 && !m_expectedData.startsWith(m_receivedData)) {
+ if (m_receivedData.size() > 0 && !m_expectedData.startsWith(m_receivedData)) {
// We had received some data but it is corrupt!
qDebug() << "CORRUPT" << m_receivedData.size();
@@ -9370,7 +9432,7 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute()
QSignalSpy finishedSpy(reply, &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply, &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QVERIFY(destroyedSpy.wait());
}
{
@@ -9381,7 +9443,7 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute()
QSignalSpy finishedSpy(reply, &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply, &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QVERIFY(destroyedSpy.wait());
}
// Now repeated, but without the attribute to make sure it does not get deleted automatically.
@@ -9395,10 +9457,10 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute()
QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QCoreApplication::processEvents();
QCoreApplication::processEvents();
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
}
{
// Post
@@ -9407,10 +9469,10 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute()
QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QCoreApplication::processEvents();
QCoreApplication::processEvents();
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
}
}
@@ -9431,7 +9493,7 @@ void tst_QNetworkReply::autoDeleteReplies()
QSignalSpy finishedSpy(reply, &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply, &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QVERIFY(destroyedSpy.wait());
}
{
@@ -9441,7 +9503,7 @@ void tst_QNetworkReply::autoDeleteReplies()
QSignalSpy finishedSpy(reply, &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply, &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QVERIFY(destroyedSpy.wait());
}
// Here we repeat the test, but override the auto-deletion in the QNetworkRequest
@@ -9456,10 +9518,10 @@ void tst_QNetworkReply::autoDeleteReplies()
QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QCoreApplication::processEvents();
QCoreApplication::processEvents();
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
}
{
// Post
@@ -9469,10 +9531,10 @@ void tst_QNetworkReply::autoDeleteReplies()
QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QCoreApplication::processEvents();
QCoreApplication::processEvents();
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
}
// Now we repeat the test with autoDeleteReplies set to false
cleanup.dismiss();
@@ -9484,10 +9546,10 @@ void tst_QNetworkReply::autoDeleteReplies()
QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QCoreApplication::processEvents();
QCoreApplication::processEvents();
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
}
{
// Post
@@ -9496,10 +9558,10 @@ void tst_QNetworkReply::autoDeleteReplies()
QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished);
QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed);
QVERIFY(finishedSpy.wait());
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
QCoreApplication::processEvents();
QCoreApplication::processEvents();
- QCOMPARE(destroyedSpy.count(), 0);
+ QCOMPARE(destroyedSpy.size(), 0);
}
}
@@ -9513,7 +9575,7 @@ void tst_QNetworkReply::getWithTimeout()
QCOMPARE(waitForFinish(reply), int(Success));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(reply->error() == QNetworkReply::NoError);
request.setTransferTimeout(1000);
@@ -9524,7 +9586,7 @@ void tst_QNetworkReply::getWithTimeout()
QCOMPARE(waitForFinish(reply2), int(Failure));
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
QVERIFY(reply2->error() == QNetworkReply::OperationCanceledError);
request.setTransferTimeout(0);
@@ -9535,7 +9597,7 @@ void tst_QNetworkReply::getWithTimeout()
QCOMPARE(waitForFinish(reply3), int(Failure));
- QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.size(), 1);
QVERIFY(reply3->error() == QNetworkReply::OperationCanceledError);
manager.setTransferTimeout(0);
@@ -9553,7 +9615,7 @@ void tst_QNetworkReply::postWithTimeout()
QCOMPARE(waitForFinish(reply), int(Success));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(reply->error() == QNetworkReply::NoError);
request.setTransferTimeout(1000);
@@ -9564,7 +9626,7 @@ void tst_QNetworkReply::postWithTimeout()
QCOMPARE(waitForFinish(reply2), int(Failure));
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
QVERIFY(reply2->error() == QNetworkReply::OperationCanceledError);
request.setTransferTimeout(0);
@@ -9575,7 +9637,7 @@ void tst_QNetworkReply::postWithTimeout()
QCOMPARE(waitForFinish(reply3), int(Failure));
- QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.size(), 1);
QVERIFY(reply3->error() == QNetworkReply::OperationCanceledError);
manager.setTransferTimeout(0);
@@ -9620,13 +9682,13 @@ void tst_QNetworkReply::moreActivitySignals()
QSignalSpy spy3(reply.data(), SIGNAL(metaDataChanged()));
QSignalSpy spy4(reply.data(), SIGNAL(finished()));
spy1.wait();
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
spy2.wait();
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
spy3.wait();
- QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.size(), 1);
spy4.wait();
- QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.size(), 1);
QVERIFY(reply->error() == QNetworkReply::NoError);
// Second request will not send socketStartedConnecting because of keep-alive, so don't check it.
QNetworkReplyPtr secondreply;
@@ -9640,11 +9702,11 @@ void tst_QNetworkReply::moreActivitySignals()
QSignalSpy secondspy3(secondreply.data(), SIGNAL(metaDataChanged()));
QSignalSpy secondspy4(secondreply.data(), SIGNAL(finished()));
secondspy2.wait();
- QCOMPARE(secondspy2.count(), 1);
+ QCOMPARE(secondspy2.size(), 1);
secondspy3.wait();
- QCOMPARE(secondspy3.count(), 1);
+ QCOMPARE(secondspy3.size(), 1);
secondspy4.wait();
- QCOMPARE(secondspy4.count(), 1);
+ QCOMPARE(secondspy4.size(), 1);
QVERIFY(secondreply->error() == QNetworkReply::NoError);
}
@@ -9653,25 +9715,53 @@ void tst_QNetworkReply::contentEncoding_data()
QTest::addColumn<QByteArray>("encoding");
QTest::addColumn<QByteArray>("body");
QTest::addColumn<QByteArray>("expected");
+ QTest::addColumn<bool>("decompress");
+ const QByteArray helloWorld = "hello world";
+
+ const QByteArray gzipBody = QByteArray::fromBase64("H4sIAAAAAAAAA8tIzcnJVyjPL8pJAQCFEUoNCwAAAA==");
QTest::newRow("gzip-hello-world")
<< QByteArray("gzip")
- << QByteArray::fromBase64("H4sIAAAAAAAAA8tIzcnJVyjPL8pJAQCFEUoNCwAAAA==")
- << QByteArray("hello world");
+ << gzipBody
+ << helloWorld
+ << true;
+ QTest::newRow("gzip-hello-world-no-decompress")
+ << QByteArray("gzip")
+ << gzipBody
+ << helloWorld
+ << false;
+ const QByteArray deflateBody = QByteArray::fromBase64("eJzLSM3JyVcozy/KSQEAGgsEXQ==");
QTest::newRow("deflate-hello-world")
- << QByteArray("deflate") << QByteArray::fromBase64("eJzLSM3JyVcozy/KSQEAGgsEXQ==")
- << QByteArray("hello world");
+ << QByteArray("deflate") << deflateBody
+ << helloWorld
+ << true;
+ QTest::newRow("deflate-hello-world-no-decompress")
+ << QByteArray("deflate") << deflateBody
+ << helloWorld
+ << false;
#if QT_CONFIG(brotli)
+ const QByteArray brotliBody = QByteArray::fromBase64("DwWAaGVsbG8gd29ybGQD");
QTest::newRow("brotli-hello-world")
- << QByteArray("br") << QByteArray::fromBase64("DwWAaGVsbG8gd29ybGQD")
- << QByteArray("hello world");
+ << QByteArray("br") << brotliBody
+ << helloWorld
+ << true;
+ QTest::newRow("brotli-hello-world-no-decompress")
+ << QByteArray("br") << brotliBody
+ << helloWorld
+ << false;
#endif
#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(zstd)
+ const QByteArray zstdBody = QByteArray::fromBase64("KLUv/QRYWQAAaGVsbG8gd29ybGRoaR6y");
QTest::newRow("zstandard-hello-world")
- << QByteArray("zstd") << QByteArray::fromBase64("KLUv/QRYWQAAaGVsbG8gd29ybGRoaR6y")
- << QByteArray("hello world");
+ << QByteArray("zstd") << zstdBody
+ << helloWorld
+ << true;
+ QTest::newRow("zstandard-hello-world-no-decompress")
+ << QByteArray("zstd") << zstdBody
+ << helloWorld
+ << false;
#else
qDebug("Note: ZStandard testdata is only available for developer builds.");
#endif
@@ -9681,12 +9771,19 @@ void tst_QNetworkReply::contentEncoding()
{
QFETCH(QByteArray, encoding);
QFETCH(QByteArray, body);
+ QFETCH(bool, decompress);
QString header("HTTP/1.0 200 OK\r\nContent-Encoding: %1\r\nContent-Length: %2\r\n\r\n");
header = header.arg(encoding, QString::number(body.size()));
MiniHttpServer server(header.toLatin1() + body);
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
+ if (!decompress) {
+ // This disables decompression of the received content:
+ request.setRawHeader("Accept-Encoding", QLatin1String("%1").arg(encoding).toLatin1());
+ // This disables the zerocopy optimization
+ request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 0);
+ }
QNetworkReplyPtr reply(manager.get(request));
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
@@ -9707,10 +9804,14 @@ void tst_QNetworkReply::contentEncoding()
QVERIFY2(list.contains(encoding), acceptedEncoding.data());
}
- QFETCH(QByteArray, expected);
-
- QCOMPARE(reply->bytesAvailable(), expected.size());
- QCOMPARE(reply->readAll(), expected);
+ if (decompress) {
+ QFETCH(QByteArray, expected);
+ QCOMPARE(reply->bytesAvailable(), expected.size());
+ QCOMPARE(reply->readAll(), expected);
+ } else {
+ QCOMPARE(reply->bytesAvailable(), body.size());
+ QCOMPARE(reply->readAll(), body);
+ }
}
void tst_QNetworkReply::contentEncodingBigPayload_data()
@@ -9724,7 +9825,7 @@ void tst_QNetworkReply::contentEncodingBigPayload_data()
QTest::addRow("gzip-4GB") << QByteArray("gzip") << (":/4G.gz") << fourGiB;
#if QT_CONFIG(brotli)
- QTest::addRow("brotli-4GB") << QByteArray("br") << (testDataDir + "./4G.br") << fourGiB;
+ QTest::addRow("brotli-4GB") << QByteArray("br") << (testDataDir + "/4G.br") << fourGiB;
#endif
#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(zstd)
QTest::addRow("zstd-4GB") << QByteArray("zstd") << (":/4G.zst") << fourGiB;
@@ -9880,6 +9981,79 @@ void tst_QNetworkReply::contentEncodingError()
QTEST(reply->error(), "expectedError");
}
+// When this test is failing it will appear flaky because it relies on the
+// timing of delivery from one socket to another in the OS.
+// + we have to send all the data at once, so the readyRead emissions are
+// compressed into a single emission, so we cannot artificially time it with
+// waits and sleeps.
+void tst_QNetworkReply::compressedReadyRead()
+{
+ // There were historically an issue where a mix of signal compression and
+ // data decompression made it so we accidentally didn't emit the final
+ // readyRead signal before emitting finished(). Test this here to make sure
+ // it happens:
+ const QByteArray gzipPayload =
+ QByteArray::fromBase64("H4sIAAAAAAAAA8tIzcnJVyjPL8pJAQCFEUoNCwAAAA==");
+ const QByteArray expected = "hello world";
+
+ QString header("HTTP/1.0 200 OK\r\nContent-Encoding: gzip\r\nContent-Length: %1\r\n\r\n");
+ header = header.arg(gzipPayload.size());
+ MiniHttpServer server(header.toLatin1()); // only send header automatically
+ server.doClose = false; // don't close and delete client socket right away
+
+ QNetworkRequest request(
+ QUrl(QLatin1String("http://localhost:%1").arg(QString::number(server.serverPort()))));
+ QNetworkReplyPtr reply(manager.get(request));
+
+ QObject::connect(reply.get(), &QNetworkReply::metaDataChanged, reply.get(),
+ [&server, &gzipPayload]() {
+ // Client received headers, now send data:
+ // We do this awkward write,flush,write dance to try to
+ // make sure the data does not all arrive at the same
+ // time. By design we send the final "=" byte by itself
+ qsizetype boundary = gzipPayload.size() - 1;
+ server.client->write(gzipPayload.sliced(0, boundary));
+ server.client->flush();
+ // Let the server take care of deleting the client once
+ // the rest of the data is written:
+ server.doClose = true;
+ server.client->write(gzipPayload.sliced(boundary));
+ });
+
+ QByteArray received;
+ QObject::connect(reply.get(), &QNetworkReply::readyRead, reply.get(),
+ [reply = reply.get(), &received]() {
+ received += reply->readAll();
+ });
+ QTRY_VERIFY(reply->isFinished());
+ QCOMPARE(received, expected);
+}
+
+void tst_QNetworkReply::notFoundWithCompression_data()
+{
+ contentEncoding_data();
+}
+
+void tst_QNetworkReply::notFoundWithCompression()
+{
+ QFETCH(QByteArray, encoding);
+ QFETCH(QByteArray, body);
+ QString header("HTTP/1.0 404 OK\r\nContent-Encoding: %1\r\nContent-Length: %2\r\n\r\n");
+ header = header.arg(encoding, QString::number(body.size()));
+
+ MiniHttpServer server(header.toLatin1() + body);
+
+ QNetworkRequest request(
+ 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);
+ QCOMPARE(reply->error(), QNetworkReply::ContentNotFoundError);
+
+ QFETCH(QByteArray, expected);
+ QCOMPARE(reply->readAll(), expected);
+}
+
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
{
diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
index b1867d55fb..d22d858b26 100644
--- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
+++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
@@ -66,7 +66,7 @@ QString tst_QDnsLookup::domainNameList(const QString &input)
QStringList tst_QDnsLookup::domainNameListAlternatives(const QString &input)
{
QStringList alternatives = input.split('|');
- for (int i = 0; i < alternatives.length(); ++i)
+ for (int i = 0; i < alternatives.size(); ++i)
alternatives[i] = domainNameList(alternatives[i]);
return alternatives;
}
@@ -367,7 +367,7 @@ void tst_QDnsLookup::bindingsAndProperties()
const QSignalSpy typeChangeSpy(&lookup, &QDnsLookup::typeChanged);
dnsTypeProp = QDnsLookup::AAAA;
- QCOMPARE(typeChangeSpy.count(), 1);
+ QCOMPARE(typeChangeSpy.size(), 1);
QCOMPARE(lookup.type(), QDnsLookup::AAAA);
dnsTypeProp.setBinding(lookup.bindableType().makeBinding());
@@ -379,7 +379,7 @@ void tst_QDnsLookup::bindingsAndProperties()
const QSignalSpy nameChangeSpy(&lookup, &QDnsLookup::nameChanged);
nameProp = QStringLiteral("a-plus-aaaa");
- QCOMPARE(nameChangeSpy.count(), 1);
+ QCOMPARE(nameChangeSpy.size(), 1);
QCOMPARE(lookup.name(), QStringLiteral("a-plus-aaaa"));
nameProp.setBinding(lookup.bindableName().makeBinding());
@@ -391,7 +391,7 @@ void tst_QDnsLookup::bindingsAndProperties()
const QSignalSpy nameserverChangeSpy(&lookup, &QDnsLookup::nameserverChanged);
nameserverProp = QHostAddress::LocalHost;
- QCOMPARE(nameserverChangeSpy.count(), 1);
+ QCOMPARE(nameserverChangeSpy.size(), 1);
QCOMPARE(lookup.nameserver(), QHostAddress::LocalHost);
nameserverProp.setBinding(lookup.bindableNameserver().makeBinding());
diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
index 4dbf891822..f735c3897f 100644
--- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
+++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
@@ -326,6 +326,12 @@ void tst_QHostAddress::isEqual_data()
QTest::newRow("anyv6-anyv4-local") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertLocalHost << false;
QTest::newRow("any-anyv4-local") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertLocalHost << false;
QTest::newRow("any-anyv6-local") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::ConvertLocalHost << false;
+ QTest::newRow("localhostv6-any-tolerant") << QHostAddress(QHostAddress::LocalHostIPv6) << QHostAddress(QHostAddress::Any) << (int)QHostAddress::TolerantConversion << false;
+ QTest::newRow("localhostv4-any-tolerant") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::Any) << (int)QHostAddress::TolerantConversion << false;
+ QTest::newRow("localhostv6-anyv6-tolerant") << QHostAddress(QHostAddress::LocalHostIPv6) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::TolerantConversion << false;
+ QTest::newRow("localhostv4-anyv6-tolerant") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::TolerantConversion << false;
+ QTest::newRow("localhostv6-anyv4-tolerant") << QHostAddress(QHostAddress::LocalHostIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::TolerantConversion << false;
+ QTest::newRow("localhostv4-anyv4-tolerant") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::TolerantConversion << false;
}
void tst_QHostAddress::isEqual()
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index f5d1c1cb5e..3564e52917 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -227,7 +227,7 @@ void tst_QHostInfo::lookupIPv4()
QCOMPARE((int)lookupResults.error(), (int)err);
QStringList tmp;
- for (int i = 0; i < lookupResults.addresses().count(); ++i)
+ for (int i = 0; i < lookupResults.addresses().size(); ++i)
tmp.append(lookupResults.addresses().at(i).toString());
tmp.sort();
@@ -272,7 +272,7 @@ void tst_QHostInfo::lookupIPv6()
QCOMPARE((int)lookupResults.error(), (int)err);
QStringList tmp;
- for (int i = 0; i < lookupResults.addresses().count(); ++i)
+ for (int i = 0; i < lookupResults.addresses().size(); ++i)
tmp.append(lookupResults.addresses().at(i).toString());
tmp.sort();
@@ -351,7 +351,7 @@ void tst_QHostInfo::lookupConnectToLambda()
QCOMPARE(int(lookupResults.error()), int(err));
QStringList tmp;
- for (int i = 0; i < lookupResults.addresses().count(); ++i)
+ for (int i = 0; i < lookupResults.addresses().size(); ++i)
tmp.append(lookupResults.addresses().at(i).toString());
tmp.sort();
@@ -405,12 +405,12 @@ static QStringList reverseLookupHelper(const QString &ip)
for (QByteArray line : lines) {
int index = -1;
if ((index = line.indexOf(nameMarkerNix)) != -1) { // Linux and macOS
- name = line.mid(index + nameMarkerNix.length()).chopped(1).trimmed();
+ name = line.mid(index + nameMarkerNix.size()).chopped(1).trimmed();
results << name;
} else if (line.startsWith(nameMarkerWin)) { // Windows formatting
name = line.mid(line.lastIndexOf(" ")).trimmed();
} else if (line.startsWith(addressMarkerWin)) {
- QByteArray address = line.mid(addressMarkerWin.length()).trimmed();
+ QByteArray address = line.mid(addressMarkerWin.size()).trimmed();
if (address == ip.toUtf8()) {
results << name;
}
@@ -477,7 +477,7 @@ void tst_QHostInfo::blockingLookup()
QHostInfo hostInfo = QHostInfo::fromName(hostname);
QStringList tmp;
- for (int i = 0; i < hostInfo.addresses().count(); ++i)
+ for (int i = 0; i < hostInfo.addresses().size(); ++i)
tmp.append(hostInfo.addresses().at(i).toString());
tmp.sort();
@@ -507,7 +507,7 @@ protected:
{
QHostInfo info = QHostInfo::fromName("a-single" TEST_DOMAIN);
QCOMPARE(info.error(), QHostInfo::NoError);
- QVERIFY(info.addresses().count() > 0);
+ QVERIFY(info.addresses().size() > 0);
QCOMPARE(info.addresses().at(0).toString(), QString("192.0.2.1"));
}
};
@@ -566,7 +566,7 @@ void tst_QHostInfo::threadSafetyAsynchronousAPI()
thread->start();
threads.append(thread);
}
- for (int k = threads.count() - 1; k >= 0; --k)
+ for (int k = threads.size() - 1; k >= 0; --k)
QVERIFY(threads.at(k)->wait(60000));
foreach (LookupReceiver* receiver, receivers) {
QCOMPARE(receiver->result.error(), QHostInfo::NoError);
diff --git a/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp b/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp
index cde2399424..720388c53f 100644
--- a/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp
+++ b/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp
@@ -241,14 +241,14 @@ void tst_QNetworkInformation::isMetered()
QSignalSpy spy(info, &QNetworkInformation::isMeteredChanged);
QVERIFY(!info->isMetered());
MockBackend::setNewMetered(true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(info->isMetered());
QVERIFY(spy[0][0].toBool());
spy.clear();
// Set the same value again, signal should not be emitted again
MockBackend::setNewMetered(true);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
QTEST_MAIN(tst_QNetworkInformation);
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index d609bf5877..36027d89da 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -251,7 +251,7 @@ void tst_QNetworkInterface::interfaceFromXXX_data()
QTest::addColumn<QNetworkInterface>("iface");
QList<QNetworkInterface> allInterfaces = QNetworkInterface::allInterfaces();
- if (allInterfaces.count() == 0)
+ if (allInterfaces.size() == 0)
QSKIP("No interfaces to test!");
foreach (QNetworkInterface iface, allInterfaces)
QTest::newRow(iface.name().toLocal8Bit()) << iface;
diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
index 63bd17f130..c9bf8b92f3 100644
--- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
+++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
@@ -83,9 +83,9 @@ public slots:
int idx = client->property("dataTransmitionIdx").toInt();
if (receivedData.contains("\r\n\r\n") ||
receivedData.contains("\n\n")) {
- if (idx < dataToTransmit.length())
+ if (idx < dataToTransmit.size())
client->write(dataToTransmit.at(idx++));
- if (idx == dataToTransmit.length()) {
+ if (idx == dataToTransmit.size()) {
client->disconnectFromHost();
disconnect(client, 0, this, 0);
client = 0;
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 9b8fec384c..7e523cfadf 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -245,8 +245,8 @@ void tst_QLocalSocket::server_basic()
QVERIFY(!timedOut);
QCOMPARE(server.listen(QString()), false);
- QCOMPARE(server.hits.count(), 0);
- QCOMPARE(spyNewConnection.count(), 0);
+ QCOMPARE(server.hits.size(), 0);
+ QCOMPARE(spyNewConnection.size(), 0);
}
void tst_QLocalSocket::server_connectionsCount()
@@ -287,11 +287,11 @@ void tst_QLocalSocket::socket_basic()
QCOMPARE(socket.waitForDisconnected(0), false);
QCOMPARE(socket.waitForReadyRead(0), false);
- QCOMPARE(spyConnected.count(), 0);
- QCOMPARE(spyDisconnected.count(), 0);
- QCOMPARE(spyError.count(), 0);
- QCOMPARE(spyStateChanged.count(), 0);
- QCOMPARE(spyReadyRead.count(), 0);
+ QCOMPARE(spyConnected.size(), 0);
+ QCOMPARE(spyDisconnected.size(), 0);
+ QCOMPARE(spyError.size(), 0);
+ QCOMPARE(spyStateChanged.size(), 0);
+ QCOMPARE(spyReadyRead.size(), 0);
}
void tst_QLocalSocket::listen_data()
@@ -321,8 +321,8 @@ void tst_QLocalSocket::listen()
QCOMPARE(server.isListening(), canListen);
QCOMPARE(server.hasPendingConnections(), false);
QCOMPARE(server.nextPendingConnection(), (QLocalSocket*)0);
- QCOMPARE(server.hits.count(), 0);
- QCOMPARE(spyNewConnection.count(), 0);
+ QCOMPARE(server.hits.size(), 0);
+ QCOMPARE(spyNewConnection.size(), 0);
if (canListen) {
QVERIFY(server.errorString().isEmpty());
QCOMPARE(server.serverError(), QAbstractSocket::UnknownSocketError);
@@ -396,7 +396,7 @@ void tst_QLocalSocket::listenAndConnect()
QCOMPARE(socket->error(), QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::ConnectedState);
//QVERIFY(socket->socketDescriptor() != -1);
- QCOMPARE(spyError.count(), 0);
+ QCOMPARE(spyError.size(), 0);
} else {
QVERIFY(!socket->errorString().isEmpty());
QVERIFY(socket->error() != QLocalSocket::UnknownSocketError);
@@ -415,13 +415,13 @@ void tst_QLocalSocket::listenAndConnect()
QCOMPARE(socket->waitForConnected(0), canListen);
QCOMPARE(socket->waitForReadyRead(0), false);
- QTRY_COMPARE(spyConnected.count(), canListen ? 1 : 0);
- QCOMPARE(spyDisconnected.count(), 0);
+ QTRY_COMPARE(spyConnected.size(), canListen ? 1 : 0);
+ QCOMPARE(spyDisconnected.size(), 0);
// error signals
- QVERIFY(spyError.count() >= 0);
+ QVERIFY(spyError.size() >= 0);
if (canListen) {
- if (spyError.count() > 0)
+ if (spyError.size() > 0)
QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]),
QLocalSocket::SocketTimeoutError);
} else {
@@ -436,8 +436,8 @@ void tst_QLocalSocket::listenAndConnect()
if (canListen)
QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketState>(spyStateChanged.last()[0]),
QLocalSocket::ConnectedState);
- QCOMPARE(spyStateChanged.count(), 2);
- QCOMPARE(spyReadyRead.count(), 0);
+ QCOMPARE(spyStateChanged.size(), 2);
+ QCOMPARE(spyReadyRead.size(), 0);
bool timedOut = true;
QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen);
@@ -451,16 +451,16 @@ void tst_QLocalSocket::listenAndConnect()
QCOMPARE(server.serverName(), name);
QVERIFY(server.fullServerName().contains(name));
QVERIFY(server.nextPendingConnection() != (QLocalSocket*)0);
- QTRY_COMPARE(server.hits.count(), i + 1);
- QCOMPARE(spyNewConnection.count(), i + 1);
+ QTRY_COMPARE(server.hits.size(), i + 1);
+ QCOMPARE(spyNewConnection.size(), i + 1);
QVERIFY(server.errorString().isEmpty());
QCOMPARE(server.serverError(), QAbstractSocket::UnknownSocketError);
} else {
QVERIFY(server.serverName().isEmpty());
QVERIFY(server.fullServerName().isEmpty());
QCOMPARE(server.nextPendingConnection(), (QLocalSocket*)0);
- QCOMPARE(spyNewConnection.count(), 0);
- QCOMPARE(server.hits.count(), 0);
+ QCOMPARE(spyNewConnection.size(), 0);
+ QCOMPARE(server.hits.size(), 0);
QVERIFY(!server.errorString().isEmpty());
QCOMPARE(server.serverError(), QAbstractSocket::HostNotFoundError);
}
@@ -469,8 +469,8 @@ void tst_QLocalSocket::listenAndConnect()
server.close();
- QCOMPARE(server.hits.count(), (canListen ? connections : 0));
- QCOMPARE(spyNewConnection.count(), (canListen ? connections : 0));
+ QCOMPARE(server.hits.size(), (canListen ? connections : 0));
+ QCOMPARE(spyNewConnection.size(), (canListen ? connections : 0));
}
void tst_QLocalSocket::connectWithOpen()
@@ -494,7 +494,7 @@ void tst_QLocalSocket::connectWithOpen()
socket.close();
server.close();
- QCOMPARE(spyAboutToClose.count(), 1);
+ QCOMPARE(spyAboutToClose.size(), 1);
}
void tst_QLocalSocket::listenAndConnectAbstractNamespaceTrailingZeros_data()
@@ -660,7 +660,7 @@ void tst_QLocalSocket::sendData()
QTest::qWait(250);
#endif
QVERIFY(!timedOut);
- QCOMPARE(spyConnected.count(), canListen ? 1 : 0);
+ QCOMPARE(spyConnected.size(), canListen ? 1 : 0);
QCOMPARE(socket.state(), canListen ? QLocalSocket::ConnectedState : QLocalSocket::UnconnectedState);
// test sending/receiving data
@@ -686,7 +686,7 @@ void tst_QLocalSocket::sendData()
QCOMPARE(socket.flush(), false);
QCOMPARE(socket.isValid(), canListen);
QCOMPARE(socket.readBufferSize(), (qint64)0);
- QCOMPARE(spyReadyRead.count(), expectedReadyReadSignals);
+ QCOMPARE(spyReadyRead.size(), expectedReadyReadSignals);
QVERIFY(testLine.startsWith(in.readLine()));
@@ -697,16 +697,16 @@ void tst_QLocalSocket::sendData()
}
socket.disconnectFromServer();
- QCOMPARE(spyConnected.count(), canListen ? 1 : 0);
- QCOMPARE(spyDisconnected.count(), canListen ? 1 : 0);
- QCOMPARE(spyError.count(), canListen ? 0 : 1);
- QCOMPARE(spyStateChanged.count(), canListen ? 4 : 2);
- QCOMPARE(spyReadyRead.count(), canListen ? expectedReadyReadSignals : 0);
+ QCOMPARE(spyConnected.size(), canListen ? 1 : 0);
+ QCOMPARE(spyDisconnected.size(), canListen ? 1 : 0);
+ QCOMPARE(spyError.size(), canListen ? 0 : 1);
+ QCOMPARE(spyStateChanged.size(), canListen ? 4 : 2);
+ QCOMPARE(spyReadyRead.size(), canListen ? expectedReadyReadSignals : 0);
server.close();
- QCOMPARE(server.hits.count(), (canListen ? 1 : 0));
- QCOMPARE(spy.count(), (canListen ? 1 : 0));
+ QCOMPARE(server.hits.size(), (canListen ? 1 : 0));
+ QCOMPARE(spy.size(), (canListen ? 1 : 0));
}
void tst_QLocalSocket::readLine_data()
@@ -1006,7 +1006,7 @@ void tst_QLocalSocket::simpleCommandProtocol2()
localSocketWrite.abort();
QCOMPARE(localSocketWrite.state(), QLocalSocket::UnconnectedState);
- QCOMPARE(spyDisconnected.count(), 1);
+ QCOMPARE(spyDisconnected.size(), 1);
QCOMPARE(localSocketWrite.bytesToWrite(), 0);
QVERIFY(!localSocketWrite.isOpen());
@@ -1068,7 +1068,7 @@ void tst_QLocalSocket::hitMaximumConnections()
bool timedOut = true;
QVERIFY(server.waitForNewConnection(3000, &timedOut));
QVERIFY(!timedOut);
- QVERIFY(server.hits.count() > 0);
+ QVERIFY(server.hits.size() > 0);
qDeleteAll(sockets.begin(), sockets.end());
}
@@ -1096,9 +1096,9 @@ public:
QVERIFY(socket.waitForConnected(1000));
// We should *not* have this signal yet!
- QCOMPARE(spyReadyRead.count(), 0);
+ QCOMPARE(spyReadyRead.size(), 0);
socket.waitForReadyRead();
- QCOMPARE(spyReadyRead.count(), 1);
+ QCOMPARE(spyReadyRead.size(), 1);
QTextStream in(&socket);
QCOMPARE(in.readLine(), testLine);
socket.close();
@@ -1140,7 +1140,7 @@ public:
--done;
delete serverSocket;
}
- QCOMPARE(server.hits.count(), clients);
+ QCOMPARE(server.hits.size(), clients);
}
};
@@ -1309,7 +1309,7 @@ void tst_QLocalSocket::waitForDisconnectByServer()
serverSocket->close();
QCOMPARE(serverSocket->state(), QLocalSocket::UnconnectedState);
QVERIFY(socket.waitForDisconnected(3000));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QLocalSocket::waitForReadyReadOnDisconnected()
@@ -1426,7 +1426,7 @@ void tst_QLocalSocket::recycleClientSocket()
QLocalSocket client;
QSignalSpy clientReadyReadSpy(&client, SIGNAL(readyRead()));
QSignalSpy clientErrorSpy(&client, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
- for (int i = 0; i < lines.count(); ++i) {
+ for (int i = 0; i < lines.size(); ++i) {
client.abort();
clientReadyReadSpy.clear();
client.connectToServer(serverName);
@@ -1521,7 +1521,7 @@ void tst_QLocalSocket::writeToClientAndDisconnect()
QVERIFY(clientSocket->waitForDisconnected());
QVERIFY(client.waitForDisconnected());
- QCOMPARE(readChannelFinishedSpy.count(), 1);
+ QCOMPARE(readChannelFinishedSpy.size(), 1);
const QByteArray received = client.readAll();
QCOMPARE(received.size(), qint64(sizeof(buffer) * chunks));
QCOMPARE(client.state(), QLocalSocket::UnconnectedState);
@@ -1551,7 +1551,7 @@ void tst_QLocalSocket::writeToDisconnected()
QCOMPARE(client.bytesToWrite(), qint64(1));
QVERIFY(!client.waitForBytesWritten());
- QCOMPARE(spyError.count(), 1);
+ QCOMPARE(spyError.size(), 1);
QCOMPARE(client.state(), QLocalSocket::UnconnectedState);
}
@@ -1656,7 +1656,7 @@ void tst_QLocalSocket::asyncDisconnectNotify()
QVERIFY(serverSocket);
delete serverSocket;
QTRY_VERIFY(!disconnectedSpy.isEmpty());
- QCOMPARE(readChannelFinishedSpy.count(), 1);
+ QCOMPARE(readChannelFinishedSpy.size(), 1);
}
void tst_QLocalSocket::verifySocketOptions_data()
diff --git a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
index a9a591d5ca..479d0f878f 100644
--- a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
+++ b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
@@ -1,8 +1,7 @@
[udpTest]
*
[passwordAuth]
-ubuntu-18.04
-ubuntu-20.04
+ubuntu
# QTBUG-101274
qnx ci
# QTBUG-74162
diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
index 3ce1153031..aa860893bb 100644
--- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
+++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
@@ -915,13 +915,13 @@ void tst_QSocks5SocketEngine::fragmentation_data()
responses << authMethodBasic << authSuccess.left(1) << authSuccess.mid(1) << connectResponseIPv4;
QTest::newRow("auth-response") << responses;
- for (int i = 1; i < connectResponseIPv4.length() - 1; i++) {
+ for (int i = 1; i < connectResponseIPv4.size() - 1; i++) {
responses.clear();
responses << authMethodNone << connectResponseIPv4.left(i) << connectResponseIPv4.mid(i);
QTest::newRow(qPrintable(QString("connect-response-ipv4-") + QString::number(i))) << responses;
}
- for (int i = 1; i < connectResponseIPv6.length() - 1; i++) {
+ for (int i = 1; i < connectResponseIPv6.size() - 1; i++) {
responses.clear();
responses << authMethodNone << connectResponseIPv6.left(i) << connectResponseIPv6.mid(i);
QTest::newRow(qPrintable(QString("connect-response-ipv6-") + QString::number(i))) << responses;
@@ -964,13 +964,13 @@ void tst_QSocks5SocketEngine::incomplete_data()
responses << authMethodBasic << authSuccess.left(1);
QTest::newRow("auth-response") << responses;
- for (int i = 1; i < connectResponseIPv4.length() - 1; i++) {
+ for (int i = 1; i < connectResponseIPv4.size() - 1; i++) {
responses.clear();
responses << authMethodNone << connectResponseIPv4.left(i);
QTest::newRow(qPrintable(QString("connect-response-ipv4-") + QString::number(i))) << responses;
}
- for (int i = 1; i < connectResponseIPv6.length() - 1; i++) {
+ for (int i = 1; i < connectResponseIPv6.size() - 1; i++) {
responses.clear();
responses << authMethodNone << connectResponseIPv6.left(i);
QTest::newRow(qPrintable(QString("connect-response-ipv6-") + QString::number(i))) << responses;
diff --git a/tests/auto/network/socket/qtcpserver/BLACKLIST b/tests/auto/network/socket/qtcpserver/BLACKLIST
index ecca156cef..339987046c 100644
--- a/tests/auto/network/socket/qtcpserver/BLACKLIST
+++ b/tests/auto/network/socket/qtcpserver/BLACKLIST
@@ -15,4 +15,3 @@ windows-10
[linkLocal]
macos arm
-
diff --git a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp
index 5e00a2bd20..c14c429520 100644
--- a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp
+++ b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp
@@ -7,18 +7,45 @@
#if defined(Q_OS_WIN) && defined(Q_CC_MSVC)
# include <crtdbg.h>
#endif
+#ifdef Q_OS_UNIX
+# include <sys/resource.h>
+# include <unistd.h>
+#endif
int main(int argc, char *argv[])
{
- // Windows: Suppress crash notification dialog.
#if defined(Q_OS_WIN) && defined(Q_CC_MSVC)
+ // Windows: Suppress crash notification dialog.
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
+#elif defined(RLIMIT_CORE)
+ // Unix: set our core dump limit to zero to request no dialogs.
+ if (struct rlimit rlim; getrlimit(RLIMIT_CORE, &rlim) == 0) {
+ rlim.rlim_cur = 0;
+ setrlimit(RLIMIT_CORE, &rlim);
+ }
#endif
+
QCoreApplication app(argc, argv);
+ if (argc < 1) {
+ fprintf(stderr, "Need a port number\n");
+ return 1;
+ }
+ int port = QByteArrayView(argv[1]).toInt();
QTcpServer server;
- if (!server.listen(QHostAddress::LocalHost, 49199)) {
- qDebug("Failed to listen: %s", server.errorString().toLatin1().constData());
+ if (!server.listen(QHostAddress::LocalHost, port)) {
+ fprintf(stderr, "Failed to listen: %s\n", server.errorString().toLatin1().constData());
+ if (server.serverError() == QTcpSocket::AddressInUseError) {
+ // let's see if we can find the process that would be holding this
+ // still open
+#ifdef Q_OS_LINUX
+ static const char *ss_args[] = {
+ "ss", "-nap", "sport", "=", argv[1], nullptr
+ };
+ dup2(STDERR_FILENO, STDOUT_FILENO);
+ execvp(ss_args[0], const_cast<char **>(ss_args));
+#endif
+ }
return 1;
}
diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
index adf3781c50..b10bce335b 100644
--- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
@@ -248,7 +248,7 @@ void tst_QTcpServer::clientServerLoop()
QVERIFY(server.waitForNewConnection(5000));
QVERIFY(server.hasPendingConnections());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTcpSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket != 0);
@@ -409,9 +409,9 @@ void tst_QTcpServer::maxPendingConnections()
// two connections have been made. The second compare makes sure no
// more are accepted. Creating connections happens multithreaded so
// qWait must be used for that.
- QTRY_COMPARE(spy.count(), 2);
+ QTRY_COMPARE(spy.size(), 2);
QTest::qWait(100);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(server.hasPendingConnections());
QVERIFY(server.nextPendingConnection());
@@ -578,9 +578,6 @@ void tst_QTcpServer::addressReusable()
#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
-#ifdef Q_OS_LINUX
- QSKIP("The addressReusable test is unstable on Linux. See QTBUG-39985.");
-#endif
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
#ifndef QT_NO_NETWORKPROXY
@@ -591,16 +588,25 @@ void tst_QTcpServer::addressReusable()
QSKIP("No proxy support");
#endif // QT_NO_NETWORKPROXY
}
+
+ QTcpServer server;
+ QVERIFY(server.listen(QHostAddress::LocalHost, 0));
+ quint16 serverPort = server.serverPort();
+ qDebug() << "Got port" << serverPort;
+ server.close(); // cleanly close
+
+ QTest::qSleep(10);
+
// The crashingServer process will crash once it gets a connection.
QProcess process;
QString processExe = crashingServerDir + "/crashingServer";
- process.start(processExe);
+ process.start(processExe, { QString::number(serverPort) });
QVERIFY2(process.waitForStarted(), qPrintable(
QString::fromLatin1("Could not start %1: %2").arg(processExe, process.errorString())));
- QVERIFY(process.waitForReadyRead(5000));
+ QVERIFY2(process.waitForReadyRead(5000), qPrintable(process.readAllStandardError()));
QTcpSocket socket;
- socket.connectToHost(QHostAddress::LocalHost, 49199);
+ socket.connectToHost(QHostAddress::LocalHost, serverPort);
QVERIFY(socket.waitForConnected(5000));
QVERIFY(process.waitForFinished(30000));
@@ -608,8 +614,9 @@ void tst_QTcpServer::addressReusable()
// Give the system some time.
QTest::qSleep(10);
- QTcpServer server;
- QVERIFY(server.listen(QHostAddress::LocalHost, 49199));
+ // listen again
+ QVERIFY2(server.listen(QHostAddress::LocalHost, serverPort),
+ qPrintable(server.errorString()));
#endif
}
@@ -1009,12 +1016,12 @@ void tst_QTcpServer::eagainBlockingAccept()
QTcpSocket s;
s.connectToHost(QHostAddress::LocalHost, 7896);
QSignalSpy spy(&server, SIGNAL(newConnection()));
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 500);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.size(), 1, 500);
s.close();
// To test try again, should connect just fine.
s.connectToHost(QHostAddress::LocalHost, 7896);
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 500);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.size(), 2, 500);
s.close();
server.close();
}
@@ -1050,13 +1057,13 @@ void tst_QTcpServer::pauseAccepting()
QTcpSocket sockets[NumSockets];
sockets[0].connectToHost(address, server.serverPort());
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
server.pauseAccepting();
for (int i = 1; i < NumSockets; ++i)
sockets[i].connectToHost(address, server.serverPort());
QVERIFY(!spy.wait(400));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
server.resumeAccepting();
if (setProxy) {
@@ -1064,7 +1071,7 @@ void tst_QTcpServer::pauseAccepting()
Abort);
}
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
}
@@ -1128,11 +1135,11 @@ void tst_QTcpServer::pendingConnectionAvailable()
QCOMPARE(socket.state(), QTcpSocket::ConnectedState);
int expectedPendingConnections = useDerivedServer ? 0 : 1;
- QCOMPARE(pendingConnectionSpy.count(), expectedPendingConnections);
+ QCOMPARE(pendingConnectionSpy.size(), expectedPendingConnections);
if (useDerivedServer)
static_cast<DerivedServer *>(server)->emitNextSocket();
- QCOMPARE(pendingConnectionSpy.count(), 1);
+ QCOMPARE(pendingConnectionSpy.size(), 1);
}
QTEST_MAIN(tst_QTcpServer)
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 981160ce6b..e35c771b0b 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -347,8 +347,8 @@ void tst_QTcpSocket::init()
QFETCH_GLOBAL(int, proxyType);
QList<QHostAddress> socks5Addresses = QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses();
QList<QHostAddress> httpProxyAddresses = QHostInfo::fromName(QtNetworkSettings::httpProxyServerName()).addresses();
- QVERIFY2(socks5Addresses.count() > 0, "failed to get ip address for SOCKS5 proxy server");
- QVERIFY2(httpProxyAddresses.count() > 0, "failed to get ip address for HTTP proxy server");
+ QVERIFY2(socks5Addresses.size() > 0, "failed to get ip address for SOCKS5 proxy server");
+ QVERIFY2(httpProxyAddresses.size() > 0, "failed to get ip address for HTTP proxy server");
QString socks5Address = socks5Addresses.first().toString();
QString httpProxyAddress = httpProxyAddresses.first().toString();
QNetworkProxy proxy;
@@ -1781,7 +1781,7 @@ void tst_QTcpSocket::recursiveReadyRead()
QVERIFY2(!timeout(),
"Timed out when waiting for the readyRead() signal.");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
delete testSocket;
}
@@ -1823,7 +1823,7 @@ void tst_QTcpSocket::atEnd()
QVERIFY2(greeting.startsWith("220 (vsFTPd 3."), qPrintable(greeting));
#else
// Test server must use some vsFTPd 2.x.x version
- QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting));
+ QVERIFY2(greeting.size() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting));
QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting));
#endif
QVERIFY2(greeting.endsWith(QLatin1Char(')')), qPrintable(greeting));
@@ -2006,8 +2006,8 @@ void tst_QTcpSocket::remoteCloseError()
enterLoop(30);
QVERIFY(!timeout());
- QCOMPARE(disconnectedSpy.count(), 1);
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(disconnectedSpy.size(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(clientSocket->error(), QAbstractSocket::RemoteHostClosedError);
delete serverSocket;
@@ -2138,7 +2138,7 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot()
if (tmpSocket->state() != QAbstractSocket::ConnectedState)
loop.exec();
- QCOMPARE(timerSpy.count(), 0);
+ QCOMPARE(timerSpy.size(), 0);
delete tmpSocket;
}
@@ -2243,7 +2243,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead()
// Wait for the read
QVERIFY(socket->waitForReadyRead(10000));
- QCOMPARE(readyReadSpy.count(), 1);
+ QCOMPARE(readyReadSpy.size(), 1);
QString s = socket->readLine();
QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), s.toLatin1().constData());
@@ -2251,7 +2251,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead()
QCoreApplication::instance()->processEvents();
QCOMPARE(socket->bytesAvailable(), qint64(0));
- QCOMPARE(readyReadSpy.count(), 1);
+ QCOMPARE(readyReadSpy.size(), 1);
delete socket;
}
@@ -2325,8 +2325,8 @@ void tst_QTcpSocket::abortiveClose()
enterLoop(5);
- QCOMPARE(readyReadSpy.count(), 0);
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(readyReadSpy.size(), 0);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(*static_cast<const int *>(errorSpy.at(0).at(0).constData()),
int(QAbstractSocket::RemoteHostClosedError));
@@ -2445,11 +2445,11 @@ void tst_QTcpSocket::connectionRefused()
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
QCOMPARE(socket->error(), QAbstractSocket::ConnectionRefusedError);
- QCOMPARE(stateSpy.count(), 3);
+ QCOMPARE(stateSpy.size(), 3);
QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState);
QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(1).at(0)), QAbstractSocket::ConnectingState);
QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(2).at(0)), QAbstractSocket::UnconnectedState);
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorSpy.size(), 1);
delete socket;
}
@@ -3118,8 +3118,8 @@ void tst_QTcpSocket::serverDisconnectWithBuffered()
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
}
// Test signal emitting
- QCOMPARE(spyDisconnected.count(), 1);
- QVERIFY(spyStateChanged.count() > 0);
+ QCOMPARE(spyDisconnected.size(), 1);
+ QVERIFY(spyStateChanged.size() > 0);
QVERIFY(qvariant_cast<QAbstractSocket::SocketState>(spyStateChanged.last().first())
== QAbstractSocket::UnconnectedState);
@@ -3208,7 +3208,7 @@ void tst_QTcpSocket::readNotificationsAfterBind()
QTestEventLoop::instance().enterLoop(10);
QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
- QCOMPARE(spyReadyRead.count(), 0);
+ QCOMPARE(spyReadyRead.size(), 0);
}
QTEST_MAIN(tst_QTcpSocket)
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index 336b528567..4380433899 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -173,7 +173,7 @@ QNetworkInterface tst_QUdpSocket::interfaceForGroup(const QHostAddress &multicas
static QNetworkInterface ipv6if = [&]() {
// find any link local address in the allAddress list
- for (const QHostAddress &addr: qAsConst(allAddresses)) {
+ for (const QHostAddress &addr: std::as_const(allAddresses)) {
if (addr.isLoopback())
continue;
@@ -269,7 +269,7 @@ void tst_QUdpSocket::initTestCase()
// ff12:: is temporary, not prefix-based, link-local
r[0] = qToBigEndian(Q_UINT64_C(0xff12) << 48);
QHostAddress llbase(*reinterpret_cast<Q_IPV6ADDR *>(&r));
- for (const QHostAddress &a : qAsConst(allAddresses)) {
+ for (const QHostAddress &a : std::as_const(allAddresses)) {
QString scope = a.scopeId();
if (scope.isEmpty())
continue;
@@ -334,7 +334,7 @@ void tst_QUdpSocket::unconnectedServerAndClientTest()
QSignalSpy stateChangedSpy(&serverSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
QVERIFY2(serverSocket.bind(), serverSocket.errorString().toLatin1().constData());
- QCOMPARE(stateChangedSpy.count(), 1);
+ QCOMPARE(stateChangedSpy.size(), 1);
const char *message[] = {"Yo mista", "Yo", "Wassap"};
@@ -386,7 +386,7 @@ void tst_QUdpSocket::broadcasting()
foreach (QNetworkInterface iface, QNetworkInterface::allInterfaces()) {
if ((iface.flags() & QNetworkInterface::CanBroadcast)
&& iface.flags() & QNetworkInterface::IsUp) {
- for (int i=0;i<iface.addressEntries().count();i++) {
+ for (int i=0;i<iface.addressEntries().size();i++) {
QHostAddress broadcast = iface.addressEntries().at(i).broadcast();
if (broadcast.protocol() == QAbstractSocket::IPv4Protocol)
broadcastAddresses.append(broadcast);
@@ -431,7 +431,7 @@ void tst_QUdpSocket::broadcasting()
QVERIFY(dgram.isValid());
QByteArray arr = dgram.data();
- QCOMPARE(arr.length(), messageLength);
+ QCOMPARE(arr.size(), messageLength);
arr.resize(messageLength);
QCOMPARE(arr, QByteArray(message[i]));
@@ -491,27 +491,27 @@ void tst_QUdpSocket::loop()
QHostAddress peterAddress = makeNonAny(peter.localAddress());
QHostAddress paulAddress = makeNonAny(paul.localAddress());
- QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(),
- paulAddress, paul.localPort()), qint64(peterMessage.length()));
- QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(),
- peterAddress, peter.localPort()), qint64(paulMessage.length()));
+ QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.size(),
+ paulAddress, paul.localPort()), qint64(peterMessage.size()));
+ QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.size(),
+ peterAddress, peter.localPort()), qint64(paulMessage.size()));
QVERIFY2(peter.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(peter).constData());
QVERIFY2(paul.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(paul).constData());
- QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.length() * 2);
- QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.length() * 2);
+ QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.size() * 2);
+ QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.size() * 2);
if (success) {
- QCOMPARE(peterDatagram.data().length(), qint64(paulMessage.length()));
- QCOMPARE(paulDatagram.data().length(), qint64(peterMessage.length()));
+ QCOMPARE(peterDatagram.data().size(), qint64(paulMessage.size()));
+ QCOMPARE(paulDatagram.data().size(), qint64(peterMessage.size()));
} else {
// this code path seems to never be executed
- QVERIFY(peterDatagram.data().length() != paulMessage.length());
- QVERIFY(paulDatagram.data().length() != peterMessage.length());
+ QVERIFY(peterDatagram.data().size() != paulMessage.size());
+ QVERIFY(paulDatagram.data().size() != peterMessage.size());
}
- QCOMPARE(peterDatagram.data().left(paulMessage.length()), paulMessage);
- QCOMPARE(paulDatagram.data().left(peterMessage.length()), peterMessage);
+ QCOMPARE(peterDatagram.data().left(paulMessage.size()), paulMessage);
+ QCOMPARE(paulDatagram.data().left(peterMessage.size()), peterMessage);
QCOMPARE(peterDatagram.senderAddress(), paulAddress);
QCOMPARE(paulDatagram.senderAddress(), peterAddress);
@@ -568,27 +568,27 @@ void tst_QUdpSocket::ipv6Loop()
peterPort = peter.localPort();
paulPort = paul.localPort();
- QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"),
- paulPort), qint64(peterMessage.length()));
- QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(),
- QHostAddress("::1"), peterPort), qint64(paulMessage.length()));
+ QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.size(), QHostAddress("::1"),
+ paulPort), qint64(peterMessage.size()));
+ QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.size(),
+ QHostAddress("::1"), peterPort), qint64(paulMessage.size()));
QVERIFY(peter.waitForReadyRead(5000));
QVERIFY(paul.waitForReadyRead(5000));
- QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.length() * 2);
- QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.length() * 2);
+ QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.size() * 2);
+ QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.size() * 2);
if (success) {
- QCOMPARE(peterDatagram.data().length(), qint64(paulMessage.length()));
- QCOMPARE(paulDatagram.data().length(), qint64(peterMessage.length()));
+ QCOMPARE(peterDatagram.data().size(), qint64(paulMessage.size()));
+ QCOMPARE(paulDatagram.data().size(), qint64(peterMessage.size()));
} else {
// this code path seems to never be executed
- QVERIFY(peterDatagram.data().length() != paulMessage.length());
- QVERIFY(paulDatagram.data().length() != peterMessage.length());
+ QVERIFY(peterDatagram.data().size() != paulMessage.size());
+ QVERIFY(paulDatagram.data().size() != peterMessage.size());
}
- QCOMPARE(peterDatagram.data().left(paulMessage.length()), paulMessage);
- QCOMPARE(paulDatagram.data().left(peterMessage.length()), peterMessage);
+ QCOMPARE(peterDatagram.data().left(paulMessage.size()), paulMessage);
+ QCOMPARE(paulDatagram.data().left(peterMessage.size()), peterMessage);
QCOMPARE(peterDatagram.senderAddress(), paulAddress);
QCOMPARE(paulDatagram.senderAddress(), peterAddress);
@@ -616,7 +616,7 @@ void tst_QUdpSocket::dualStack()
QVERIFY(v4Sock.bind(QHostAddress(QHostAddress::AnyIPv4), 0));
//test v4 -> dual
- QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.length(), QHostAddress(QHostAddress::LocalHost), dualSock.localPort()), v4Data.length());
+ QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.size(), QHostAddress(QHostAddress::LocalHost), dualSock.localPort()), v4Data.size());
QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData());
QNetworkDatagram dgram = dualSock.receiveDatagram(100);
QVERIFY(dgram.isValid());
@@ -628,7 +628,7 @@ void tst_QUdpSocket::dualStack()
QCOMPARE(dgram.senderAddress(), makeNonAny(v4Sock.localAddress(), QHostAddress::Null));
if (dgram.destinationPort() != -1) {
QCOMPARE(dgram.destinationPort(), int(dualSock.localPort()));
- QVERIFY(dgram.destinationAddress().isEqual(dualSock.localAddress()));
+ QVERIFY(dgram.destinationAddress().isEqual(makeNonAny(dualSock.localAddress(), QHostAddress::LocalHost)));
} else {
qInfo("Getting IPv4 destination address failed.");
}
@@ -639,7 +639,7 @@ void tst_QUdpSocket::dualStack()
QVERIFY(v6Sock.bind(QHostAddress(QHostAddress::AnyIPv6), 0));
//test v6 -> dual
- QCOMPARE((int)v6Sock.writeDatagram(v6Data.constData(), v6Data.length(), QHostAddress(QHostAddress::LocalHostIPv6), dualSock.localPort()), v6Data.length());
+ QCOMPARE((int)v6Sock.writeDatagram(v6Data.constData(), v6Data.size(), QHostAddress(QHostAddress::LocalHostIPv6), dualSock.localPort()), v6Data.size());
QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData());
dgram = dualSock.receiveDatagram(100);
QVERIFY(dgram.isValid());
@@ -650,7 +650,7 @@ void tst_QUdpSocket::dualStack()
QCOMPARE(dgram.destinationAddress(), makeNonAny(dualSock.localAddress(), QHostAddress::LocalHostIPv6));
//test dual -> v6
- QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length());
+ QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.size());
QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData());
dgram = v6Sock.receiveDatagram(100);
QVERIFY(dgram.isValid());
@@ -662,7 +662,7 @@ void tst_QUdpSocket::dualStack()
}
//test dual -> v4
- QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length());
+ QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.size());
QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData());
dgram = v4Sock.receiveDatagram(100);
QVERIFY(dgram.isValid());
@@ -701,19 +701,19 @@ void tst_QUdpSocket::dualStackAutoBinding()
//test an autobound socket can send to both v4 and v6 addresses (v4 first)
QUdpSocket dualSock;
- QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length());
+ QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.size());
QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData());
buffer.reserve(100);
size = v4Sock.readDatagram(buffer.data(), 100, &from, &port);
- QCOMPARE((int)size, dualData.length());
+ QCOMPARE((int)size, dualData.size());
buffer.resize(size);
QCOMPARE(buffer, dualData);
- QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length());
+ QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.size());
QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData());
buffer.reserve(100);
size = v6Sock.readDatagram(buffer.data(), 100, &from, &port);
- QCOMPARE((int)size, dualData.length());
+ QCOMPARE((int)size, dualData.size());
buffer.resize(size);
QCOMPARE(buffer, dualData);
}
@@ -722,19 +722,19 @@ void tst_QUdpSocket::dualStackAutoBinding()
//test an autobound socket can send to both v4 and v6 addresses (v6 first)
QUdpSocket dualSock;
- QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length());
+ QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.size());
QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData());
buffer.reserve(100);
size = v6Sock.readDatagram(buffer.data(), 100, &from, &port);
- QCOMPARE((int)size, dualData.length());
+ QCOMPARE((int)size, dualData.size());
buffer.resize(size);
QCOMPARE(buffer, dualData);
- QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length());
+ QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.size());
QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData());
buffer.reserve(100);
size = v4Sock.readDatagram(buffer.data(), 100, &from, &port);
- QCOMPARE((int)size, dualData.length());
+ QCOMPARE((int)size, dualData.size());
buffer.resize(size);
QCOMPARE(buffer, dualData);
}
@@ -755,7 +755,7 @@ void tst_QUdpSocket::dualStackNoIPv4onV6only()
QVERIFY(v6Sock.bind(QHostAddress(QHostAddress::AnyIPv6), 0));
//test v4 -> v6 (should not be received as this is a v6 only socket)
- QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.length(), QHostAddress(QHostAddress::LocalHost), v6Sock.localPort()), v4Data.length());
+ QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.size(), QHostAddress(QHostAddress::LocalHost), v6Sock.localPort()), v4Data.size());
QVERIFY(!v6Sock.waitForReadyRead(1000));
}
@@ -875,17 +875,17 @@ void tst_QUdpSocket::writeDatagram()
#if defined (Q_OS_HPUX)
QSKIP("HP-UX 11.11 on hai (PA-RISC 64) truncates too long datagrams.");
#endif
- QCOMPARE(bytesspy.count(), 0);
- QCOMPARE(errorspy.count(), 1);
+ QCOMPARE(bytesspy.size(), 0);
+ QCOMPARE(errorspy.size(), 1);
QCOMPARE(*static_cast<const int *>(errorspy.at(0).at(0).constData()),
int(QUdpSocket::DatagramTooLargeError));
QCOMPARE(client.error(), QUdpSocket::DatagramTooLargeError);
break;
}
- QCOMPARE(bytesspy.count(), 1);
+ QCOMPARE(bytesspy.size(), 1);
QCOMPARE(*static_cast<const qint64 *>(bytesspy.at(0).at(0).constData()),
qint64(i * 1024));
- QCOMPARE(errorspy.count(), 0);
+ QCOMPARE(errorspy.size(), 0);
if (!server.waitForReadyRead(5000))
QSKIP(QString("UDP packet lost at size %1, unable to complete the test.").arg(i * 1024).toLatin1().data());
QCOMPARE(server.pendingDatagramSize(), qint64(i * 1024));
@@ -998,7 +998,7 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer()
QVERIFY(sUdp.bind());
QCOMPARE(sUdp.writeDatagram("", 1, peerAddress, peerPort), qint64(1));
QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(sReadyReadSpy.count(), 0);
+ QCOMPARE(sReadyReadSpy.size(), 0);
}
void tst_QUdpSocket::writeToNonExistingPeer_data()
@@ -1041,8 +1041,8 @@ void tst_QUdpSocket::writeToNonExistingPeer()
// the third one will succeed...
QCOMPARE(sConnected.write("", 1), qint64(1));
QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(sConnectedReadyReadSpy.count(), 0);
- QCOMPARE(sConnectedErrorSpy.count(), 1);
+ QCOMPARE(sConnectedReadyReadSpy.size(), 0);
+ QCOMPARE(sConnectedErrorSpy.size(), 1);
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError));
// we should now get a read error
@@ -1334,7 +1334,7 @@ void tst_QUdpSocket::multicastJoinBeforeBind_data()
QTest::newRow("valid ipv4 group address") << multicastGroup4;
QTest::newRow("invalid ipv4 group address") << QHostAddress(QHostAddress::Broadcast);
QTest::newRow("valid ipv6 group address") << multicastGroup6;
- for (const QHostAddress &a : qAsConst(linklocalMulticastGroups))
+ for (const QHostAddress &a : std::as_const(linklocalMulticastGroups))
QTest::addRow("valid ipv6 %s-link group address", a.scopeId().toLatin1().constData()) << a;
QTest::newRow("invalid ipv6 group address") << QHostAddress(QHostAddress::AnyIPv6);
}
@@ -1354,7 +1354,7 @@ void tst_QUdpSocket::multicastLeaveAfterClose_data()
QTest::addColumn<QHostAddress>("groupAddress");
QTest::newRow("ipv4") << multicastGroup4;
QTest::newRow("ipv6") << multicastGroup6;
- for (const QHostAddress &a : qAsConst(linklocalMulticastGroups))
+ for (const QHostAddress &a : std::as_const(linklocalMulticastGroups))
QTest::addRow("ipv6-link-%s", a.scopeId().toLatin1().constData()) << a;
}
@@ -1448,13 +1448,13 @@ void tst_QUdpSocket::multicast_data()
QTest::newRow("valid bind, group ipv4 address") << anyAddress << true << groupAddress << true;
QTest::newRow("valid bind, invalid group ipv4 address") << anyAddress << true << anyAddress << false;
QTest::newRow("valid bind, group ipv6 address") << any6Address << true << group6Address << true;
- for (const QHostAddress &a : qAsConst(linklocalMulticastGroups))
+ for (const QHostAddress &a : std::as_const(linklocalMulticastGroups))
QTest::addRow("valid bind, %s-link group ipv6 address", a.scopeId().toLatin1().constData())
<< any6Address << true << a << true;
QTest::newRow("valid bind, invalid group ipv6 address") << any6Address << true << any6Address << false;
QTest::newRow("dual bind, group ipv4 address") << dualAddress << true << groupAddress << false;
QTest::newRow("dual bind, group ipv6 address") << dualAddress << true << group6Address << true;
- for (const QHostAddress &a : qAsConst(linklocalMulticastGroups))
+ for (const QHostAddress &a : std::as_const(linklocalMulticastGroups))
QTest::addRow("dual bind, %s-link group ipv6 address", a.scopeId().toLatin1().constData())
<< dualAddress << true << a << true;
}
@@ -1550,7 +1550,7 @@ void tst_QUdpSocket::echo()
{
QFETCH(bool, connect);
QHostInfo info = QHostInfo::fromName(QtNetworkSettings::echoServerName());
- QVERIFY(info.addresses().count());
+ QVERIFY(info.addresses().size());
QHostAddress remote = info.addresses().first();
QUdpSocket sock;
@@ -1577,7 +1577,7 @@ void tst_QUdpSocket::echo()
in = sock.read(sock.pendingDatagramSize());
} else {
in.resize(sock.pendingDatagramSize());
- sock.readDatagram(in.data(), in.length(), &from, &port);
+ sock.readDatagram(in.data(), in.size(), &from, &port);
}
if (in==out)
successes++;
@@ -1647,21 +1647,21 @@ void tst_QUdpSocket::linkLocalIPv6()
QSignalSpy spy(s, SIGNAL(readyRead()));
QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort()));
- QTRY_VERIFY(neutralReadSpy.count() > 0); //note may need to accept a firewall prompt
+ QTRY_VERIFY(neutralReadSpy.size() > 0); //note may need to accept a firewall prompt
- QNetworkDatagram dgram = neutral.receiveDatagram(testData.length() * 2);
+ QNetworkDatagram dgram = neutral.receiveDatagram(testData.size() * 2);
QVERIFY(dgram.isValid());
QCOMPARE(dgram.senderAddress(), s->localAddress());
QCOMPARE(dgram.senderPort(), int(s->localPort()));
QCOMPARE(dgram.destinationAddress(), s->localAddress());
QCOMPARE(dgram.destinationPort(), int(neutral.localPort()));
- QCOMPARE(dgram.data().length(), testData.length());
+ QCOMPARE(dgram.data().size(), testData.size());
QCOMPARE(dgram.data(), testData);
QVERIFY(neutral.writeDatagram(dgram.makeReply(testData)));
- QTRY_VERIFY(spy.count() > 0); //note may need to accept a firewall prompt
+ QTRY_VERIFY(spy.size() > 0); //note may need to accept a firewall prompt
- dgram = s->receiveDatagram(testData.length() * 2);
+ dgram = s->receiveDatagram(testData.size() * 2);
QCOMPARE(dgram.data(), testData);
//sockets bound to other interfaces shouldn't have received anything
@@ -1728,11 +1728,11 @@ void tst_QUdpSocket::linkLocalIPv4()
QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort()));
QVERIFY2(neutral.waitForReadyRead(10000), QtNetworkSettings::msgSocketError(neutral).constData());
- QNetworkDatagram dgram = neutral.receiveDatagram(testData.length() * 2);
+ QNetworkDatagram dgram = neutral.receiveDatagram(testData.size() * 2);
QVERIFY(dgram.isValid());
QCOMPARE(dgram.senderAddress(), s->localAddress());
QCOMPARE(dgram.senderPort(), int(s->localPort()));
- QCOMPARE(dgram.data().length(), testData.length());
+ QCOMPARE(dgram.data().size(), testData.size());
QCOMPARE(dgram.data(), testData);
// Unlike for IPv6 with IPV6_PKTINFO, IPv4 has no standardized way of
@@ -1751,7 +1751,7 @@ void tst_QUdpSocket::linkLocalIPv4()
QVERIFY(neutral.writeDatagram(dgram.makeReply(testData)));
QVERIFY2(s->waitForReadyRead(10000), QtNetworkSettings::msgSocketError(*s).constData());
- dgram = s->receiveDatagram(testData.length() * 2);
+ dgram = s->receiveDatagram(testData.size() * 2);
QVERIFY(dgram.isValid());
QCOMPARE(dgram.data(), testData);
@@ -1786,7 +1786,7 @@ void tst_QUdpSocket::readyRead()
QTest::qWait(100);
// make sure only one signal was emitted
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(receiver.hasPendingDatagrams());
#ifdef RELIABLE_BYTES_AVAILABLE
QCOMPARE(receiver.bytesAvailable(), qint64(2));
@@ -1798,7 +1798,7 @@ void tst_QUdpSocket::readyRead()
// no new signal should be emitted because we haven't read the first datagram yet
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(receiver.hasPendingDatagrams());
QVERIFY(receiver.bytesAvailable() >= 1); // most likely is 1, but it could be 1 + 2 in the future
QCOMPARE(receiver.pendingDatagramSize(), qint64(2));
@@ -1810,7 +1810,7 @@ void tst_QUdpSocket::readyRead()
// write a new datagram and ensure the signal is emitted now
sender.writeDatagram("abc", makeNonAny(receiver.localAddress()), port);
QTest::qWait(100);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(receiver.hasPendingDatagrams());
#ifdef RELIABLE_BYTES_AVAILABLE
QCOMPARE(receiver.bytesAvailable(), qint64(3));
@@ -1890,7 +1890,7 @@ void tst_QUdpSocket::asyncReadDatagram()
QTestEventLoop::instance().enterLoop(1);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
delete m_asyncSender;
delete m_asyncReceiver;
diff --git a/tests/auto/network/ssl/CMakeLists.txt b/tests/auto/network/ssl/CMakeLists.txt
index f6d231289d..fdc5609331 100644
--- a/tests/auto/network/ssl/CMakeLists.txt
+++ b/tests/auto/network/ssl/CMakeLists.txt
@@ -1,10 +1,10 @@
# Generated from ssl.pro.
add_subdirectory(qpassworddigestor)
-add_subdirectory(qsslcertificate)
-add_subdirectory(qsslcipher)
-add_subdirectory(qsslellipticcurve)
if(QT_FEATURE_ssl)
+ add_subdirectory(qsslcertificate)
+ add_subdirectory(qsslcipher)
+ add_subdirectory(qsslellipticcurve)
add_subdirectory(qsslkey)
add_subdirectory(qsslerror)
endif()
diff --git a/tests/auto/network/ssl/qdtls/certs/fluke.cert b/tests/auto/network/ssl/qdtls/certs/fluke.cert
index ace4e4f0eb..4cc4d9a5ea 100644
--- a/tests/auto/network/ssl/qdtls/certs/fluke.cert
+++ b/tests/auto/network/ssl/qdtls/certs/fluke.cert
@@ -1,75 +1,34 @@
-Certificate:
- Data:
- Version: 3 (0x2)
- Serial Number: 0 (0x0)
- Signature Algorithm: sha1WithRSAEncryption
- Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
- Validity
- Not Before: Dec 4 01:10:32 2007 GMT
- Not After : Apr 21 01:10:32 2035 GMT
- Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
- Subject Public Key Info:
- Public Key Algorithm: rsaEncryption
- RSA Public Key: (1024 bit)
- Modulus (1024 bit):
- 00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
- 1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
- 21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
- d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
- aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
- 84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
- 02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
- 5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
- 3b:f6:45:f3:27:6a:9b:94:9d
- Exponent: 65537 (0x10001)
- X509v3 extensions:
- X509v3 Basic Constraints:
- CA:FALSE
- Netscape Comment:
- OpenSSL Generated Certificate
- X509v3 Subject Key Identifier:
- 21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
- X509v3 Authority Key Identifier:
- DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
- serial:8E:A8:B4:E8:91:B7:54:2E
-
- Signature Algorithm: sha1WithRSAEncryption
- 6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
- a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
- 53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
- a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
- a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
- 24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
- ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
- c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
- 40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
- 8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
- b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
- 7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
- 31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
- c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
- ec:6a:f2:c3
-----BEGIN CERTIFICATE-----
-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
+MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
+BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
+MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
+DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
+MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
+VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
+eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
+CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
+AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
+VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
+5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
+r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
+ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
+Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
+NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
+PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
+LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
+CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
+PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
+DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
+amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
+q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
+0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
+8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
+uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
+kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
+/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
+jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
+IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
+Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
+r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
+gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qdtls/certs/fluke.key b/tests/auto/network/ssl/qdtls/certs/fluke.key
index 9d1664d609..337ce541a6 100644
--- a/tests/auto/network/ssl/qdtls/certs/fluke.key
+++ b/tests/auto/network/ssl/qdtls/certs/fluke.key
@@ -1,15 +1,52 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
------END RSA PRIVATE KEY-----
+-----BEGIN PRIVATE KEY-----
+MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
+6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
+UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
+LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
+aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
+HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
+p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
+lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
+TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
+Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
+CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
+5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
+iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
+eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
+eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
+AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
+zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
+a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
+2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
+yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
+Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
+CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
+LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
+9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
+UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
+nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
+eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
+C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
+bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
+dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
+irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
+rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
+uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
+uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
+eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
+2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
+SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
+Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
+3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
+dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
+Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
+m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
+rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
+KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
+3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
+7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
+6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
+g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
+-----END PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qocsp/CMakeLists.txt b/tests/auto/network/ssl/qocsp/CMakeLists.txt
index 827c81e9d8..159516f1de 100644
--- a/tests/auto/network/ssl/qocsp/CMakeLists.txt
+++ b/tests/auto/network/ssl/qocsp/CMakeLists.txt
@@ -12,6 +12,12 @@ qt_internal_add_test(tst_qocsp
Qt::NetworkPrivate
)
+qt_internal_extend_target(tst_qocsp CONDITION QT_FEATURE_openssl_linked
+ LIBRARIES
+ WrapOpenSSL::WrapOpenSSL
+)
+
+
## Scopes:
#####################################################################
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.0.9.8 b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.0.9.8
deleted file mode 100644
index 20500b221f..0000000000
--- a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.0.9.8
+++ /dev/null
@@ -1,42 +0,0 @@
-Certificate:
- Data:
- Version: 3 (0x2)
- Serial Number:
- ce:db:31:28:45:c4:05:40
- Signature Algorithm: sha1WithRSAEncryption
- Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
- Validity
- Not Before: Aug 4 09:53:41 2010 GMT
- Not After : Aug 29 09:53:41 2051 GMT
- Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
- Subject Public Key Info:
- Public Key Algorithm: rsaEncryption
- RSA Public Key: (1024 bit)
- Modulus (1024 bit):
- 00:cd:aa:db:6f:d6:34:c9:a7:f1:c0:be:e4:41:18:
- 19:e2:02:c9:22:e6:a7:d5:ba:03:2e:9e:28:7a:f4:
- 5f:1a:77:5f:77:a9:11:3b:8f:7e:f0:2e:c6:9e:eb:
- 3a:d9:12:d7:c1:0c:51:e8:24:52:3f:23:c3:42:0c:
- 11:c6:f2:1c:a1:42:fe:b4:c2:69:83:ad:f7:70:b1:
- 18:15:cc:20:28:62:30:f0:2c:15:e6:33:19:af:c3:
- eb:1c:c0:91:f7:11:68:94:50:f8:49:37:08:32:d7:
- 3e:75:df:a3:bc:69:00:15:de:cd:87:0f:5c:02:6b:
- 82:c8:01:7d:6a:f0:1d:dc:73
- Exponent: 65537 (0x10001)
- X509v3 extensions:
- X509v3 Subject Key Identifier:
- 8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
- X509v3 Authority Key Identifier:
- keyid:8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
-
- X509v3 Basic Constraints:
- CA:TRUE
- Signature Algorithm: sha1WithRSAEncryption
- a1:74:8e:5d:36:96:2c:05:7e:ea:66:cc:2e:68:c7:3d:93:dc:
- 8c:a3:11:ad:b5:7e:6e:d0:04:c4:09:bd:0a:f9:39:3b:97:d7:
- f0:bb:0c:09:7b:83:fe:bf:87:b0:47:e8:94:b7:aa:9c:79:ad:
- 71:9e:b7:c4:99:98:6f:1d:38:32:f8:a3:75:38:c4:e5:e7:37:
- 37:21:ec:7b:50:8b:15:b0:97:1e:17:9c:50:17:3c:c1:df:94:
- 55:fb:60:2e:50:40:d1:ea:23:c6:3c:21:6f:97:8c:06:16:a5:
- 82:72:c1:63:14:64:86:eb:d7:ff:72:f6:09:f5:6d:e6:04:13:
- 7a:6a
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1 b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1
deleted file mode 100644
index 1a7d945b76..0000000000
--- a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1
+++ /dev/null
@@ -1,42 +0,0 @@
-Certificate:
- Data:
- Version: 3 (0x2)
- Serial Number:
- ce:db:31:28:45:c4:05:40
- Signature Algorithm: sha1WithRSAEncryption
- Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
- Validity
- Not Before: Aug 4 09:53:41 2010 GMT
- Not After : Aug 29 09:53:41 2051 GMT
- Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
- Subject Public Key Info:
- Public Key Algorithm: rsaEncryption
- Public-Key: (1024 bit)
- Modulus:
- 00:cd:aa:db:6f:d6:34:c9:a7:f1:c0:be:e4:41:18:
- 19:e2:02:c9:22:e6:a7:d5:ba:03:2e:9e:28:7a:f4:
- 5f:1a:77:5f:77:a9:11:3b:8f:7e:f0:2e:c6:9e:eb:
- 3a:d9:12:d7:c1:0c:51:e8:24:52:3f:23:c3:42:0c:
- 11:c6:f2:1c:a1:42:fe:b4:c2:69:83:ad:f7:70:b1:
- 18:15:cc:20:28:62:30:f0:2c:15:e6:33:19:af:c3:
- eb:1c:c0:91:f7:11:68:94:50:f8:49:37:08:32:d7:
- 3e:75:df:a3:bc:69:00:15:de:cd:87:0f:5c:02:6b:
- 82:c8:01:7d:6a:f0:1d:dc:73
- Exponent: 65537 (0x10001)
- X509v3 extensions:
- X509v3 Subject Key Identifier:
- 8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
- X509v3 Authority Key Identifier:
- keyid:8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
-
- X509v3 Basic Constraints:
- CA:TRUE
- Signature Algorithm: sha1WithRSAEncryption
- a1:74:8e:5d:36:96:2c:05:7e:ea:66:cc:2e:68:c7:3d:93:dc:
- 8c:a3:11:ad:b5:7e:6e:d0:04:c4:09:bd:0a:f9:39:3b:97:d7:
- f0:bb:0c:09:7b:83:fe:bf:87:b0:47:e8:94:b7:aa:9c:79:ad:
- 71:9e:b7:c4:99:98:6f:1d:38:32:f8:a3:75:38:c4:e5:e7:37:
- 37:21:ec:7b:50:8b:15:b0:97:1e:17:9c:50:17:3c:c1:df:94:
- 55:fb:60:2e:50:40:d1:ea:23:c6:3c:21:6f:97:8c:06:16:a5:
- 82:72:c1:63:14:64:86:eb:d7:ff:72:f6:09:f5:6d:e6:04:13:
- 7a:6a
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1c b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1c
deleted file mode 100644
index a45ed864f4..0000000000
--- a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.1c
+++ /dev/null
@@ -1,41 +0,0 @@
-Certificate:
- Data:
- Version: 3 (0x2)
- Serial Number: 14905561440751715648 (0xcedb312845c40540)
- Signature Algorithm: sha1WithRSAEncryption
- Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
- Validity
- Not Before: Aug 4 09:53:41 2010 GMT
- Not After : Aug 29 09:53:41 2051 GMT
- Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
- Subject Public Key Info:
- Public Key Algorithm: rsaEncryption
- Public-Key: (1024 bit)
- Modulus:
- 00:cd:aa:db:6f:d6:34:c9:a7:f1:c0:be:e4:41:18:
- 19:e2:02:c9:22:e6:a7:d5:ba:03:2e:9e:28:7a:f4:
- 5f:1a:77:5f:77:a9:11:3b:8f:7e:f0:2e:c6:9e:eb:
- 3a:d9:12:d7:c1:0c:51:e8:24:52:3f:23:c3:42:0c:
- 11:c6:f2:1c:a1:42:fe:b4:c2:69:83:ad:f7:70:b1:
- 18:15:cc:20:28:62:30:f0:2c:15:e6:33:19:af:c3:
- eb:1c:c0:91:f7:11:68:94:50:f8:49:37:08:32:d7:
- 3e:75:df:a3:bc:69:00:15:de:cd:87:0f:5c:02:6b:
- 82:c8:01:7d:6a:f0:1d:dc:73
- Exponent: 65537 (0x10001)
- X509v3 extensions:
- X509v3 Subject Key Identifier:
- 8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
- X509v3 Authority Key Identifier:
- keyid:8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
-
- X509v3 Basic Constraints:
- CA:TRUE
- Signature Algorithm: sha1WithRSAEncryption
- a1:74:8e:5d:36:96:2c:05:7e:ea:66:cc:2e:68:c7:3d:93:dc:
- 8c:a3:11:ad:b5:7e:6e:d0:04:c4:09:bd:0a:f9:39:3b:97:d7:
- f0:bb:0c:09:7b:83:fe:bf:87:b0:47:e8:94:b7:aa:9c:79:ad:
- 71:9e:b7:c4:99:98:6f:1d:38:32:f8:a3:75:38:c4:e5:e7:37:
- 37:21:ec:7b:50:8b:15:b0:97:1e:17:9c:50:17:3c:c1:df:94:
- 55:fb:60:2e:50:40:d1:ea:23:c6:3c:21:6f:97:8c:06:16:a5:
- 82:72:c1:63:14:64:86:eb:d7:ff:72:f6:09:f5:6d:e6:04:13:
- 7a:6a
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.0 b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.3.0.5
index b2ccb2751e..a2cf759c10 100644
--- a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.0.0
+++ b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.3.0.5
@@ -27,11 +27,11 @@ Certificate:
X509v3 Subject Key Identifier:
8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
X509v3 Authority Key Identifier:
- keyid:8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
-
+ 8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
X509v3 Basic Constraints:
CA:TRUE
Signature Algorithm: sha1WithRSAEncryption
+ Signature Value:
a1:74:8e:5d:36:96:2c:05:7e:ea:66:cc:2e:68:c7:3d:93:dc:
8c:a3:11:ad:b5:7e:6e:d0:04:c4:09:bd:0a:f9:39:3b:97:d7:
f0:bb:0c:09:7b:83:fe:bf:87:b0:47:e8:94:b7:aa:9c:79:ad:
diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
index 6799ed7ca3..3f8361a5c2 100644
--- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
@@ -14,6 +14,7 @@
#include <qscopeguard.h>
#ifndef QT_NO_OPENSSL
+#include <openssl/opensslv.h>
#include <openssl/obj_mac.h>
#endif
@@ -497,7 +498,7 @@ void tst_QSslCertificate::utf8SubjectNames()
static const char *ou = "\xe3\x88\xa7" "A" "\xe3\x89\x81\xef\xbd\xab" "BC";
// the following two tests should help find "\x"-literal encoding bugs in the test itself
- QCOMPARE(cert.subjectInfo("O")[0].length(), QString::fromUtf8(o).length());
+ QCOMPARE(cert.subjectInfo("O")[0].size(), QString::fromUtf8(o).size());
QCOMPARE (cert.subjectInfo("O")[0].toUtf8().toHex(), QByteArray(o).toHex());
QCOMPARE(cert.subjectInfo("O")[0], QString::fromUtf8(o));
@@ -945,8 +946,8 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489
void tst_QSslCertificate::blacklistedCertificates()
{
QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath(testDataDir + "more-certificates/blacklisted*.pem", QSsl::Pem, QSslCertificate::PatternSyntax::Wildcard);
- QVERIFY(blacklistedCerts.count() > 0);
- for (int a = 0; a < blacklistedCerts.count(); a++) {
+ QVERIFY(blacklistedCerts.size() > 0);
+ for (int a = 0; a < blacklistedCerts.size(); a++) {
QVERIFY(blacklistedCerts.at(a).isBlacklisted());
}
}
@@ -969,42 +970,26 @@ void tst_QSslCertificate::toText()
QCOMPARE(certList.size(), 1);
const QSslCertificate &cert = certList.at(0);
- // Openssl's cert dump method changed slightly between 0.9.8, 1.0.0 and 1.01 versions, so we want it to match any output
-
- QFile f098(testDataDir + "more-certificates/cert-large-expiration-date.txt.0.9.8");
- QVERIFY(f098.open(QIODevice::ReadOnly | QFile::Text));
- QByteArray txt098 = f098.readAll();
-
- QFile f100(testDataDir + "more-certificates/cert-large-expiration-date.txt.1.0.0");
- QVERIFY(f100.open(QIODevice::ReadOnly | QFile::Text));
- QByteArray txt100 = f100.readAll();
-
- QFile f101(testDataDir + "more-certificates/cert-large-expiration-date.txt.1.0.1");
- QVERIFY(f101.open(QIODevice::ReadOnly | QFile::Text));
- QByteArray txt101 = f101.readAll();
-
- QFile f101c(testDataDir + "more-certificates/cert-large-expiration-date.txt.1.0.1c");
- QVERIFY(f101c.open(QIODevice::ReadOnly | QFile::Text));
- QByteArray txt101c = f101c.readAll();
-
+ // Openssl's cert dump method changed slightly between 1.1.1 and 3.0.5 versions, so we want it to match any output
QFile f111(testDataDir + "more-certificates/cert-large-expiration-date.txt.1.1.1");
QVERIFY(f111.open(QIODevice::ReadOnly | QFile::Text));
QByteArray txt111 = f111.readAll();
+ QFile f305(testDataDir + "more-certificates/cert-large-expiration-date.txt.3.0.5");
+ QVERIFY(f305.open(QIODevice::ReadOnly | QFile::Text));
+ QByteArray txt305 = f305.readAll();
+
QString txtcert = cert.toText();
- QVERIFY(QString::fromLatin1(txt098) == txtcert ||
- QString::fromLatin1(txt100) == txtcert ||
- QString::fromLatin1(txt101) == txtcert ||
- QString::fromLatin1(txt101c) == txtcert ||
- QString::fromLatin1(txt111) == txtcert );
+ QVERIFY(QString::fromLatin1(txt111) == txtcert ||
+ QString::fromLatin1(txt305) == txtcert);
}
void tst_QSslCertificate::multipleCommonNames()
{
QList<QSslCertificate> certList =
QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-two-cns-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString);
- QVERIFY(certList.count() > 0);
+ QVERIFY(certList.size() > 0);
QStringList commonNames = certList[0].subjectInfo(QSslCertificate::CommonName);
QVERIFY(commonNames.contains(QString("www.example.com")));
@@ -1015,14 +1000,14 @@ void tst_QSslCertificate::subjectAndIssuerAttributes()
{
QList<QSslCertificate> certList =
QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-with-drink-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString);
- QVERIFY(certList.count() > 0);
+ QVERIFY(certList.size() > 0);
QList<QByteArray> attributes = certList[0].subjectInfoAttributes();
QVERIFY(attributes.contains(QByteArray("favouriteDrink")));
attributes.clear();
certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString);
- QVERIFY(certList.count() > 0);
+ QVERIFY(certList.size() > 0);
QByteArray shortName("1.3.6.1.4.1.311.60.2.1.3");
#if !defined(QT_NO_OPENSSL) && defined(SN_jurisdictionCountryName)
@@ -1049,7 +1034,7 @@ void tst_QSslCertificate::verify()
// Empty chain is unspecified error
errors = QSslCertificate::verify(toVerify);
- VERIFY_VERBOSE(errors.count() == 1);
+ VERIFY_VERBOSE(errors.size() == 1);
VERIFY_VERBOSE(errors[0] == QSslError(QSslError::UnspecifiedError));
errors.clear();
@@ -1068,7 +1053,7 @@ void tst_QSslCertificate::verify()
toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString);
errors = QSslCertificate::verify(toVerify);
- VERIFY_VERBOSE(errors.count() == 0);
+ VERIFY_VERBOSE(errors.size() == 0);
errors.clear();
// Test a blacklisted certificate
@@ -1103,11 +1088,11 @@ void tst_QSslCertificate::verify()
toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-is-ca-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first();
toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-ca-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first();
errors = QSslCertificate::verify(toVerify);
- VERIFY_VERBOSE(errors.count() == 0);
+ VERIFY_VERBOSE(errors.size() == 0);
// Recheck the above with hostname validation
errors = QSslCertificate::verify(toVerify, QLatin1String("example.com"));
- VERIFY_VERBOSE(errors.count() == 0);
+ VERIFY_VERBOSE(errors.size() == 0);
// Recheck the above with a bad hostname
errors = QSslCertificate::verify(toVerify, QLatin1String("fail.example.com"));
@@ -1132,11 +1117,11 @@ void tst_QSslCertificate::extensions()
{
QList<QSslCertificate> certList =
QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString);
- QVERIFY(certList.count() > 0);
+ QVERIFY(certList.size() > 0);
QSslCertificate cert = certList[0];
QList<QSslCertificateExtension> extensions = cert.extensions();
- QCOMPARE(extensions.count(), 9);
+ QCOMPARE(extensions.size(), 9);
int unknown_idx = -1;
int authority_info_idx = -1;
@@ -1144,7 +1129,7 @@ void tst_QSslCertificate::extensions()
int subject_key_idx = -1;
int auth_key_idx = -1;
- for (int i=0; i < extensions.length(); ++i) {
+ for (int i=0; i < extensions.size(); ++i) {
QSslCertificateExtension ext = extensions[i];
//qDebug() << i << ":" << ext.name() << ext.oid();
@@ -1230,16 +1215,16 @@ void tst_QSslCertificate::extensionsCritical()
{
QList<QSslCertificate> certList =
QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString);
- QVERIFY(certList.count() > 0);
+ QVERIFY(certList.size() > 0);
QSslCertificate cert = certList[0];
QList<QSslCertificateExtension> extensions = cert.extensions();
- QCOMPARE(extensions.count(), 9);
+ QCOMPARE(extensions.size(), 9);
int basic_constraints_idx = -1;
int key_usage_idx = -1;
- for (int i=0; i < extensions.length(); ++i) {
+ for (int i=0; i < extensions.size(); ++i) {
QSslCertificateExtension ext = extensions[i];
if (ext.name() == QStringLiteral("basicConstraints"))
@@ -1377,6 +1362,10 @@ void tst_QSslCertificate::pkcs12()
return;
}
+#if !defined(QT_NO_OPENSSL) && OPENSSL_VERSION_MAJOR >= 3
+ QSKIP("leaf.p12 is using RC2, which is disabled by default in OpenSSL v >= 3");
+#endif
+
QFile f(testDataDir + QLatin1String("pkcs12/leaf.p12"));
bool ok = f.open(QIODevice::ReadOnly);
QVERIFY(ok);
diff --git a/tests/auto/network/ssl/qsslkey/CMakeLists.txt b/tests/auto/network/ssl/qsslkey/CMakeLists.txt
index 8bf450f8fd..32a12eb34b 100644
--- a/tests/auto/network/ssl/qsslkey/CMakeLists.txt
+++ b/tests/auto/network/ssl/qsslkey/CMakeLists.txt
@@ -22,6 +22,11 @@ qt_internal_add_test(tst_qsslkey
TESTDATA ${test_data}
)
+qt_internal_extend_target(tst_qsslkey CONDITION QT_FEATURE_private_tests AND QT_FEATURE_openssl_linked
+ LIBRARIES
+ WrapOpenSSL::WrapOpenSSL
+)
+
## Scopes:
#####################################################################
diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
index ac42704b30..12f29bf107 100644
--- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
+++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
@@ -156,6 +156,7 @@ bool tst_QSslKey::fileContainsUnsupportedEllipticCurve(const QString &fileName)
bool tst_QSslKey::algorithmsSupported(const QString &fileName) const
{
+#if QT_CONFIG(ssl)
if (isSchannel && fileName.contains("RC2-64")) // Schannel treats RC2 as 128 bit
return false;
@@ -164,10 +165,9 @@ bool tst_QSslKey::algorithmsSupported(const QString &fileName) const
return !(fileName.contains(QRegularExpression("-aes\\d\\d\\d-")) || fileName.contains("pkcs8-pkcs12"));
}
-#if OPENSSL_VERSION_MAJOR < 3
- // If it's not built with OpenSSL or it's OpenSSL v < 3.
- return true;
-#else
+ if (!isOpenSsl || QSslSocket::sslLibraryVersionNumber() >> 28 < 3)
+ return true;
+
// OpenSSL v3 first introduced the notion of 'providers'. Many algorithms
// were moved into the 'legacy' provider. While they are still supported in theory,
// the 'legacy' provider is NOT loaded by default and we are not loading it either.
@@ -178,7 +178,10 @@ bool tst_QSslKey::algorithmsSupported(const QString &fileName) const
return false;
return !name.contains("-rc2-") && !name.contains("-rc4-");
-#endif
+#else
+ Q_UNUSED(fileName);
+ return false;
+#endif // QT_CONFIG(ssl)
}
@@ -312,7 +315,7 @@ void tst_QSslKey::constructorHandle()
passphrase = "1234";
BIO* bio = q_BIO_new(q_BIO_s_mem());
- q_BIO_write(bio, pem.constData(), pem.length());
+ q_BIO_write(bio, pem.constData(), pem.size());
EVP_PKEY *origin = func(bio, nullptr, nullptr, static_cast<void *>(passphrase.data()));
Q_ASSERT(origin);
q_EVP_PKEY_up_ref(origin);
@@ -545,12 +548,12 @@ void tst_QSslKey::passphraseChecks_data()
const QByteArray pass("123");
const QByteArray aesPass("1234");
-#if OPENSSL_VERSION_MAJOR < 3
- // DES and RC2 are not provided by default in OpenSSL v3.
- // This part is for either non-OpenSSL build, or OpenSSL v < 3.x.
- QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass;
- QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass;
-#endif // OPENSSL_VERSION_MAJOR
+ if (!isOpenSsl || QSslSocket::sslLibraryVersionNumber() >> 28 < 3) {
+ // DES and RC2 are not provided by default in OpenSSL v3.
+ // This part is for either non-OpenSSL build, or OpenSSL v < 3.x.
+ QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass;
+ QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass;
+ }
QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem") << pass;
diff --git a/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp b/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp
index b13114cb47..13a3201345 100644
--- a/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp
+++ b/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp
@@ -23,6 +23,9 @@ private slots:
void testHandshakeInterruptedOnError();
void testPreSharedKeyAuthenticationRequired();
#endif
+ void plaintextClient();
+ void quietClient();
+ void twoGoodAndManyBadClients();
private:
QString testDataDir;
@@ -139,15 +142,15 @@ void tst_QSslServer::testOneSuccessfulConnection()
QVERIFY(server.startedEncryptionHandshakeSpy.isValid());
// Check that no connections has occurred
- QCOMPARE(server.sslErrorsSpy.count(), 0);
- QCOMPARE(server.peerVerifyErrorSpy.count(), 0);
- QCOMPARE(server.errorOccurredSpy.count(), 0);
- QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0);
- QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0);
- QCOMPARE(server.alertSentSpy.count(), 0);
- QCOMPARE(server.alertReceivedSpy.count(), 0);
- QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0);
- QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 0);
+ QCOMPARE(server.sslErrorsSpy.size(), 0);
+ QCOMPARE(server.peerVerifyErrorSpy.size(), 0);
+ QCOMPARE(server.errorOccurredSpy.size(), 0);
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0);
+ QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0);
+ QCOMPARE(server.alertSentSpy.size(), 0);
+ QCOMPARE(server.alertReceivedSpy.size(), 0);
+ QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0);
+ QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 0);
// Connect client
QSslSocket client;
@@ -184,15 +187,15 @@ void tst_QSslServer::testOneSuccessfulConnection()
loop.exec();
// Check that one encrypted connection has occurred without error
- QCOMPARE(server.sslErrorsSpy.count(), 0);
- QCOMPARE(server.peerVerifyErrorSpy.count(), 0);
- QCOMPARE(server.errorOccurredSpy.count(), 0);
- QCOMPARE(server.pendingConnectionAvailableSpy.count(), 1);
- QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0);
- QCOMPARE(server.alertSentSpy.count(), 0);
- QCOMPARE(server.alertReceivedSpy.count(), 0);
- QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0);
- QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1);
+ QCOMPARE(server.sslErrorsSpy.size(), 0);
+ QCOMPARE(server.peerVerifyErrorSpy.size(), 0);
+ QCOMPARE(server.errorOccurredSpy.size(), 0);
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 1);
+ QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0);
+ QCOMPARE(server.alertSentSpy.size(), 0);
+ QCOMPARE(server.alertReceivedSpy.size(), 0);
+ QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0);
+ QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1);
// Check client socket
QVERIFY(client.isEncrypted());
@@ -221,16 +224,16 @@ void tst_QSslServer::testSelfSignedCertificateRejectedByServer()
loop.exec();
// Check that one encrypted connection has failed
- QCOMPARE(server.sslErrorsSpy.count(), 1);
- QCOMPARE(server.peerVerifyErrorSpy.count(), 1);
- QCOMPARE(server.errorOccurredSpy.count(), 1);
- QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0);
- QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0);
- QCOMPARE(server.alertSentSpy.count(),
+ QCOMPARE(server.sslErrorsSpy.size(), 1);
+ QCOMPARE(server.peerVerifyErrorSpy.size(), 1);
+ QCOMPARE(server.errorOccurredSpy.size(), 1);
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0);
+ QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0);
+ QCOMPARE(server.alertSentSpy.size(),
isTestingOpenSsl ? 1 : 0); // OpenSSL only signal
- QCOMPARE(server.alertReceivedSpy.count(), 0);
- QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0);
- QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1);
+ QCOMPARE(server.alertReceivedSpy.size(), 0);
+ QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0);
+ QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1);
// Type of certificate error to expect
const auto certificateError =
@@ -238,13 +241,13 @@ void tst_QSslServer::testSelfSignedCertificateRejectedByServer()
// Check the sslErrorsSpy
const auto sslErrorsSpyErrors =
- qvariant_cast<QList<QSslError>>(qAsConst(server.sslErrorsSpy).first()[1]);
+ qvariant_cast<QList<QSslError>>(std::as_const(server.sslErrorsSpy).first()[1]);
QCOMPARE(sslErrorsSpyErrors.size(), 1);
QCOMPARE(sslErrorsSpyErrors.first().error(), certificateError);
// Check the peerVerifyErrorSpy
const auto peerVerifyErrorSpyError =
- qvariant_cast<QSslError>(qAsConst(server.peerVerifyErrorSpy).first()[1]);
+ qvariant_cast<QSslError>(std::as_const(server.peerVerifyErrorSpy).first()[1]);
QCOMPARE(peerVerifyErrorSpyError.error(), certificateError);
// Check client socket
@@ -287,32 +290,32 @@ void tst_QSslServer::testSelfSignedCertificateRejectedByClient()
QTcpSocket *connection = server.server.nextPendingConnection();
if (connection == nullptr) {
// Client disconnected before connection accepted by server
- QCOMPARE(server.sslErrorsSpy.count(), 0);
- QCOMPARE(server.peerVerifyErrorSpy.count(), 0);
- QCOMPARE(server.errorOccurredSpy.count(), 1); // Client rejected first
- QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0);
- QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0);
- QCOMPARE(server.alertSentSpy.count(), 0);
- QCOMPARE(server.alertReceivedSpy.count(),
+ QCOMPARE(server.sslErrorsSpy.size(), 0);
+ QCOMPARE(server.peerVerifyErrorSpy.size(), 0);
+ QCOMPARE(server.errorOccurredSpy.size(), 1); // Client rejected first
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0);
+ QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0);
+ QCOMPARE(server.alertSentSpy.size(), 0);
+ QCOMPARE(server.alertReceivedSpy.size(),
isTestingOpenSsl ? 1 : 0); // OpenSSL only signal
- QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0);
- QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1);
+ QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0);
+ QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1);
const auto errrOccuredSpyError = qvariant_cast<QAbstractSocket::SocketError>(
- qAsConst(server.errorOccurredSpy).first()[1]);
+ std::as_const(server.errorOccurredSpy).first()[1]);
QCOMPARE(errrOccuredSpyError, socketError);
} else {
// Client disconnected after connection accepted by server
- QCOMPARE(server.sslErrorsSpy.count(), 0);
- QCOMPARE(server.peerVerifyErrorSpy.count(), 0);
- QCOMPARE(server.errorOccurredSpy.count(), 0); // Server accepted first
- QCOMPARE(server.pendingConnectionAvailableSpy.count(), 1);
- QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0);
- QCOMPARE(server.alertSentSpy.count(), 0);
- QCOMPARE(server.alertReceivedSpy.count(),
+ QCOMPARE(server.sslErrorsSpy.size(), 0);
+ QCOMPARE(server.peerVerifyErrorSpy.size(), 0);
+ QCOMPARE(server.errorOccurredSpy.size(), 0); // Server accepted first
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 1);
+ QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0);
+ QCOMPARE(server.alertSentSpy.size(), 0);
+ QCOMPARE(server.alertReceivedSpy.size(),
isTestingOpenSsl ? 1 : 0); // OpenSSL only signal
- QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0);
- QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1);
+ QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0);
+ QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1);
QCOMPARE(connection->state(), QAbstractSocket::UnconnectedState);
QCOMPARE(connection->error(), socketError);
@@ -322,12 +325,12 @@ void tst_QSslServer::testSelfSignedCertificateRejectedByClient()
}
// Check that client has rejected server
- QCOMPARE(clientConnectedSpy.count(), 1);
- QCOMPARE(clientHostFoundSpy.count(), 1);
- QCOMPARE(clientDisconnectedSpy.count(), 1);
- QCOMPARE(clientConnectionEncryptedSpy.count(), 0);
- QCOMPARE(clientSslErrorsSpy.count(), isTestingOpenSsl ? 0 : 1);
- QCOMPARE(clientErrorOccurredSpy.count(), 1);
+ QCOMPARE(clientConnectedSpy.size(), 1);
+ QCOMPARE(clientHostFoundSpy.size(), 1);
+ QCOMPARE(clientDisconnectedSpy.size(), 1);
+ QCOMPARE(clientConnectionEncryptedSpy.size(), 0);
+ QCOMPARE(clientSslErrorsSpy.size(), isTestingOpenSsl ? 0 : 1);
+ QCOMPARE(clientErrorOccurredSpy.size(), 1);
// Check client socket
QVERIFY(!client.isEncrypted());
@@ -361,15 +364,15 @@ void tst_QSslServer::testHandshakeInterruptedOnError()
loop.exec();
// Check that client certificate causes handshake interrupted signal to be emitted
- QCOMPARE(server.sslErrorsSpy.count(), 0);
- QCOMPARE(server.peerVerifyErrorSpy.count(), 0);
- QCOMPARE(server.errorOccurredSpy.count(), 1);
- QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0);
- QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0);
- QCOMPARE(server.alertSentSpy.count(), 1);
- QCOMPARE(server.alertReceivedSpy.count(), 0);
- QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 1);
- QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1);
+ QCOMPARE(server.sslErrorsSpy.size(), 0);
+ QCOMPARE(server.peerVerifyErrorSpy.size(), 0);
+ QCOMPARE(server.errorOccurredSpy.size(), 1);
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0);
+ QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0);
+ QCOMPARE(server.alertSentSpy.size(), 1);
+ QCOMPARE(server.alertReceivedSpy.size(), 0);
+ QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 1);
+ QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1);
}
void tst_QSslServer::testPreSharedKeyAuthenticationRequired()
@@ -419,15 +422,15 @@ void tst_QSslServer::testPreSharedKeyAuthenticationRequired()
loop.exec();
// Check that server is connected
- QCOMPARE(server.sslErrorsSpy.count(), 1);
- QCOMPARE(server.peerVerifyErrorSpy.count(), 1);
- QCOMPARE(server.errorOccurredSpy.count(), 0);
- QCOMPARE(server.pendingConnectionAvailableSpy.count(), 1);
- QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 1);
- QCOMPARE(server.alertSentSpy.count(), 0);
- QCOMPARE(server.alertReceivedSpy.count(), 0);
- QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0);
- QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1);
+ QCOMPARE(server.sslErrorsSpy.size(), 1);
+ QCOMPARE(server.peerVerifyErrorSpy.size(), 1);
+ QCOMPARE(server.errorOccurredSpy.size(), 0);
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 1);
+ QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 1);
+ QCOMPARE(server.alertSentSpy.size(), 0);
+ QCOMPARE(server.alertReceivedSpy.size(), 0);
+ QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0);
+ QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1);
// Check client socket
QVERIFY(client.isEncrypted());
@@ -436,6 +439,93 @@ void tst_QSslServer::testPreSharedKeyAuthenticationRequired()
#endif
+void tst_QSslServer::plaintextClient()
+{
+ QSslConfiguration serverConfiguration = selfSignedServerQSslConfiguration();
+ SslServerSpy server(serverConfiguration);
+ QVERIFY(server.server.listen());
+
+ QTcpSocket socket;
+ QSignalSpy socketDisconnectedSpy(&socket, &QTcpSocket::disconnected);
+ socket.connectToHost(QHostAddress::LocalHost, server.server.serverPort());
+ QVERIFY(socket.waitForConnected());
+ QTest::qWait(100);
+ // No disconnect from short break...:
+ QCOMPARE(socket.state(), QAbstractSocket::SocketState::ConnectedState);
+
+ // ... but we write some plaintext data...:
+ socket.write("Hello World!");
+ socket.waitForBytesWritten();
+ // ... and quickly get disconnected:
+ QTRY_COMPARE_GT(socketDisconnectedSpy.size(), 0);
+ QCOMPARE(socket.state(), QAbstractSocket::SocketState::UnconnectedState);
+}
+
+void tst_QSslServer::quietClient()
+{
+ QSslConfiguration serverConfiguration = selfSignedServerQSslConfiguration();
+ SslServerSpy server(serverConfiguration);
+ server.server.setHandshakeTimeout(1'000);
+ QVERIFY(server.server.listen());
+
+ quint16 serverPeerPort = 0;
+ auto grabServerPeerPort = [&serverPeerPort](QSslSocket *socket) {
+ serverPeerPort = socket->peerPort();
+ };
+ QObject::connect(&server.server, &QSslServer::errorOccurred, &server.server,
+ grabServerPeerPort);
+
+ QTcpSocket socket;
+ QSignalSpy socketDisconnectedSpy(&socket, &QTcpSocket::disconnected);
+ socket.connectToHost(QHostAddress::LocalHost, server.server.serverPort());
+ quint16 clientLocalPort = socket.localPort();
+ QVERIFY(socket.waitForConnected());
+ // Disconnects after overlong break:
+ QVERIFY(socketDisconnectedSpy.wait(5'000));
+ QCOMPARE(socket.state(), QAbstractSocket::SocketState::UnconnectedState);
+
+ QCOMPARE_GT(server.errorOccurredSpy.size(), 0);
+ QCOMPARE(serverPeerPort, clientLocalPort);
+}
+
+void tst_QSslServer::twoGoodAndManyBadClients()
+{
+ QSslConfiguration serverConfiguration = selfSignedServerQSslConfiguration();
+ SslServerSpy server(serverConfiguration);
+ server.server.setHandshakeTimeout(750);
+ constexpr qsizetype ExpectedConnections = 5;
+ server.server.setMaxPendingConnections(ExpectedConnections);
+ QVERIFY(server.server.listen());
+
+ auto connectGoodClient = [&server](QSslSocket *socket) {
+ QObject::connect(socket, &QSslSocket::sslErrors, socket,
+ qOverload<const QList<QSslError> &>(&QSslSocket::ignoreSslErrors));
+ socket->connectToHostEncrypted("127.0.0.1", server.server.serverPort());
+ };
+ // Connect one socket encrypted so we have a socket in the regular queue
+ QSslSocket tlsSocket;
+ connectGoodClient(&tlsSocket);
+
+ // Then we connect a bunch of TCP sockets who will not send any data at all
+ std::array<QTcpSocket, size_t(ExpectedConnections) * 2> sockets;
+ for (QTcpSocket &socket : sockets)
+ socket.connectToHost(QHostAddress::LocalHost, server.server.serverPort());
+ QTest::qWait(500); // some leeway to let connections try to connect...
+
+ // I happen to know the sockets are all children of the server, so let's see
+ // how many are created:
+ qsizetype connectedCount = server.server.findChildren<QSslSocket *>().size();
+ QCOMPARE(connectedCount, ExpectedConnections);
+ // 1 socket is ready and pending
+ QCOMPARE(server.pendingConnectionAvailableSpy.size(), 1);
+
+ // Connect another client to make sure that the server is accepting connections again even after
+ // all the bad actors tried to connect:
+ QSslSocket goodClient;
+ connectGoodClient(&goodClient);
+ QTRY_COMPARE(server.pendingConnectionAvailableSpy.size(), 2);
+}
+
QTEST_MAIN(tst_QSslServer)
#include "tst_qsslserver.moc"
diff --git a/tests/auto/network/ssl/qsslsocket/CMakeLists.txt b/tests/auto/network/ssl/qsslsocket/CMakeLists.txt
index 0e6bf353ee..80732a6109 100644
--- a/tests/auto/network/ssl/qsslsocket/CMakeLists.txt
+++ b/tests/auto/network/ssl/qsslsocket/CMakeLists.txt
@@ -17,10 +17,16 @@ qt_internal_add_test(tst_qsslsocket
PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::NetworkPrivate
+ Qt::TestPrivate
TESTDATA ${test_data}
QT_TEST_SERVER_LIST "squid" "danted" "cyrus" "apache2" "echo" # special case
)
+qt_internal_extend_target(tst_qsslsocket CONDITION QT_FEATURE_private_tests AND QT_FEATURE_openssl_linked
+ LIBRARIES
+ WrapOpenSSL::WrapOpenSSL
+)
+
#### Keys ignored in scope 1:.:.:qsslsocket.pro:<TRUE>:
# _REQUIREMENTS = "qtConfig(private_tests)"
diff --git a/tests/auto/network/ssl/qsslsocket/certs/ca-generate.sh b/tests/auto/network/ssl/qsslsocket/certs/ca-generate.sh
new file mode 100644
index 0000000000..10aea0905e
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket/certs/ca-generate.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright (C) 2016 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+# generate ca.crt
+openssl genrsa -out ca.key 8192
+openssl req -x509 -new -sha512 -nodes -key ca.key -days 10000 -out ca.crt -config ca.conf
+
+# generate inter.crt
+openssl genrsa -out inter.key 8192
+openssl req -new -sha512 -nodes -key inter.key -out inter.csr -config inter.conf
+openssl x509 -req -sha512 -days 45 -in inter.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out inter.crt
+rm inter.csr
+rm ca.srl
+
+# generate leaf.crt
+openssl genrsa -out leaf.key 8192
+openssl req -new -sha512 -nodes -key leaf.key -out leaf.csr -config leaf.conf
+openssl x509 -req -sha512 -days 45 -in leaf.csr -CA inter.crt -CAkey inter.key -CAcreateserial -out leaf.crt
+rm leaf.csr
+rm inter.srl
diff --git a/tests/auto/network/ssl/qsslsocket/certs/ca.conf b/tests/auto/network/ssl/qsslsocket/certs/ca.conf
new file mode 100644
index 0000000000..1f94247a2f
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket/certs/ca.conf
@@ -0,0 +1,10 @@
+basicConstraints = CA:TRUE
+keyUsage = cRLSign, keyCertSign
+[req]
+distinguished_name = network-tests.qt-project.org
+prompt = no
+[network-tests.qt-project.org]
+C = NO
+ST = Oslo
+L = Oslo
+CN = Fake Qt Project Certificate Authority
diff --git a/tests/auto/network/ssl/qsslsocket/certs/ca.crt b/tests/auto/network/ssl/qsslsocket/certs/ca.crt
index 5cbe8ef726..8e6c6e255c 100644
--- a/tests/auto/network/ssl/qsslsocket/certs/ca.crt
+++ b/tests/auto/network/ssl/qsslsocket/certs/ca.crt
@@ -1,22 +1,52 @@
-----BEGIN CERTIFICATE-----
-MIIDpTCCAl2gAwIBAgIQAKraD9BoqaSa75qOqcP7ZTANBgkqhkiG9w0BAQUFADA8
-MQswCQYDVQQGEwJHQjEZMBcGA1UEChMQV2VzdHBvaW50IENBIEtleTESMBAGA1UE
-ChMJV2VzdHBvaW50MB4XDTEzMDIxNjE2NTMwOFoXDTIzMDIxNjE2NTMwOFowPDEL
-MAkGA1UEBhMCR0IxGTAXBgNVBAoTEFdlc3Rwb2ludCBDQSBLZXkxEjAQBgNVBAoT
-CVdlc3Rwb2ludDCCAVIwDQYJKoZIhvcNAQEBBQADggE/ADCCAToCggExAJv0H92j
-WjDB9h1DmSQzt772IPSirpE82sN9ls5J19TJcPnw49LdUUqkELJkpS1ty2hYPdUw
-7q3n00D+nzS+rt1QIDSKwDVoqeIyFZw4h0ULbASErfy51xBjVIr6NNoiqazp59wQ
-RDvqps7of+b/NcbOh73MsiYi8T5OoI4Quv9rMBefQTAI3d2NRQ4GUzS6Hzh2INOc
-4twApTDYY+yrU8IalXttIOVdKJZTHeTCdIXD3HMfHCkzyELz8rCI1/wDEp8zyoqF
-/tpBStZ5LUSrlRRM7PegqcnM+aojXyrEiXBvPuqO7tabU3nsfix9+8+7GDweDXsP
-OUHv+ahGNTUya7hBDaQmVk3/5hbig9kQlNiOcvcdnYYyJqiXhvjPPzOBbRaFNvBT
-uG/ehHNHYsdhEBkCAwEAAaNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNVHQ8BAf8E
-BQMDBwYAMB0GA1UdDgQWBBSUJzi1uYQUxqb3Nr33LOLCaUUTyTANBgkqhkiG9w0B
-AQUFAAOCATEAPeGh2GiIhT3cii3DU8ihd5TmnEstuHKz2FwHDChmen0zxE8lf08/
-onL1yIeaxbDA8KwZnv71/zZHJv02sPtIMUfuXQc0wOIFjDf0ngc6xIBuU7FUpLxF
-2dK7g9OsiNeC7L/ZemRXgpJURdNF2Ujge9/H9yfpHFBXZztmaWir+TXc5g3PKIu6
-97t75Og+stPhTcSlph8ZHYep08b2uthCfcnuIRGeDW9LkfR8VugnuUf7GoIlqSTs
-SR6bNuyTnnCHQMJzbsQ472+ag3aZS5HzoR8wyGiPmpc43lQM5ZEDrWGu8bub2gKa
-/+KeqHd0wnl7Y5cxnmAptQjxvzBXX/pl4sWczesiGcYm5z5mabp4CY09Y8JtrJZT
-IJodXy9ykRmEurgtRoRVc1aSp+xfV725bQ==
+MIIJPzCCBScCFEE7H06QrHfL4z31/1+EDVDhQUAeMA0GCSqGSIb3DQEBDQUAMFsx
+CzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMS4wLAYD
+VQQDDCVGYWtlIFF0IFByb2plY3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MCAXDTIy
+MDkwMjE1MDIyMFoYDzIwNTAwMTE4MTUwMjIwWjBbMQswCQYDVQQGEwJOTzENMAsG
+A1UECAwET3NsbzENMAsGA1UEBwwET3NsbzEuMCwGA1UEAwwlRmFrZSBRdCBQcm9q
+ZWN0IENlcnRpZmljYXRlIEF1dGhvcml0eTCCBCIwDQYJKoZIhvcNAQEBBQADggQP
+ADCCBAoCggQBAOMlzl5JB31G5CmRRKltbua0LtM0U7mh/yeK7jNaRAY5VKmmh4mg
+N/Ib7Rn4jCY5ccGaOdxtHdPE6WN4v4GZJ23dr+AofJnZHj+wiYjE+KKpoiuPDqhP
+F231zg16WGlc2HWbpX93InnxnO7KRwHumn0Xxn50BfKgyvmdDQBtAkYU868GWwqR
+cy+K4c+tB46XGS1URv/PDYy15IbcOwpDUSpXQBrHZHyje2iwZR6AKESGZRkSttyY
+oSJAmfIhDST41g+9uV9zA9u1XAVYb3kAstSU1nWEYZ7oBQEhh6LIR34YjCE/ThQy
+djWlc9afnFxA8r+q/mjAOTsH/Pml6Z/DQKW9Bfjw9ne0Oeiz+Z1J8Goj/YzGsKeI
+u2XPU8bbjxv32IkhZmH/g22a9Jl41nAYGmAzP7yfOCSRTDTn5JybInxaEdrPrgS2
+A66+NiFWIu/QKnBrKwVlINOdi0z533Aejmc3ybtyJeHPeG0deNbfJbEavfq4yb4P
+DlWpWA4yMbZCqazP/Yku9DkJoT8kAKOaGK2Swjt3NvnT4LaKIPXLCwz/HUjWcppx
+54acMDOUz2ch/yIXx/m/jnl1hMHnv2KPoxgQYeRs0iX4lwd79zaRydMmLYceY64H
+Ek4b+vSsuEnOTThx9jv358aFI7f9fL0Qbqknf9EUo5X4OTCFIkdtLEYsU5+uzmqC
+LgB6musrIaMgNLef7VbKPgtqZDEvWbm0tqdh5dk/wpyFimc8x9V9MSBNAqGE/dm4
+KCtRGBiyQ1KRB+RRqAKMHaR8dFBuHtDvSq20logNTab6eTE79zNMyo0W61GrriQt
+94a0ahTSKaySXRgTKhElAp3n5v5YDTO1DEYtMy0hI/wx1d2bkJsO8gSr+aBzVZUc
+QsWFK3qgmDfC9ZF5CsvLEPy7I5pf2TcaQjTrr4XcTPSHEyN2WI7bj9sU6+tkLi/Y
+OI3z0NsXOZM2OJPZ523TJbnhCRX9wEvh+sts5cbMgAbZVYWHImjmkdnssAChhrCh
+DPaq20KVma00ZvbbfICG/1QiSY9FVX/AVID8yDc49ZfLiLWTLoEFoYH0lqGj0817
+4LwWswNlH86EeY1KPxmNPCF0bzj39hnYN1kd5qTxg5hwPTZehw5JR6w1eQ0VamV1
+Al1u8XqBkrk48iWeOBQr0u6HiNNElCjH+j/hC8Ms4Ykmh8iaJhlpwKt6pGoROX6l
++T98AvrzFUmh+NJu+bGWATBrGmaSjW8AUYwVSbHDL2jk41uVGQdgFTCHwhh6/OV8
+VuladbVA5aA33Jky6SKUNeUh+WcVuwMa1Y/ZKX8Klo7p8ZmxCeAOmcd8fbTfQVu5
+fqu1Oz4Ai6cMQmPpOi9tMzr86ig9NlZPxA8CAwEAATANBgkqhkiG9w0BAQ0FAAOC
+BAEAsYfgbpxN2SzVk8FWs+fHnMkMVX4KUPSKHCea6YoaPJN3glH0Y8I7uYpbwmWf
+AqaXmZhY4YFGG77uao533hS7gapnkuoH+e4LZ0G1QrlCDhl69iNgL/HG/yq1eCDu
+M3Oc8ujpkFoGkDQUVqVSqFvSOGm/KKVazQDF9VhUrlmfHapMYlrSZssbibzfjoKp
+DKMQHYN5OiX6WZ7PVCvGn53ufO1dtENbBRHCD/ck7dMM/bzANXDd+Yw2rHAuXnRX
+Lyp7XoqD/coB+Nn23mKtn+HLOYp1MkaONO/JruFV+HYd9kP+yoICTOWDU6Nx/Knz
+0pnGktQwySha6cDKB8V/rLLrnyZGRLbmajtlGQNnYeeJdQFjFP8dnCjHS78KxURe
+zqKAcO79hzZNqcsGxHVfS49+j8NOvUzKfj6Rda4x1Yb7Cnm0VAs1lo+rtQbRdB2z
+KVNVed7ns4eO2jM/UYRse66RHsIY4+45fQH4OwshJNU2Rn8nDUikrCo7G2MDeTq3
+4M0y0W8tr4NbnTGNVQLnY+HX5AWoB12E++rfv7CACKDxvJ519Ai/uxZSLWcmPM05
+g/JDKi6Rn1EbAZlru+9GV19QAq60elaLMDUVGZ4EYhjunF2syewqCkeyXWC3zMDL
+pNdq8t0IM5Q9x1Vfj9XAecO5QftS54K5RAxiMTPBwYSWA3yduEPfSQSRYovVarLd
+gsOWWSNwJ16wxEibCgueo6njB+9yfbFTtYLTpQKDVAgV7IBiATW6LcR2WgF4g9zq
+vduJYu5uQFSC0g9/2uZ7wqihEVdNEecOHz/uidpK8K4vlJ5oPKUo/YS4ok5rOPFd
+BocpE8stbr6seRmkQcjrjqjLkzdi/lag2giuWglgjyL18MG6lBKFD9I/0iade3J+
+H7GaWZkLhsng2vG9ix+fQkq68yZwq8sx91nE1RJPeLaNkgX9oUtSg6e7I5ks6lS5
+UxBPouki7wH/kHY/xG+YVhm499s9KRdv7ZUGB/OhwdiBJW1DduPBIklMA8YHnWGG
+2om0dCno+K/g88JzEI29Ob3AwIbtMI5vbWI8hWAfHEH0zEyfl9rB6/TcsHY8hjqj
+cSCFT2rdno/S8gbBTuTLK8RhgmXKpZxVmLMz1rSRpMby5HAJ4Sh11bYzu4x1SuUo
+HHiypXjIjBvwnX5/so2q4mw2TNZR0QQ9dQ8bcG74h6cJxSv2pXQTwQRP5PkMpmOF
+JIgv+Pa0UOG+ejcKc94PhLAZmpxwdjlyfdCHT+RW6znqsCDHVvace/gHUY0bkUaD
+rQSwaeiNTc5l7MP8Xb1k6DwsEnuaAGTua/fX41Qk/XE3acUz0kmr2As/IlABqyJ6
+i+VYGJPNrI6E/LMy1lq/iCVQJQ==
-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qsslsocket/certs/ca.key b/tests/auto/network/ssl/qsslsocket/certs/ca.key
new file mode 100644
index 0000000000..eb2c48dbac
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket/certs/ca.key
@@ -0,0 +1,99 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIISKgIBAAKCBAEA4yXOXkkHfUbkKZFEqW1u5rQu0zRTuaH/J4ruM1pEBjlUqaaH
+iaA38hvtGfiMJjlxwZo53G0d08TpY3i/gZknbd2v4Ch8mdkeP7CJiMT4oqmiK48O
+qE8XbfXODXpYaVzYdZulf3ciefGc7spHAe6afRfGfnQF8qDK+Z0NAG0CRhTzrwZb
+CpFzL4rhz60HjpcZLVRG/88NjLXkhtw7CkNRKldAGsdkfKN7aLBlHoAoRIZlGRK2
+3JihIkCZ8iENJPjWD725X3MD27VcBVhveQCy1JTWdYRhnugFASGHoshHfhiMIT9O
+FDJ2NaVz1p+cXEDyv6r+aMA5Owf8+aXpn8NApb0F+PD2d7Q56LP5nUnwaiP9jMaw
+p4i7Zc9TxtuPG/fYiSFmYf+DbZr0mXjWcBgaYDM/vJ84JJFMNOfknJsifFoR2s+u
+BLYDrr42IVYi79AqcGsrBWUg052LTPnfcB6OZzfJu3Il4c94bR141t8lsRq9+rjJ
+vg8OValYDjIxtkKprM/9iS70OQmhPyQAo5oYrZLCO3c2+dPgtoog9csLDP8dSNZy
+mnHnhpwwM5TPZyH/IhfH+b+OeXWEwee/Yo+jGBBh5GzSJfiXB3v3NpHJ0yYthx5j
+rgcSThv69Ky4Sc5NOHH2O/fnxoUjt/18vRBuqSd/0RSjlfg5MIUiR20sRixTn67O
+aoIuAHqa6yshoyA0t5/tVso+C2pkMS9ZubS2p2Hl2T/CnIWKZzzH1X0xIE0CoYT9
+2bgoK1EYGLJDUpEH5FGoAowdpHx0UG4e0O9KrbSWiA1Npvp5MTv3M0zKjRbrUauu
+JC33hrRqFNIprJJdGBMqESUCnefm/lgNM7UMRi0zLSEj/DHV3ZuQmw7yBKv5oHNV
+lRxCxYUreqCYN8L1kXkKy8sQ/Lsjml/ZNxpCNOuvhdxM9IcTI3ZYjtuP2xTr62Qu
+L9g4jfPQ2xc5kzY4k9nnbdMlueEJFf3AS+H6y2zlxsyABtlVhYciaOaR2eywAKGG
+sKEM9qrbQpWZrTRm9tt8gIb/VCJJj0VVf8BUgPzINzj1l8uItZMugQWhgfSWoaPT
+zXvgvBazA2UfzoR5jUo/GY08IXRvOPf2Gdg3WR3mpPGDmHA9Nl6HDklHrDV5DRVq
+ZXUCXW7xeoGSuTjyJZ44FCvS7oeI00SUKMf6P+ELwyzhiSaHyJomGWnAq3qkahE5
+fqX5P3wC+vMVSaH40m75sZYBMGsaZpKNbwBRjBVJscMvaOTjW5UZB2AVMIfCGHr8
+5XxW6Vp1tUDloDfcmTLpIpQ15SH5ZxW7AxrVj9kpfwqWjunxmbEJ4A6Zx3x9tN9B
+W7l+q7U7PgCLpwxCY+k6L20zOvzqKD02Vk/EDwIDAQABAoIEAQDUCUGYIAHevuNT
+rihzJBVnRIGFZI5XddJSHk13IGbpjHDsoOha33X6CnmNScfCEtOOzyH+EtnKCkF3
+OotCNi5pT4zS6dhOYS/sciYgxwX2CfW5RaSAFryfR9peGHwZdrMVLgMSdqp3PMSq
+36XjNtF9vkjrV/EJaXGwCxvM7vU1aG+FTaCEv/vPQIzEKRgp0gCNoONZ/fT/CfhW
+r5RpYyeMJ8BOfxzdgFo+ApOSIj30oaQUALU0PUIFUFqkfJfhkGt6bDdz01Chsq1A
+zCnawX0uFfYP41ChXqL1SFBt8xlRqyZ8DrUbA3P3Zgg5K+tw7qvroXo1XGLQKQfM
+H0VzfneFf2ro1D6uxU1dXUvAuPm0iv4vgHX9HhUY162zrtbrW7QFZmlFR5hvIzv7
+W6KJJubQMGbp85McB4okxOdSDTrm68lJAZ7HBQVxBFxRSC/6vs4u/Ms/EQTQpXsY
+kxQxfESgM6Kb2NVl8h7PdLiNk+aCaZ04Q3EHetR9wEPTlKV1Jstu5wUcHvmZmNSt
+tTTng3xP4vRvQDzQfymAHHbiGvSo4Ch9CroWVAe1T21raRkmg8S/FYX2LAuac8pG
+m8e7AKxVVU2cRrzw9xo8wUqm5PaKpVPQktyn4jADO/lKl0S8mNjavP8HQcZZOYV7
+RiQ/9Ovn+VhGW0bNQtZX5Z93H4E5ynrYZ+Bu4E6KBzApeG1wiSCGhyo2q8hMBLPy
+52YcPEj7LYeoBCjExgHUmE4FEKq6+zC067jjLB65D9vouoni4lPnH4SEYQudumU9
+ywUG88Wg3p4wTekaFdObadL+hEVY96PqwLHj03YxlPzVZc2hYTYbTR5HG0X+wyeQ
+pHhZ3O93bOq8i3IP1yBue6P3t7zp/iKNi4LZos043RWF2n9Q9RTMVNaRpdbaEMm4
+/JckhjjF6OgqYs7/ju5m8Oi8bEvi3+XETzHzGEaiYKfadrIaR+NpuGla61lCvKo8
+G2Uq/WwJxUICiDvAy3y5Z/FoXe0r87KF9LdC6MhRJvQ8dAEZWVCNs9HaLb+t/G1Y
+H2vLmTtUJUXkuLtNpQdQZnAN7HQ8Y/qRXslLcoGC733L81PQcm3rojAUInyoc5M9
+JJWWk0DLP3BpFCo2cOrsjYzBO4ZC/PNNeJY938JXpvSIz+y+fuXV/Vd/EWNaQylb
+6chCI7Pyz2HZhaKLI7+KPkEBprKbNBQDX4/uZuHtsccPguKF8yrLxk29u/Zy02Lp
+TAGKB3gk8xsDSOKtTalEEHW2aXKvo3tkdRUqjJ4Q5vBO/mmiOZHhmYneumT9SIH7
+jt4wJS56Kh5utHT3RXgmrZn/XX7PoNGkW29HdHive7q/L8WnNar8Yloarn01wE04
+CE+x5vL5AoICAQDzIRy/LzkKOOz8Pz7qO66yLa/dxdiNud0IIYtB705RZduQ7wdD
+oO0J8VOzrgy048EdOKf7mP2zma+xXPCfWHKMXRxIH+ewtNo5mxMxxPSkaUy25pK7
+vB6bOAIYvIZU/eMGtE5GTTMeJvyWC+uKVY4HUlzPaFmzz6KEJiTTVxwCi6SYikKB
+EpJdaZ3S03Gxky4Nlr6ILk1lPKCdWIN/9EeFdjvgN/Cx21wI+9untNfIRKRLbNAe
+dD4jC8mvx/Cb07Yzq+apkYWA7S2i30nocfWE3Wl0nk7nPTiIubetqNn15AjdOt+l
+AyG8ZuaRbcemfQ+slLZ9jkvHCSlUVpYAo+iiztYtViLIWTzGk+VeJhvjdZq7K1+7
+5iph2G9gt2WFaaK4/Ikkz3Uq+SMSlW3iAb1Zj60qzzx1+ZlNMq/MvqJNAzPBxoFY
+33ZySKnQSCOjVSr1K+PUO1m2Jisz6Fhj8lquCttZUrIudPaDVNmVXPXExxnnMu8x
+ms9oOQPozgcUYW9MLv8NVRg5bIqvEb/j/cVnQm4l7eSj8WvkDi+xGEpO5AFJSb/A
+rO9f61JamuHU2RwH2wq7ATMyG3chOu1b1jIuUFIt8cgAbUuTLbIuFQrTzXOMVch1
+dNVIPq8/vuLiNtXW3KhQFiM7AsvUQtsXbGuL8R4w4QM/DOkUK90gXXjlbQKCAgEA
+7ywcQpTjEmuj2xo+FGiZo8hV1cT7yUjbTCtyMReVOFY0+/LP+XldOpi1d73GoUE4
+keXDSXh70AjeHH4KVRzYk2qBNG7ejscX7MhLIlVV6rp6EE1MFPDX1Z2tnwHwz9lb
+kUgGs+Allg1dY6+B2Wmo7vWQ9EHwaGteLanfWsJtHpVEsRwSMSl3XUeydXf9x2nz
+eRJ23V+e07XzeLvL4kn7vPZ8v0qRF+WLy9IBngO1RlrPrI+b//Vsk/2Mf3pfkm1M
+g50Owm+fTOftcUvWkiIcUYCRVbOIBrTGEu4zLaNo3wHshuNmDWNr84lKEmVoXnoS
+fpZ1IUwlLchzTD+Iv88kIVwBE4kMXlU8qZlffVCxAQWOOSS178v7iwc/ApU6aln5
+lXr8JmxjD0Wi1PpHRK4ogtnhikkkN67++aHJKBEYELKeashdxB04kokBl32ywJRf
+oekeqCB/s5xlck7d4hFK3wfawxXqkNaN1q0q39BaaqOPRZFPaJ06umLb2Dy+raMX
+7lNVv30rtiwEUYQiXcEF0j1XNABP14Qkwvk6rDUhM6s1B9c17ZOONeUt03kHjRg8
+tZ3FDAIqHeF67ZROK8WDuVxNCNarS0zn48YZo6xN8+lAn7kNsIVmmio0ChMDJIOk
+hlvlBtO5wd7/9u0+MrcfMej21qbehRltuqi9eFRlLesCggIBAOaoMFyU0XmIPhSl
+b+vKiVcTDvjIPUVf4nlXUYVRIi0JBEBA9NRNNPSs1aruYbGvLUOqv3trTq14DX2n
+3cRepfXSVAV891LmkO372D7sSug72gLfRrACrcq2XQ7YtFynrR1sK6J4lRlzBUjY
+sDJCLod1tQU0S33Sa60RfvhdeP5VOudYq/VGCEPE8mzUGtXL+vH7ZHFP9C8qUHpW
+QhM/Tico3289wwUJRgxj3KUDZX/i1zeTWPK7d0PKaCJy/irntMDawe93Vn/VA+m0
+CqsSikntwKFZmyO4Kg1UnBSNz5J/L4Wq2Af1q6jQuseXrcSeeyNQxrzhJbUDVQll
+R9P9rLPgpMLIKCGIv6bpIr6qSuUFarFNWfqqRuUi76+C7jae3DjBpN6eTtthFswH
+pgK3gcsZCsFFcGfAT5c0kiIdbV7AvfaFe6sz/Ww40Zn/BohrQWDtraxoThkHpw8M
+y+auQydAt47LbK20WzaHZhFU6vkvprx3zwNxinmnNbVE2OSV94AASgp9A4lfF0c2
+AKWs2P24wUUMp1B9tszaRJavo7eqiincZKXHqyWF3FCHBd7nxrcRMOHvJoHQGroU
+7KCm2l6j5wMdkZAOIJfVz2f2oJoGHSwzKgV8vOdYSOyiDR9txHueRbQM/Il8gqGy
+d6aGPpW6P9lBb9H+TpXLc3LEGvEVAoICAF6cf21jQlQ2GnKA9g/StPxSMopGyyd7
+16xQ/3ImFxRbHciQ6+6PMO8OG7MLcni1uTAVyOPWcnwAFgUFYwb6Sz49gnEAbq/i
+WDeFoBsr0LnzHHg4a6FZCLhrEJR3CxDdtdhJusULJTMvhEL72YzsvDQTFk1ZjEVy
+O6Yqrb1UbiAMAklhhlzGP3657wGC/vQUmIjLYhP+UHEFaBPZjjSs+ZVtmDl/wNfI
+KT3ujE86vknfgImNobNmHZaJVTvUZ9wfuoXR6lXGHCkrEgWgb3gNYFBpYJSbWXL1
+rektKzehjcmyFCPj7qnbK4gCRjfyv4+oEIrc7+bFHWv4AIwoEet2gJ9lqtNUgn0K
+kN2yW1DSS8LQtMssF4CNm6sKqcVWzO3nO9EC/p4ggCs5a8l+XBTyI/pnQE4Y0ufo
+JNsRQebEpFVuozYwns8GlCt7YRLRWZXO2+nLsyHlAT9G3eaTBjj4iDqj+8jycYDs
+Lt2+UNiKrknC+9kUO2px0BqNItRuayt6+euAMcp3NIRy8x5f+8xEoA3j0Aw1F2B0
+2Kn8N1aKCeFLl8XLP30EwtvVFgSyuub4sINTrvAqJwj8+kjjQu0TzCDWP28ApHA8
+MvsqkVfqwEd9fN/yL1Ul4EmZ6k4V6UdXgAzaa0YBGVl04qKGhPVA9Wkj9AlDp4DV
+Z0/Qkmr4T7ITAoICAQDntedF62qFLmlgum58QBAbZiEDNiwUlSPUlk6o0Cs/bsSA
+4xIYoxGfQP3T9caKSKGS+JGfiONYgemLWW0V4U5/v+YlJMXctl/TJmi7v43m0tPD
+frjspJjfl3DGOWOb7lVAMOWL0b0MyOV9oBdL+WSBR7+ZiHo6FABqOdJBomO6wrHB
+rKe8DnxE62d9fu1YRL0XVTcJQcSPFhd0JxY8fV9OKPtDLNR6+Q19b3B8MoIrAugp
+M9DLyQwsObCa22A7MP9uLBBTJa2ubJfusW6V11Hf/48rFg6t1ahCYa3gyn6MHxji
+aKIrXH2J8l2pOcf2aAuF1SgeSqnvtnFBgI1vebK+crXVDNYW7GvLaTfEdWRHpNc/
+9/ajew5rRS2HHO907Zub7dNckNeOInpSY7mBoSh1EG/IkdUYZ4hMWlxJzNSu3WWl
+YprvHghpt2uyVMM1fsd39DLTtGv51NJJ5od9GKFWFBI/DRc6iwenKDGIpFi23jie
+c9qb2J2oBiBH9Nt+0hpkqAt61U+306GgrIIUOHbdLWwXy8LOzaZxxVQ4KyVYvDJj
+4zPT6SLaKCqHe8SWSXZyfa3zRIe8pBbAw3+L26yHI7X3aXJGHq6Yy7TbLFypDDoa
+9DNXth8P3qxQq0AckCajAx4ka1glU9vuCAmsetHkgXybSJ1Wire2/zbqQRpWtQ==
+-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qsslsocket/certs/inter.conf b/tests/auto/network/ssl/qsslsocket/certs/inter.conf
new file mode 100644
index 0000000000..ed350da8ea
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket/certs/inter.conf
@@ -0,0 +1,14 @@
+[req]
+default_md = sha512
+basicConstraints = CA:TRUE
+keyUsage = cRLSign, keyCertSign
+[req]
+distinguished_name = intermediate_authority
+prompt = no
+[intermediate_authority]
+C = NO
+ST = Oslo
+L = Oslo
+O = The Qt Project
+OU = The Qt Project
+CN = Fake Qt Project Intermediate Certificate
diff --git a/tests/auto/network/ssl/qsslsocket/certs/inter.crt b/tests/auto/network/ssl/qsslsocket/certs/inter.crt
index 4e1d67c3e0..2d924f3a96 100644
--- a/tests/auto/network/ssl/qsslsocket/certs/inter.crt
+++ b/tests/auto/network/ssl/qsslsocket/certs/inter.crt
@@ -1,22 +1,53 @@
-----BEGIN CERTIFICATE-----
-MIIDvDCCAnSgAwIBAgIQO+uZxerYC10Ll11PBnVL4TANBgkqhkiG9w0BAQUFADA8
-MQswCQYDVQQGEwJHQjEZMBcGA1UEChMQV2VzdHBvaW50IENBIEtleTESMBAGA1UE
-ChMJV2VzdHBvaW50MB4XDTEzMDIxNjE2NTMwOFoXDTIzMDIxNjE2NTMwOFowMjEL
-MAkGA1UEBhMCR0IxIzAhBgNVBAoTGldlc3Rwb2ludCBJbnRlcm1lZGlhdGUgS2V5
-MIIBUjANBgkqhkiG9w0BAQEFAAOCAT8AMIIBOgKCATEAsR4tRskg2IFfQFMfGBJ1
-eqlrNejANw0oM6k5HlEB8uFA9qeyAzmflwQUPoJ55KRQ/gVHTOBdWrtgGgPMiekF
-1Q36Ry1elwbAl4a+LZ6qsc9ASipvk8HirKpt1v5L9hG+aI4yDxyvjNztFtg5R4P5
-zqsh/WwhCgsYmEVfcSDbhUjqoqxGRLaZxPKO+IMCNFrjZqi0yxc8f6Un4G5SQzHA
-4szi/ezcITnAFYWxHG2yaed4hawpxNS1WXabk2rzCi0pWeIcHuIczaCfZ7ElRcqV
-VNNXbGTtUDlfIsh6FAVI5kTUDcPV27uf6BmHuFOu/R9Tjni25+vBFvohwQh7ZwCX
-5COXnfkJLPkJQQEFVQv8nS27ht/vmyoKjERUeiuMd+hFcN5zl7bS5A2JCgi7erlP
-ZQIDAQABo2QwYjAPBgNVHRMBAf8EBTADAQH/MA8GA1UdDwEB/wQFAwMHBgAwHQYD
-VR0OBBYEFGn5shQ0SeTcc3x/cNu6TkoV0bPmMB8GA1UdIwQYMBaAFJQnOLW5hBTG
-pvc2vfcs4sJpRRPJMA0GCSqGSIb3DQEBBQUAA4IBMQAVDS0enQQ1FL0d92xOFfwx
-mjcNPz9oO7jMyEVxAs2eR2QD+xZ3Xj4gAiUEp40aGieDcLv+dg+cmuBFWF61IYSR
-UyuoakVm08VDcLAwUzU+xtSvJiSSROb0GsAnVsYZj4TYlvKDplqfapOYaiIkwF+c
-iE4n7G0hQW9fzqO+n3FGtBD8YUjghRqLggeRVJ2+8S3Bm8cfx8xPpRIO3ksA6opn
-CORRGuzetDHihbks59mkoY3GqKFgBOyrC3kG07nv5wtKjdKDtmD/kS/SAc4fIXKy
-Uruq2uXNf/1BUgF5gFGRyj22yB2D0763fJJpl5nqcLrL5RmnVObQKZGhE2VsRTV0
-untj+AmiJivhiAjjkHfw3XDf8tuL7D4pTmEkGgl5xl23fyeTIuygDCLT8fRD3ZqQ
+MIIJczCCBVsCFBFyNLwh5soEJBP4NUiEpuneliIVMA0GCSqGSIb3DQEBDQUAMFsx
+CzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMS4wLAYD
+VQQDDCVGYWtlIFF0IFByb2plY3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTIy
+MDkwMjE1MDIyMVoXDTIyMTAxNzE1MDIyMVowgZAxCzAJBgNVBAYTAk5PMQ0wCwYD
+VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgUHJvamVj
+dDEXMBUGA1UECwwOVGhlIFF0IFByb2plY3QxMTAvBgNVBAMMKEZha2UgUXQgUHJv
+amVjdCBJbnRlcm1lZGlhdGUgQ2VydGlmaWNhdGUwggQiMA0GCSqGSIb3DQEBAQUA
+A4IEDwAwggQKAoIEAQDf31Hd+5tMLrBf966j4BiTBP7yIS7BJ7jBSUWVStd8F1Pc
+hxB/h8hKj8T8M8Fq2prmxkkjg4epxmgqYeGqYnBqPY0Gke0RXC506WGW8B4IQ+qk
+szVHJyNC2dnZ7byaqj1/vleQESmaQhXRxSvaw3Qu54/SbXuEOot8tiBZ90oVvHHt
+yn1nQYpGGDszTATKMaaqaE+D/lsNzxJGGzndbg9yjrvLRKBRbFIhT7L7ME4d2NLm
+AcXvFHHjV2bEBCvQrShXE0t11qAUrT48rDcBA0OsMW6YwxCBoFXvnpg5iuCfbQGf
+zRVgGIhb8Bo1dV2nTBTMpz9ssupTOmlS1/WJ99w4nPHUHBtYe8QBaWigHbIqyxlP
+hm6NBe4i1EoqY7fsfI6uH9eo0l8ZvB/tLCgFRE5OqHQZXPUHutnlhSoouj7gA7Lp
+VPYundGY8mauVV9YFVDECh8oiJI9/dqq4i6QhLHFXFUG6P95yqgzv9fsy2HKKr06
+2deBjOGMoQv7CRgRr9/JOAYOdk8SeQ1eWRA2O2Vx9N2davIczvuODqP2Y2IqJ9/x
+xvYVZNlnLIrtJvTCh4ROe3+ecdLeg/hFT/J2BmG6oHeNm0TJPnI1bK6TDJYb/Nqi
+EIuDDpbNs4IZn70DCU+Fg1FiV+evAziQ67utijyOg/xooUKVvXH4c5s7jUcFmYJd
+Zf/3GwwLVoTpeBpAKyuZ/ffUZkXUi4GhBS5g+3P+O5LASKiA+785qk/FtY7tYo/H
+VfH+3n1hQK4xdw8VA81LSanhZMYkwpKSh4Per0jeGz5GeYfCbBuxlfZovmUHcq2s
+1seIcxRzcI4f+uAsjdAh5dAn3OFqComcbGls9iWn+mGs41tLgNf+J357N66234DQ
+K0FXrRGyjmlYNPibS3DkCJCmEslNjSh/ObvMSTiJkpVYEXP5lo6Rq67C0iaF8yxs
+jsMfzINqQX0gQj8QYbxmy3M89dTwNoiJ/XJuDKwAGdsfJZV7clUY2cLcCue/XiXM
+xOmGvSU/Bkq6vb2ij7TPeMoV7gNVhNfVyM+h09q1CesTjAauRMp4/ZYYETPkdII0
+Hkd7J9QQP/aUHX56vl+R6kEBE+IMfEIXpsmnKjwxdfbYfiJZP0wewkM0LfdI9T00
+DVc9NI2xqZLPx8N2WxnvmDHrz2kpITBdiseddNK/L6X/sZdxFf+2YQiA3o+nvifd
+iq9/2MyVnghcGOazlmzTB366OS6vbePWObm2+9t4h1yJMOIoXr69XkMzsmNCHyR3
+q84/VmDACRfoeA0h68wpeMphKKjlJhGWD4e3k4hIvbKW5/HvtIJfaW1RBXtpiS+3
+tJwjpHdIZGKW9CKheupACkARHO2udeJRYFi29RMNAgMBAAEwDQYJKoZIhvcNAQEN
+BQADggQBAEMvISwrzGYljSkM/04Iym9m1nLZ8teOLxar0bULGIAVGZ01uBwSwapm
+C5lvsNU+IY3O4TgjhMMq/cLXM0KUyhNK/oD0oEjNKuk10uoqs2sRU6+t+iFtf/74
+xPYImmDCqEfVu2Eew0SMKclPlPOBGHXVm4oOcbCp7xFTTg2YIrRDa0cKekaDDtsy
+gQqMKNk/wGHI9SQVjVerzsqg31x4rvVaI31Ss/KosZWi0La/QjvJzhFF+UJ+AGkX
+0p0iOKzGbMgi9tSLrLTK87n+x48XayW/P1+BKdvXUGXQUskCaEdhRvUHTi5LKFyP
+mZ6xkyCxNig5fuwUnfrb/976VzQCucR5kIVh52WBusgEnCj8mvdlHQov5Vy8dwxF
+4tO51lb92R5Gu0e7XuKK3LMANQO1HNFDASPyI2AQXXCVgrxOqnNSyk9sAFsyRWDx
+9m0v4KjOezukbJ5OssBNVj/aQrvYq+L88Z8NFq9q0DoM2fVzxfbSixpRh3wbMm4c
+Ttv7zXgLFhA/jrrUCiQVzgp0KSnM2Fchi/IxaVH34+8JCC+tKX4EK6vaIif8Omzb
+iEsPUUbINcoIHgfVEYmmk6Z4KcHBKOz/iiTgaPiQJyymGlgXRLKjpkbifbRIm31M
+UxCpv+KyTmjDeDFRXX+Yl/b1/sRNg4TfGTVySsb56vzRMghRPJlnHfMxJRroBo6L
+FZfimQUcJxbNpavPdj29Vg3Y6bXGdUATx1YDHFSCynOnwXE4kgDvQGyoWHHN1zWm
+Fl6JyVor9vb6viBB5HCerZsQ5HDpmQ9UqVs0iWJqYfgyFThW6mZGbBY2inw4hjtT
+oVxVzW8gTTaeYLlrY7BqSpjtWQduSzSgaIiCGuvM3Yg2N6jiHzlN0h0pI+uHbvNW
+F5ZMfVMU8IcheMilj1a7lgmQQas4xy0emo1H1GH9Lcw6+yW7yN77grKOgWhimvMX
+UvoHaxE/T67jpK+SLyyzhfsGwOWhx91BzAFpyDqrYd5ERR8EUUUEVKLYofmDh5Ey
+FqMqQEwXOBQxB1Y/1UcSbycu+Zr6raKJ0G6eCS7O6dlCpIZwpggqqnKZYFnunskE
+lNw5ZpsSHADp8rwRVJGlLxgqM0TEvQa07+wb85sR8Hl47Y5QSq0E/Hn8a2ZcGERR
+chsW89yr7qpUNPoTQUDQ3ZGByzeXMYSvNWvsChomy6GqSmFtnuI6Ta07CNdcbqQ+
+8Pmo8Mi3UUNZueP2VNIdHXeYEabjwl7v8KjyT4bc0/SKk/4L7ADvLxV4Fe1Na73Z
+2hrMwmHCWJ+4sdVFF/3t0yDg9GQMGCTXkbd8ofJwIkM72NAUYAkMvOBx8+NaSDBW
+wvnYOPu8PDnRWerAdoRZUNlKigb6oUA=
-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qsslsocket/certs/inter.key b/tests/auto/network/ssl/qsslsocket/certs/inter.key
new file mode 100644
index 0000000000..8d282647e5
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket/certs/inter.key
@@ -0,0 +1,99 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIISKQIBAAKCBAEA399R3fubTC6wX/euo+AYkwT+8iEuwSe4wUlFlUrXfBdT3IcQ
+f4fISo/E/DPBatqa5sZJI4OHqcZoKmHhqmJwaj2NBpHtEVwudOlhlvAeCEPqpLM1
+RycjQtnZ2e28mqo9f75XkBEpmkIV0cUr2sN0LueP0m17hDqLfLYgWfdKFbxx7cp9
+Z0GKRhg7M0wEyjGmqmhPg/5bDc8SRhs53W4Pco67y0SgUWxSIU+y+zBOHdjS5gHF
+7xRx41dmxAQr0K0oVxNLddagFK0+PKw3AQNDrDFumMMQgaBV756YOYrgn20Bn80V
+YBiIW/AaNXVdp0wUzKc/bLLqUzppUtf1iffcOJzx1BwbWHvEAWlooB2yKssZT4Zu
+jQXuItRKKmO37HyOrh/XqNJfGbwf7SwoBUROTqh0GVz1B7rZ5YUqKLo+4AOy6VT2
+Lp3RmPJmrlVfWBVQxAofKIiSPf3aquIukISxxVxVBuj/ecqoM7/X7Mthyiq9OtnX
+gYzhjKEL+wkYEa/fyTgGDnZPEnkNXlkQNjtlcfTdnWryHM77jg6j9mNiKiff8cb2
+FWTZZyyK7Sb0woeETnt/nnHS3oP4RU/ydgZhuqB3jZtEyT5yNWyukwyWG/zaohCL
+gw6WzbOCGZ+9AwlPhYNRYlfnrwM4kOu7rYo8joP8aKFClb1x+HObO41HBZmCXWX/
+9xsMC1aE6XgaQCsrmf331GZF1IuBoQUuYPtz/juSwEiogPu/OapPxbWO7WKPx1Xx
+/t59YUCuMXcPFQPNS0mp4WTGJMKSkoeD3q9I3hs+RnmHwmwbsZX2aL5lB3KtrNbH
+iHMUc3COH/rgLI3QIeXQJ9zhagqJnGxpbPYlp/phrONbS4DX/id+ezeutt+A0CtB
+V60Rso5pWDT4m0tw5AiQphLJTY0ofzm7zEk4iZKVWBFz+ZaOkauuwtImhfMsbI7D
+H8yDakF9IEI/EGG8ZstzPPXU8DaIif1ybgysABnbHyWVe3JVGNnC3Arnv14lzMTp
+hr0lPwZKur29oo+0z3jKFe4DVYTX1cjPodPatQnrE4wGrkTKeP2WGBEz5HSCNB5H
+eyfUED/2lB1+er5fkepBARPiDHxCF6bJpyo8MXX22H4iWT9MHsJDNC33SPU9NA1X
+PTSNsamSz8fDdlsZ75gx689pKSEwXYrHnXTSvy+l/7GXcRX/tmEIgN6Pp74n3Yqv
+f9jMlZ4IXBjms5Zs0wd+ujkur23j1jm5tvvbeIdciTDiKF6+vV5DM7JjQh8kd6vO
+P1ZgwAkX6HgNIevMKXjKYSio5SYRlg+Ht5OISL2ylufx77SCX2ltUQV7aYkvt7Sc
+I6R3SGRilvQioXrqQApAERztrnXiUWBYtvUTDQIDAQABAoIEABn2G9hSRUAgafO3
+FVmLs03ZVnddwb5EjPhdNuSJOVP6oI8CWrdvV5rN8VoN5nAtyajZdcHYjvLxP0Mq
+9rB7me24FZKdeZB50ClepyKJ1fG/boaLAbKupzgpa0oKd8S32UnnGOBsHRb2cvFQ
+nDVSVTbbQ6Jzb891updLx5SnSMAcilm5EbHXt+FJDhR0zFlmSJ2aWx5DcOu5B7V5
+ksxK5x+xzbVU0AKhPST/yRG4GFb9vfdOXVXMWSi0CgbRNQOOEQ+H/Ug9C3NaY81F
+a1uCtWZSlTDB7jgaD90p1x1VLZdPXNDbR49NSQLgZSmt4p50BDV3b7N7TBE6xNwG
+j0Lgq3klOiYO3Fz2fVRslOV8jBzKULUYMdnIxkTjuXYQ+lNCXolyx9+cBctGNa2b
+YUi7ExmsD0qhrQiocnxbZPg0IPZ5d1X3tFTTmGrUMXQmElh0oFkbk2Fv9QWbWrBW
+am/382Wfv3x9qKLHDZpytOeQ7lYzfp5EhOlRHRbh1jHWbCQg8SK0jH9A2QqbXyGB
+0o93c9wzOT/4FvugRSvEJt97xvZ8iUvQdtkkSNHeKH439kpYzM8NI0+Mg5eqVjAz
+hTqKouqxkSuqxd9Qjo4DfHsxCndUa0ZABO29018nYf72t0SS39Xr1JRC/WseRIEJ
+1UnargsY4zx+9unGfmEBhw7w4zuSyiMARmEmigdKvofTj7V4nIBWmy64Pvp9U3iQ
++lx9mtqcybdNLA5VOrzF03W8snO3xxSBC2If9Vr9uelRtBecTYa2pRVAhfwrLlVR
+fexDIzOTHrm7kwZnFAfVf5y6pz7m2b7kMZxjRvZZ+WQVGGwafwPAaCeHR3txKd1L
+ixHRUwvoseef3hqDPzA/0CtcuSfk+IPSrCGbymWMpRYtSDkHectI6o2BolUzjY95
+dpzILDlCHewAWJbP11Hugi+NZOFXluom0vCVYgs8Y61S62xFqHifzF/usHmQ4laP
+zHQkoIaZlTHA3gxKDpYpyJw5/x7WQ4UAtXW/GzS0Bec5FOEv5NtyEW4s/jYkX8J4
+DlmI/iW/q/LG+G7EL+AnOqnnoBhY045mUFjXO7OpWH2Kjt7XG6zXMSAsDKm8Wp0o
+Ily9FgfPxsHOw6i3NrOWNVmURVyCqY1Ut8F/T1vQ2e8b8O4FlaIMQN/tjgSpkaDa
+8ziPehQEZqZZKkmq6InZlY1MlqXrXivZYkDJCqzhGKxIPt0C3sfTBQxCzJwIO9ma
+STOxdgj1HfczNyaTwRYtbdtkroOKWclmB3lbQrZmT5DVKCtLvwFAG1LYGGy4w8gf
+6/IEsV3uRGLMbnY+qvl2eI2wwI0FYYaxdydiNDYHyiK/Wea8QCsbU48QlBB7W1Of
+zzNv+gECggIBAPvP57PPQaeDKZRb/lbVjw8IIPN36Vb2ZSRBoYuvSb+a+62czrYI
+ZNbadBb9VCx99VlDaxthE/9m5Xa5JhfHckf0dSYuXzX/fnzXlT+J/SKLhGVXsqG/
+HBhXu75wn6cvxV8D0WQ+C7I8xIXHeQsyC5u/HFHtOiAZjjg/BInBIenCdtDLehBL
+axBN363U7hmd/u0wDiiKKSKTDZwBcnfQUdEmdDT7VvnYdQVwsBmYXR0XNS2bROGH
+NaJWxIUUPS3Sv5KIkNSzGCgD/FDGa2w1tRfKalMXZ9ttzCzmKGcHNLtLSeC0Be5Z
+mG6Jc1dTKbhD29VLTJgidnNne6VkZjQoLXJEeWWQeRqpCqOx8AUp0b1d9Zhdf52b
+FYazIyoD2ARMyj6S16xalSS6mYYMzvXI+LXMjS3WEM6Vxxk1is9LhQdD7voszCVI
+SOIZheub+ifssPvbw2fdR9V+euT/Gx8IAnYYFPtW8BLvAAvp7Rgximbp5bs8SdkV
+9ciPCJAC7DRgBUT3CI3Img5c53ZONoWUJVjTBh3BULBdsk5QFLUxj4WXv+ckoq4T
+2qCWMXdFF6EFbh31dfz1S+97snOIkaJDlo+nNvUIPYeNuPMwFaNLcg4XebVFw2in
+24C5l7V+jAE123seJLquupQETAOGCkEYwPcQPRw+jDnyAfIsLFKc5G3VAoICAQDj
+mHXltSg9zQACyk5ky+EHyc8nwJ3i6zWGIlaaJ/6G1t2pLXv9ZsLLvYI0nuBM3Qb8
++SJajT2TKsH9kLd0BmoBMgqM/+cA5aGCCrdpmAdSSkrHQOOSaNVSEu3oqz5n0/ft
+/sh4Sj07n7w1rsorK3RbP8ZltYjrQriATiIRV9/tTayZfi9uwpl+0ByvZbfqGGbC
+wbDFHyskbwe4OZOrKDkf6sKCyzLsVI8mujmqE6BZ6pskbrXIGbUPvau9azpHbcvY
+WY8Bk8Rv29BCHt8m9Qvgfet3dxoWVaMV3W13DvVs0zEhYTfphL6WP+STNt8vuU5/
+A8C5MOwelLzzGxeIl915rC3Y7PzYZlO9V1KQv3DhBTub7Ow8Jilhzsan3Sx0CikO
+B+HdcjzW2YWxglqC/QX7jtVUIfHvssQajNzv9C+feXU//Fn0uudX3xMUxbBXsBJ3
+x17IXHP3a8PGEbBp454KhhFlmTyk1rUkGboctakepV+nkl4FZs7ClK4u9plMGuvy
+02QDuy0cVn9pLrqpKimKNUzv0Uz6UQfZXphCB31BDA7nxhCvK1LQv79BIBon0jhk
+KMBMMJ4/FsNO+vU0a2fApu99ZkbpIPPWsDnj0W5uyULVZiJWh4pHb+Azo8/EptA/
+PdcYIZm7pT2NmXyWalaNE+2Fj5iuT5riKsGr/P1UWQKCAgEAo83y470G8HkaKzBM
+myABF74p8TcnyzItSRCIjd1RFBs1bRJ8RV3gewNQUUQp5Wdqms6Idh8IazP8QObg
+KMfNR5F2Q4gW14GEPqHerJ6O1FH9pg8OXLl9BTjNIG0S7ibdNZm+NH9IDIILNRs1
+WlsLwhznx0OSdB8rrNsRkKrZ7L5bnCdBGCh3VPvTbbj9yhxFIPYJv8VgTOVsDPfE
+Bry0/GEPZwe45H4yYX+UjpHWwH3AUhKXFD5oXVokLI2l3pEhnajIzhRSunUdRU5N
+wu6NBxTdZX/sR4l9MBfoYF0HqG6peEqjMRGHXyB6r2uh0AQUlQOOp8iDVT8T59sP
+wQ4BwjtY3QDGRtl/2kx93l392jms8Zig0112+1C8pzAo7WMmjN3o/m1OZ74a8GCU
+oL5DS7/sdsyx0jEMexGhYoe12awPYR6TDg2fm7UOsN2eNSp7Vtr2mjIP8Il+WEi6
+08zaDQhNXdKICUj/tsBNQ1e2uIuerdXiFB187SJeZ4//J3Lu+pXYMqMz0/QLfaIT
+RYHBaa6cY+7FFnVc8CSX0+aRfk3gv/PM/4Baz+vj8bo4TL7DiymJvyuyYe8Nfqpw
+UiW1Y21bCrp5jBxdG5VD/h2t7AzJV2oyW3oWB/6y+ZWAbakjRUuuiOHw7Sh+aixf
+r0jy/cTKe/0UKv2K1oZ1rqfw0KECggIBAOHCKbBhsjkbUBd0da6mTeFb3ZChD/w3
+NDCJfz4Kzf8Sw209IPCLLk7K/I0Vy4hy9quYtOr9j0ab8zGCi3cbparp6G1Uqd/J
+6BsGZkjn9Ns7tlFPnG1ub6up+zQAKTb0m8oIIPKxMWwjVp4pc4C+6fxZloLtP5Od
+60XaOxDZCdZqZfsboBFOFtQju1CApZ4f9k7Zsm7WLAVH3XBwLHpqu79dLvRue2TR
+u+2+a9S5AyYuARZyev6yAVhL3D9YTcbssnc43xHBcelDMaFk3hXWnKFiRl+KVOYy
+rELUEfE3dVstYl6qALwyYJrJZgJhO6IrPiHfpxwL2yu6fnLnPMDRY299yzySV3yQ
+hCAcrlnGjEGo3ygcK3i+oe3THlsEmUPBkFfKmdD/sDmuK1+Y3g9wzK5rUFDUGxiZ
+SszLTZz3qwWVhSijONf5TeFr9ZF1Rya0EJ2ftfUpQB79VoTypvtiPTJTKo6NIgqg
+r63Plz1DNS6g+/FMztas1AtPUDhlhEppqgKEjYDl+ilR47CCGcYTfIELvfVkt+bU
+2eRUYNOeejA7tc1SOtqHLu7CRQRkw40cibNQeO8ait4pxjJh3TjSEWiYLpdFDLHT
+bgxXYhUJeXGLUjA7z3PlntSdtNeEdmOq1Ibm4KWfLs9jaVs8FMlfUds/GSyS8/B0
+Jj6SCup/WQqBAoICAEkNfMe4BOR5jm3l625O2w28b37tzl/MIpvofXX/pIw3E7Bb
+KL5Djv/rQNx5FmwEdE/1iR5fqQtY17nhxVQEoAPUrdJxaPR6rWnnDLI7tg+Vme27
+x+KDaonj0mMqVopBCs+G7+E8SDDeFnDyOgJEd32q/m4Mwujv7AuKH7uDl2cER2gc
+5xnYyJexlk42DW7X+6fdYZxyMoGFz+Qxylj4kO9UpEXk6Yb09uFZaX1yGJZhuCWs
+NgEXYYfTHV47XTF7hOrs+KlYQt33TY+zfOV+ySn0B1PFJ5fpCC1n4qoysdfjquwJ
+Q1FmNCRYfA/SS8rnzZVTY4zh5//cryvzhiVNWDEoXx4PDEkH/xgvag/KVKDZahCr
+lwXG8Ipqn8WUZWy/fq6ItOKPQOIECk/hctf9awBYU97G1Qk4LoCNOzbcnBY4BvKo
+roxcm3N3uaGPiDuapmnCfKNrvGmlQvWWtI39paXRWezARHBFQVFzp3w69/MnVDD8
+zmeNrOLCxCxmMxCrE+nARSHANUG5VXLbAK0dfPm5+3eLnvuD0GxkDhUwQS7r8kcP
+xalXLIa5oul8gBwQf1YV/FPNzTxsB9EyaTAWJzaLOYwq/ugtzr6yHvDIUvOxhnHr
+r0sXSrqOWhl6uMaMoExTTmVsEXgzCFiXBufo7CwT1DFyS10nNNvA/kxh3rDc
+-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qsslsocket/certs/leaf.conf b/tests/auto/network/ssl/qsslsocket/certs/leaf.conf
new file mode 100644
index 0000000000..5ecbd31b55
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket/certs/leaf.conf
@@ -0,0 +1,14 @@
+[req]
+default_md = sha512
+basicConstraints = CA:FALSE
+keyUsage = nonRepudiation, digitalSignature, keyEncipherment
+[req]
+distinguished_name = leaf_cert
+prompt = no
+[leaf_cert]
+C = NO
+ST = Oslo
+L = Oslo
+O = The Qt Project
+OU = The Qt Project
+CN = networking-tests.qt-project.org
diff --git a/tests/auto/network/ssl/qsslsocket/certs/leaf.crt b/tests/auto/network/ssl/qsslsocket/certs/leaf.crt
index 4a7dc40540..b9af13b896 100644
--- a/tests/auto/network/ssl/qsslsocket/certs/leaf.crt
+++ b/tests/auto/network/ssl/qsslsocket/certs/leaf.crt
@@ -1,23 +1,54 @@
-----BEGIN CERTIFICATE-----
-MIID3zCCApegAwIBAgIQEKCtd1j2bq5Gk6ND+VmKnjANBgkqhkiG9w0BAQUFADAy
-MQswCQYDVQQGEwJHQjEjMCEGA1UEChMaV2VzdHBvaW50IEludGVybWVkaWF0ZSBL
-ZXkwHhcNMTMwMjE2MTY1MzA4WhcNMjMwMjE2MTY1MzA4WjA1MQswCQYDVQQGEwJH
-QjESMBAGA1UEChMJV2VzdHBvaW50MRIwEAYDVQQDEwkxMjcuMC4wLjEwggFSMA0G
-CSqGSIb3DQEBAQUAA4IBPwAwggE6AoIBMQC7EIWIzb7XCfmQQ1KFdZ5E9f49eNK/
-KvsXYfq/iV29K1cz2hUyvfdKgyU5F/+BOPQKQ5zdWn1CraZosFv/ibuO3mhRpMfB
-SfNn3rfdrE7WtA0wgT2YNIN0L4aCe+C15j2ESdmyMaFLUaUIS47JS66UtaYxp5ia
-mJFO1hSNaoI0pGHyPFTTtfOza9z/01qkBbHB4htzauqs/fX5ZrnyCDSrfpVipXke
-zkPKg4MkkytEkjRKw6tSXLpWIgF3ee2N/jBdefqlw8YPW08K0wmwF5qGuX6PZ8vB
-sOZeWeCfVr136BopkbfP3TkGWw2BrD8xSzOUez9HVc0v4SZ/7pe5w3L4V/mzYQLt
-O+1AHevCjX8+M58HYGBaWCAjxYUPGcGKcj0LLtgZgL6wY88N7RtfeOY3AgMBAAGj
-gY0wgYowFAYDVR0RBA0wC4IJMTI3LjAuMC4xMAwGA1UdEwEB/wQCMAAwEwYDVR0l
-BAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/BAUDAwcoADAdBgNVHQ4EFgQUKKuyJSrT
-Y+dnm1do7l0sVMX96SYwHwYDVR0jBBgwFoAUafmyFDRJ5NxzfH9w27pOShXRs+Yw
-DQYJKoZIhvcNAQEFBQADggExAHELijlIFdcncP3B+vxEp0SGKl0arIaCXahivb2F
-VxeM3WajN6O+oDRLFltzMeDKA9RVkao7fgITzXQgCGzeNhKv0vc9iDyvR9/67vuS
-W8xEEJrYowtw3VK5H1y0ewqZaxJhvKUjm4TBRWe8FGKD3s64lEsfbjOaI5VPidVc
-DXmdAlXsj0Hk+v4Ej8mshPQAnVSyJ3D0ZMgTjk8Di28N0qROFIYJaTObK1rCb1nQ
-GaCcmbZU6JnkYvVZ+iUe5U0GXFbb+LRNTUT8/fw1zADeHnv/G+WWVrfND+sov5Oc
-33fkNE6z+n6ayABVnGLuCYhbzD38sv0dnxeh8vbykNBPzYdzPg6nw3Czv2vlhKpJ
-8Yj/maoXuAyTXVf30K1/fAWyU45noq57MjQpU6UxIX1D7qw=
+MIIJoDCCBYgCFFjfM8GbvMVRegCGZEOUQeIm7z+JMA0GCSqGSIb3DQEBDQUAMIGQ
+MQswCQYDVQQGEwJOTzENMAsGA1UECAwET3NsbzENMAsGA1UEBwwET3NsbzEXMBUG
+A1UECgwOVGhlIFF0IFByb2plY3QxFzAVBgNVBAsMDlRoZSBRdCBQcm9qZWN0MTEw
+LwYDVQQDDChGYWtlIFF0IFByb2plY3QgSW50ZXJtZWRpYXRlIENlcnRpZmljYXRl
+MB4XDTIyMDkwMjE1MDIzMFoXDTIyMTAxNzE1MDIzMFowgYcxCzAJBgNVBAYTAk5P
+MQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQg
+UHJvamVjdDEXMBUGA1UECwwOVGhlIFF0IFByb2plY3QxKDAmBgNVBAMMH25ldHdv
+cmtpbmctdGVzdHMucXQtcHJvamVjdC5vcmcwggQiMA0GCSqGSIb3DQEBAQUAA4IE
+DwAwggQKAoIEAQCjQsmsZpATuLv54ERkqSdjWZYuulm5gZwzz9fS7R/K1CoSFQza
+T+rY7Kauv1zpalfZGNs4zmEiHDsJ/hhVxCC0L6L2PqmkZjFT9psAkPHENRMIvBYl
+QsrJbSNj09UeBfAR+ux2vktreyZc3UFyq74iQbHeXFuzDnH17BZMR8nMs72wDD5J
+QMaRmvtEvOlNuiT6X7YluO7L3f4EAGbLh3s4OxDHOIqtSXkFjMlgmqU3fKBsZ89F
+YlYH/v0X6ItK7tMbwJjXea1gPomO7pIH2H7CzTQ2DNL6fGRvqCFjZeseZudgRhwN
+LYz67yDKtZ0TvjqD3ShEboh5CxjL+8kskmofBf4WcF0z8xg2GtopAwFQU6ZI+FKY
+rNbUvTWcew4Q/Q0Ya01obeTXsOKZ7IVAo5SxOFSdBa+wS4Igekl7A0C9d9QTduxA
+4fnD+Rhw0dvZqL3lBnSisIsCIo/WK6g2L/gYvgRG/3ChRibfeW81rU8q6+MJIx4P
+Ad3f1wvEWGAWiYYnHfF0qpxhd3UYUN/31w3idaA4LAuQCOSfQHKnGEhp0hVng68H
+seclzMWNHSGoJ+BpOfyYBCA75qIGWjM9RLam2J1qh6ODYVs8XWBdbnoWgWjBluCd
+MQyWSjaJB0m2loe+NGSnBdatEadsq4+axBuiKrSrz7KSiISdozEFq2Ua8HXAntII
+GLEOP4rtep10w/VLxF5y/3LV/8p1I0betPvrL226/zZJQep1bttodL9Yh2xNLk2J
+h9GdxIw1CGJYQmLWxwUYpYyq05WSZyjC8e10xE4po/f4Os89Nj9LG2IdW2VKdOsn
+kRqeTJaCGtJOpcebzBSbHQ2YWcQLhLS/CmmxEAaWLZuQUOMx85dGTonqvmdmLwgm
+KSNQMRvvEKt8lwqCuw5nPmFyHpnK/l6B9OA96FO9RbSwYOEmHK0EJM4tY8swYCsG
+aYdb13MzHW1g1bnsyZbXbOOn3DbyudIWpIvMhJxjBXapDKb3oGMacLfAtlWK2GvY
+wD3UrQhxqvwPcDngqOWKkNtGoRKrqhxbp6CnoUxMEn9Lzw9TlSCcGlXQo1m4CF1K
+0yP7CzTgkBSemAs8VIOh0zNBCI6VKV148r4+j/eMrt25WawAAFddNsPQMFxxd3kk
+wkVi+/YAISLeArR55vsg+FaspD4o/IXIsFYnU/FfNPkz02BaUR/Rz99dv7doM3m7
+dT0kTuZiyGbwXxeY5NYhHfhkEk/1wMfoHRBFSjXwDmIU7CULfWE5HKlfcE9FBS4V
+R4LL9b7b6z1Yj+rNHVeQfIlTSTeX7694rB51zn2FRBr85c6TxfpbZu6j00d5qS0n
+hr16guvSxKdWFmhghJmZmWDkkMcOakY5MG3RAgMBAAEwDQYJKoZIhvcNAQENBQAD
+ggQBAN43Kko2uq+2tejqyRQS+oUQkM4zshCTP3E4pXKZZrsx2j1gqHqA+2ltrCji
+YUIDNuLgQa/gvww1wfmLWOgRdq7cNXZJnXbyOog005aiwlShLGwD3JdEcjjc0nBD
+oGiym83piLuuoEiM/z/v/4lXzWdjOUalnmkYGLs4BonKCjCNuM6skompycMw/DOu
+Ou0QW7VVWsn2yR5VT1+BIEgjFNjk94mTkEDo2R7CqZhxMnqb+dNQ17J55YI13IsB
+DFNbSPdABi8ve5jJg3fvgC/u7+DKQP97D9Rc6RNw4zHzmpBYWvlEzygc1GQb5R5l
+rki2cDz88W0VD7d0lZEeZV2w7ZcGTNDVDAAuQYC75Gyb0/69/5aiV4LlfyayZFgB
+hQBlgKffD3CpcH/YzWeDjsspzpR656jAZhdbeRNhKX9ifdwh97Xf4fapJ1YFLdZG
+dNqz8Y3SrT09k9tORP2Tpsx9spA5hT4I+PAVEJzJP01MSOqm/wNcd15NEtGFrbhq
+eru4GKmMZFmfQIA6pnP4t1C/pTSYCESLnXvXmGYBX2Co6Os8vmAok1BQTyWBbOxE
+nCm8lChE1/i4qjBiiPIZU8w6J+PwADfRU2wRiSVRWmL5hmTqtb/4yNkytNw0HyKe
+98hnrrwd6B+ZnzvNk3NTGLJbebhHalDR4gSNrh4cgn09VWxH5gSsDsZI0US9q4i/
+yLiHJ0Ol1T7kilURO4+8qxNK411wNW8AW23tVa82uprpB5IYciQkLLyoK1XfdMRf
+aGoGT1lZQl6da/20iihQCWAENdiaoCC6/h9hZF3Jwj0tEPB83qGuriQflP9MxS+D
+2/IeTtSLfpbBOo5O5kJ2okKGOrp5X8+QWMS99Wk+jpFdmg/t2D3cS3JsrwPGlBU8
++PiW1SklS9pbt08o5O7jT2dwJd1oPk8woeJl5uft2EoPwaiF1rCYaEi7tWMQPxt4
+10SlaDQ8GyLCOz5NFyyn/ilOmwy7L1FDOhnnTu2JO+K8MSi/x1a8YXSEifCGQbvr
+niHxP0g1SQQB8yOyo6booHuJI1kl1h8J5mDotl8XZ04jtjvg4Bcdi+CsfBkS6nJq
+2FwY82yFQyVRw8j24DExDKyZO/0yDY/9olkI06W/HcOhdm/zVwDBDJRDILPrdoI1
+29KIs7acAsdVNLMf8a9Eljl847+sFlKiCQ93AmobcmNN7QcjPVF3e7IF6XMoY05H
+JmYjbHfoUIbv0N6BKIAuPF/dGO0BFLuE7QLQ1d4Gyg00QI/9QV7yKP1LCTy4yano
+WTmoSRsgChQ7BcfNNV9ucHrZlbtgXQf59A7CDY/z6tUajtjkmOrDEVpkE96he+fe
+y7Sk5pZgg67qgXybVQfxbPwEK6A=
-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qsslsocket/certs/leaf.key b/tests/auto/network/ssl/qsslsocket/certs/leaf.key
index 54327925d8..738d5ea8b9 100644
--- a/tests/auto/network/ssl/qsslsocket/certs/leaf.key
+++ b/tests/auto/network/ssl/qsslsocket/certs/leaf.key
@@ -1,32 +1,99 @@
-----BEGIN RSA PRIVATE KEY-----
-MIIFfAIBAAKCATEAuxCFiM2+1wn5kENShXWeRPX+PXjSvyr7F2H6v4ldvStXM9oV
-Mr33SoMlORf/gTj0CkOc3Vp9Qq2maLBb/4m7jt5oUaTHwUnzZ9633axO1rQNMIE9
-mDSDdC+GgnvgteY9hEnZsjGhS1GlCEuOyUuulLWmMaeYmpiRTtYUjWqCNKRh8jxU
-07Xzs2vc/9NapAWxweIbc2rqrP31+Wa58gg0q36VYqV5Hs5DyoODJJMrRJI0SsOr
-Uly6ViIBd3ntjf4wXXn6pcPGD1tPCtMJsBeahrl+j2fLwbDmXlngn1a9d+gaKZG3
-z905BlsNgaw/MUszlHs/R1XNL+Emf+6XucNy+Ff5s2EC7TvtQB3rwo1/PjOfB2Bg
-WlggI8WFDxnBinI9Cy7YGYC+sGPPDe0bX3jmNwIDAQABAoIBMQCczBNyAStGqjjC
-oHuKHHWmTh9mPWFBFfDTv6/jXmvxRWPZtaHxH2Qp09Wejqv/D9MWy2ev7spx2oZS
-2Ai1ICjTbz83uAwryyW4Wen6aBTJSLCJiLstWk8ZU0DHHLjVH4FO4mwUPh95t5zC
-YDr2JXbXdY8xrc5vPxUFZNJjWvR61ZK37bQYpTn5mZ7r3KfsNk2yOylRTDwa9XFo
-ZZ+B82NKdrrz0UvGOnXZa5qd1ap7V+67FIAS2Mt8AMzSCG8TW0JXRUk89ISgAd8r
-NQTPtX9XCnMZSbBzDKdznXfHS9ZlJcSrpsbQCPcvMVNrdBfCF0eNnsRJffJGdaXI
-MsN6PvbcXWD08lXNGyeLjon03RdJnTAamNM3YQEIcjFmu5Y0o0CCJkZSCJPKJGMG
-0d/1tN/5AoGZANOcOgQZ9Wiu0ej3YoQ3aSHu3y8ZBJH4B3ViX8i+2x/6UnG7KNaa
-4Ygid1upnX6hk4CW5WZcoxGFacrFRpInKh5Ng8lEIHGp0VSzOBVDR0L5sAxutFuX
-6N9C0CuH80vD101mOloNnfT5KHZMI5RXqP6sDGUFlwak2XybDL1qOAza3gZAy25H
-vS/ll1BneBavikR5j+zxoTztAoGZAOJOJ5RyOrqpNuhiWZylah5LIFT9N1lCF4Hl
-ZbFIjUZ4jcApJ7JxkMXNQ4RU/3AiKCC1xr5ib7dd/qyjKXhdMo4SnLoKhapx5R9G
-3XOsQMahiCD/Zcymv9tmk8MxxzbLxhZYhEPzIP/NFkua3CHiX+d1e6fkzFLF/EiX
-ZGQOgRcFKrlzUeBputRQRXAkKJH+kMClgAWvy28zAoGYKyaMXhG9DV+4xjzMBhIW
-iijfsgbz+6AMRU+OIK1qmZa+ARsdNMXYf54noLVxvETOg0ZB+SGizwvZitO3lE4Q
-NKWx3fTaeNMcMJ1rLkrN2UZ5M8/PT24muoAxWu8aGbURzmKuO3bTYwT7z0OvbayC
-dYw36tG8/knXX6Vub6GdVGG9LKFB2nceiQnUVT0EK/wXwebYBoUvT/ECgZgF9qdG
-Wyg/CPyAbS8NWLKOL86fTrjpqjsyWhgu7smCROT/XlZEdoepHrqbvx2oF85U5lVh
-aPimrVxrsjUCjfoqEkV9BY/2KOAvzc9CIBTo5xLOQ8yr8uz1XCOiriogwIfsyNJb
-dAm3k/D1dxQ79FowoEDs8LONrtfyFcM4e8VdFO7GSkqrDj41IBRkWx+SkVHBMdtI
-yxQiTwKBmQCWym2iDCJg1ZZq4/lVwRudMhVmHoD0yoCAwADYHjjAi8QBplM0vfdd
-CESKsnBhlcrPGB279BKVJyZHehKZG+/dfnFs+to14l6A3IqU2d6+pu3EyFNX34HS
-xo+64QxMeF0akWnSaIPfUJfk36phjCvLBr4eLXN1i4jW3RdGFwF1THXt29VSSGmU
-q/hM51H0bsQ13AIVUSdNHA==
+MIISKgIBAAKCBAEAo0LJrGaQE7i7+eBEZKknY1mWLrpZuYGcM8/X0u0fytQqEhUM
+2k/q2Oymrr9c6WpX2RjbOM5hIhw7Cf4YVcQgtC+i9j6ppGYxU/abAJDxxDUTCLwW
+JULKyW0jY9PVHgXwEfrsdr5La3smXN1Bcqu+IkGx3lxbsw5x9ewWTEfJzLO9sAw+
+SUDGkZr7RLzpTbok+l+2Jbjuy93+BABmy4d7ODsQxziKrUl5BYzJYJqlN3ygbGfP
+RWJWB/79F+iLSu7TG8CY13mtYD6Jju6SB9h+ws00NgzS+nxkb6ghY2XrHmbnYEYc
+DS2M+u8gyrWdE746g90oRG6IeQsYy/vJLJJqHwX+FnBdM/MYNhraKQMBUFOmSPhS
+mKzW1L01nHsOEP0NGGtNaG3k17DimeyFQKOUsThUnQWvsEuCIHpJewNAvXfUE3bs
+QOH5w/kYcNHb2ai95QZ0orCLAiKP1iuoNi/4GL4ERv9woUYm33lvNa1PKuvjCSMe
+DwHd39cLxFhgFomGJx3xdKqcYXd1GFDf99cN4nWgOCwLkAjkn0BypxhIadIVZ4Ov
+B7HnJczFjR0hqCfgaTn8mAQgO+aiBlozPUS2ptidaoejg2FbPF1gXW56FoFowZbg
+nTEMlko2iQdJtpaHvjRkpwXWrRGnbKuPmsQboiq0q8+ykoiEnaMxBatlGvB1wJ7S
+CBixDj+K7XqddMP1S8Recv9y1f/KdSNG3rT76y9tuv82SUHqdW7baHS/WIdsTS5N
+iYfRncSMNQhiWEJi1scFGKWMqtOVkmcowvHtdMROKaP3+DrPPTY/SxtiHVtlSnTr
+J5EankyWghrSTqXHm8wUmx0NmFnEC4S0vwppsRAGli2bkFDjMfOXRk6J6r5nZi8I
+JikjUDEb7xCrfJcKgrsOZz5hch6Zyv5egfTgPehTvUW0sGDhJhytBCTOLWPLMGAr
+BmmHW9dzMx1tYNW57MmW12zjp9w28rnSFqSLzIScYwV2qQym96BjGnC3wLZVithr
+2MA91K0Icar8D3A54KjlipDbRqESq6ocW6egp6FMTBJ/S88PU5UgnBpV0KNZuAhd
+StMj+ws04JAUnpgLPFSDodMzQQiOlSldePK+Po/3jK7duVmsAABXXTbD0DBccXd5
+JMJFYvv2ACEi3gK0eeb7IPhWrKQ+KPyFyLBWJ1PxXzT5M9NgWlEf0c/fXb+3aDN5
+u3U9JE7mYshm8F8XmOTWIR34ZBJP9cDH6B0QRUo18A5iFOwlC31hORypX3BPRQUu
+FUeCy/W+2+s9WI/qzR1XkHyJU0k3l++veKwedc59hUQa/OXOk8X6W2buo9NHeakt
+J4a9eoLr0sSnVhZoYISZmZlg5JDHDmpGOTBt0QIDAQABAoIEAG4O1A2YhoAFBROK
+EBEbxyW+evO9REc+DKMQ9hmHKOt+422VKzjwrwzVW/hpoKTpv5bmnsJIvkpUZahy
+1szajoFpq5382DevfIlxsURMce8nKFG3Gea8hCANptHhN8YpkpFMaqQR3J30QwRP
+U5OOG3rUdqfD8z1d+40hPlbl/jA06ycG2eZf+Hyn0cOg5lYzqkHuy8faR4C/gkII
+U0PZbUOW7dSfVT1EToVjR04MclxZc3wg7yWDCSQSzWOUrHIzVbVbvK1lpW9AOVNV
+mLQZSjrgQtY9Bu09diefXAK57ipsjIXmPXrUvjlbguukSuPIVYIXUNHxAac3x9ub
+PR8DBO8tBwDxdqNSuXuf1nnXQMd53JtMa8Hoolp/wuhePDlPnchcba58hsywvdGu
+FJZisBZYNxIzhyB9hpeGWIrIwpf3c8w7W0DSFaH7BnLnxiGRE5KVK4ORJ+Skj/p9
+K8R7yfBECHYkNTVDKWl1X3b8AmaY5lB+kADl7UC8o34VZZFL3Ff6Y4+WhB1gfluK
+CbH2E7IaQYwchR7wH88Ljz79q7NKoItLxm6Vi5F73aEnhkzptOq64IFKJsC61Xca
+z3f6HneTh2sNTTmAJBUpjZDurPcG/iujHoBZVHbsSJ9Pfm3MRG4Au+mske/R+t/T
+N9fJZCeKSomYVnVZ+qyaGq4LwPjLFaliBb0C45RD/Eg3z081jwdhvNQr53ChgeX0
+FxJNEVYes0P2WxcGUPm613qCNY3q9LZR+eYtdCFVu4ZRcU789zMTE22h6UJPNyN/
+d6UcxVexuAFFR/vE16+1SvKlLvDnlMzydAoBSz+zyTopdvlvvWLTp5QUWMwpgvJn
+VNDq0mpYedS23qFHfjXvX/1JWfYHQJWBkH37E56d3+dtIeDWiPv9r0/96Mx2ivxy
+dlxKaCHgMiArbh86B8vFZGtoY/QCzSgeGIZhfUYP7Uq0JD+ohdaRjr1p4SHbEBlb
+9MqzbPDl80S0ebQftssxUhcu85CY1u/c/pm5Cw/SEM/86cFjqB+nPuGet48EZv0S
+Ck9QOfXvvmOX/EcR+mjCY0cCV+DMQFsQbO9F5aBNj23JNy3wMV8NNLdp7Gbp6Pw/
+qoUNWdK9cGH8myrSLyq+ckzJlSqIlu9GKA5FqhrQ1t84KC1F3KUhKEMsBSM5S6ay
+XYZup7czit7dsIkJXjyFMyspufg3ECMJWItjCzDJ/N97itFCI6nrlrVMyrRYxxmx
+Le0X4d2ie8IbVUp2YsJAsm2f88NV7N2lVkH88W6xbZamyYNuXom8IiPLScNqQahe
+xMysKBAUF58ilB2p/3TCrLhkISF5xve9USYpTuNSKh9mvxGdAsyjEOrqPrqidQ4A
+4fpJmAECggIBAM/raykBAvw0xn5NnMMuhX+F4eXOQtFlCEjyN/wCVh0K5W10ZFh8
+Rio/DNdJKE81TxdLs7Hp4tQ8yxV9fjTa7WooHWlQWeUOBZNCFyvlCG5f0C/netp/
+NFIqUCLurZ04Hmlh1QdS/CZ+s6Sh/qZoLZc1LnCfUu5zcpGNVnarlLtgr1ha2GdG
+f8l9KRE9HTTrSYZmhxZFt5m+tgtcqd2BBh2tKcgH2cOngoqQEhynmu7ygM+CDX2I
+4xAEuQh1cu/fptr3anS9PE5eG5H2rGPy3yQjePE1sqxtRUM9k0UVAlAyGdW1Zd9J
+QKBZfrcRXGAJlDg1ZOu1XIQBZFc+p+0KESjvZbYE2vN1lLPpjtfae591RRnA2UjL
+5zvZfJEliKVAopK3sAlZteJEfWkp9AyoNR3q9bNdCqT41APIAn5631AVSPPcKLwH
+kgwBQWlJjfpM3A8dw2FPw30O4anxoNz32CRYRWJgLLfmHPXK0aCx1/D6MI2Qb89v
+bm0qH0Q3fheJEVLG1OcK0JvMeiXwXJqpiV2L7zkl9fJeP1B06voffkXf+iOCwdzf
+DR2fxCheL3K2plBb5lO3pzFsuPeftHIbtzOdUCpxwWSHXqGIldDTQOcID5ufGts6
+0pA2heeISoiAKloOXY+M8wESygRDfXYnvj9YRX9DPNiZ1D0DShlwzQOhAoICAQDJ
+A6EEy2vVBnyjgvCnFH/JHYQRAQbrBy1nLzZQOWfpfw66Ja7T/QvWF5SbQfCVaCve
+yoIvkTtI/f53Fma9p1cdQbyB15u9p0dEeI6wYFreVyHHyZrXhAeybRoDj6DGRidT
+cta5IlAVs9Nk5Wb1w1bXxt4biWgwngpo3mbwrvxNVLH26Sm/3WbDXDgY+uJYmBN4
+XoLBgc+Dt7cyYYNr+Z3k6ntOZ9iMNXatPWT/dJiLK8msymFpmOB9rfTT/3lLeCM9
+J/93WuVlcvAIq26n1BqSXH+NL10wI1FiPZk+7YOX/QunKf9fJCD6qgtYIOZ7FmRi
+B29KgxHtLrzJYpYQ6IG1WOruwhpaDOrGE6nihhInZ5EWaOIcbhGVh5qidgDhbTBm
+uWqFxq6rcB715qFhLdrUkXcsxKQBWwMmkU1+GstItIjYQenKOW6oGhwNgq6jzUej
+bwYfo/bIslO44GfktLFayBuS7vzBbkyaTUJZgdtNnecvUacO+xs5qU126nama5A8
+kRcGdZyAx3L0W2E9GiRvAA283mU8geYHw3JlYJBtJGmhD3TyNKr23jm9WY6R8CTg
+CkZ83rVpwd2zaupUOrzv4RjUZTreQCFZbzxPpEcOAicjbXAVyBDlaiXlqASt3Zlx
+J1AbZLKIh4QqmrMj97C+bW4w/m3oAviGhIskHnk8MQKCAgEAyRreqml1FraBKxcs
+wkjUDRVU+u73CAvd6JiH9/PWkP7CDI1gpYmGYERdyjnTiFF6r4CkTTh5Emm+0Ily
+MfNzYZNtZzi1ymw2jkmFmgpMjl2UQ1F1LbONys9sdW1Adeoa2DktUIk+pIk2fs3F
+PfVT64Yf5gTktQjrTsdTUzMAiACreR1dZP72iM/LkgX3owDVO+8dSDikrkudTv4Q
+utOaM8gSuoyFX8484IMbUaX3oJjkaFFVdQ+a+BppUjovsr4zaGWZDVMf6njx18us
+0HvQwuagi0YyDL8gGDqNoGsCssjS3jc3UrJKlQ4bFzzuiWGagId8ltPzqSajhBNx
+Xz+2e06apWSq1oLrEt2cMUH9Aq3t6UvznorCnMvuxYF1Wslateh/l3uzBijS2I4g
+pMFppwdlIVij/A9FGmcxql50csQzrNNMfxofdAce2pSvg+MlkmVqXkxFPEfRk4vH
+2RLMd9L9QXrepf0oE8FZ40FBKa8EmViUHSKdv27XkSbPijokjFkPAm4eeiNcHigP
+mfTTjazU9QS3j/cC7HI5+TXO8A0Ep6ZIlrcTu4yVsanv4Nezo9RPwrfHOnH7sl9B
+rIEMQRsut+8RbIfWyw0OQ06h3xSX7CEHW/bYRW7HM7xKwx6cWEC+1CMzw90Fkvwo
+dMlaJXDev4osZyDa/SyaVmMZmSECggIBAJhqJAEarNyNWpwwgIBvTqUTuDucZ751
+ZrvCVJBntp6ZNHV4dSNPz1W583f1e5INtpXrPuMKX8VssTFizuwmoisQ2PoqnXAk
+Eimcr7SUmtHTh02RU9LtzVhA2WSx1tn//3mKrb0ag1axTyxFtNfMEWDy7R48BcA3
+VPVHDQ6Z37xS582r5XgRTAX9OpvWPyGlzb2LC+Hlp47cEhAlWBza3BnioTRGES/e
+qemZj6cSpUeBIB3gJhSHUlB5QhYss6/BnBaW6WF6jk1p5Q7tza17adpoQF6w9xu0
+69RtmHDabtkjiV5qvbNKFad6n7dm2tuhkuOxd3UsBL+unH6mPdr8ML1selYm3wxA
+lxMxfbLArasrIBu50xhzbOnQNDPS/b/vpq99D4P3riFXlmIlSWACANcEpTRQtXpB
+pBXuPq/LaS/rk4dGExq+iWT0xyiHWhvhXtxRJnd/P3PVox2fKaeESqXm7OFwTD3u
+gC7PPevYRoyHme+LHfyB8Za7BH2SMfzluivyZ18CdnQ+xq75SrWlyNJRXBlFF8XV
+SLHCRE8R9PCMl3sD2Ux9GtSsk2M7MJr/VzZ5FBFCXJOf55ZPDvZmwzOvncAOMaCr
+R54kdbp9eVLp1vtJ057wX79TyQBlcYbTa7EceeULaUOUXWZgfkxbVqxNFSwY/wTY
+m9CDV20/nfVBAoICAQDMfQKuLGK/d43i5twBsk2H+6jZah19ZA4ffYRjKcWfXbd6
+TxbNjGW23mfW49VD+/lNp8OdplL+ztqG+4kz+2k4npj+c0cVMFDbPpD0daMMFs+c
+AKVTc2g03a18Q+Q+5IFEY7VvCUfbYlHeqOBBNXtVQphtgjc8ZCTAYGXuytHKkhMg
+l5hYdicrimOK+7LZCe1vuUzxKTO1YTcrBlYerwbn95/JO7Rv3bWUbYXRGbGiQs9n
++MKsPY9qCSz2KihTNDotHgx1HENWK2HvlQOn65MU91LYcB3VGLibQaKUiXXV4BEA
+WVOTr+XKEJYD24J3v6cH+Ol0JNT+gYHO1CX1dhFL9AkgGBTtwDf8KcQCKfNU5384
+cUyT05BrXg4oWTOxdYFTGTQU95G10cPcAVyltPvPmiMCE0D+njsNWl3fDaRGhlku
+j4ogCD2UcnFQRbUtYhHffkbqohSpzRYYxlh0M0XhN6aPmOwm7RgjgCxch04HFgsE
+SSoW2zQ61YdR6NXXnMq0eyxTPejH/ycZLfb3EstmXYhsMftJebwwM3Ni+L8qqfg+
+7aJMGqq6CP+tXCjN88oaweZJbkhl14SmFA3TumqHmYSO4wFDA2Hf9c06fmXMewon
+lksq5bd72R9VfzBw44UyLoy3ae8MuQZTNoVkSKzedCxFtc/RBOm980Tnu/lp4Q==
-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index 8af83b3972..b4d630ee54 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -19,6 +19,8 @@
#include <QtNetwork/qtcpserver.h>
#include <QtNetwork/qsslpresharedkeyauthenticator.h>
+#include <QtTest/private/qemulationdetector_p.h>
+
#include <QTest>
#include <QNetworkProxy>
#include <QAuthenticator>
@@ -834,30 +836,30 @@ void tst_QSslSocket::simpleConnect()
// Entered connecting state
QCOMPARE(socket.state(), QAbstractSocket::ConnectingState);
- QCOMPARE(connectedSpy.count(), 0);
- QCOMPARE(hostFoundSpy.count(), 1);
- QCOMPARE(disconnectedSpy.count(), 0);
+ QCOMPARE(connectedSpy.size(), 0);
+ QCOMPARE(hostFoundSpy.size(), 1);
+ QCOMPARE(disconnectedSpy.size(), 0);
enterLoop(10);
// Entered connected state
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socket.mode(), QSslSocket::UnencryptedMode);
QVERIFY(!socket.isEncrypted());
- QCOMPARE(connectedSpy.count(), 1);
- QCOMPARE(hostFoundSpy.count(), 1);
- QCOMPARE(disconnectedSpy.count(), 0);
+ QCOMPARE(connectedSpy.size(), 1);
+ QCOMPARE(hostFoundSpy.size(), 1);
+ QCOMPARE(disconnectedSpy.size(), 0);
// Enter encrypted mode
socket.startClientEncryption();
QCOMPARE(socket.mode(), QSslSocket::SslClientMode);
QVERIFY(!socket.isEncrypted());
- QCOMPARE(connectionEncryptedSpy.count(), 0);
- QCOMPARE(sslErrorsSpy.count(), 0);
+ QCOMPARE(connectionEncryptedSpy.size(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 0);
// Starting handshake
enterLoop(10);
- QCOMPARE(sslErrorsSpy.count(), 1);
- QCOMPARE(connectionEncryptedSpy.count(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 1);
+ QCOMPARE(connectionEncryptedSpy.size(), 0);
QVERIFY(!socket.isEncrypted());
QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState);
}
@@ -895,10 +897,10 @@ void tst_QSslSocket::simpleConnectWithIgnore()
enterLoop(10);
// Done; encryption should be enabled.
- QCOMPARE(sslErrorsSpy.count(), 1);
+ QCOMPARE(sslErrorsSpy.size(), 1);
QVERIFY(socket.isEncrypted());
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
- QCOMPARE(encryptedSpy.count(), 1);
+ QCOMPARE(encryptedSpy.size(), 1);
// Wait for incoming data
if (!socket.canReadLine())
@@ -968,7 +970,7 @@ void tst_QSslSocket::sslErrors()
// check the same errors were emitted by sslErrors
QVERIFY(!sslErrorsSpy.isEmpty());
SslErrorList emittedErrors;
- const auto sslErrorsSpyErrors = qvariant_cast<QList<QSslError> >(qAsConst(sslErrorsSpy).first().first());
+ const auto sslErrorsSpyErrors = qvariant_cast<QList<QSslError> >(std::as_const(sslErrorsSpy).first().first());
for (const QSslError &err : sslErrorsSpyErrors)
emittedErrors << err.error();
std::sort(emittedErrors.begin(), emittedErrors.end());
@@ -1017,7 +1019,7 @@ void tst_QSslSocket::ciphers()
QString ciphersAsString;
const auto &supported = sslConfig.supportedCiphers();
for (const auto &cipher : supported) {
- if (cipher.isNull() || !cipher.name().length())
+ if (cipher.isNull() || !cipher.name().size())
continue;
if (ciphers.size() > 0)
ciphersAsString += QStringLiteral(":");
@@ -1235,7 +1237,7 @@ void tst_QSslSocket::peerCertificateChain()
QSslSocketPtr socket = newSocket();
this->socket = socket.data();
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(httpServerCertChainPath());
- QCOMPARE(caCertificates.count(), 1);
+ QCOMPARE(caCertificates.size(), 1);
auto config = socket->sslConfiguration();
config.addCaCertificates(caCertificates);
socket->setSslConfiguration(config);
@@ -1252,7 +1254,7 @@ void tst_QSslSocket::peerCertificateChain()
QSKIP("Skipping flaky test - See QTBUG-29941");
QList<QSslCertificate> certChain = socket->peerCertificateChain();
- QVERIFY(certChain.count() > 0);
+ QVERIFY(certChain.size() > 0);
QCOMPARE(certChain.first(), socket->peerCertificate());
socket->disconnectFromHost();
@@ -1561,24 +1563,18 @@ void tst_QSslSocket::protocolServerSide_data()
QTest::addColumn<QSsl::SslProtocol>("clientProtocol");
QTest::addColumn<bool>("works");
- QTest::newRow("tls1.0-tls1.0") << Test::TlsV1_0 << Test::TlsV1_0 << true;
QTest::newRow("any-any") << QSsl::AnyProtocol << QSsl::AnyProtocol << true;
QTest::newRow("secure-secure") << QSsl::SecureProtocols << QSsl::SecureProtocols << true;
QTest::newRow("tls1.0-secure") << Test::TlsV1_0 << QSsl::SecureProtocols << false;
- QTest::newRow("tls1.0-any") << Test::TlsV1_0 << QSsl::AnyProtocol << true;
-
QTest::newRow("secure-tls1.0") << QSsl::SecureProtocols << Test::TlsV1_0 << false;
QTest::newRow("secure-any") << QSsl::SecureProtocols << QSsl::AnyProtocol << true;
- QTest::newRow("tls1.0orlater-tls1.0") << Test::TlsV1_0OrLater << Test::TlsV1_0 << true;
- QTest::newRow("tls1.0orlater-tls1.1") << Test::TlsV1_0OrLater << Test::TlsV1_1 << true;
QTest::newRow("tls1.0orlater-tls1.2") << Test::TlsV1_0OrLater << QSsl::TlsV1_2 << true;
if (supportsTls13())
QTest::newRow("tls1.0orlater-tls1.3") << Test::TlsV1_0OrLater << QSsl::TlsV1_3 << true;
QTest::newRow("tls1.1orlater-tls1.0") << Test::TlsV1_1OrLater << Test::TlsV1_0 << false;
- QTest::newRow("tls1.1orlater-tls1.1") << Test::TlsV1_1OrLater << Test::TlsV1_1 << true;
QTest::newRow("tls1.1orlater-tls1.2") << Test::TlsV1_1OrLater << QSsl::TlsV1_2 << true;
if (supportsTls13())
@@ -1595,7 +1591,6 @@ void tst_QSslSocket::protocolServerSide_data()
QTest::newRow("tls1.3orlater-tls1.3") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_3 << true;
}
- QTest::newRow("any-tls1.0") << QSsl::AnyProtocol << Test::TlsV1_0 << true;
QTest::newRow("any-secure") << QSsl::AnyProtocol << QSsl::SecureProtocols << true;
}
@@ -1663,11 +1658,28 @@ void tst_QSslSocket::serverCipherPreferences()
if (setProxy)
return;
- // First using the default (server preference)
+ QSslCipher testedCiphers[2];
{
+ // First using the default (server preference)
+ const auto supportedCiphers = QSslConfiguration::supportedCiphers();
+ int nSet = 0;
+ for (const auto &cipher : supportedCiphers) {
+ // Ciphersuites from TLS 1.2 and 1.3 are set separately,
+ // let's select 1.3 or above explicitly.
+ if (cipher.protocol() < QSsl::TlsV1_3)
+ continue;
+
+ testedCiphers[nSet++] = cipher;
+ if (nSet == 2)
+ break;
+ }
+
+ if (nSet != 2)
+ QSKIP("Failed to find two proper ciphersuites to test, bailing out.");
+
SslServer server;
- server.protocol = Test::TlsV1_0;
- server.ciphers = {QSslCipher("AES128-SHA"), QSslCipher("AES256-SHA")};
+ server.protocol = QSsl::TlsV1_2OrLater;
+ server.ciphers = {testedCiphers[0], testedCiphers[1]};
QVERIFY(server.listen());
QEventLoop loop;
@@ -1677,8 +1689,8 @@ void tst_QSslSocket::serverCipherPreferences()
socket = &client;
auto sslConfig = socket->sslConfiguration();
- sslConfig.setProtocol(Test::TlsV1_0OrLater);
- sslConfig.setCiphers({QSslCipher("AES256-SHA"), QSslCipher("AES128-SHA")});
+ sslConfig.setProtocol(QSsl::TlsV1_2OrLater);
+ sslConfig.setCiphers({testedCiphers[1], testedCiphers[0]});
socket->setSslConfiguration(sslConfig);
// upon SSL wrong version error, errorOccurred will be triggered, not sslErrors
@@ -1691,17 +1703,19 @@ void tst_QSslSocket::serverCipherPreferences()
loop.exec();
QVERIFY(client.isEncrypted());
- QCOMPARE(client.sessionCipher().name(), QString("AES128-SHA"));
+ QCOMPARE(client.sessionCipher().name(), testedCiphers[0].name());
}
{
+ if (QTestPrivate::isRunningArmOnX86())
+ QSKIP("This test is known to crash on QEMU emulation for no good reason.");
// Now using the client preferences
SslServer server;
QSslConfiguration config = QSslConfiguration::defaultConfiguration();
config.setSslOption(QSsl::SslOptionDisableServerCipherPreference, true);
server.config = config;
- server.protocol = Test::TlsV1_0OrLater;
- server.ciphers = {QSslCipher("AES128-SHA"), QSslCipher("AES256-SHA")};
+ server.protocol = QSsl::TlsV1_2OrLater;
+ server.ciphers = {testedCiphers[0], testedCiphers[1]};
QVERIFY(server.listen());
QEventLoop loop;
@@ -1711,8 +1725,8 @@ void tst_QSslSocket::serverCipherPreferences()
socket = &client;
auto sslConfig = socket->sslConfiguration();
- sslConfig.setProtocol(Test::TlsV1_0);
- sslConfig.setCiphers({QSslCipher("AES256-SHA"), QSslCipher("AES128-SHA")});
+ sslConfig.setProtocol(QSsl::TlsV1_2OrLater);
+ sslConfig.setCiphers({testedCiphers[1], testedCiphers[0]});
socket->setSslConfiguration(sslConfig);
// upon SSL wrong version error, errorOccurred will be triggered, not sslErrors
@@ -1725,7 +1739,7 @@ void tst_QSslSocket::serverCipherPreferences()
loop.exec();
QVERIFY(client.isEncrypted());
- QCOMPARE(client.sessionCipher().name(), QString("AES256-SHA"));
+ QCOMPARE(client.sessionCipher().name(), testedCiphers[1].name());
}
}
@@ -1807,8 +1821,10 @@ void tst_QSslSocket::setLocalCertificateChain()
}
QCOMPARE(chain.size(), 2);
- QCOMPARE(chain[0].serialNumber(), QByteArray("10:a0:ad:77:58:f6:6e:ae:46:93:a3:43:f9:59:8a:9e"));
- QCOMPARE(chain[1].serialNumber(), QByteArray("3b:eb:99:c5:ea:d8:0b:5d:0b:97:5d:4f:06:75:4b:e1"));
+ QCOMPARE(chain[0].serialNumber(),
+ QByteArray("58:df:33:c1:9b:bc:c5:51:7a:00:86:64:43:94:41:e2:26:ef:3f:89"));
+ QCOMPARE(chain[1].serialNumber(),
+ QByteArray("11:72:34:bc:21:e6:ca:04:24:13:f8:35:48:84:a6:e9:de:96:22:15"));
}
void tst_QSslSocket::tlsConfiguration()
@@ -2813,7 +2829,7 @@ void tst_QSslSocket::closeWhileEmittingSocketError()
QTestEventLoop::instance().enterLoopMSecs(1000);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(socketErrorSpy.count(), 1);
+ QCOMPARE(socketErrorSpy.size(), 1);
}
#endif // Feature 'openssl'.
@@ -2910,7 +2926,7 @@ void tst_QSslSocket::ignoreSslErrorsList()
bool expectEncryptionSuccess = (expectedSslErrorSignalCount == 0);
if (socket.waitForEncrypted(10000) != expectEncryptionSuccess)
QSKIP("Skipping flaky test - See QTBUG-29941");
- QCOMPARE(sslErrorsSpy.count(), expectedSslErrorSignalCount);
+ QCOMPARE(sslErrorsSpy.size(), expectedSslErrorSignalCount);
}
void tst_QSslSocket::ignoreSslErrorsListWithSlot_data()
@@ -3070,7 +3086,7 @@ void tst_QSslSocket::blacklistedCertificates()
connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop()));
enterLoop(1);
QList<QSslError> sslErrors = receiver->sslHandshakeErrors();
- QVERIFY(sslErrors.count() > 0);
+ QVERIFY(sslErrors.size() > 0);
// there are more errors (self signed cert and hostname mismatch), but we only care about the blacklist error
QCOMPARE(sslErrors.at(0).error(), QSslError::CertificateBlacklisted);
}
@@ -3154,9 +3170,9 @@ void tst_QSslSocket::resume()
QFETCH_GLOBAL(bool, setProxy);
if (setProxy && QTestEventLoop::instance().timeout())
QSKIP("Skipping flaky test - See QTBUG-29941");
- QCOMPARE(sslErrorSpy.count(), 1);
- QCOMPARE(errorSpy.count(), 0);
- QCOMPARE(encryptedSpy.count(), 0);
+ QCOMPARE(sslErrorSpy.size(), 1);
+ QCOMPARE(errorSpy.size(), 0);
+ QCOMPARE(encryptedSpy.size(), 0);
QVERIFY(!socket.isEncrypted());
if (ignoreErrorsAfterPause) {
if (errorsToIgnore.empty())
@@ -3168,15 +3184,15 @@ void tst_QSslSocket::resume()
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout()); // quit by encrypted() or error() signal
if (expectSuccess) {
- QCOMPARE(encryptedSpy.count(), 1);
+ QCOMPARE(encryptedSpy.size(), 1);
QVERIFY(socket.isEncrypted());
- QCOMPARE(errorSpy.count(), 0);
+ QCOMPARE(errorSpy.size(), 0);
socket.disconnectFromHost();
QVERIFY(socket.waitForDisconnected(10000));
} else {
- QCOMPARE(encryptedSpy.count(), 0);
+ QCOMPARE(encryptedSpy.size(), 0);
QVERIFY(!socket.isEncrypted());
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(socket.error(), QAbstractSocket::SslHandshakeFailedError);
}
}
@@ -3363,17 +3379,17 @@ void tst_QSslSocket::qtbug18498_peek2()
bigblock.fill('#', QIODEVICE_BUFFERSIZE + 1024);
QVERIFY(client->write(QByteArray("head")));
QVERIFY(client->write(bigblock));
- QTRY_COMPARE(server->bytesAvailable(), bigblock.length() + 4);
+ QTRY_COMPARE(server->bytesAvailable(), bigblock.size() + 4);
QCOMPARE(server->read(4), QByteArray("head"));
- QCOMPARE(server->peek(bigblock.length()), bigblock);
- b.reserve(bigblock.length());
- b.resize(server->peek(b.data(), bigblock.length()));
+ QCOMPARE(server->peek(bigblock.size()), bigblock);
+ b.reserve(bigblock.size());
+ b.resize(server->peek(b.data(), bigblock.size()));
QCOMPARE(b, bigblock);
//check oversized peek
- QCOMPARE(server->peek(bigblock.length() * 3), bigblock);
- b.reserve(bigblock.length() * 3);
- b.resize(server->peek(b.data(), bigblock.length() * 3));
+ QCOMPARE(server->peek(bigblock.size() * 3), bigblock);
+ b.reserve(bigblock.size() * 3);
+ b.resize(server->peek(b.data(), bigblock.size() * 3));
QCOMPARE(b, bigblock);
QCOMPARE(server->readAll(), bigblock);
@@ -3667,7 +3683,7 @@ void tst_QSslSocket::verifyClientCertificate()
}
SslServer server;
- server.protocol = Test::TlsV1_0;
+ server.protocol = QSsl::TlsV1_2;
server.addCaCertificates = testDataDir + "certs/bogus-ca.crt";
server.ignoreSslErrors = false;
server.peerVerifyMode = peerVerifyMode;
@@ -3709,7 +3725,7 @@ void tst_QSslSocket::verifyClientCertificate()
} else {
QCOMPARE(server.socket->peerCertificate(), clientCerts.first());
if (isTestingSchannel) {
- if (clientCerts.count() == 1 && server.socket->peerCertificateChain().count() == 2) {
+ if (clientCerts.size() == 1 && server.socket->peerCertificateChain().size() == 2) {
QEXPECT_FAIL("",
"Schannel includes the entire chain, not just the leaf and intermediates",
Continue);
@@ -4069,14 +4085,14 @@ void tst_QSslSocket::simplePskConnect()
case PskConnectWrongCredentials:
// provide totally wrong credentials
- provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.length() - 1));
- provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.length() - 1));
+ provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.size() - 1));
+ provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.size() - 1));
connect(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), &provider, SLOT(providePsk(QSslPreSharedKeyAuthenticator*)));
break;
case PskConnectWrongIdentity:
// right PSK, wrong identity
- provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.length() - 1));
+ provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.size() - 1));
provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY);
connect(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), &provider, SLOT(providePsk(QSslPreSharedKeyAuthenticator*)));
break;
@@ -4084,7 +4100,7 @@ void tst_QSslSocket::simplePskConnect()
case PskConnectWrongPreSharedKey:
// right identity, wrong PSK
provider.setIdentity(PSK_CLIENT_IDENTITY);
- provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.length() - 1));
+ provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.size() - 1));
connect(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), &provider, SLOT(providePsk(QSslPreSharedKeyAuthenticator*)));
break;
@@ -4136,32 +4152,32 @@ void tst_QSslSocket::simplePskConnect()
// Entered connecting state
QCOMPARE(socket.state(), QAbstractSocket::ConnectingState);
- QCOMPARE(connectedSpy.count(), 0);
- QCOMPARE(hostFoundSpy.count(), 1);
- QCOMPARE(disconnectedSpy.count(), 0);
+ QCOMPARE(connectedSpy.size(), 0);
+ QCOMPARE(hostFoundSpy.size(), 1);
+ QCOMPARE(disconnectedSpy.size(), 0);
enterLoop(10);
// Entered connected state
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socket.mode(), QSslSocket::UnencryptedMode);
QVERIFY(!socket.isEncrypted());
- QCOMPARE(connectedSpy.count(), 1);
- QCOMPARE(hostFoundSpy.count(), 1);
- QCOMPARE(disconnectedSpy.count(), 0);
+ QCOMPARE(connectedSpy.size(), 1);
+ QCOMPARE(hostFoundSpy.size(), 1);
+ QCOMPARE(disconnectedSpy.size(), 0);
// Enter encrypted mode
socket.startClientEncryption();
QCOMPARE(socket.mode(), QSslSocket::SslClientMode);
QVERIFY(!socket.isEncrypted());
- QCOMPARE(connectionEncryptedSpy.count(), 0);
- QCOMPARE(sslErrorsSpy.count(), 0);
- QCOMPARE(peerVerifyErrorSpy.count(), 0);
+ QCOMPARE(connectionEncryptedSpy.size(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 0);
+ QCOMPARE(peerVerifyErrorSpy.size(), 0);
// Start handshake.
enterLoop(10);
// We must get the PSK signal in all cases
- QCOMPARE(pskAuthenticationRequiredSpy.count(), 1);
+ QCOMPARE(pskAuthenticationRequiredSpy.size(), 1);
switch (pskTestType) {
case PskConnectDoNotHandlePsk:
@@ -4170,40 +4186,40 @@ void tst_QSslSocket::simplePskConnect()
case PskConnectWrongIdentity:
case PskConnectWrongPreSharedKey:
// Handshake failure
- QCOMPARE(socketErrorsSpy.count(), 1);
+ QCOMPARE(socketErrorsSpy.size(), 1);
QCOMPARE(qvariant_cast<QAbstractSocket::SocketError>(socketErrorsSpy.at(0).at(0)), QAbstractSocket::SslHandshakeFailedError);
- QCOMPARE(sslErrorsSpy.count(), 0);
- QCOMPARE(peerVerifyErrorSpy.count(), 0);
- QCOMPARE(connectionEncryptedSpy.count(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 0);
+ QCOMPARE(peerVerifyErrorSpy.size(), 0);
+ QCOMPARE(connectionEncryptedSpy.size(), 0);
QVERIFY(!socket.isEncrypted());
break;
case PskConnectRightCredentialsPeerVerifyFailure:
// Peer verification failure
- QCOMPARE(socketErrorsSpy.count(), 1);
+ QCOMPARE(socketErrorsSpy.size(), 1);
QCOMPARE(qvariant_cast<QAbstractSocket::SocketError>(socketErrorsSpy.at(0).at(0)), QAbstractSocket::SslHandshakeFailedError);
- QCOMPARE(sslErrorsSpy.count(), 1);
- QCOMPARE(peerVerifyErrorSpy.count(), 1);
- QCOMPARE(connectionEncryptedSpy.count(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 1);
+ QCOMPARE(peerVerifyErrorSpy.size(), 1);
+ QCOMPARE(connectionEncryptedSpy.size(), 0);
QVERIFY(!socket.isEncrypted());
break;
case PskConnectRightCredentialsVerifyPeer:
// Peer verification failure, but ignore it and keep connecting
- QCOMPARE(socketErrorsSpy.count(), 0);
- QCOMPARE(sslErrorsSpy.count(), 1);
- QCOMPARE(peerVerifyErrorSpy.count(), 1);
- QCOMPARE(connectionEncryptedSpy.count(), 1);
+ QCOMPARE(socketErrorsSpy.size(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 1);
+ QCOMPARE(peerVerifyErrorSpy.size(), 1);
+ QCOMPARE(connectionEncryptedSpy.size(), 1);
QVERIFY(socket.isEncrypted());
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
break;
case PskConnectRightCredentialsDoNotVerifyPeer:
// No peer verification => no failure
- QCOMPARE(socketErrorsSpy.count(), 0);
- QCOMPARE(sslErrorsSpy.count(), 0);
- QCOMPARE(peerVerifyErrorSpy.count(), 0);
- QCOMPARE(connectionEncryptedSpy.count(), 1);
+ QCOMPARE(socketErrorsSpy.size(), 0);
+ QCOMPARE(sslErrorsSpy.size(), 0);
+ QCOMPARE(peerVerifyErrorSpy.size(), 0);
+ QCOMPARE(connectionEncryptedSpy.size(), 1);
QVERIFY(socket.isEncrypted());
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
break;
@@ -4244,7 +4260,7 @@ void tst_QSslSocket::simplePskConnect()
}
QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState);
- QCOMPARE(disconnectedSpy.count(), 1);
+ QCOMPARE(disconnectedSpy.size(), 1);
}
void tst_QSslSocket::ephemeralServerKey_data()
@@ -4277,7 +4293,7 @@ void tst_QSslSocket::ephemeralServerKey()
client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
spy.wait();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(server.config.ephemeralServerKey().isNull());
QCOMPARE(client->sslConfiguration().ephemeralServerKey().isNull(), emptyKey);
}
@@ -4340,22 +4356,22 @@ void tst_QSslSocket::pskServer()
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socket.mode(), QSslSocket::UnencryptedMode);
QVERIFY(!socket.isEncrypted());
- QCOMPARE(connectedSpy.count(), 1);
- QCOMPARE(disconnectedSpy.count(), 0);
+ QCOMPARE(connectedSpy.size(), 1);
+ QCOMPARE(disconnectedSpy.size(), 0);
// Enter encrypted mode
socket.startClientEncryption();
QCOMPARE(socket.mode(), QSslSocket::SslClientMode);
QVERIFY(!socket.isEncrypted());
- QCOMPARE(connectionEncryptedSpy.count(), 0);
+ QCOMPARE(connectionEncryptedSpy.size(), 0);
// Start handshake.
enterLoop(10);
// We must get the PSK signal in all cases
- QCOMPARE(pskAuthenticationRequiredSpy.count(), 1);
+ QCOMPARE(pskAuthenticationRequiredSpy.size(), 1);
- QCOMPARE(connectionEncryptedSpy.count(), 1);
+ QCOMPARE(connectionEncryptedSpy.size(), 1);
QVERIFY(socket.isEncrypted());
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
@@ -4368,7 +4384,7 @@ void tst_QSslSocket::pskServer()
enterLoop(10);
QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState);
- QCOMPARE(disconnectedSpy.count(), 1);
+ QCOMPARE(disconnectedSpy.size(), 1);
}
void tst_QSslSocket::signatureAlgorithm_data()
@@ -4521,7 +4537,7 @@ void tst_QSslSocket::forwardReadChannelFinished()
&QTestEventLoop::instance(), &QTestEventLoop::exitLoop);
socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443);
enterLoop(10);
- QVERIFY(readChannelFinishedSpy.count());
+ QVERIFY(readChannelFinishedSpy.size());
}
#endif // QT_CONFIG(openssl)
@@ -4603,13 +4619,15 @@ void tst_QSslSocket::oldErrorsOnSocketReuse()
if (setProxy)
return; // not relevant
SslServer server;
- server.protocol = Test::TlsV1_1;
+ if (!isTestingOpenSsl)
+ server.protocol = Test::TlsV1_1;
server.m_certFile = testDataDir + "certs/fluke.cert";
server.m_keyFile = testDataDir + "certs/fluke.key";
QVERIFY(server.listen(QHostAddress::SpecialAddress::LocalHost));
QSslSocket socket;
- socket.setProtocol(Test::TlsV1_1);
+ if (!isTestingOpenSsl)
+ socket.setProtocol(Test::TlsV1_1);
QList<QSslError> errorList;
auto connection = connect(&socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors),
[&socket, &errorList](const QList<QSslError> &errors) {
@@ -4706,8 +4724,8 @@ void tst_QSslSocket::alertMissingCertificate()
runner.enterLoopMSecs(10000);
}
- QVERIFY(serverSpy.count() > 0);
- QVERIFY(clientSpy.count() > 0);
+ QVERIFY(serverSpy.size() > 0);
+ QVERIFY(clientSpy.size() > 0);
QVERIFY(server.socket && !server.socket->isEncrypted());
QVERIFY(!clientSocket.isEncrypted());
}
@@ -4760,9 +4778,9 @@ void tst_QSslSocket::alertInvalidCertificate()
runner.enterLoopMSecs(1000);
- QVERIFY(serverSpy.count() > 0);
- QVERIFY(clientSpy.count() > 0);
- QVERIFY(interruptedSpy.count() > 0);
+ QVERIFY(serverSpy.size() > 0);
+ QVERIFY(clientSpy.size() > 0);
+ QVERIFY(interruptedSpy.size() > 0);
QVERIFY(server.socket && !server.socket->isEncrypted());
QVERIFY(!clientSocket.isEncrypted());
}
@@ -4889,14 +4907,14 @@ void tst_QSslSocket::selfSignedCertificates()
runner.enterLoopMSecs(1000);
if (clientKnown) {
- QCOMPARE(serverSpy.count(), 0);
- QCOMPARE(clientSpy.count(), 0);
+ QCOMPARE(serverSpy.size(), 0);
+ QCOMPARE(clientSpy.size(), 0);
QVERIFY(server.socket && server.socket->isEncrypted());
QVERIFY(clientSocket.isEncrypted());
} else {
- QVERIFY(serverSpy.count() > 0);
+ QVERIFY(serverSpy.size() > 0);
QEXPECT_FAIL("", "Failing to trigger signal, QTBUG-81661", Continue);
- QVERIFY(clientSpy.count() > 0);
+ QVERIFY(clientSpy.size() > 0);
QVERIFY(server.socket && !server.socket->isEncrypted());
QVERIFY(!clientSocket.isEncrypted());
}
@@ -5027,15 +5045,15 @@ void tst_QSslSocket::pskHandshake()
runner.enterLoopMSecs(1000);
if (pskRight) {
- QCOMPARE(serverSpy.count(), 0);
- QCOMPARE(clientSpy.count(), 0);
+ QCOMPARE(serverSpy.size(), 0);
+ QCOMPARE(clientSpy.size(), 0);
QVERIFY(server.socket && server.socket->isEncrypted());
QVERIFY(clientSocket.isEncrypted());
} else {
- QVERIFY(serverSpy.count() > 0);
+ QVERIFY(serverSpy.size() > 0);
QCOMPARE(serverSpy.first().at(0).toInt(), static_cast<int>(QSsl::AlertLevel::Fatal));
QCOMPARE(serverSpy.first().at(1).toInt(), static_cast<int>(QSsl::AlertType::BadRecordMac));
- QVERIFY(clientSpy.count() > 0);
+ QVERIFY(clientSpy.size() > 0);
QCOMPARE(clientSpy.first().at(0).toInt(), static_cast<int>(QSsl::AlertLevel::Fatal));
QCOMPARE(clientSpy.first().at(1).toInt(), static_cast<int>(QSsl::AlertType::BadRecordMac));
QVERIFY(server.socket && !server.socket->isEncrypted());
diff --git a/tests/auto/network/ssl/shared/qopenssl_symbols.h b/tests/auto/network/ssl/shared/qopenssl_symbols.h
index 13cacc5317..7f1f6c8285 100644
--- a/tests/auto/network/ssl/shared/qopenssl_symbols.h
+++ b/tests/auto/network/ssl/shared/qopenssl_symbols.h
@@ -405,7 +405,7 @@ struct LibGreaterThan
{
const auto lhsparts = lhs.split(QLatin1Char('.'));
const auto rhsparts = rhs.split(QLatin1Char('.'));
- Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
+ Q_ASSERT(lhsparts.size() > 1 && rhsparts.size() > 1);
// note: checking rhs < lhs, the same as lhs > rhs
return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(),
@@ -481,7 +481,7 @@ QStringList findAllLibs(QLatin1String filter)
QStringList entryList = dir.entryList(filters, QDir::Files);
std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
- for (const QString &entry : qAsConst(entryList))
+ for (const QString &entry : std::as_const(entryList))
found << path + QLatin1Char('/') + entry;
}
diff --git a/tests/auto/network/ssl/shared/tlshelpers.h b/tests/auto/network/ssl/shared/tlshelpers.h
index aa5f2c3c58..71db837d4b 100644
--- a/tests/auto/network/ssl/shared/tlshelpers.h
+++ b/tests/auto/network/ssl/shared/tlshelpers.h
@@ -12,13 +12,8 @@
#include <QtCore/qstring.h>
#include <QtCore/qglobal.h>
-// TODO: these 'helpers' later to include OpenSSL resolver/sumbols
-// required by some auto-tests.
-
QT_BEGIN_NAMESPACE
-
-
namespace TlsAux {
inline bool classImplemented(QSsl::ImplementedClass cl)
diff --git a/tests/auto/other/android/CMakeLists.txt b/tests/auto/other/android/CMakeLists.txt
deleted file mode 100644
index c2749825ac..0000000000
--- a/tests/auto/other/android/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Generated from android.pro.
-
-#####################################################################
-## tst_android Test:
-#####################################################################
-
-qt_internal_add_test(tst_android
- SOURCES
- tst_android.cpp
-)
-
-if(ANDROID)
- set_property(TARGET tst_android APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
- ${CMAKE_CURRENT_SOURCE_DIR}/testdata
- )
- # QTBUG-88840 # special case
- qt_android_generate_deployment_settings(tst_android) # special case
-endif()
-
-#### Keys ignored in scope 1:.:.:android.pro:<TRUE>:
-# DISTFILES = "testdata/assets/test.txt"
diff --git a/tests/auto/other/android/tst_android.cpp b/tests/auto/other/android/tst_android.cpp
deleted file mode 100644
index 938ff3c9b2..0000000000
--- a/tests/auto/other/android/tst_android.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include <jni.h>
-
-#include <QTest>
-#include <QtCore/qnativeinterface.h>
-#include <QtCore/qjniobject.h>
-
-class tst_Android : public QObject
-{
-Q_OBJECT
-private slots:
- void assetsRead();
- void assetsNotWritable();
- void testAndroidSdkVersion();
- void testAndroidActivity();
-};
-
-void tst_Android::assetsRead()
-{
- {
- QFile file(QStringLiteral("assets:/test.txt"));
- QVERIFY(file.open(QIODevice::ReadOnly));
- QCOMPARE(file.readAll(), QByteArray("FooBar"));
- }
-
- {
- QFile file(QStringLiteral("assets:/test.txt"));
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
- QCOMPARE(file.readAll(), QByteArray("FooBar"));
- }
-}
-
-void tst_Android::assetsNotWritable()
-{
- QFile file(QStringLiteral("assets:/test.txt"));
- QVERIFY(!file.open(QIODevice::WriteOnly));
- QVERIFY(!file.open(QIODevice::ReadWrite));
- QVERIFY(!file.open(QIODevice::Append));
-}
-
-void tst_Android::testAndroidSdkVersion()
-{
- QVERIFY(QNativeInterface::QAndroidApplication::sdkVersion() > 0);
-}
-
-void tst_Android::testAndroidActivity()
-{
- QJniObject activity = QNativeInterface::QAndroidApplication::context();
- QVERIFY(activity.isValid());
- QVERIFY(activity.callMethod<jboolean>("isTaskRoot"));
-}
-
-QTEST_MAIN(tst_Android)
-#include "tst_android.moc"
-
diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST
index 5b4f12b80d..494005abf3 100644
--- a/tests/auto/other/gestures/BLACKLIST
+++ b/tests/auto/other/gestures/BLACKLIST
@@ -1,32 +1,10 @@
-[]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
[customGesture]
opensuse-leap
# QTBUG-67254
opensuse-42.3
-[graphicsItemGesture]
-ubuntu-18.04
-ubuntu-20.04
-rhel
-centos
-[graphicsItemTreeGesture]
-ubuntu-18.04
-ubuntu-20.04
-[graphicsView]
-ubuntu-18.04
-ubuntu-20.04
-rhel
-centos
-[explicitGraphicsObjectTarget]
-ubuntu-18.04
+[panelPropagation]
ubuntu-20.04
-rhel
-centos
-[autoCancelGestures2]
-ubuntu-18.04
+ubuntu-22.04 ci
+[panelStacksBehindParent]
ubuntu-20.04
-rhel
-centos
+ubuntu-22.04 ci
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp
index 81b186c0a1..ac85872b1d 100644
--- a/tests/auto/other/gestures/tst_gestures.cpp
+++ b/tests/auto/other/gestures/tst_gestures.cpp
@@ -282,6 +282,10 @@ Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
+
+ void init();
+ void cleanup();
+
void customGesture();
void autoCancelingGestures();
void gestureOverChild();
@@ -318,16 +322,28 @@ private slots:
void testQGestureRecognizerCleanup();
void testReuseCanceledGestures();
void bug_13501_gesture_not_accepted();
+private:
+ QPoint m_availableTopLeft;
};
void tst_Gestures::initTestCase()
{
+ const QScreen *screen = QGuiApplication::primaryScreen();
+ m_availableTopLeft = screen->availableGeometry().topLeft();
+}
+
+void tst_Gestures::cleanupTestCase()
+{
+}
+
+void tst_Gestures::init()
+{
CustomGesture::GestureType = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
QVERIFY(CustomGesture::GestureType != Qt::GestureType(0));
QVERIFY(CustomGesture::GestureType != Qt::CustomGesture);
}
-void tst_Gestures::cleanupTestCase()
+void tst_Gestures::cleanup()
{
QGestureRecognizer::unregisterRecognizer(CustomGesture::GestureType);
}
@@ -571,6 +587,9 @@ void tst_Gestures::conflictingGestures()
child->reset();
Qt::GestureType ContinuousGesture = QGestureRecognizer::registerRecognizer(new CustomContinuousGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([ContinuousGesture]{
+ QGestureRecognizer::unregisterRecognizer(ContinuousGesture);
+ });
static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
child->grabGesture(ContinuousGesture);
// child accepts override. And it also receives another custom gesture.
@@ -580,11 +599,9 @@ void tst_Gestures::conflictingGestures()
QCOMPARE(child->gestureOverrideEventsReceived, 1);
QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount);
- QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount);
+ QCOMPARE(child->events.all.size(), TotalGestureEventsCount + ContinuousGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, 0);
-
- QGestureRecognizer::unregisterRecognizer(ContinuousGesture);
}
void tst_Gestures::finishedWithoutStarted()
@@ -800,6 +817,7 @@ void tst_Gestures::graphicsItemGesture()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item = new GestureItem("item");
scene.addItem(item);
@@ -862,6 +880,7 @@ void tst_Gestures::graphicsView()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item = new GestureItem("item");
scene.addItem(item);
@@ -927,6 +946,7 @@ void tst_Gestures::graphicsItemTreeGesture()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
item1->setPos(100, 100);
@@ -984,6 +1004,7 @@ void tst_Gestures::explicitGraphicsObjectTarget()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
scene.addItem(item1);
@@ -1138,6 +1159,9 @@ void tst_Gestures::twoGesturesOnDifferentLevel()
l->addWidget(child);
Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([SecondGesture]{
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ });
parent.grabGesture(CustomGesture::GestureType);
child->grabGesture(SecondGesture);
@@ -1164,8 +1188,6 @@ void tst_Gestures::twoGesturesOnDifferentLevel()
QCOMPARE(parent.events.all.size(), TotalGestureEventsCount);
for(int i = 0; i < child->events.all.size(); ++i)
QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType);
-
- QGestureRecognizer::unregisterRecognizer(SecondGesture);
}
void tst_Gestures::multipleGesturesInTree()
@@ -1179,6 +1201,10 @@ void tst_Gestures::multipleGesturesInTree()
Qt::GestureType FirstGesture = CustomGesture::GestureType;
Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([SecondGesture, ThirdGesture]{
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ QGestureRecognizer::unregisterRecognizer(ThirdGesture);
+ });
Qt::GestureFlags flags = Qt::ReceivePartialGestures;
A->grabGesture(FirstGesture, flags); // A [1 3]
@@ -1235,9 +1261,6 @@ void tst_Gestures::multipleGesturesInTree()
QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount);
QCOMPARE(A->events.all.count(SecondGesture), 0);
QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount);
-
- QGestureRecognizer::unregisterRecognizer(SecondGesture);
- QGestureRecognizer::unregisterRecognizer(ThirdGesture);
}
void tst_Gestures::multipleGesturesInComplexTree()
@@ -1255,6 +1278,14 @@ void tst_Gestures::multipleGesturesInComplexTree()
Qt::GestureType FifthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
Qt::GestureType SixthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
Qt::GestureType SeventhGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([=]{
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ QGestureRecognizer::unregisterRecognizer(ThirdGesture);
+ QGestureRecognizer::unregisterRecognizer(FourthGesture);
+ QGestureRecognizer::unregisterRecognizer(FifthGesture);
+ QGestureRecognizer::unregisterRecognizer(SixthGesture);
+ QGestureRecognizer::unregisterRecognizer(SeventhGesture);
+ });
Qt::GestureFlags flags = Qt::ReceivePartialGestures;
A->grabGesture(FirstGesture, flags); // A [1,3,4]
@@ -1332,13 +1363,6 @@ void tst_Gestures::multipleGesturesInComplexTree()
QCOMPARE(A->events.all.count(FifthGesture), 0);
QCOMPARE(A->events.all.count(SixthGesture), 0);
QCOMPARE(A->events.all.count(SeventhGesture), 0);
-
- QGestureRecognizer::unregisterRecognizer(SecondGesture);
- QGestureRecognizer::unregisterRecognizer(ThirdGesture);
- QGestureRecognizer::unregisterRecognizer(FourthGesture);
- QGestureRecognizer::unregisterRecognizer(FifthGesture);
- QGestureRecognizer::unregisterRecognizer(SixthGesture);
- QGestureRecognizer::unregisterRecognizer(SeventhGesture);
}
void tst_Gestures::testMapToScene()
@@ -1401,13 +1425,13 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
// sending an event will cause the QGesture objects to be instantiated for the widgets
sendCustomGesture(&event, b);
- QCOMPARE(a->gestures.count(), 1);
+ QCOMPARE(a->gestures.size(), 1);
QPointer<QGesture> customGestureA;
customGestureA = *(a->gestures.begin());
QVERIFY(!customGestureA.isNull());
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
- QCOMPARE(b->gestures.count(), 1);
+ QCOMPARE(b->gestures.size(), 1);
QPointer<QGesture> customGestureB;
customGestureB = *(b->gestures.begin());
QVERIFY(!customGestureB.isNull());
@@ -1418,7 +1442,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
// sending an event will cause the QGesture objects to be instantiated for the widget
sendCustomGesture(&event, a);
- QCOMPARE(a->gestures.count(), 1);
+ QCOMPARE(a->gestures.size(), 1);
customGestureA = *(a->gestures.begin());
QVERIFY(!customGestureA.isNull());
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
@@ -1463,7 +1487,7 @@ void tst_Gestures::autoCancelGestures()
{
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- if (ge->gestures().count() != 1)
+ if (ge->gestures().size() != 1)
++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
@@ -1474,6 +1498,9 @@ void tst_Gestures::autoCancelGestures()
};
const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([secondGesture]{
+ QGestureRecognizer::unregisterRecognizer(secondGesture);
+ });
MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext
parent.resize(300, 100);
@@ -1496,15 +1523,15 @@ void tst_Gestures::autoCancelGestures()
CustomEvent event;
event.serial = CustomGesture::SerialStartedThreshold;
QApplication::sendEvent(child, &event);
- QCOMPARE(child->events.all.count(), 2);
- QCOMPARE(child->events.started.count(), 1);
- QCOMPARE(child->events.canceled.count(), 1);
- QCOMPARE(parent.events.all.count(), 1);
+ QCOMPARE(child->events.all.size(), 2);
+ QCOMPARE(child->events.started.size(), 1);
+ QCOMPARE(child->events.canceled.size(), 1);
+ QCOMPARE(parent.events.all.size(), 1);
// clean up, make the parent gesture finish
event.serial = CustomGesture::SerialFinishedThreshold;
QApplication::sendEvent(child, &event);
- QCOMPARE(parent.events.all.count(), 2);
+ QCOMPARE(parent.events.all.size(), 2);
QCOMPARE(parent.badGestureEvents, 0);
}
@@ -1518,7 +1545,7 @@ void tst_Gestures::autoCancelGestures2()
{
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- if (ge->gestures().count() != 1)
+ if (ge->gestures().size() != 1)
++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
@@ -1529,10 +1556,14 @@ void tst_Gestures::autoCancelGestures2()
};
const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([secondGesture]{
+ QGestureRecognizer::unregisterRecognizer(secondGesture);
+ });
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
MockItem *parent = new MockItem("parent");
GestureItem *child = new GestureItem("child");
@@ -1552,15 +1583,15 @@ void tst_Gestures::autoCancelGestures2()
event.hasHotSpot = true;
event.hotSpot = mapToGlobal(QPointF(5, 5), child, &view);
scene.sendEvent(child, &event);
- QCOMPARE(parent->events.all.count(), 1);
- QCOMPARE(child->events.started.count(), 1);
- QCOMPARE(child->events.canceled.count(), 1);
- QCOMPARE(child->events.all.count(), 2);
+ QCOMPARE(parent->events.all.size(), 1);
+ QCOMPARE(child->events.started.size(), 1);
+ QCOMPARE(child->events.canceled.size(), 1);
+ QCOMPARE(child->events.all.size(), 2);
// clean up, make the parent gesture finish
event.serial = CustomGesture::SerialFinishedThreshold;
scene.sendEvent(child, &event);
- QCOMPARE(parent->events.all.count(), 2);
+ QCOMPARE(parent->events.all.size(), 2);
QCOMPARE(parent->badGestureEvents, 0);
}
@@ -1569,6 +1600,7 @@ void tst_Gestures::graphicsViewParentPropagation()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item0 = new GestureItem("item0");
scene.addItem(item0);
@@ -1629,6 +1661,7 @@ void tst_Gestures::panelPropagation()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item0 = new GestureItem("item0");
scene.addItem(item0);
@@ -1753,6 +1786,7 @@ void tst_Gestures::panelStacksBehindParent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
item1->grabGesture(CustomGesture::GestureType);
@@ -1940,6 +1974,7 @@ void tst_Gestures::partialGesturePropagation()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
item1->grabGesture(CustomGesture::GestureType);
@@ -2030,10 +2065,14 @@ void tst_Gestures::testQGestureRecognizerCleanup()
// Mimic QGestureManager: register both default and "platform" recognizers
// (this is done in windows when QT_NO_NATIVE_GESTURES is not defined)
PanRecognizer *def = new PanRecognizer(PanRecognizer::Default);
- QGestureRecognizer::registerRecognizer(def);
+ auto defRecognizer = QGestureRecognizer::registerRecognizer(def);
PanRecognizer *plt = new PanRecognizer(PanRecognizer::Platform);
- QGestureRecognizer::registerRecognizer(plt);
+ auto pltRecognizer = QGestureRecognizer::registerRecognizer(plt);
qDebug () << "register: default =" << def << "; platform =" << plt;
+ auto unregisterRecognizer = qScopeGuard([defRecognizer, pltRecognizer]{
+ QGestureRecognizer::unregisterRecognizer(defRecognizer);
+ QGestureRecognizer::unregisterRecognizer(pltRecognizer);
+ });
// ^-- Qt singleton QGManager initialization
@@ -2147,11 +2186,16 @@ void tst_Gestures::testReuseCanceledGestures()
new ReuseCanceledGesturesRecognizer(ReuseCanceledGesturesRecognizer::RmbAndCancelAllType));
Qt::GestureType tapGestureTypeId = QGestureRecognizer::registerRecognizer(
new ReuseCanceledGesturesRecognizer(ReuseCanceledGesturesRecognizer::LmbType));
+ auto unregisterRecognizer = qScopeGuard([=]{
+ QGestureRecognizer::unregisterRecognizer(cancellingGestureTypeId);
+ QGestureRecognizer::unregisterRecognizer(tapGestureTypeId);
+ });
QMainWindow mw;
mw.setWindowFlags(Qt::X11BypassWindowManagerHint);
QGraphicsView *gv = new QGraphicsView(&mw);
QGraphicsScene *scene = new QGraphicsScene;
+ mw.move(m_availableTopLeft);
gv->setScene(scene);
scene->setSceneRect(0,0,100,100);
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp
index 824f26aeaa..16b7d33097 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp
@@ -105,8 +105,8 @@ static QString prettyByteArray(const QByteArray &array)
{
// any control chars?
QString result;
- result.reserve(array.length() + array.length() / 3);
- for (int i = 0; i < array.length(); ++i) {
+ result.reserve(array.size() + array.size() / 3);
+ for (int i = 0; i < array.size(); ++i) {
char c = array.at(i);
switch (c) {
case '\n':
@@ -208,11 +208,11 @@ static void netChat(int port, const QList<Chat> &chat)
switch (it->type) {
case Chat::Expect: {
qDebug() << i << "Expecting" << prettyByteArray(it->data);
- if (!doSocketRead(&socket, it->data.length(), 3 * defaultReadTimeoutMS))
- QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length()));
+ if (!doSocketRead(&socket, it->data.size(), 3 * defaultReadTimeoutMS))
+ QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size()));
// pop that many bytes off the socket
- QByteArray received = socket.read(it->data.length());
+ QByteArray received = socket.read(it->data.size());
// is it what we expected?
QVERIFY2(received == it->data,
@@ -226,8 +226,8 @@ static void netChat(int port, const QList<Chat> &chat)
qDebug() << i << "Discarding until" << prettyByteArray(it->data);
while (true) {
// scan the buffer until we have our string
- if (!doSocketRead(&socket, it->data.length()))
- QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length()));
+ if (!doSocketRead(&socket, it->data.size()))
+ QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size()));
QByteArray buffer;
buffer.resize(socket.bytesAvailable());
@@ -239,7 +239,7 @@ static void netChat(int port, const QList<Chat> &chat)
continue;
}
- buffer = socket.read(pos + it->data.length());
+ buffer = socket.read(pos + it->data.size());
qDebug() << i << "Discarded" << prettyByteArray(buffer);
break;
}
diff --git a/tests/auto/other/qaccessibility/accessiblewidgets.h b/tests/auto/other/qaccessibility/accessiblewidgets.h
index 2e93f24fd3..b0382ef60a 100644
--- a/tests/auto/other/qaccessibility/accessiblewidgets.h
+++ b/tests/auto/other/qaccessibility/accessiblewidgets.h
@@ -116,7 +116,7 @@ public:
int cursorPosition() const override { return textWidget()->cursorPosition; }
void setCursorPosition(int position) override { textWidget()->cursorPosition = position; }
QString text(int startOffset, int endOffset) const override { return textWidget()->text.mid(startOffset, endOffset); }
- int characterCount() const override { return textWidget()->text.length(); }
+ int characterCount() const override { return textWidget()->text.size(); }
QRect characterRect(int) const override { return QRect(); }
int offsetAtPoint(const QPoint &) const override { return 0; }
void scrollToSubstring(int, int) override {}
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 89ef57e29b..60a8dde623 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -163,6 +163,7 @@ public slots:
void cleanup();
private slots:
void eventTest();
+ void eventWithChildTest();
void customWidget();
void deletedWidget();
void subclassedWidget();
@@ -210,6 +211,7 @@ private slots:
void treeTest();
void tableTest();
+ void uniqueIdTest();
void calendarWidgetTest();
void dockWidgetTest();
void comboBoxTest();
@@ -292,9 +294,9 @@ void tst_QAccessibility::cleanup()
{
const EventList list = QTestAccessibility::events();
if (!list.isEmpty()) {
- qWarning("%zd accessibility event(s) were not handled in testfunction '%s':", size_t(list.count()),
+ qWarning("%zd accessibility event(s) were not handled in testfunction '%s':", size_t(list.size()),
QString(QTest::currentTestFunction()).toLatin1().constData());
- for (int i = 0; i < list.count(); ++i)
+ for (int i = 0; i < list.size(); ++i)
qWarning(" %d: Object: %p Event: '%s' Child: %d", i + 1, list.at(i)->object(),
qAccessibleEventString(list.at(i)->type()), list.at(i)->child());
}
@@ -353,6 +355,33 @@ void tst_QAccessibility::eventTest()
QTestAccessibility::clearEvents();
}
+void tst_QAccessibility::eventWithChildTest()
+{
+ // make sure that QAccessibleEvent created using either of the two QAccessibleEvent
+ // behaves the same when the same underlying QObject is used
+ QWidget widget;
+ QWidget childWidget(&widget);
+
+ // QAccessibleEvent constructor called with the QObject*
+ QAccessibleEvent event1(&widget, QAccessible::Focus);
+
+ // QAccessibleEvent constructor called with the QAccessibleInterface* for the same QObject*
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&widget);
+ QAccessibleEvent event2(iface, QAccessible::Focus);
+
+ QVERIFY(event1.accessibleInterface() != nullptr);
+ QVERIFY(event2.accessibleInterface() != nullptr);
+ QCOMPARE(event1.accessibleInterface(), event2.accessibleInterface());
+
+ // set same child for both
+ event1.setChild(0);
+ event2.setChild(0);
+
+ QVERIFY(event1.accessibleInterface() != nullptr);
+ QVERIFY(event2.accessibleInterface() != nullptr);
+ QCOMPARE(event1.accessibleInterface(), event2.accessibleInterface());
+}
+
void tst_QAccessibility::customWidget()
{
{
@@ -753,7 +782,7 @@ void tst_QAccessibility::textAttributes()
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit);
QAccessibleTextInterface *textInterface=interface->textInterface();
QVERIFY(textInterface);
- QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().length());
+ QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().size());
int startOffset = -1;
int endOffset = -1;
@@ -1915,7 +1944,7 @@ void tst_QAccessibility::mdiAreaTest()
mdiArea.addSubWindow(new QWidget, Qt::Dialog)->show();
QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
- QCOMPARE(subWindows.count(), subWindowCount);
+ QCOMPARE(subWindows.size(), subWindowCount);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mdiArea);
QVERIFY(interface);
@@ -1953,7 +1982,7 @@ void tst_QAccessibility::mdiSubWindowTest()
}
QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
- QCOMPARE(subWindows.count(), subWindowCount);
+ QCOMPARE(subWindows.size(), subWindowCount);
QMdiSubWindow *testWindow = subWindows.at(3);
QVERIFY(testWindow);
@@ -2077,10 +2106,10 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(iface->text(QAccessible::Value), QString());
le->setEchoMode(QLineEdit::Password);
QVERIFY(iface->state().passwordEdit);
- QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::PasswordEchoOnEdit);
QVERIFY(iface->state().passwordEdit);
- QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::Normal);
QVERIFY(!(iface->state().passwordEdit));
QCOMPARE(iface->text(QAccessible::Value), secret);
@@ -2172,7 +2201,7 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(textIface->textAtOffset(5, QAccessible::ParagraphBoundary,&start,&end), cite);
QCOMPARE(start, 0);
- QCOMPARE(end, cite.length());
+ QCOMPARE(end, cite.size());
QCOMPARE(textIface->textAtOffset(5, QAccessible::LineBoundary,&start,&end), cite);
QCOMPARE(textIface->textAtOffset(5, QAccessible::NoBoundary,&start,&end), cite);
@@ -2216,8 +2245,8 @@ void tst_QAccessibility::lineEditTest()
QVERIFY_EVENT(&sel);
lineEdit->selectAll();
- sel.setSelection(0, lineEdit->text().length());
- sel.setCursorPosition(lineEdit->text().length());
+ sel.setSelection(0, lineEdit->text().size());
+ sel.setCursorPosition(lineEdit->text().size());
QVERIFY_EVENT(&sel);
lineEdit->setSelection(10, -4);
@@ -2573,7 +2602,7 @@ void tst_QAccessibility::dialogButtonBoxTest()
std::sort(buttons.begin(), buttons.end(), accessibleInterfaceLeftOf);
- for (int i = 0; i < buttons.count(); ++i)
+ for (int i = 0; i < buttons.size(); ++i)
actualOrder << buttons.at(i)->text(QAccessible::Name);
QStringList expectedOrder;
@@ -2625,7 +2654,7 @@ void tst_QAccessibility::dialogButtonBoxTest()
std::sort(buttons.begin(), buttons.end(), accessibleInterfaceAbove);
- for (int i = 0; i < buttons.count(); ++i)
+ for (int i = 0; i < buttons.size(); ++i)
actualOrder << buttons.at(i)->text(QAccessible::Name);
QStringList expectedOrder;
@@ -3357,6 +3386,25 @@ void tst_QAccessibility::tableTest()
QTestAccessibility::clearEvents();
}
+void tst_QAccessibility::uniqueIdTest()
+{
+ // Test that an ID isn't reassigned to another interface right away when an accessible interface
+ // that has just been created is removed from the cache and deleted before the next
+ // accessible interface is registered.
+ // For example for AT-SPI, that would result in the same object path being used, and thus
+ // data from the old and new interface can get confused due to caching.
+ QWidget widget1;
+ QAccessibleInterface *iface1 = QAccessible::queryAccessibleInterface(&widget1);
+ QAccessible::Id id1 = QAccessible::uniqueId(iface1);
+ QAccessible::deleteAccessibleInterface(id1);
+
+ QWidget widget2;
+ QAccessibleInterface *iface2 = QAccessible::queryAccessibleInterface(&widget2);
+ QAccessible::Id id2 = QAccessible::uniqueId(iface2);
+
+ QVERIFY(id1 != id2);
+}
+
void tst_QAccessibility::calendarWidgetTest()
{
#if QT_CONFIG(calendarwidget)
@@ -3668,7 +3716,7 @@ void tst_QAccessibility::labelTest()
QCOMPARE(acc_label->state().readOnly, true);
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels = acc_label->relations();
- QCOMPARE(rels.count(), 1);
+ QCOMPARE(rels.size(), 1);
QAccessibleInterface *iface = rels.first().first;
QAccessible::Relation rel = rels.first().second;
@@ -4125,7 +4173,7 @@ void tst_QAccessibility::focusChild()
spy.clear();
tableView->setCurrentCell(2, 1);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QAccessibleInterface *child = iface->focusChild();
QVERIFY(child);
@@ -4133,7 +4181,7 @@ void tst_QAccessibility::focusChild()
spy.clear();
tableView->setCurrentCell(1, 2);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
child = iface->focusChild();
QVERIFY(child);
@@ -4185,7 +4233,7 @@ void tst_QAccessibility::focusChild()
spy.clear();
treeView->setCurrentItem(item2);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QAccessibleInterface *child = iface->focusChild();
QVERIFY(child);
@@ -4193,12 +4241,53 @@ void tst_QAccessibility::focusChild()
spy.clear();
treeView->setCurrentItem(item3);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
child = iface->focusChild();
QVERIFY(child);
QCOMPARE(child->text(QAccessible::Name), QStringLiteral("Klimt"));
}
+ {
+ QWidget window;
+ // takes the initial focus
+ QLineEdit lineEdit;
+ QComboBox comboBox;
+ comboBox.addItems({"One", "Two", "Three"});
+ QComboBox editableComboBox;
+ editableComboBox.setEditable(true);
+ editableComboBox.addItems({"A", "B", "C"});
+ QVBoxLayout vbox;
+ vbox.addWidget(&lineEdit);
+ vbox.addWidget(&comboBox);
+ vbox.addWidget(&editableComboBox);
+ window.setLayout(&vbox);
+
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QTestAccessibility::clearEvents();
+ QAccessibleInterface *iface = nullptr;
+
+ comboBox.setFocus();
+ {
+ QAccessibleEvent focusEvent(&comboBox, QAccessible::Focus);
+ QVERIFY(QTestAccessibility::containsEvent(&focusEvent));
+ }
+ iface = QAccessible::queryAccessibleInterface(&comboBox);
+ QVERIFY(iface);
+ QCOMPARE(iface->focusChild(), nullptr);
+
+ editableComboBox.setFocus();
+ // Qt updates about the editable combobox, not the lineedit, as the
+ // combobox is the lineedit's focus proxy.
+ {
+ QAccessibleEvent focusEvent(&editableComboBox, QAccessible::Focus);
+ QVERIFY(QTestAccessibility::containsEvent(&focusEvent));
+ }
+ iface = QAccessible::queryAccessibleInterface(&editableComboBox);
+ QVERIFY(iface);
+ QVERIFY(iface->focusChild());
+ QCOMPARE(iface->focusChild()->role(), QAccessible::EditableText);
+ }
}
void tst_QAccessibility::messageBoxTest_data()
@@ -4288,20 +4377,10 @@ void tst_QAccessibility::messageBoxTest()
if (!boxPrivate->canBeNativeDialog()) {
// platforms that use a native message box will not emit accessibility events
box.show();
- QVERIFY(QTest::qWaitForWindowActive(&box));
QAccessibleEvent showEvent(&box, QAccessible::DialogStart);
QVERIFY(QTestAccessibility::containsEvent(&showEvent));
- // on some platforms, like macOS, not all widgets get key board focus; we
- // only care about a push button getting focus
- if (QTest::qWaitFor([&box]{ return qobject_cast<QPushButton *>(box.focusWidget()); }, 1000)) {
- // a widget that gets focus through window activation should not emit an accessibility
- // notification
- QAccessibleEvent focusEvent(box.focusWidget(), QAccessible::Focus);
- QVERIFY(!QTestAccessibility::containsEvent(&focusEvent));
- }
-
box.hide();
QAccessibleEvent hideEvent(&box, QAccessible::DialogEnd);
diff --git a/tests/auto/other/qaccessibilitymac/CMakeLists.txt b/tests/auto/other/qaccessibilitymac/CMakeLists.txt
index 6dd30a6fa1..03762f1fcd 100644
--- a/tests/auto/other/qaccessibilitymac/CMakeLists.txt
+++ b/tests/auto/other/qaccessibilitymac/CMakeLists.txt
@@ -1,32 +1,14 @@
-# Generated from qaccessibilitymac.pro.
if(NOT APPLE)
return()
endif()
-#####################################################################
-## tst_qaccessibilitymac Test:
-#####################################################################
-
qt_internal_add_test(tst_qaccessibilitymac
SOURCES
- tst_qaccessibilitymac.cpp
- tst_qaccessibilitymac_helpers.h
+ tst_qaccessibilitymac.mm
PUBLIC_LIBRARIES
Qt::Gui
Qt::Widgets
-)
-
-#### Keys ignored in scope 1:.:.:qaccessibilitymac.pro:<TRUE>:
-# _REQUIREMENTS = "mac"
-
-## Scopes:
-#####################################################################
-
-qt_internal_extend_target(tst_qaccessibilitymac CONDITION APPLE
- SOURCES
- tst_qaccessibilitymac_helpers.mm
- PUBLIC_LIBRARIES
${FWAppKit}
${FWApplicationServices}
${FWSecurity}
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp
deleted file mode 100644
index 2141869f16..0000000000
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include <QApplication>
-#include <QtWidgets>
-#include <QTest>
-#include <QtCore/qcoreapplication.h>
-
-#include "tst_qaccessibilitymac_helpers.h"
-
-QT_USE_NAMESPACE
-
-
-class AccessibleTestWindow : public QWidget
-{
- Q_OBJECT
-public:
- AccessibleTestWindow()
- {
- new QHBoxLayout(this);
- }
-
- void addWidget(QWidget* widget)
- {
- layout()->addWidget(widget);
- widget->show();
- QVERIFY(QTest::qWaitForWindowExposed(widget));
- }
-
- void clearChildren()
- {
- qDeleteAll(children());
- new QHBoxLayout(this);
- }
-};
-
-class tst_QAccessibilityMac : public QObject
-{
-Q_OBJECT
-private slots:
- void init();
- void cleanup();
-
- void singleWidgetTest();
- void lineEditTest();
- void hierarchyTest();
- void notificationsTest();
- void checkBoxTest();
-
-private:
- AccessibleTestWindow *m_window;
-};
-
-
-void tst_QAccessibilityMac::init()
-{
- m_window = new AccessibleTestWindow();
- m_window->setWindowTitle("Test window");
- m_window->show();
- m_window->resize(400, 400);
-
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
-}
-
-void tst_QAccessibilityMac::cleanup()
-{
- delete m_window;
-}
-
-void tst_QAccessibilityMac::singleWidgetTest()
-{
- delete m_window;
- m_window = 0;
-
- QVERIFY(singleWidget());
-}
-
-void tst_QAccessibilityMac::lineEditTest()
-{
- QLineEdit *lineEdit = new QLineEdit(m_window);
- lineEdit->setText("a11y test QLineEdit");
- m_window->addWidget(lineEdit);
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
- QCoreApplication::processEvents();
-
- QVERIFY(testLineEdit());
-}
-
-void tst_QAccessibilityMac::hierarchyTest()
-{
- QWidget *w = new QWidget(m_window);
- m_window->addWidget(w);
-
- w->setLayout(new QVBoxLayout());
- QPushButton *b = new QPushButton(w);
- w->layout()->addWidget(b);
- b->setText("I am a button");
-
- QPushButton *b2 = new QPushButton(w);
- w->layout()->addWidget(b2);
- b2->setText("Button 2");
-
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
- QCoreApplication::processEvents();
- QVERIFY(testHierarchy(w));
-}
-
-void tst_QAccessibilityMac::notificationsTest()
-{
- QVERIFY(notifications(m_window));
-}
-
-void tst_QAccessibilityMac::checkBoxTest()
-{
- QCheckBox *cb = new QCheckBox(m_window);
- cb->setText("Great option");
- m_window->addWidget(cb);
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
- QCoreApplication::processEvents();
-
- QVERIFY(testCheckBox(cb));
-}
-
-QTEST_MAIN(tst_QAccessibilityMac)
-#include "tst_qaccessibilitymac.moc"
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm
index ceac828eed..39ffe504c7 100644
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
+++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm
@@ -1,10 +1,14 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#include <QApplication>
+#include <QtWidgets>
+#include <QTest>
+#include <QtCore/qcoreapplication.h>
+
// some versions of CALayer.h use 'slots' as an identifier
#define QT_NO_KEYWORDS
-#include "tst_qaccessibilitymac_helpers.h"
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qlineedit.h>
#include <QtWidgets/qpushbutton.h>
@@ -55,14 +59,6 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
return dbg;
}
-#define EXPECT(cond) \
- if (!(cond)) { \
- qWarning("Failure in %s, line: %d", __FILE__ , __LINE__); \
- return false; \
- } \
-
-#define TRY_EXPECT(cond) EXPECT(QTest::qWaitFor([&]{ return (cond); }))
-
@interface TestAXObject : NSObject
{
AXUIElementRef reference;
@@ -341,66 +337,138 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
@end
+QVector<int> notificationList;
+
+void observerCallback(AXObserverRef /*observer*/, AXUIElementRef /*element*/, CFStringRef notification, void *)
+{
+ if ([(NSString*)notification isEqualToString: NSAccessibilityFocusedUIElementChangedNotification])
+ notificationList.append(QAccessible::Focus);
+ else if ([(NSString*)notification isEqualToString: NSAccessibilityValueChangedNotification])
+ notificationList.append(QAccessible::ValueChanged);
+ else
+ notificationList.append(-1);
+}
+
+class AccessibleTestWindow : public QWidget
+{
+ Q_OBJECT
+public:
+ AccessibleTestWindow()
+ {
+ new QHBoxLayout(this);
+ }
+
+ void addWidget(QWidget* widget)
+ {
+ layout()->addWidget(widget);
+ widget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(widget));
+ }
+
+ void clearChildren()
+ {
+ qDeleteAll(children());
+ new QHBoxLayout(this);
+ }
+};
+
+class tst_QAccessibilityMac : public QObject
+{
+Q_OBJECT
+private Q_SLOTS:
+ void init();
+ void cleanup();
+
+ void singleWidgetTest();
+ void lineEditTest();
+ void hierarchyTest();
+ void notificationsTest();
+ void checkBoxTest();
+
+private:
+ AccessibleTestWindow *m_window;
+};
+
+
+void tst_QAccessibilityMac::init()
+{
+ m_window = new AccessibleTestWindow();
+ m_window->setWindowTitle("Test window");
+ m_window->show();
+ m_window->resize(400, 400);
+
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+}
-bool singleWidget()
+void tst_QAccessibilityMac::cleanup()
{
+ delete m_window;
+}
+
+void tst_QAccessibilityMac::singleWidgetTest()
+{
+ delete m_window;
+ m_window = 0;
+
QLineEdit *le = new QLineEdit();
le->setText("button");
le->show();
- EXPECT(QTest::qWaitForWindowExposed(le));
+ QVERIFY(QTest::qWaitForWindowExposed(le));
QCoreApplication::processEvents();
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windows = [appObject windowList];
- EXPECT([windows count] == 1);
+ QTRY_VERIFY(appObject.windowList.count == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windows objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
AXUIElementRef lineEditRef = [window findDirectChildByRole: kAXTextFieldRole];
- EXPECT(lineEditRef != nil);
+ QVERIFY(lineEditRef != nil);
TestAXObject *lineEdit = [[TestAXObject alloc] initWithAXUIElementRef: lineEditRef];
- EXPECT([[lineEdit value] isEqualToString:@"button"]);
+ QVERIFY([[lineEdit value] isEqualToString:@"button"]);
// Access invalid reference, should return empty value
delete le;
QCoreApplication::processEvents();
TestAXObject *lineEditInvalid = [[TestAXObject alloc] initWithAXUIElementRef: lineEditRef];
- EXPECT([[lineEditInvalid value] length] == 0);
-
- return true;
+ QVERIFY([[lineEditInvalid value] length] == 0);
}
-bool testLineEdit()
+void tst_QAccessibilityMac::lineEditTest()
{
+ QLineEdit *lineEdit = new QLineEdit(m_window);
+ lineEdit->setText("a11y test QLineEdit");
+ m_window->addWidget(lineEdit);
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
- EXPECT([window rect].size.width == 400);
+ QVERIFY([window rect].size.width == 400);
// height of window includes title bar
- EXPECT([window rect].size.height >= 400);
+ QVERIFY([window rect].size.height >= 400);
- EXPECT([window.title isEqualToString:@"Test window"]);
+ QVERIFY([window.title isEqualToString:@"Test window"]);
// children of window:
- AXUIElementRef lineEdit = [window findDirectChildByRole: kAXTextFieldRole];
- EXPECT(lineEdit != nil);
+ AXUIElementRef lineEditElement = [window findDirectChildByRole: kAXTextFieldRole];
+ QVERIFY(lineEditElement != nil);
- TestAXObject *le = [[TestAXObject alloc] initWithAXUIElementRef: lineEdit];
+ TestAXObject *le = [[TestAXObject alloc] initWithAXUIElementRef: lineEditElement];
NSString *value = @"a11y test QLineEdit";
- EXPECT([le.value isEqualToString:value]);
- EXPECT(value.length <= NSIntegerMax);
- EXPECT(le.numberOfCharacters == static_cast<NSInteger>(value.length));
+ QVERIFY([le.value isEqualToString:value]);
+ QVERIFY(value.length <= NSIntegerMax);
+ QVERIFY(le.numberOfCharacters == static_cast<NSInteger>(value.length));
const NSRange ranges[] = {
{ 0, 0},
{ 0, 1},
@@ -415,82 +483,81 @@ bool testLineEdit()
NSString *expectedSubstring = [value substringWithRange:range];
NSString *actualSubstring = [le stringForRange:range];
NSString *actualAttributedSubstring = [le attributedStringForRange:range].string;
- EXPECT([actualSubstring isEqualTo:expectedSubstring]);
- EXPECT([actualAttributedSubstring isEqualTo:expectedSubstring]);
+ QVERIFY([actualSubstring isEqualTo:expectedSubstring]);
+ QVERIFY([actualAttributedSubstring isEqualTo:expectedSubstring]);
}
- return true;
}
-bool testHierarchy(QWidget *w)
+void tst_QAccessibilityMac::hierarchyTest()
{
+ QWidget *w = new QWidget(m_window);
+ m_window->addWidget(w);
+
+ w->setLayout(new QVBoxLayout());
+ QPushButton *b = new QPushButton(w);
+ w->layout()->addWidget(b);
+ b->setText("I am a button");
+
+ QPushButton *b2 = new QPushButton(w);
+ w->layout()->addWidget(b2);
+ b2->setText("Button 2");
+
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
// Because the plain widget is filtered out of the hierarchy, we expect the button
// to be a direct child of the window
AXUIElementRef buttonRef = [window findDirectChildByRole: kAXButtonRole];
- EXPECT(buttonRef != nil);
+ QVERIFY(buttonRef != nil);
TestAXObject *buttonObject = [[TestAXObject alloc] initWithAXUIElementRef: buttonRef];
TestAXObject *parentObject = [[TestAXObject alloc] initWithAXUIElementRef: [buttonObject parent]];
// check that the parent is a window
- EXPECT([[parentObject role] isEqualToString: NSAccessibilityWindowRole]);
+ QVERIFY([[parentObject role] isEqualToString: NSAccessibilityWindowRole]);
// test the focus
// child 0 is the layout, then button1 and 2
QPushButton *button1 = qobject_cast<QPushButton*>(w->children().at(1));
- EXPECT(button1);
+ QVERIFY(button1);
QPushButton *button2 = qobject_cast<QPushButton*>(w->children().at(2));
- EXPECT(button2);
+ QVERIFY(button2);
button2->setFocus();
AXUIElementRef systemWideElement = AXUIElementCreateSystemWide();
AXUIElementRef focussedElement = NULL;
AXError error = AXUIElementCopyAttributeValue(systemWideElement,
(CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement);
- EXPECT(!error);
- EXPECT(focussedElement);
+ QVERIFY(!error);
+ QVERIFY(focussedElement);
TestAXObject *focusButton2 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement];
- EXPECT([[focusButton2 role] isEqualToString: NSAccessibilityButtonRole]);
- EXPECT([[focusButton2 title] isEqualToString: @"Button 2"]);
+ QVERIFY([[focusButton2 role] isEqualToString: NSAccessibilityButtonRole]);
+ QVERIFY([[focusButton2 title] isEqualToString: @"Button 2"]);
button1->setFocus();
error = AXUIElementCopyAttributeValue(systemWideElement,
(CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement);
- EXPECT(!error);
- EXPECT(focussedElement);
+ QVERIFY(!error);
+ QVERIFY(focussedElement);
TestAXObject *focusButton1 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement];
- EXPECT([[focusButton1 role] isEqualToString: NSAccessibilityButtonRole]);
- EXPECT([[focusButton1 title] isEqualToString: @"I am a button"]);
-
- return true;
-}
-
-QVector<int> notificationList;
-
-void observerCallback(AXObserverRef /*observer*/, AXUIElementRef /*element*/, CFStringRef notification, void *)
-{
- if ([(NSString*)notification isEqualToString: NSAccessibilityFocusedUIElementChangedNotification])
- notificationList.append(QAccessible::Focus);
- else if ([(NSString*)notification isEqualToString: NSAccessibilityValueChangedNotification])
- notificationList.append(QAccessible::ValueChanged);
- else
- notificationList.append(-1);
+ QVERIFY([[focusButton1 role] isEqualToString: NSAccessibilityButtonRole]);
+ QVERIFY([[focusButton1 title] isEqualToString: @"I am a button"]);
}
-
-bool notifications(QWidget *w)
+void tst_QAccessibilityMac::notificationsTest()
{
+ auto *w = m_window;
QLineEdit *le1 = new QLineEdit(w);
QLineEdit *le2 = new QLineEdit(w);
w->layout()->addWidget(le1);
@@ -500,76 +567,79 @@ bool notifications(QWidget *w)
QTest::qWait(100);
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
AXUIElementRef lineEdit1 = [window findDirectChildByRole: kAXTextFieldRole];
- EXPECT(lineEdit1 != nil);
+ QVERIFY(lineEdit1 != nil);
AXObserverRef observer = 0;
AXError err = AXObserverCreate(getpid(), observerCallback, &observer);
- EXPECT(!err);
+ QVERIFY(!err);
AXObserverAddNotification(observer, appObject.ref, kAXFocusedUIElementChangedNotification, 0);
AXObserverAddNotification(observer, lineEdit1, kAXValueChangedNotification, 0);
CFRunLoopAddSource( [[NSRunLoop currentRunLoop] getCFRunLoop], AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode);
- EXPECT(notificationList.length() == 0);
+ QVERIFY(notificationList.length() == 0);
le2->setFocus();
- TRY_EXPECT(notificationList.length() == 1);
- TRY_EXPECT(notificationList.at(0) == QAccessible::Focus);
+ QTRY_VERIFY(notificationList.length() == 1);
+ QTRY_VERIFY(notificationList.at(0) == QAccessible::Focus);
le1->setFocus();
- TRY_EXPECT(notificationList.length() == 2);
- TRY_EXPECT(notificationList.at(1) == QAccessible::Focus);
+ QTRY_VERIFY(notificationList.length() == 2);
+ QTRY_VERIFY(notificationList.at(1) == QAccessible::Focus);
le1->setText("hello");
- TRY_EXPECT(notificationList.length() == 3);
- TRY_EXPECT(notificationList.at(2) == QAccessible::ValueChanged);
+ QTRY_VERIFY(notificationList.length() == 3);
+ QTRY_VERIFY(notificationList.at(2) == QAccessible::ValueChanged);
le1->setText("foo");
- TRY_EXPECT(notificationList.length() == 4);
- TRY_EXPECT(notificationList.at(3) == QAccessible::ValueChanged);
-
- return true;
+ QTRY_VERIFY(notificationList.length() == 4);
+ QTRY_VERIFY(notificationList.at(3) == QAccessible::ValueChanged);
}
-bool testCheckBox(QCheckBox *ckBox)
+void tst_QAccessibilityMac::checkBoxTest()
{
+ QCheckBox *ckBox = new QCheckBox(m_window);
+ ckBox->setText("Great option");
+ m_window->addWidget(ckBox);
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
// children of window:
AXUIElementRef checkBox = [window findDirectChildByRole: kAXCheckBoxRole];
- EXPECT(checkBox != nil);
+ QVERIFY(checkBox != nil);
TestAXObject *cb = [[TestAXObject alloc] initWithAXUIElementRef: checkBox];
// here start actual checkbox tests
- EXPECT([cb valueNumber] == 0);
- EXPECT([cb.title isEqualToString:@"Great option"]);
+ QVERIFY([cb valueNumber] == 0);
+ QVERIFY([cb.title isEqualToString:@"Great option"]);
// EXPECT(cb.description == nil); // currently returns "" instead of nil
- EXPECT([cb.actions containsObject:(NSString*)kAXPressAction]);
+ QVERIFY([cb.actions containsObject:(NSString*)kAXPressAction]);
[cb performAction:kAXPressAction];
- EXPECT([cb valueNumber] == 1);
+ QVERIFY([cb valueNumber] == 1);
[cb performAction:kAXPressAction];
- EXPECT([cb valueNumber] == 0);
+ QVERIFY([cb valueNumber] == 0);
ckBox->setCheckState(Qt::PartiallyChecked);
- EXPECT([cb valueNumber] == 2);
-
- return true;
+ QVERIFY([cb valueNumber] == 2);
}
+
+QTEST_MAIN(tst_QAccessibilityMac)
+#include "tst_qaccessibilitymac.moc"
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h
deleted file mode 100644
index 003aa90dfd..0000000000
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#include <QtCore/QString>
-#include <QtCore/QPair>
-#include <QtWidgets/QWidget>
-#include <QtWidgets/QCheckBox>
-
-#pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X.
-
-QT_USE_NAMESPACE
-
-bool testLineEdit();
-bool testHierarchy(QWidget *w);
-bool singleWidget();
-bool notifications(QWidget *w);
-bool testCheckBox(QCheckBox *ckBox);
diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
index 1b944bf1b6..a164851886 100644
--- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
@@ -84,7 +84,7 @@ void tst_QComplexText::bidiReorderString()
if (si.analysis.bidiLevel % 2) {
// reverse sub
QChar *a = sub.data();
- QChar *b = a + sub.length() - 1;
+ QChar *b = a + sub.size() - 1;
while (a < b) {
QChar tmp = *a;
*a = *b;
@@ -93,7 +93,7 @@ void tst_QComplexText::bidiReorderString()
--b;
}
a = (QChar *)sub.unicode();
- b = a + sub.length();
+ b = a + sub.size();
while (a<b) {
*a = a->mirroredChar();
++a;
@@ -315,7 +315,7 @@ static void testBidiString(const QString &data, int paragraphDirection,
if (si.analysis.bidiLevel % 2) {
// reverse sub
QChar *a = sub.data();
- QChar *b = a + sub.length() - 1;
+ QChar *b = a + sub.size() - 1;
while (a < b) {
QChar tmp = *a;
*a = *b;
@@ -324,7 +324,7 @@ static void testBidiString(const QString &data, int paragraphDirection,
--b;
}
a = (QChar *)sub.unicode();
- b = a + sub.length();
+ b = a + sub.size();
// while (a<b) {
// *a = a->mirroredChar();
// ++a;
diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
index 0d34b8dfea..d265326e6d 100644
--- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
@@ -332,9 +332,10 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
d->hide();
if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)
- || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) {
+ || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)
+ || !QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive)) {
// Activate window of testFocusWidget, focus in that window goes to childFocusWidgetOne
- qWarning("Platforms offscreen and minimal require explicit activateWindow()");
+ qWarning("Platforms offscreen, minimal and macOS require explicit activateWindow()");
testFocusWidget->activateWindow();
}
diff --git a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
index e70d132ea7..3541576bb8 100644
--- a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
+++ b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
@@ -35,20 +35,20 @@ void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop()
qApp->processEvents(QEventLoop::AllEvents, 100);
// we mustn't have read anything in the event loop
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// ensure the process hasn't died
QVERIFY(!process.waitForFinished(250));
// we mustn't have read anything during waitForFinished either
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// release the child for the second write
process.write("\n");
QVERIFY(process.waitForFinished(5000));
QCOMPARE(int(process.exitStatus()), int(QProcess::NormalExit));
QCOMPARE(process.exitCode(), 0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(process.readAll().trimmed(), msg);
#endif
}
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index e4ce742e7c..6b058c88f4 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -1702,7 +1702,7 @@ void tst_QPrinter::reusePageMetrics()
QPrinter defaultP;
QPrinterInfo info(defaultP);
QString otherPrinterName;
- for (QPrinterInfo i : qAsConst(availablePrinters)) {
+ for (QPrinterInfo i : std::as_const(availablePrinters)) {
if (i.printerName() != defaultP.printerName()) {
otherPrinterName = i.printerName();
break;
@@ -1712,9 +1712,9 @@ void tst_QPrinter::reusePageMetrics()
QList<QPageSize> defaultPageSizes = info.supportedPageSizes();
QList<QPageSize> otherPageSizes = QPrinterInfo(otherP).supportedPageSizes();
QPageSize unavailableSizeToSet;
- for (QPageSize s : qAsConst(defaultPageSizes)) {
+ for (QPageSize s : std::as_const(defaultPageSizes)) {
bool found = false;
- for (QPageSize os : qAsConst(otherPageSizes)) {
+ for (QPageSize os : std::as_const(otherPageSizes)) {
if (os.isEquivalentTo(s)) {
found = true;
break;
diff --git a/tests/auto/sql/kernel/qsql/tst_qsql.cpp b/tests/auto/sql/kernel/qsql/tst_qsql.cpp
index 1d6b271f44..55cbfad421 100644
--- a/tests/auto/sql/kernel/qsql/tst_qsql.cpp
+++ b/tests/auto/sql/kernel/qsql/tst_qsql.cpp
@@ -125,10 +125,10 @@ void tst_QSql::open()
QVERIFY(dbs.open());
if (count == -1)
// first iteration: see how many dbs are open
- count = (int) dbs.dbNames.count();
+ count = (int) dbs.dbNames.size();
else
// next iterations: make sure all are opened again
- QCOMPARE(count, (int)dbs.dbNames.count());
+ QCOMPARE(count, (int)dbs.dbNames.size());
dbs.close();
}
}
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
index 5b0283d285..a3408e38d7 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
@@ -125,7 +125,7 @@ public:
QTest::addColumn<QString>( "dbName" );
int count = 0;
- for ( int i = 0; i < dbNames.count(); ++i ) {
+ for ( int i = 0; i < dbNames.size(); ++i ) {
QSqlDatabase db = QSqlDatabase::database( dbNames.at( i ) );
if ( !db.isValid() )
@@ -146,7 +146,7 @@ public:
QTest::addColumn<int>("submitpolicy_i");
int count = 0;
- for ( int i = 0; i < dbNames.count(); ++i ) {
+ for ( int i = 0; i < dbNames.size(); ++i ) {
QSqlDatabase db = QSqlDatabase::database( dbNames.at( i ) );
if ( !db.isValid() )
@@ -182,6 +182,14 @@ public:
if ( port > 0 )
cName += QLatin1Char(':') + QString::number( port );
+ if (driver == "QSQLITE") {
+ // Since the database for sqlite is generated at runtime it's always
+ // available, but we use QTempDir so it's always in a different
+ // location. Thus, let's ignore the path completely.
+ cName = "SQLite";
+ qInfo("SQLite will use the database located at %ls", qUtf16Printable(dbName));
+ }
+
db = QSqlDatabase::addDatabase( driver, cName );
if ( !db.isValid() ) {
@@ -250,7 +258,7 @@ public:
}
QTemporaryDir *sqLiteDir = dbDir();
if (sqLiteDir) {
- addDb(QStringLiteral("QSQLITE"), QDir::toNativeSeparators(sqLiteDir->path() + QStringLiteral("/foo.db")));
+ addDb(QStringLiteral("QSQLITE"), QDir::toNativeSeparators(sqLiteDir->path() + QStringLiteral("/sqlite.db")));
added = true;
}
return added;
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 2e143aff21..c1d8faa418 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -210,7 +210,7 @@ struct FieldDef {
rt.replace(QRegularExpression("\\s"), QString("_"));
int i = rt.indexOf(QLatin1Char('('));
if (i == -1)
- i = rt.length();
+ i = rt.size();
if (i > 20)
i = 20;
return "t_" + rt.left(i);
@@ -1904,13 +1904,13 @@ void tst_QSqlDatabase::odbc_testqGetString()
QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + testqGetString + " ORDER BY id"));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 1);
- QCOMPARE(q.value(1).toString().length(), 65536);
+ QCOMPARE(q.value(1).toString().size(), 65536);
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 2);
- QCOMPARE(q.value(1).toString().length(), 65537);
+ QCOMPARE(q.value(1).toString().size(), 65537);
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 3);
- QCOMPARE(q.value(1).toString().length(), 65538);
+ QCOMPARE(q.value(1).toString().size(), 65538);
}
@@ -2189,7 +2189,7 @@ void tst_QSqlDatabase::eventNotificationIBase()
// Interbase needs some time to post the notification and call the driver callback.
// This happends from another thread, and we have to process events in order for the
// event handler in the driver to be executed and emit the notification signal.
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), procedureName);
QVERIFY_SQL(*driver, unsubscribeFromNotification(procedureName));
@@ -2211,7 +2211,7 @@ void tst_QSqlDatabase::eventNotificationPSQL()
QVERIFY_SQL(*driver, subscribeToNotification(procedureName));
QSignalSpy spy(driver, QOverload<const QString &, QSqlDriver::NotificationSource, const QVariant &>::of(&QSqlDriver::notification));
query.exec(QString("NOTIFY \"%1\", '%2'").arg(procedureName).arg(payload));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), procedureName);
QCOMPARE(qvariant_cast<QSqlDriver::NotificationSource>(arguments.at(1)), QSqlDriver::SelfSource);
@@ -2237,12 +2237,12 @@ void tst_QSqlDatabase::eventNotificationSQLite()
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INTEGER, realVal REAL)"));
driver->subscribeToNotification(noEscapeTableName);
QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)"));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), noEscapeTableName);
driver->unsubscribeFromNotification(noEscapeTableName);
QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)"));
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
}
void tst_QSqlDatabase::sqlite_bindAndFetchUInt()
diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
index 3a6e16020f..e2877a1157 100644
--- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
+++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp
@@ -125,10 +125,10 @@ void tst_QSqlDriver::record()
QCOMPARE(rec.field(1).length(), 20);
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2)
- for(int i = 0; i < fields.count(); ++i)
+ for(int i = 0; i < fields.size(); ++i)
fields[i] = fields[i].toUpper();
- for (int i = 0; i < fields.count(); ++i)
+ for (int i = 0; i < fields.size(); ++i)
QCOMPARE(rec.fieldName(i), fields[i]);
if (driverSupportsDefaultValues(dbType))
@@ -145,7 +145,7 @@ void tst_QSqlDriver::record()
QCOMPARE(rec.count(), 5);
}
- for (int i = 0; i < fields.count(); ++i)
+ for (int i = 0; i < fields.size(); ++i)
QCOMPARE(rec.fieldName(i), fields[i]);
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2)
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 026c9becec..308940b8d0 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -226,6 +226,9 @@ private slots:
void sqlite_real_data() { generic_data("QSQLITE"); }
void sqlite_real();
+ void prepared_query_json_row_data() { generic_data(); }
+ void prepared_query_json_row();
+
void aggregateFunctionTypes_data() { generic_data(); }
void aggregateFunctionTypes();
@@ -401,7 +404,7 @@ void tst_QSqlQuery::createTestTables(QSqlDatabase db)
if (dbType == QSqlDriver::PostgreSQL) {
QVERIFY_SQL(q, exec(QLatin1String(
"create table %1 (id serial NOT NULL, t_varchar varchar(20), "
- "t_char char(20), primary key(id)) WITH OIDS").arg(qtest)));
+ "t_char char(20), primary key(id))").arg(qtest)));
} else {
QVERIFY_SQL(q, exec(QLatin1String(
"create table %1 (id int %2 NOT NULL, t_varchar varchar(20), "
@@ -2221,7 +2224,7 @@ void tst_QSqlQuery::prepare_bind_exec()
q.bindValue(":id", i);
QVERIFY_SQL(q, exec());
const QVariantList m = q.boundValues();
- QCOMPARE(m.count(), qsizetype(2));
+ QCOMPARE(m.size(), qsizetype(2));
QCOMPARE(m.at(0).toInt(), i);
QCOMPARE(m.at(1).toString(), values[i]);
}
@@ -3602,14 +3605,14 @@ void tst_QSqlQuery::task_250026()
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, exec("select * from " + tableName));
QVERIFY_SQL(q, next());
- QCOMPARE(q.value(0).toString().length(), data258.length());
+ QCOMPARE(q.value(0).toString().size(), data258.size());
QVERIFY_SQL(q, next());
- QCOMPARE(q.value(0).toString().length(), data1026.length());
+ QCOMPARE(q.value(0).toString().size(), data1026.size());
}
void tst_QSqlQuery::crashQueryOnCloseDatabase()
{
- for (const auto &dbName : qAsConst(dbs.dbNames)) {
+ for (const auto &dbName : std::as_const(dbs.dbNames)) {
const auto tidier = qScopeGuard([]() { QSqlDatabase::removeDatabase("crashTest"); });
// Note: destruction of clonedDb needs to happen before we call removeDatabase.
QSqlDatabase clonedDb = QSqlDatabase::cloneDatabase(
@@ -4443,6 +4446,43 @@ void tst_QSqlQuery::sqlite_real()
QCOMPARE(q.value(0).toDouble(), 5.6);
}
+void tst_QSqlQuery::prepared_query_json_row()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+ if (tst_Databases::getDatabaseType(db) != QSqlDriver::MySqlServer &&
+ tst_Databases::getDatabaseType(db) != QSqlDriver::PostgreSQL) {
+ QSKIP("PostgreSQL / MySQL specific test");
+ }
+
+ const QString tableName(qTableName("tableWithJsonRow", __FILE__, db));
+ tst_Databases::safeDropTable(db, tableName);
+
+ QSqlQuery q(db);
+ const QLatin1String vals[] = {QLatin1String("{\"certificateNumber\": \"CERT-001\"}"),
+ QLatin1String("{\"certificateNumber\": \"CERT-002\"}")};
+ QVERIFY_SQL(q, exec(QLatin1String("CREATE TABLE %1 (id INTEGER, value JSON)").arg(tableName)));
+ for (const QLatin1String &json : vals) {
+ QVERIFY_SQL(q, exec(QLatin1String("INSERT INTO %1 (id, value) VALUES (1, '%2')")
+ .arg(tableName, json)));
+ }
+
+ QVERIFY_SQL(q, prepare(QLatin1String("SELECT id, value FROM %1 WHERE id = ?").arg(tableName)));
+ q.addBindValue(1);
+ QVERIFY_SQL(q, exec());
+
+ size_t iCount = 0;
+ while (q.next()) {
+ QVERIFY(iCount < sizeof(vals));
+ const int id = q.value(0).toInt();
+ const QByteArray json = q.value(1).toByteArray();
+ QCOMPARE(id, 1);
+ QCOMPARE(json, vals[iCount].data());
+ ++iCount;
+ }
+}
+
void tst_QSqlQuery::aggregateFunctionTypes()
{
QFETCH(QString, dbName);
@@ -4825,7 +4865,7 @@ void tst_QSqlQuery::dateTime_data()
#endif
};
- for (const QString &dbName : qAsConst(dbs.dbNames)) {
+ for (const QString &dbName : std::as_const(dbs.dbNames)) {
QSqlDatabase db = QSqlDatabase::database(dbName);
if (!db.isValid())
continue;
@@ -4868,13 +4908,13 @@ void tst_QSqlQuery::dateTime()
QSqlQuery q(db);
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + createTableString));
- for (const QDateTime &dt : qAsConst(initialDateTimes)) {
+ for (const QDateTime &dt : std::as_const(initialDateTimes)) {
QVERIFY_SQL(q, prepare(QLatin1String("INSERT INTO %1 values(:dt)").arg(tableName)));
q.bindValue(":dt", dt);
QVERIFY_SQL(q, exec());
}
QVERIFY_SQL(q, exec("SELECT * FROM " + tableName));
- for (const QDateTime &dt : qAsConst(expectedDateTimes)) {
+ for (const QDateTime &dt : std::as_const(expectedDateTimes)) {
QVERIFY(q.next());
QCOMPARE(q.value(0).toDateTime(), dt);
}
diff --git a/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp b/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
index 478dec6ac4..4d41c6aaa9 100644
--- a/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
+++ b/tests/auto/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
@@ -14,12 +14,7 @@
class tst_QSqlRecord : public QObject
{
-Q_OBJECT
-
-public:
- tst_QSqlRecord();
- virtual ~tst_QSqlRecord();
-
+ Q_OBJECT
public slots:
void init();
@@ -47,26 +42,11 @@ private slots:
void append();
private:
- QSqlRecord* rec;
- QSqlField* fields[ NUM_FIELDS ];
+ std::unique_ptr<QSqlRecord> rec;
+ std::array<std::unique_ptr<QSqlField>, NUM_FIELDS> fields;
void createTestRecord();
};
-tst_QSqlRecord::tst_QSqlRecord()
-{
- rec = 0;
- for ( int i = 0; i < NUM_FIELDS; ++i )
- fields[ i ] = 0;
-}
-
-tst_QSqlRecord::~tst_QSqlRecord()
-{
- delete rec;
- for ( int i = 0; i < NUM_FIELDS; ++i )
- delete fields[ i ];
- rec = 0;
-}
-
void tst_QSqlRecord::init()
{
cleanup();
@@ -74,31 +54,26 @@ void tst_QSqlRecord::init()
void tst_QSqlRecord::cleanup()
{
- delete rec;
- for ( int i = 0; i < NUM_FIELDS; ++i ) {
- delete fields[ i ];
- fields[ i ] = 0;
- }
- rec = 0;
+ rec = nullptr;
+ for (auto &field : fields)
+ field = nullptr;
}
void tst_QSqlRecord::createTestRecord()
{
- delete rec;
- rec = new QSqlRecord();
- fields[0] = new QSqlField(QStringLiteral("string"), QMetaType(QMetaType::QString), QStringLiteral("stringtable"));
- fields[1] = new QSqlField(QStringLiteral("int"), QMetaType(QMetaType::Int), QStringLiteral("inttable"));
- fields[2] = new QSqlField(QStringLiteral("double"), QMetaType(QMetaType::Double), QStringLiteral("doubletable"));
- fields[3] = new QSqlField(QStringLiteral("bool"), QMetaType(QMetaType::Bool));
- for ( int i = 0; i < NUM_FIELDS; ++i )
- rec->append( *(fields[ i ] ) );
+ rec = std::make_unique<QSqlRecord>();
+ fields[0] = std::make_unique<QSqlField>(QStringLiteral("string"), QMetaType(QMetaType::QString), QStringLiteral("stringtable"));
+ 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));
+ for (const auto &field : fields)
+ rec->append(*field);
}
void tst_QSqlRecord::append()
{
- delete rec;
- rec = new QSqlRecord();
+ rec = std::make_unique<QSqlRecord>();
rec->append(QSqlField("string", QMetaType(QMetaType::QString), QStringLiteral("stringtable")));
QCOMPARE( rec->field( 0 ).name(), (QString) "string" );
QCOMPARE(rec->field(0).tableName(), QStringLiteral("stringtable"));
@@ -157,10 +132,7 @@ void tst_QSqlRecord::clearValues()
QFETCH( double, dval );
QFETCH( int, bval );
- if(rec)
- delete rec;
-
- rec = new QSqlRecord();
+ rec = std::make_unique<QSqlRecord>();
rec->append( QSqlField( "string", QMetaType(QMetaType::QString) ) );
QCOMPARE( rec->field(0).name(), (QString) "string" );
QVERIFY( !rec->isEmpty() );
@@ -200,8 +172,8 @@ void tst_QSqlRecord::clearValues()
void tst_QSqlRecord::contains()
{
createTestRecord();
- for ( int i = 0; i < NUM_FIELDS; ++i )
- QVERIFY( rec->contains( fields[ i ]->name() ) );
+ for (const auto &field : fields)
+ QVERIFY(rec->contains(field->name()));
QVERIFY( !rec->contains( "__Harry__" ) );
}
@@ -233,8 +205,8 @@ void tst_QSqlRecord::fieldName()
{
createTestRecord();
- for ( int i = 0; i < NUM_FIELDS; ++i )
- QVERIFY( rec->field( (fields[ i ] )->name() ) == *( fields[ i ] ) );
+ for (const auto &field : fields)
+ QVERIFY(rec->field(field->name()) == *field);
QVERIFY( rec->fieldName( NUM_FIELDS ).isNull() );
}
@@ -412,8 +384,7 @@ void tst_QSqlRecord::setValue()
{
int i;
- delete rec;
- rec = new QSqlRecord();
+ rec = std::make_unique<QSqlRecord>();
rec->append( QSqlField( "string", QMetaType(QMetaType::QString) ) );
QCOMPARE( rec->field( 0 ).name(), (QString) "string" );
QVERIFY( !rec->isEmpty() );
diff --git a/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp b/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp
index b8fd27bc50..6ef3ad4d19 100644
--- a/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp
+++ b/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp
@@ -29,7 +29,7 @@ void tst_QSqlResult::positionalToNamedBinding()
TestSqlDriverResult result(&testDriver);
QString query("INSERT INTO MYTABLE (ID, NAME, BIRTH) VALUES(?, ?, ?)");
QVERIFY(result.savePrepare(query));
- QCOMPARE(result.boundValues().count(), 3);
+ QCOMPARE(result.boundValues().size(), 3);
}
void tst_QSqlResult::parseOfBoundValues()
@@ -37,43 +37,43 @@ void tst_QSqlResult::parseOfBoundValues()
TestSqlDriver testDriver;
TestSqlDriverResult result(&testDriver);
QVERIFY(result.savePrepare("SELECT :1 AS \":2\""));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT :1 AS ':2'"));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT :1 AS [:2]"));
if (testDriver.dbmsType() == QSqlDriver::PostgreSQL)
- QCOMPARE(result.boundValues().count(), 2);
+ QCOMPARE(result.boundValues().size(), 2);
else
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT :1 AS [:2]]]"));
if (testDriver.dbmsType() == QSqlDriver::PostgreSQL)
- QCOMPARE(result.boundValues().count(), 2);
+ QCOMPARE(result.boundValues().size(), 2);
else
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT :1 AS [:2]]]]]"));
if (testDriver.dbmsType() == QSqlDriver::PostgreSQL)
- QCOMPARE(result.boundValues().count(), 2);
+ QCOMPARE(result.boundValues().size(), 2);
else
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT ? AS \"?\""));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT ? AS '?'"));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT ? AS [?]"));
if (testDriver.dbmsType() == QSqlDriver::PostgreSQL)
- QCOMPARE(result.boundValues().count(), 2);
+ QCOMPARE(result.boundValues().size(), 2);
else
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT ? AS \"'?\""));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT ? AS '?\"'"));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT ? AS '?''?'"));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
QVERIFY(result.savePrepare("SELECT ? AS [\"?']"));
- QCOMPARE(result.boundValues().count(), 1);
+ QCOMPARE(result.boundValues().size(), 1);
}
QTEST_MAIN( tst_QSqlResult )
diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp
index d868cf0197..a174ea6f37 100644
--- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp
+++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp
@@ -258,7 +258,7 @@ void tst_QSqlThread::generic_data(const QString& engine)
void tst_QSqlThread::dropTestTables()
{
- for (int i = 0; i < dbs.dbNames.count(); ++i) {
+ for (int i = 0; i < dbs.dbNames.size(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlQuery q(db);
@@ -268,7 +268,7 @@ void tst_QSqlThread::dropTestTables()
void tst_QSqlThread::createTestTables()
{
- for (int i = 0; i < dbs.dbNames.count(); ++i) {
+ for (int i = 0; i < dbs.dbNames.size(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlQuery q(db);
@@ -285,7 +285,7 @@ void tst_QSqlThread::createTestTables()
void tst_QSqlThread::repopulateTestTables()
{
- for (int i = 0; i < dbs.dbNames.count(); ++i) {
+ for (int i = 0; i < dbs.dbNames.size(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlQuery q(db);
diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
index 8b7476b3e7..202fc1080c 100644
--- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -202,7 +202,7 @@ void tst_QSqlQueryModel::removeColumn()
QCOMPARE(model.columnCount(), 3);
QVERIFY(model.removeColumn(0));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(*(QModelIndex *)spy.at(0).at(0).constData() == QModelIndex());
QCOMPARE(spy.at(0).at(1).toInt(), 0);
QCOMPARE(spy.at(0).at(2).toInt(), 0);
@@ -232,7 +232,7 @@ void tst_QSqlQueryModel::removeColumn()
QVERIFY(model.removeColumn(2));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(*(QModelIndex *)spy.at(1).at(0).constData() == QModelIndex());
QCOMPARE(spy.at(1).at(1).toInt(), 2);
QCOMPARE(spy.at(1).at(2).toInt(), 2);
@@ -245,7 +245,7 @@ void tst_QSqlQueryModel::removeColumn()
QVERIFY(model.removeColumn(1));
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
QVERIFY(*(QModelIndex *)spy.at(2).at(0).constData() == QModelIndex());
QCOMPARE(spy.at(2).at(1).toInt(), 1);
QCOMPARE(spy.at(2).at(2).toInt(), 1);
@@ -259,7 +259,7 @@ void tst_QSqlQueryModel::removeColumn()
QVERIFY(model.removeColumn(0));
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
QVERIFY(*(QModelIndex *)spy.at(3).at(0).constData() == QModelIndex());
QCOMPARE(spy.at(3).at(1).toInt(), 0);
QCOMPARE(spy.at(3).at(2).toInt(), 0);
@@ -301,7 +301,7 @@ void tst_QSqlQueryModel::insertColumn()
QVERIFY(model.insertColumn(1));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(*(QModelIndex *)spy.at(0).at(0).constData() == QModelIndex());
QCOMPARE(spy.at(0).at(1).toInt(), 1);
QCOMPARE(spy.at(0).at(2).toInt(), 1);
@@ -330,7 +330,7 @@ void tst_QSqlQueryModel::insertColumn()
QVERIFY(model.insertColumn(0));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(*(QModelIndex *)spy.at(1).at(0).constData() == QModelIndex());
QCOMPARE(spy.at(1).at(1).toInt(), 0);
QCOMPARE(spy.at(1).at(2).toInt(), 0);
@@ -345,7 +345,7 @@ void tst_QSqlQueryModel::insertColumn()
QVERIFY(!model.insertColumn(6));
QVERIFY(model.insertColumn(5));
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
QVERIFY(*(QModelIndex *)spy.at(2).at(0).constData() == QModelIndex());
QCOMPARE(spy.at(2).at(1).toInt(), 5);
QCOMPARE(spy.at(2).at(2).toInt(), 5);
@@ -424,7 +424,7 @@ void tst_QSqlQueryModel::setHeaderData()
QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
QVERIFY(model.setHeaderData(2, Qt::Horizontal, "bar"));
QCOMPARE(model.headerData(2, Qt::Horizontal).toString(), QString("bar"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::Orientation>(spy.value(0).value(0)), Qt::Horizontal);
QCOMPARE(spy.value(0).value(1).toInt(), 2);
QCOMPARE(spy.value(0).value(2).toInt(), 2);
@@ -452,8 +452,8 @@ void tst_QSqlQueryModel::fetchMore()
model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__, db), db));
int rowCount = model.rowCount();
- QCOMPARE(modelAboutToBeResetSpy.count(), 1);
- QCOMPARE(modelResetSpy.count(), 1);
+ QCOMPARE(modelAboutToBeResetSpy.size(), 1);
+ QCOMPARE(modelResetSpy.size(), 1);
// If the driver doesn't return the query size fetchMore() causes the
// model to grow and new signals are emitted
@@ -499,11 +499,11 @@ void tst_QSqlQueryModel::withSortFilterProxyModel()
QCOMPARE(proxy.rowCount(), 511);
// setQuery() resets the model accompanied by begin and end signals
- QCOMPARE(modelAboutToBeResetSpy.count(), 1);
- QCOMPARE(modelResetSpy.count(), 1);
+ QCOMPARE(modelAboutToBeResetSpy.size(), 1);
+ QCOMPARE(modelResetSpy.size(), 1);
// The call to scrollToBottom() forces the model to fetch additional rows.
- QCOMPARE(modelRowsInsertedSpy.count(), 1);
+ QCOMPARE(modelRowsInsertedSpy.size(), 1);
QCOMPARE(modelRowsInsertedSpy.value(0).value(1).toInt(), 256);
QCOMPARE(modelRowsInsertedSpy.value(0).value(2).toInt(), 510);
}
@@ -523,14 +523,14 @@ void tst_QSqlQueryModel::setQuerySignalEmission()
// First select, the model was empty and no rows had to be removed, but model resets anyway.
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db));
- QCOMPARE(modelAboutToBeResetSpy.count(), 1);
- QCOMPARE(modelResetSpy.count(), 1);
+ QCOMPARE(modelAboutToBeResetSpy.size(), 1);
+ QCOMPARE(modelResetSpy.size(), 1);
// Second select, the model wasn't empty and two rows had to be removed!
// setQuery() resets the model accompanied by begin and end signals
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db));
- QCOMPARE(modelAboutToBeResetSpy.count(), 2);
- QCOMPARE(modelResetSpy.count(), 2);
+ QCOMPARE(modelAboutToBeResetSpy.size(), 2);
+ QCOMPARE(modelResetSpy.size(), 2);
}
// For task 170783: When the query's result set is empty no rows should be inserted,
@@ -549,8 +549,8 @@ void tst_QSqlQueryModel::setQueryWithNoRowsInResultSet()
QSqlQuery query(db);
QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__, db) + " where 0 = 1"));
model.setQuery(std::move(query));
- QCOMPARE(modelRowsAboutToBeInsertedSpy.count(), 0);
- QCOMPARE(modelRowsInsertedSpy.count(), 0);
+ QCOMPARE(modelRowsAboutToBeInsertedSpy.size(), 0);
+ QCOMPARE(modelRowsInsertedSpy.size(), 0);
}
class NestedResetsTest: public QSqlQueryModel
diff --git a/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp b/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp
index 5c49600b8f..1a9f8310c9 100644
--- a/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp
+++ b/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp
@@ -146,7 +146,7 @@ void tst_QSqlRelationalDelegate::comboBoxEditor()
tv.setCurrentIndex(index);
tv.edit(index);
QList<QComboBox*> comboBoxes = tv.viewport()->findChildren<QComboBox *>();
- QCOMPARE(comboBoxes.count(), 1);
+ QCOMPARE(comboBoxes.size(), 1);
QComboBox *editor = comboBoxes.at(0);
QCOMPARE(editor->currentText(), "herr");
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index ebddefb5fd..ece99efa0a 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -148,7 +148,7 @@ tst_QSqlTableModel::~tst_QSqlTableModel()
void tst_QSqlTableModel::dropTestTables()
{
- for (int i = 0; i < dbs.dbNames.count(); ++i) {
+ for (int i = 0; i < dbs.dbNames.size(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
QSqlQuery q(db);
@@ -177,7 +177,7 @@ void tst_QSqlTableModel::dropTestTables()
void tst_QSqlTableModel::createTestTables()
{
- for (int i = 0; i < dbs.dbNames.count(); ++i) {
+ for (int i = 0; i < dbs.dbNames.size(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
QSqlQuery q(db);
@@ -207,7 +207,7 @@ void tst_QSqlTableModel::createTestTables()
void tst_QSqlTableModel::repopulateTestTables()
{
- for (int i = 0; i < dbs.dbNames.count(); ++i) {
+ for (int i = 0; i < dbs.dbNames.size(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlQuery q(db);
const auto test = qTableName("test1", __FILE__, db);
@@ -602,8 +602,8 @@ void tst_QSqlTableModel::setRecord()
// dataChanged() emitted by setData() for each *changed* column
if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit) {
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(0).count(), 2);
+ QCOMPARE(spy.size(), 2);
+ QCOMPARE(spy.at(0).size(), 2);
QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1));
QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1));
QCOMPARE(qvariant_cast<QModelIndex>(spy.at(1).at(0)), model.index(i, 2));
@@ -614,10 +614,10 @@ void tst_QSqlTableModel::setRecord()
else {
if ((QSqlTableModel::EditStrategy)submitpolicy != QSqlTableModel::OnManualSubmit)
// dataChanged() also emitted by selectRow()
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
else
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(0).count(), 2);
+ QCOMPARE(spy.size(), 2);
+ QCOMPARE(spy.at(0).size(), 2);
QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1));
QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1));
QCOMPARE(qvariant_cast<QModelIndex>(spy.at(1).at(0)), model.index(i, 2));
@@ -1092,7 +1092,7 @@ void tst_QSqlTableModel::removeRow()
QSignalSpy headerDataChangedSpy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
QVERIFY(model.removeRow(1));
- QCOMPARE(headerDataChangedSpy.count(), 1);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
QCOMPARE(*static_cast<const Qt::Orientation *>(headerDataChangedSpy.at(0).value(0).constData()), Qt::Vertical);
QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 1);
QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 1);
@@ -1112,7 +1112,7 @@ void tst_QSqlTableModel::removeRow()
headerDataChangedSpy.clear();
QVERIFY(model.removeRow(1));
- QCOMPARE(headerDataChangedSpy.count(), 1);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
QCOMPARE(model.rowCount(), 3);
QVERIFY_SQL(model, select());
@@ -1148,7 +1148,7 @@ void tst_QSqlTableModel::removeRows()
QVERIFY_SQL(model, removeRows(0, 1));
QVERIFY_SQL(model, removeRows(1, 1));
- QCOMPARE(beforeDeleteSpy.count(), 2);
+ QCOMPARE(beforeDeleteSpy.size(), 2);
QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0);
QCOMPARE(beforeDeleteSpy.at(1).at(0).toInt(), 1);
// deleted rows shown as empty until select
@@ -1179,15 +1179,15 @@ void tst_QSqlTableModel::removeRows()
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
QSignalSpy headerDataChangedSpy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
QVERIFY(model.removeRows(0, 2, QModelIndex()));
- QCOMPARE(headerDataChangedSpy.count(), 2);
+ QCOMPARE(headerDataChangedSpy.size(), 2);
QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 1);
QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 1);
QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 0);
QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 0);
QCOMPARE(model.rowCount(), 3);
- QCOMPARE(beforeDeleteSpy.count(), 0);
+ QCOMPARE(beforeDeleteSpy.size(), 0);
QVERIFY(model.submitAll());
- QCOMPARE(beforeDeleteSpy.count(), 2);
+ QCOMPARE(beforeDeleteSpy.size(), 2);
QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0);
QCOMPARE(beforeDeleteSpy.at(1).at(0).toInt(), 1);
QCOMPARE(model.rowCount(), 1);
@@ -1784,8 +1784,8 @@ void tst_QSqlTableModel::setFilter()
model.setFilter("id = 2");
// check the signals
- QCOMPARE(modelAboutToBeResetSpy.count(), 1);
- QCOMPARE(modelResetSpy.count(), 1);
+ QCOMPARE(modelAboutToBeResetSpy.size(), 1);
+ QCOMPARE(modelResetSpy.size(), 1);
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.data(model.index(0, 0)).toInt(), 2);
@@ -1928,8 +1928,8 @@ void tst_QSqlTableModel::insertRecordsInLoop()
model.submitAll(); // submitAll() calls select() which clears and repopulates the table
// model emits reset signals
- QCOMPARE(modelAboutToBeResetSpy.count(), 1);
- QCOMPARE(modelResetSpy.count(), 1);
+ QCOMPARE(modelAboutToBeResetSpy.size(), 1);
+ QCOMPARE(modelResetSpy.size(), 1);
QCOMPARE(model.rowCount(), 13);
QCOMPARE(model.columnCount(), 3);
diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
index ac7336e8e3..8b0319679f 100644
--- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
+++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
@@ -79,15 +79,15 @@ void tst_QSignalSpy::spyWithoutArgs()
QtTestObject obj;
QSignalSpy spy(&obj, SIGNAL(sig0()));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
emit obj.sig0();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
emit obj.sig0();
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QList<QVariant> args = spy.takeFirst();
- QCOMPARE(args.count(), 0);
+ QCOMPARE(args.size(), 0);
}
void tst_QSignalSpy::spyWithBasicArgs()
@@ -96,10 +96,10 @@ void tst_QSignalSpy::spyWithBasicArgs()
QSignalSpy spy(&obj, SIGNAL(sig1(int,int)));
emit obj.sig1(1, 2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> args = spy.takeFirst();
- QCOMPARE(args.count(), 2);
+ QCOMPARE(args.size(), 2);
QCOMPARE(args.at(0).toInt(), 1);
QCOMPARE(args.at(1).toInt(), 2);
@@ -107,7 +107,7 @@ void tst_QSignalSpy::spyWithBasicArgs()
emit obj.sigLong(1l, 2l);
args = spyl.takeFirst();
- QCOMPARE(args.count(), 2);
+ QCOMPARE(args.size(), 2);
QCOMPARE(qvariant_cast<long>(args.at(0)), 1l);
QCOMPARE(qvariant_cast<long>(args.at(1)), 2l);
}
@@ -124,10 +124,10 @@ void tst_QSignalSpy::spyWithPointers()
int i2 = 2;
emit obj.sig2(&i1, &i2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> args = spy.takeFirst();
- QCOMPARE(args.count(), 2);
+ QCOMPARE(args.size(), 2);
QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1);
QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2);
}
@@ -155,15 +155,15 @@ void tst_QSignalSpy::spyWithBasicQtClasses()
QSignalSpy spy(&obj, SIGNAL(sig(QString)));
emit obj.sig(QString("bubu"));
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.at(0).size(), 1);
QCOMPARE(spy.at(0).at(0).toString(), QString("bubu"));
QSignalSpy spy2(&obj, SIGNAL(sig5(QVariant)));
QVariant val(45);
emit obj.sig5(val);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy2.at(0).count(), 1);
+ QCOMPARE(spy2.size(), 1);
+ QCOMPARE(spy2.at(0).size(), 1);
QCOMPARE(spy2.at(0).at(0), val);
QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val);
}
@@ -176,8 +176,8 @@ void tst_QSignalSpy::spyWithQtClasses()
QSignalSpy spy(&obj, SIGNAL(sig2(QDateTime)));
QDateTime dt = QDateTime::currentDateTime();
emit obj.sig2(dt);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.at(0).size(), 1);
QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime");
QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt);
QCOMPARE(spy.at(0).at(0).toDateTime(), dt);
@@ -248,7 +248,7 @@ void tst_QSignalSpy::wait_signalEmittedTooLate()
QTimer::singleShot(500, this, SIGNAL(sigFoo()));
QSignalSpy spy(this, SIGNAL(sigFoo()));
QVERIFY(!spy.wait(200));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
}
void tst_QSignalSpy::wait_signalEmittedMultipleTimes()
@@ -257,13 +257,13 @@ void tst_QSignalSpy::wait_signalEmittedMultipleTimes()
QTimer::singleShot(800, this, SIGNAL(sigFoo()));
QSignalSpy spy(this, SIGNAL(sigFoo()));
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 1); // we don't wait for the second signal...
+ QCOMPARE(spy.size(), 1); // we don't wait for the second signal...
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(!spy.wait(1));
QTimer::singleShot(10, this, SIGNAL(sigFoo()));
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QSignalSpy::spyFunctionPointerWithoutArgs()
@@ -271,15 +271,15 @@ void tst_QSignalSpy::spyFunctionPointerWithoutArgs()
QtTestObject obj;
QSignalSpy spy(&obj, &QtTestObject::sig0);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
emit obj.sig0();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
emit obj.sig0();
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QList<QVariant> args = spy.takeFirst();
- QCOMPARE(args.count(), 0);
+ QCOMPARE(args.size(), 0);
}
void tst_QSignalSpy::spyFunctionPointerWithBasicArgs()
@@ -288,10 +288,10 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicArgs()
QSignalSpy spy(&obj, &QtTestObject::sig1);
emit obj.sig1(1, 2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> args = spy.takeFirst();
- QCOMPARE(args.count(), 2);
+ QCOMPARE(args.size(), 2);
QCOMPARE(args.at(0).toInt(), 1);
QCOMPARE(args.at(1).toInt(), 2);
@@ -299,7 +299,7 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicArgs()
emit obj.sigLong(1l, 2l);
args = spyl.takeFirst();
- QCOMPARE(args.count(), 2);
+ QCOMPARE(args.size(), 2);
QCOMPARE(qvariant_cast<long>(args.at(0)), 1l);
QCOMPARE(qvariant_cast<long>(args.at(1)), 2l);
}
@@ -316,10 +316,10 @@ void tst_QSignalSpy::spyFunctionPointerWithPointers()
int i2 = 2;
emit obj.sig2(&i1, &i2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> args = spy.takeFirst();
- QCOMPARE(args.count(), 2);
+ QCOMPARE(args.size(), 2);
QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1);
QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2);
}
@@ -330,15 +330,15 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicQtClasses()
QSignalSpy spy(&obj, &QtTestObject2::sig);
emit obj.sig(QString("bubu"));
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.at(0).size(), 1);
QCOMPARE(spy.at(0).at(0).toString(), QString("bubu"));
QSignalSpy spy2(&obj, &QtTestObject2::sig5);
QVariant val(45);
emit obj.sig5(val);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy2.at(0).count(), 1);
+ QCOMPARE(spy2.size(), 1);
+ QCOMPARE(spy2.at(0).size(), 1);
QCOMPARE(spy2.at(0).at(0), val);
QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val);
}
@@ -350,8 +350,8 @@ void tst_QSignalSpy::spyFunctionPointerWithQtClasses()
QSignalSpy spy(&obj, &QtTestObject2::sig2);
QDateTime dt = QDateTime::currentDateTime();
emit obj.sig2(dt);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.at(0).size(), 1);
QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime");
QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt);
QCOMPARE(spy.at(0).at(0).toDateTime(), dt);
@@ -373,8 +373,8 @@ void tst_QSignalSpy::spyFunctionPointerWithCustomClass()
{
QSignalSpy spy(&obj, &QtTestObject2::sig6);
emit obj.sig6({});
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.at(0).size(), 1);
QCOMPARE(spy.at(0).at(0).typeName(), "CustomType");
}
@@ -420,7 +420,7 @@ void tst_QSignalSpy::waitFunctionPointer_signalEmittedTooLate()
QSignalSpy spy(this, &tst_QSignalSpy::sigFoo);
QVERIFY(!spy.wait(200));
QTest::qWait(400);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes()
@@ -429,13 +429,13 @@ void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes()
QTimer::singleShot(800, this, SIGNAL(sigFoo()));
QSignalSpy spy(this, &tst_QSignalSpy::sigFoo);
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 1); // we don't wait for the second signal...
+ QCOMPARE(spy.size(), 1); // we don't wait for the second signal...
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(!spy.wait(1));
QTimer::singleShot(10, this, SIGNAL(sigFoo()));
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QSignalSpy::spyOnMetaMethod()
@@ -454,7 +454,7 @@ void tst_QSignalSpy::spyOnMetaMethod()
QVERIFY(spy.isValid());
obj.setObjectName("A new object name");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
Q_DECLARE_METATYPE(QMetaMethod);
diff --git a/tests/auto/testlib/selftests/CMakeLists.txt b/tests/auto/testlib/selftests/CMakeLists.txt
index ceea1226f8..c3f428d110 100644
--- a/tests/auto/testlib/selftests/CMakeLists.txt
+++ b/tests/auto/testlib/selftests/CMakeLists.txt
@@ -56,6 +56,7 @@ set(subprograms
deleteLater
deleteLater_noApp
differentexec
+ eventloop
exceptionthrow
expectfail
extendedcompare
diff --git a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp
index cb69905c34..ec54f786d9 100644
--- a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp
+++ b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp
@@ -180,16 +180,16 @@ int main(int argc, char** argv)
if (badstring == -1) {
tst_BadXml test;
- return QTest::qExec(&test, args.count(), const_cast<char**>(args.data()));
+ return QTest::qExec(&test, args.size(), const_cast<char**>(args.data()));
}
QList<QByteArray> badstrings = tst_BadXml::badStrings();
- if (badstring >= badstrings.count())
+ if (badstring >= badstrings.size())
qFatal("`-badstring %d' is out of range", badstring);
tst_BadXmlSub test;
test.className = badstrings[badstring].constData();
- return QTest::qExec(&test, args.count(), const_cast<char**>(args.data()));
+ return QTest::qExec(&test, args.size(), const_cast<char**>(args.data()));
}
#include "tst_badxml.moc"
diff --git a/tests/auto/testlib/selftests/catch_p_p.h b/tests/auto/testlib/selftests/catch_p_p.h
index 9034ac2204..f22183557d 100644
--- a/tests/auto/testlib/selftests/catch_p_p.h
+++ b/tests/auto/testlib/selftests/catch_p_p.h
@@ -1,6 +1,6 @@
/*
- * Catch v2.13.9
- * Generated: 2022-04-12 22:37:23.260201
+ * Catch v2.13.10
+ * Generated: 2022-10-16 11:01:23.452308
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved.
@@ -15,7 +15,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
-#define CATCH_VERSION_PATCH 9
+#define CATCH_VERSION_PATCH 10
#ifdef __clang__
# pragma clang system_header
@@ -7395,8 +7395,6 @@ namespace Catch {
template <typename T, bool Destruct>
struct ObjectStorage
{
- using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
-
ObjectStorage() : data() {}
ObjectStorage(const ObjectStorage& other)
@@ -7439,7 +7437,7 @@ namespace Catch {
return *static_cast<T*>(static_cast<void*>(&data));
}
- TStorage data;
+ struct { alignas(T) unsigned char data[sizeof(T)]; } data;
};
}
@@ -7949,7 +7947,7 @@ namespace Catch {
#if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
- #define CATCH_TRAP() __asm__(".inst 0xd4200000")
+ #define CATCH_TRAP() __asm__(".inst 0xd43e0000")
#endif
#elif defined(CATCH_PLATFORM_IPHONE)
@@ -13560,7 +13558,7 @@ namespace Catch {
// Handle list request
if( Option<std::size_t> listed = list( m_config ) )
- return static_cast<int>( *listed );
+ return (std::min) (MaxExitCode, static_cast<int>(*listed));
TestGroup tests { m_config };
auto const totals = tests.execute();
@@ -15393,7 +15391,7 @@ namespace Catch {
}
Version const& libraryVersion() {
- static Version version( 2, 13, 9, "", 0 );
+ static Version version( 2, 13, 10, "", 0 );
return version;
}
@@ -17528,12 +17526,20 @@ namespace Catch {
#ifndef __OBJC__
+#ifndef CATCH_INTERNAL_CDECL
+#ifdef _MSC_VER
+#define CATCH_INTERNAL_CDECL __cdecl
+#else
+#define CATCH_INTERNAL_CDECL
+#endif
+#endif
+
#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
// Standard C/C++ Win32 Unicode wmain entry point
-extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
+extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point
-int main (int argc, char * argv[]) {
+int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) {
#endif
return Catch::Session().run( argc, argv );
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index 94c04157f2..072324880e 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -1,9 +1,9 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include <QtCore/QCoreApplication>
#include <QTest>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QTimer>
#ifdef QT_GUI_LIB
#include <QtGui/QColor>
#include <QtGui/QImage>
@@ -139,6 +139,7 @@ private slots:
void compareQVector3D();
void compareQVector4D();
#endif
+ void tryCompare();
void verify();
void verify2();
void tryVerify();
@@ -649,16 +650,88 @@ void tst_Cmptest::verify2()
QVERIFY2(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData());
}
+class DeferredFlag : public QObject // Can't be const.
+{
+ Q_OBJECT
+ bool m_flag;
+public:
+ // A boolean that either starts out true or decays to true after 50 ms.
+ // However, that decay will only happen when the event loop is run.
+ explicit DeferredFlag(bool initial = false) : m_flag(initial)
+ {
+ if (!initial)
+ QTimer::singleShot(50, this, &DeferredFlag::onTimeOut);
+ }
+ explicit operator bool() const { return m_flag; }
+ bool operator!() const { return !m_flag; }
+ friend bool operator==(const DeferredFlag &a, const DeferredFlag &b)
+ {
+ return bool(a) == bool(b);
+ }
+public slots:
+ void onTimeOut() { m_flag = true; }
+};
+
+char *toString(const DeferredFlag &val)
+{
+ return qstrdup(bool(val) ? "DeferredFlag(true)" : "DeferredFlag(false)");
+}
+
+void tst_Cmptest::tryCompare()
+{
+ /* Note that expected values given as DeferredFlag() shall be re-evaluated
+ each time the comparison is checked, hence supply a fresh false instance,
+ that'll be discarded before it has a chance to decay, hence only compare
+ equal to a false instance. Do not replace them with a local variable
+ initialized to false, as it would (of course) decay.
+ */
+ DeferredFlag trueAlready(true);
+ {
+ DeferredFlag c;
+ // QTRY should check before looping, so be equal to the fresh false immediately.
+ QTRY_COMPARE(c, DeferredFlag());
+ // Given time, it'll end up equal to a true one.
+ QTRY_COMPARE(c, trueAlready);
+ }
+ {
+ DeferredFlag c;
+ QTRY_COMPARE_WITH_TIMEOUT(c, DeferredFlag(), 300);
+ QVERIFY(!c); // Instantly equal, so succeeded without delay.
+ QTRY_COMPARE_WITH_TIMEOUT(c, trueAlready, 200);
+ qInfo("Should now time out and fail");
+ QTRY_COMPARE_WITH_TIMEOUT(c, DeferredFlag(), 200);
+ }
+}
+
void tst_Cmptest::tryVerify()
{
- QTRY_VERIFY(opaqueFunc() > 2);
- QTRY_VERIFY_WITH_TIMEOUT(opaqueFunc() < 2, 1);
+ {
+ DeferredFlag c;
+ QTRY_VERIFY(!c);
+ QTRY_VERIFY(c);
+ }
+ {
+ DeferredFlag c;
+ QTRY_VERIFY_WITH_TIMEOUT(!c, 300);
+ QTRY_VERIFY_WITH_TIMEOUT(c, 200);
+ qInfo("Should now time out and fail");
+ QTRY_VERIFY_WITH_TIMEOUT(!c, 200);
+ }
}
void tst_Cmptest::tryVerify2()
{
- QTRY_VERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData());
- QTRY_VERIFY2_WITH_TIMEOUT(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData(), 1);
+ {
+ DeferredFlag c;
+ QTRY_VERIFY2(!c, "Failed to check before looping");
+ QTRY_VERIFY2(c, "Failed to trigger single-shot");
+ }
+ {
+ DeferredFlag c;
+ QTRY_VERIFY2_WITH_TIMEOUT(!c, "Failed to check before looping", 300);
+ QTRY_VERIFY2_WITH_TIMEOUT(c, "Failed to trigger single-shot", 200);
+ QTRY_VERIFY2_WITH_TIMEOUT(!c, "Should time out and fail", 200);
+ }
}
void tst_Cmptest::verifyExplicitOperatorBool()
diff --git a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
index abac42c723..38ed27d331 100644
--- a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
+++ b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
@@ -7,6 +7,8 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
+#else
+#include <sys/resource.h>
#endif
class tst_Crashes: public QObject
@@ -22,6 +24,12 @@ void tst_Crashes::crash()
#if defined(Q_OS_WIN)
//we avoid the error dialogbox to appear on windows
SetErrorMode( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+#elif defined(RLIMIT_CORE)
+ // Unix: set our core dump limit to zero to request no dialogs.
+ if (struct rlimit rlim; getrlimit(RLIMIT_CORE, &rlim) == 0) {
+ rlim.rlim_cur = 0;
+ setrlimit(RLIMIT_CORE, &rlim);
+ }
#endif
/*
We deliberately dereference an invalid but non-zero address;
diff --git a/tests/auto/testlib/selftests/eventloop/CMakeLists.txt b/tests/auto/testlib/selftests/eventloop/CMakeLists.txt
new file mode 100644
index 0000000000..f1fa9a788c
--- /dev/null
+++ b/tests/auto/testlib/selftests/eventloop/CMakeLists.txt
@@ -0,0 +1,16 @@
+#####################################################################
+## eventloop Binary:
+#####################################################################
+
+qt_internal_add_executable(eventloop
+ NO_INSTALL
+ OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ SOURCES
+ tst_eventloop.cpp
+ PUBLIC_LIBRARIES
+ Qt::Test
+)
+
+## Scopes:
+#####################################################################
+qt_internal_apply_testlib_coverage_options(eventloop)
diff --git a/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp b/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp
new file mode 100644
index 0000000000..202a8b77f1
--- /dev/null
+++ b/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp
@@ -0,0 +1,104 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <QTest>
+#include <QTestEventLoop>
+#include <QtCore/QTimer>
+
+// Tests for QTestEventLoop (and some QTRY_* details)
+class tst_EventLoop: public QObject
+{
+Q_OBJECT
+
+ bool m_inTestFunction = false;
+private slots:
+ void cleanup();
+ void fail();
+ void skip();
+ void pass();
+};
+
+class DeferredFlag : public QObject // Can't be const.
+{
+ Q_OBJECT
+ bool m_flag;
+public:
+ // A boolean that either starts out true or decays to true after 50 ms.
+ // However, that decay will only happen when the event loop is run.
+ explicit DeferredFlag(bool initial = false) : m_flag(initial)
+ {
+ if (!initial)
+ QTimer::singleShot(50, this, &DeferredFlag::onTimeOut);
+ }
+ explicit operator bool() const { return m_flag; }
+ bool operator!() const { return !m_flag; }
+ friend bool operator==(const DeferredFlag &a, const DeferredFlag &b)
+ {
+ return bool(a) == bool(b);
+ }
+public slots:
+ void onTimeOut() { m_flag = true; }
+};
+
+char *toString(const DeferredFlag &val)
+{
+ return qstrdup(bool(val) ? "DeferredFlag(true)" : "DeferredFlag(false)");
+}
+
+void tst_EventLoop::cleanup()
+{
+ // QTBUG-104441: looping didn't happen in cleanup() if test failed or skipped.
+ {
+ DeferredFlag flag;
+ auto &loop = QTestEventLoop::instance();
+ loop.enterLoopMSecs(100);
+ QVERIFY2(loop.timeout(), "QTestEventLoop exited prematurely in cleanup()");
+ QVERIFY(flag);
+ }
+ {
+ DeferredFlag flag;
+ QTRY_VERIFY2(flag, "QTRY_* loop exited prematurely in cleanup()");
+ }
+
+ m_inTestFunction = false;
+}
+
+void tst_EventLoop::fail()
+{
+ QVERIFY2(!std::exchange(m_inTestFunction, true), "Earlier test failed to clean up");
+ QFAIL("Failing test should still clean up");
+}
+
+void tst_EventLoop::skip()
+{
+ QVERIFY2(!std::exchange(m_inTestFunction, true), "Earlier test failed to clean up");
+ QSKIP("Skipping test should still clean up");
+}
+
+void tst_EventLoop::pass()
+{
+ QVERIFY2(!std::exchange(m_inTestFunction, true), "Earlier test failed to clean up");
+ {
+ DeferredFlag flag;
+ auto &loop = QTestEventLoop::instance();
+ loop.enterLoopMSecs(100);
+ QVERIFY(loop.timeout());
+ QVERIFY(flag);
+ }
+ {
+ DeferredFlag flag;
+ QTRY_VERIFY(flag);
+ }
+ DeferredFlag flag;
+ QTestEventLoop loop(this);
+ QVERIFY(!flag);
+ loop.enterLoopMSecs(1);
+ QVERIFY(loop.timeout());
+ QVERIFY(!flag);
+ loop.enterLoopMSecs(100);
+ QVERIFY(loop.timeout());
+ QVERIFY(flag);
+}
+
+QTEST_MAIN(tst_EventLoop)
+#include "tst_eventloop.moc"
diff --git a/tests/auto/testlib/selftests/expected_cmptest.junitxml b/tests/auto/testlib/selftests/expected_cmptest.junitxml
index f71b8f0a19..75ec61ba99 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.junitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.junitxml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite name="tst_Cmptest" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="69" failures="48" errors="0" skipped="0" time="@TEST_DURATION@">
+<testsuite name="tst_Cmptest" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="70" failures="49" errors="0" skipped="0" time="@TEST_DURATION@">
<properties>
<property name="QTestVersion" value="@INSERT_QT_VERSION_HERE@"/>
<property name="QtVersion" value="@INSERT_QT_VERSION_HERE@"/>
@@ -282,6 +282,15 @@
Expected (v4b): QVector4D(1, 3, 3, 4)]]>
</failure>
</testcase>
+ <testcase name="tryCompare" classname="tst_Cmptest" time="@TEST_DURATION@">
+ <failure type="fail" message="Compared values are not the same">
+ <![CDATA[ Actual (c) : DeferredFlag(true)
+ Expected (DeferredFlag()): DeferredFlag(false)]]>
+ </failure>
+ <system-out>
+ <![CDATA[Should now time out and fail]]>
+ </system-out>
+ </testcase>
<testcase name="verify" classname="tst_Cmptest" time="@TEST_DURATION@">
<failure type="fail" message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. ()"/>
</testcase>
@@ -289,10 +298,13 @@
<failure type="fail" message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. (42)"/>
</testcase>
<testcase name="tryVerify" classname="tst_Cmptest" time="@TEST_DURATION@">
- <failure type="fail" message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. ()"/>
+ <failure type="fail" message="&apos;!c&apos; returned FALSE. ()"/>
+ <system-out>
+ <![CDATA[Should now time out and fail]]>
+ </system-out>
</testcase>
<testcase name="tryVerify2" classname="tst_Cmptest" time="@TEST_DURATION@">
- <failure type="fail" message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. (42)"/>
+ <failure type="fail" message="&apos;!c&apos; returned FALSE. (Should time out and fail)"/>
</testcase>
<testcase name="verifyExplicitOperatorBool" classname="tst_Cmptest" time="@TEST_DURATION@"/>
<testcase name="cleanupTestCase" classname="tst_Cmptest" time="@TEST_DURATION@"/>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml
index 3cb492361b..351fad849c 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.lightxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml
@@ -377,6 +377,17 @@
</Incident>
<Duration msecs="0"/>
</TestFunction>
+ <TestFunction name="tryCompare">
+ <Message type="qinfo" file="" line="0">
+ <Description><![CDATA[Should now time out and fail]]></Description>
+ </Message>
+ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
+ <Description><![CDATA[Compared values are not the same
+ Actual (c) : DeferredFlag(true)
+ Expected (DeferredFlag()): DeferredFlag(false)]]></Description>
+ </Incident>
+ <Duration msecs="0"/>
+ </TestFunction>
<TestFunction name="verify">
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
@@ -390,14 +401,17 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify">
+ <Message type="qinfo" file="" line="0">
+ <Description><![CDATA[Should now time out and fail]]></Description>
+ </Message>
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
- <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
+ <Description><![CDATA['!c' returned FALSE. ()]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify2">
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
- <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
+ <Description><![CDATA['!c' returned FALSE. (Should time out and fail)]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.tap b/tests/auto/testlib/selftests/expected_cmptest.tap
index da7f21ab70..19c90bcb93 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.tap
+++ b/tests/auto/testlib/selftests/expected_cmptest.tap
@@ -516,7 +516,23 @@ not ok 63 - compareQVector4D()
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
line: 0
...
-not ok 64 - verify()
+not ok 64 - tryCompare()
+ ---
+ type: QCOMPARE
+ message: Compared values are not the same
+ wanted: DeferredFlag(false) (DeferredFlag())
+ found: DeferredFlag(true) (c)
+ expected: DeferredFlag(false) (DeferredFlag())
+ actual: DeferredFlag(true) (c)
+ at: tst_Cmptest::tryCompare() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:0)
+ file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+ line: 0
+ extensions:
+ messages:
+ - severity: info
+ message: Should now time out and fail
+ ...
+not ok 65 - verify()
---
type: QVERIFY
message: Verification failed
@@ -528,7 +544,7 @@ not ok 64 - verify()
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
line: 0
...
-not ok 65 - verify2()
+not ok 66 - verify2()
---
type: QVERIFY
message: 42
@@ -540,33 +556,37 @@ not ok 65 - verify2()
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
line: 0
...
-not ok 66 - tryVerify()
+not ok 67 - tryVerify()
---
type: QVERIFY
message: Verification failed
- wanted: true (opaqueFunc() < 2)
- found: false (opaqueFunc() < 2)
- expected: true (opaqueFunc() < 2)
- actual: false (opaqueFunc() < 2)
+ wanted: true (!c)
+ found: false (!c)
+ expected: true (!c)
+ actual: false (!c)
at: tst_Cmptest::tryVerify() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:0)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
line: 0
+ extensions:
+ messages:
+ - severity: info
+ message: Should now time out and fail
...
-not ok 67 - tryVerify2()
+not ok 68 - tryVerify2()
---
type: QVERIFY
- message: 42
- wanted: true (opaqueFunc() < 2)
- found: false (opaqueFunc() < 2)
- expected: true (opaqueFunc() < 2)
- actual: false (opaqueFunc() < 2)
+ message: Should time out and fail
+ wanted: true (!c)
+ found: false (!c)
+ expected: true (!c)
+ actual: false (!c)
at: tst_Cmptest::tryVerify2() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:0)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
line: 0
...
-ok 68 - verifyExplicitOperatorBool()
-ok 69 - cleanupTestCase()
-1..69
-# tests 69
+ok 69 - verifyExplicitOperatorBool()
+ok 70 - cleanupTestCase()
+1..70
+# tests 70
# pass 21
-# fail 48
+# fail 49
diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity
index 83e007413e..5f1e8374b9 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.teamcity
+++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity
@@ -169,6 +169,10 @@
##teamcity[testStarted name='compareQVector4D()' flowId='tst_Cmptest']
##teamcity[testFailed name='compareQVector4D()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v4a): QVector4D(1, 2, 3, 4)|n Expected (v4b): QVector4D(1, 3, 3, 4)' flowId='tst_Cmptest']
##teamcity[testFinished name='compareQVector4D()' flowId='tst_Cmptest']
+##teamcity[testStarted name='tryCompare()' flowId='tst_Cmptest']
+##teamcity[testFailed name='tryCompare()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (c) : DeferredFlag(true)|n Expected (DeferredFlag()): DeferredFlag(false)' flowId='tst_Cmptest']
+##teamcity[testStdOut name='tryCompare()' out='QINFO: Should now time out and fail' flowId='tst_Cmptest']
+##teamcity[testFinished name='tryCompare()' flowId='tst_Cmptest']
##teamcity[testStarted name='verify()' flowId='tst_Cmptest']
##teamcity[testFailed name='verify()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()' flowId='tst_Cmptest']
##teamcity[testFinished name='verify()' flowId='tst_Cmptest']
@@ -176,10 +180,11 @@
##teamcity[testFailed name='verify2()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)' flowId='tst_Cmptest']
##teamcity[testFinished name='verify2()' flowId='tst_Cmptest']
##teamcity[testStarted name='tryVerify()' flowId='tst_Cmptest']
-##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()' flowId='tst_Cmptest']
+##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'!c|' returned FALSE. ()' flowId='tst_Cmptest']
+##teamcity[testStdOut name='tryVerify()' out='QINFO: Should now time out and fail' flowId='tst_Cmptest']
##teamcity[testFinished name='tryVerify()' flowId='tst_Cmptest']
##teamcity[testStarted name='tryVerify2()' flowId='tst_Cmptest']
-##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)' flowId='tst_Cmptest']
+##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'!c|' returned FALSE. (Should time out and fail)' flowId='tst_Cmptest']
##teamcity[testFinished name='tryVerify2()' flowId='tst_Cmptest']
##teamcity[testStarted name='verifyExplicitOperatorBool()' flowId='tst_Cmptest']
##teamcity[testFinished name='verifyExplicitOperatorBool()' flowId='tst_Cmptest']
diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt
index 8547119988..f323729000 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.txt
+++ b/tests/auto/testlib/selftests/expected_cmptest.txt
@@ -191,15 +191,21 @@ FAIL! : tst_Cmptest::compareQVector4D() Compared values are not the same
Actual (v4a): QVector4D(1, 2, 3, 4)
Expected (v4b): QVector4D(1, 3, 3, 4)
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
+QINFO : tst_Cmptest::tryCompare() Should now time out and fail
+FAIL! : tst_Cmptest::tryCompare() Compared values are not the same
+ Actual (c) : DeferredFlag(true)
+ Expected (DeferredFlag()): DeferredFlag(false)
+ Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. ()
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42)
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
-FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. ()
+QINFO : tst_Cmptest::tryVerify() Should now time out and fail
+FAIL! : tst_Cmptest::tryVerify() '!c' returned FALSE. ()
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
-FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42)
+FAIL! : tst_Cmptest::tryVerify2() '!c' returned FALSE. (Should time out and fail)
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
PASS : tst_Cmptest::verifyExplicitOperatorBool()
PASS : tst_Cmptest::cleanupTestCase()
-Totals: 21 passed, 48 failed, 0 skipped, 0 blacklisted, 0ms
+Totals: 21 passed, 49 failed, 0 skipped, 0 blacklisted, 0ms
********* Finished testing of tst_Cmptest *********
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml
index f296a9e797..0bee84c786 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xml
@@ -379,6 +379,17 @@
</Incident>
<Duration msecs="0"/>
</TestFunction>
+ <TestFunction name="tryCompare">
+ <Message type="qinfo" file="" line="0">
+ <Description><![CDATA[Should now time out and fail]]></Description>
+ </Message>
+ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
+ <Description><![CDATA[Compared values are not the same
+ Actual (c) : DeferredFlag(true)
+ Expected (DeferredFlag()): DeferredFlag(false)]]></Description>
+ </Incident>
+ <Duration msecs="0"/>
+ </TestFunction>
<TestFunction name="verify">
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
@@ -392,14 +403,17 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify">
+ <Message type="qinfo" file="" line="0">
+ <Description><![CDATA[Should now time out and fail]]></Description>
+ </Message>
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
- <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
+ <Description><![CDATA['!c' returned FALSE. ()]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify2">
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
- <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
+ <Description><![CDATA['!c' returned FALSE. (Should time out and fail)]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_eventloop.junitxml b/tests/auto/testlib/selftests/expected_eventloop.junitxml
new file mode 100644
index 0000000000..566bc1605e
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_eventloop.junitxml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<testsuite name="tst_EventLoop" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="5" failures="1" errors="0" skipped="1" time="@TEST_DURATION@">
+ <properties>
+ <property name="QTestVersion" value="@INSERT_QT_VERSION_HERE@"/>
+ <property name="QtVersion" value="@INSERT_QT_VERSION_HERE@"/>
+ <property name="QtBuild" value=""/>
+ </properties>
+ <testcase name="initTestCase" classname="tst_EventLoop" time="@TEST_DURATION@"/>
+ <testcase name="fail" classname="tst_EventLoop" time="@TEST_DURATION@">
+ <failure type="fail" message="Failing test should still clean up"/>
+ </testcase>
+ <testcase name="skip" classname="tst_EventLoop" time="@TEST_DURATION@">
+ <skipped message="Skipping test should still clean up"/>
+ </testcase>
+ <testcase name="pass" classname="tst_EventLoop" time="@TEST_DURATION@"/>
+ <testcase name="cleanupTestCase" classname="tst_EventLoop" time="@TEST_DURATION@"/>
+</testsuite>
diff --git a/tests/auto/testlib/selftests/expected_eventloop.lightxml b/tests/auto/testlib/selftests/expected_eventloop.lightxml
new file mode 100644
index 0000000000..40880fde01
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_eventloop.lightxml
@@ -0,0 +1,30 @@
+ <Environment>
+ <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
+ <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
+ </Environment>
+ <TestFunction name="initTestCase">
+ <Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="fail">
+ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0">
+ <Description><![CDATA[Failing test should still clean up]]></Description>
+ </Incident>
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="skip">
+ <Incident type="skip" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0">
+ <Description><![CDATA[Skipping test should still clean up]]></Description>
+ </Incident>
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="pass">
+ <Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="cleanupTestCase">
+ <Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+ </TestFunction>
+ <Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_eventloop.tap b/tests/auto/testlib/selftests/expected_eventloop.tap
new file mode 100644
index 0000000000..496a6e636a
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_eventloop.tap
@@ -0,0 +1,17 @@
+TAP version 13
+# tst_EventLoop
+ok 1 - initTestCase()
+not ok 2 - fail()
+ ---
+ # Failing test should still clean up
+ at: tst_EventLoop::fail() (qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp:0)
+ file: qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp
+ line: 0
+ ...
+ok 3 - skip() # SKIP Skipping test should still clean up
+ok 4 - pass()
+ok 5 - cleanupTestCase()
+1..5
+# tests 5
+# pass 3
+# fail 1
diff --git a/tests/auto/testlib/selftests/expected_eventloop.teamcity b/tests/auto/testlib/selftests/expected_eventloop.teamcity
new file mode 100644
index 0000000000..a293a20135
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_eventloop.teamcity
@@ -0,0 +1,14 @@
+##teamcity[testSuiteStarted name='tst_EventLoop' flowId='tst_EventLoop']
+##teamcity[testStarted name='initTestCase()' flowId='tst_EventLoop']
+##teamcity[testFinished name='initTestCase()' flowId='tst_EventLoop']
+##teamcity[testStarted name='fail()' flowId='tst_EventLoop']
+##teamcity[testFailed name='fail()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)|]' details='Failing test should still clean up' flowId='tst_EventLoop']
+##teamcity[testFinished name='fail()' flowId='tst_EventLoop']
+##teamcity[testStarted name='skip()' flowId='tst_EventLoop']
+##teamcity[testIgnored name='skip()' message='Skipping test should still clean up |[Loc: qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)|]' flowId='tst_EventLoop']
+##teamcity[testFinished name='skip()' flowId='tst_EventLoop']
+##teamcity[testStarted name='pass()' flowId='tst_EventLoop']
+##teamcity[testFinished name='pass()' flowId='tst_EventLoop']
+##teamcity[testStarted name='cleanupTestCase()' flowId='tst_EventLoop']
+##teamcity[testFinished name='cleanupTestCase()' flowId='tst_EventLoop']
+##teamcity[testSuiteFinished name='tst_EventLoop' flowId='tst_EventLoop']
diff --git a/tests/auto/testlib/selftests/expected_eventloop.txt b/tests/auto/testlib/selftests/expected_eventloop.txt
new file mode 100644
index 0000000000..548ef393f6
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_eventloop.txt
@@ -0,0 +1,11 @@
+********* Start testing of tst_EventLoop *********
+Config: Using QtTest library
+PASS : tst_EventLoop::initTestCase()
+FAIL! : tst_EventLoop::fail() Failing test should still clean up
+ Loc: [qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)]
+SKIP : tst_EventLoop::skip() Skipping test should still clean up
+ Loc: [qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)]
+PASS : tst_EventLoop::pass()
+PASS : tst_EventLoop::cleanupTestCase()
+Totals: 3 passed, 1 failed, 1 skipped, 0 blacklisted, 0ms
+********* Finished testing of tst_EventLoop *********
diff --git a/tests/auto/testlib/selftests/expected_eventloop.xml b/tests/auto/testlib/selftests/expected_eventloop.xml
new file mode 100644
index 0000000000..f9d9475666
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_eventloop.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestCase name="tst_EventLoop">
+ <Environment>
+ <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
+ <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
+ </Environment>
+ <TestFunction name="initTestCase">
+ <Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="fail">
+ <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0">
+ <Description><![CDATA[Failing test should still clean up]]></Description>
+ </Incident>
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="skip">
+ <Incident type="skip" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0">
+ <Description><![CDATA[Skipping test should still clean up]]></Description>
+ </Incident>
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="pass">
+ <Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+ </TestFunction>
+ <TestFunction name="cleanupTestCase">
+ <Incident type="pass" file="" line="0" />
+ <Duration msecs="0"/>
+ </TestFunction>
+ <Duration msecs="0"/>
+</TestCase>
diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py
index 987a08b2c1..8f6134725b 100755
--- a/tests/auto/testlib/selftests/generate_expected_output.py
+++ b/tests/auto/testlib/selftests/generate_expected_output.py
@@ -31,8 +31,8 @@ TESTS = ['assert', 'badxml', 'benchlibcallgrind', 'benchlibcounting',
'benchlibeventcounter', 'benchliboptions', 'benchlibtickcounter',
'benchlibwalltime', 'blacklisted', 'cmptest', 'commandlinedata',
'counting', 'crashes', 'datatable', 'datetime', 'deleteLater',
- 'deleteLater_noApp', 'differentexec', 'exceptionthrow', 'expectfail',
- "extendedcompare", 'failcleanup', 'failcleanuptestcase',
+ 'deleteLater_noApp', 'differentexec', 'eventloop', 'exceptionthrow',
+ 'expectfail', "extendedcompare", 'failcleanup', 'failcleanuptestcase',
'faildatatype', 'failfetchtype', 'failinit', 'failinitdata',
'fetchbogus', 'findtestdata', 'float', 'globaldata', 'longstring',
'maxwarnings', 'mouse', 'multiexec', 'pairdiagnostics', 'pass',
diff --git a/tests/auto/testlib/selftests/qt_attribution.json b/tests/auto/testlib/selftests/qt_attribution.json
index 6c483749a1..3a126f59ed 100644
--- a/tests/auto/testlib/selftests/qt_attribution.json
+++ b/tests/auto/testlib/selftests/qt_attribution.json
@@ -8,7 +8,7 @@
"Description": "Catch2 is a multi-paradigm test framework for C++.",
"Homepage": "https://github.com/catchorg/Catch2",
- "Version": "2.13.8",
+ "Version": "2.13.10",
"License": "Boost Software License 1.0",
"LicenseId": "BSL-1.0",
"LicenseFile": "CATCH_LICENSE.txt",
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index b70aec2c85..f6c97bc345 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -432,8 +432,8 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error)
// format:
// "function","[globaltag:]tag","metric",value_per_iteration,total,iterations
QStringList split = line.split(',');
- if (split.count() != 6) {
- if (error) *error = QString("Wrong number of columns (%1)").arg(split.count());
+ if (split.size() != 6) {
+ if (error) *error = QString("Wrong number of columns (%1)").arg(split.size());
return out;
}
@@ -636,6 +636,11 @@ bool TestLogger::shouldIgnoreTest(const QString &test) const
return true;
#endif
+ if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")) {
+ qDebug() << "TestLogger::shouldIgnoreTest() ignore" << test << "on wayland/xwayland!";
+ return true;
+ }
+
// These tests are affected by timing and whether the CPU tick counter
// is monotonically increasing. They won't work on some machines so
// leave them off by default. Feel free to enable them for your own
diff --git a/tests/auto/tools/moc/qmlmacro.h b/tests/auto/tools/moc/qmlmacro.h
new file mode 100644
index 0000000000..cb3b291bf1
--- /dev/null
+++ b/tests/auto/tools/moc/qmlmacro.h
@@ -0,0 +1,19 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+
+#ifndef QMlMACRO_H
+#define QMlMACRO_H
+
+#include <QObject>
+#include <QByteArray>
+
+struct QmlMacro : QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("QML.Element", "auto")
+
+ signals:
+ void f(QByteArray &b);
+};
+#endif
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index d2946efb3f..8862b0daf2 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -56,12 +56,23 @@
#include "fwdclass2.h"
#include "fwdclass3.h"
+#include "qmlmacro.h"
+
#ifdef Q_MOC_RUN
// check that moc can parse these constructs, they are being used in Windows winsock2.h header
#define STRING_HASH_HASH(x) ("foo" ## x ## "bar")
const char *string_hash_hash = STRING_HASH_HASH("baz");
#endif
+#if defined(Q_MOC_RUN) || __cplusplus > 202002L
+/* Check that nested inline namespaces are at least not causing moc to break.
+ Check it even outside of C++20 mode as moc gets passed the wrong __cplusplus version
+ and also to increase coverage, given how few C++20 configurations exist in the CI at the time
+ of writing this comment.
+*/
+namespace A::inline B {}
+#endif
+
Q_DECLARE_METATYPE(const QMetaObject*);
#define TESTEXPORTMACRO Q_DECL_EXPORT
diff --git a/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
index 6cbea1b328..b86d3643cc 100644
--- a/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
+++ b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
@@ -162,7 +162,8 @@ void tst_qdbusxml2cpp::process_data()
"<arg type=\"s\" direction=\"out\"/>"
"<arg type=\"s\" direction=\"out\"/>"
"</method>"
- << QRegularExpression("Q_SLOTS:.*QDBusPendingReply<QString, QString> Method\\(const QString &\\w*, const QString &",
+ << QRegularExpression("Q_SLOTS:.*QDBusPendingReply<QString, QString> Method\\(const QString &\\w*, const QString &\\w*\\)"
+ ".*inline QDBusReply<QString> Method\\(const QString &\\w*, const QString &\\w*, QString &\\w*\\)",
QRegularExpression::DotMatchesEverythingOption)
<< QRegularExpression("Q_SLOTS:.*QString Method\\(const QString &\\w*, const QString &\\w*, QString &",
QRegularExpression::DotMatchesEverythingOption);
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index c03fb44791..ba23e05525 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -124,7 +124,7 @@ void tst_qmake::initTestCase()
QString testDataPath = QFINDTESTDATA(subProgram);
if (!testDataPath.endsWith(subProgram))
QFAIL("Cannot find test data directory.");
- testDataPath.chop(subProgram.length() - testDataSubDir.length());
+ testDataPath.chop(subProgram.size() - testDataSubDir.size());
QString userWorkDir = qgetenv("TST_QMAKE_BUILD_DIR");
if (userWorkDir.isEmpty()) {
diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp
index bddaeba042..8e6d7eada2 100644
--- a/tests/auto/tools/qmakelib/evaltest.cpp
+++ b/tests/auto/tools/qmakelib/evaltest.cpp
@@ -2800,7 +2800,7 @@ static bool compareState(QMakeEvaluator *eval, ProFile *out)
}
ProValueMap::Iterator it;
ProValueMap *vmap = eval->findValues(var, &it);
- if (value.length() == 1 && value.at(0) == "UNDEF") {
+ if (value.size() == 1 && value.at(0) == "UNDEF") {
if (vmap) {
qWarning("Value of %s is incorrect.\n Actual:%s\nExpected: <UNDEFINED>",
qPrintable(var.toQString()),
diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
index 7d2f59dc83..a35864811a 100644
--- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
+++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
@@ -77,7 +77,7 @@ void tst_QColorDialog::native_activeModalWidget()
void tst_QColorDialog::postKeyReturn() {
QWidgetList list = QApplication::topLevelWidgets();
- for (int i=0; i<list.count(); ++i) {
+ for (int i=0; i<list.size(); ++i) {
QColorDialog *dialog = qobject_cast<QColorDialog *>(list[i]);
if (dialog) {
QTest::keyClick( list[i], Qt::Key_Return, Qt::NoModifier );
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index b18a5c9d12..3b43e765d9 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -21,6 +21,7 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformtheme_p.h>
+#include <qpa/qplatformintegration.h>
QT_FORWARD_DECLARE_CLASS(QDialog)
@@ -284,6 +285,10 @@ void tst_QDialog::showAsTool()
{
if (QStringList{"xcb", "offscreen"}.contains(QGuiApplication::platformName()))
QSKIP("activeWindow() is not respected by all Xcb window managers and the offscreen plugin");
+
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
DummyDialog testWidget;
testWidget.resize(200, 200);
testWidget.setWindowTitle(QTest::currentTestFunction());
@@ -689,7 +694,7 @@ void tst_QDialog::virtualsOnClose()
// Qt doesn't deliver events to QWidgets closed during destruction
QCOMPARE(filter.closeEventCount, 0);
// QDialog doesn't emit signals when closed by destruction
- QCOMPARE(rejectedSpy.count(), 0);
+ QCOMPARE(rejectedSpy.size(), 0);
}
}
@@ -742,7 +747,7 @@ void tst_QDialog::quitOnDone()
// also quit with a timer in case the test fails
QTimer::singleShot(1000, QApplication::instance(), &QApplication::quit);
QApplication::exec();
- QCOMPARE(quitSpy.count(), 1);
+ QCOMPARE(quitSpy.size(), 1);
}
void tst_QDialog::focusWidgetAfterOpen()
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index f236779eb5..8fa9061066 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -206,7 +206,7 @@ void tst_QFiledialog::currentChangedSignal()
QVERIFY(listView->model()->hasChildren(folder));
listView->setCurrentIndex(folder);
- QCOMPARE(spyCurrentChanged.count(), 1);
+ QCOMPARE(spyCurrentChanged.size(), 1);
}
// only emitted from the views, sidebar, or lookin combo
@@ -228,7 +228,7 @@ void tst_QFiledialog::directoryEnteredSignal()
QVERIFY(secondItem.isValid());
sidebar->setCurrentIndex(secondItem);
QTest::keyPress(sidebar->viewport(), Qt::Key_Return);
- QCOMPARE(spyDirectoryEntered.count(), 1);
+ QCOMPARE(spyDirectoryEntered.size(), 1);
spyDirectoryEntered.clear();
// lookInCombo
@@ -237,7 +237,7 @@ void tst_QFiledialog::directoryEnteredSignal()
QVERIFY(comboBox->view()->model()->index(1, 0).isValid());
comboBox->view()->setCurrentIndex(comboBox->view()->model()->index(1, 0));
QTest::keyPress(comboBox->view()->viewport(), Qt::Key_Return);
- QCOMPARE(spyDirectoryEntered.count(), 1);
+ QCOMPARE(spyDirectoryEntered.size(), 1);
spyDirectoryEntered.clear();
// view
@@ -314,7 +314,7 @@ void tst_QFiledialog::filesSelectedSignal()
QVERIFY(button->isEnabled());
button->animateClick();
QTRY_COMPARE(fd.isVisible(), false);
- QCOMPARE(spyFilesSelected.count(), 1);
+ QCOMPARE(spyFilesSelected.size(), 1);
}
// only emitted when the combo box is activated
@@ -339,7 +339,7 @@ void tst_QFiledialog::filterSelectedSignal()
QTest::keyPress(filters, Qt::Key_Down);
- QCOMPARE(spyFilterSelected.count(), 1);
+ QCOMPARE(spyFilterSelected.size(), 1);
}
void tst_QFiledialog::args()
@@ -380,14 +380,14 @@ void tst_QFiledialog::directory()
#ifndef Q_OS_WIN
QCOMPARE(tempPath, fd.directory().absolutePath());
#endif
- QCOMPARE(spyCurrentChanged.count(), 0);
- QCOMPARE(spyDirectoryEntered.count(), 0);
- QCOMPARE(spyFilesSelected.count(), 0);
- QCOMPARE(spyFilterSelected.count(), 0);
+ QCOMPARE(spyCurrentChanged.size(), 0);
+ QCOMPARE(spyDirectoryEntered.size(), 0);
+ QCOMPARE(spyFilesSelected.size(), 0);
+ QCOMPARE(spyFilterSelected.size(), 0);
// Check my way
QList<QListView*> list = fd.findChildren<QListView*>("listView");
- QVERIFY(list.count() > 0);
+ QVERIFY(list.size() > 0);
#ifdef Q_OS_WIN
QCOMPARE(list.at(0)->rootIndex().data().toString().toLower(), temp.dirName().toLower());
#else
@@ -418,7 +418,18 @@ void tst_QFiledialog::completer_data()
QTest::newRow("goto root") << QString() << rootPath << -1;
QTest::newRow("start at root") << rootPath << QString() << -1;
- QFileInfoList list = QDir::root().entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ QDir dir = QDir::root();
+#ifdef Q_OS_ANDROID
+ // Android 11 and above doesn't allow accessing root filesystem as before,
+ // so let's opt int for the app's home.
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 30) {
+ const auto homePaths = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
+ QVERIFY(!homePaths.isEmpty());
+ dir = QDir(homePaths.first());
+ }
+#endif
+
+ QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
QVERIFY(!list.isEmpty());
const QString folder = list.first().absoluteFilePath();
QTest::newRow("start at one below root r") << folder << "r" << -1;
@@ -561,16 +572,16 @@ void tst_QFiledialog::completer_up()
fd.show();
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
- QCOMPARE(spyFilesSelected.count(), 0);
- int depth = QDir::currentPath().split('/').count();
+ QCOMPARE(spyFilesSelected.size(), 0);
+ int depth = QDir::currentPath().split('/').size();
for (int i = 0; i <= depth * 3 + 1; ++i) {
lineEdit->insert("../");
qApp->processEvents();
}
- QCOMPARE(spyCurrentChanged.count(), 0);
- QCOMPARE(spyDirectoryEntered.count(), 0);
- QCOMPARE(spyFilesSelected.count(), 0);
- QCOMPARE(spyFilterSelected.count(), 0);
+ QCOMPARE(spyCurrentChanged.size(), 0);
+ QCOMPARE(spyDirectoryEntered.size(), 0);
+ QCOMPARE(spyFilesSelected.size(), 0);
+ QCOMPARE(spyFilterSelected.size(), 0);
}
void tst_QFiledialog::acceptMode()
@@ -650,7 +661,7 @@ void tst_QFiledialog::filters()
// effects
QList<QComboBox*> views = fd.findChildren<QComboBox*>("fileTypeCombo");
- QCOMPARE(views.count(), 1);
+ QCOMPARE(views.size(), 1);
QCOMPARE(views.at(0)->isVisible(), false);
QStringList filters;
@@ -665,15 +676,15 @@ void tst_QFiledialog::filters()
QCOMPARE(fd.nameFilters(), filters);
fd.setNameFilter("Image files (*.png *.xpm *.jpg);;Text files (*.txt);;Any files (*.*)");
QCOMPARE(fd.nameFilters(), filters);
- QCOMPARE(spyCurrentChanged.count(), 0);
- QCOMPARE(spyDirectoryEntered.count(), 0);
- QCOMPARE(spyFilesSelected.count(), 0);
- QCOMPARE(spyFilterSelected.count(), 0);
+ QCOMPARE(spyCurrentChanged.size(), 0);
+ QCOMPARE(spyDirectoryEntered.size(), 0);
+ QCOMPARE(spyFilesSelected.size(), 0);
+ QCOMPARE(spyFilterSelected.size(), 0);
// setting shouldn't emit any signals
for (int i = views.at(0)->currentIndex(); i < views.at(0)->count(); ++i)
views.at(0)->setCurrentIndex(i);
- QCOMPARE(spyFilterSelected.count(), 0);
+ QCOMPARE(spyFilterSelected.size(), 0);
//Let check if filters with whitespaces
QFileDialog fd2;
@@ -712,7 +723,7 @@ void tst_QFiledialog::selectFilter()
QCOMPARE(fd.selectedNameFilter(), filters.at(2));
fd.selectNameFilter("");
QCOMPARE(fd.selectedNameFilter(), filters.at(2));
- QCOMPARE(spyFilterSelected.count(), 0);
+ QCOMPARE(spyFilterSelected.size(), 0);
}
void tst_QFiledialog::history()
@@ -751,10 +762,10 @@ void tst_QFiledialog::history()
badHistory << QDir::toNativeSeparators(QDir::current().absolutePath());
QCOMPARE(fd.history(), badHistory);
- QCOMPARE(spyCurrentChanged.count(), 0);
- QCOMPARE(spyDirectoryEntered.count(), 0);
- QCOMPARE(spyFilesSelected.count(), 0);
- QCOMPARE(spyFilterSelected.count(), 0);
+ QCOMPARE(spyCurrentChanged.size(), 0);
+ QCOMPARE(spyDirectoryEntered.size(), 0);
+ QCOMPARE(spyFilesSelected.size(), 0);
+ QCOMPARE(spyFilterSelected.size(), 0);
}
void tst_QFiledialog::iconProvider()
@@ -857,7 +868,7 @@ void tst_QFiledialog::selectFile()
QVERIFY(model);
fd->setDirectory(QDir::currentPath());
// default value
- QCOMPARE(fd->selectedFiles().count(), 1);
+ QCOMPARE(fd->selectedFiles().size(), 1);
QScopedPointer<QTemporaryFile> tempFile;
if (file == QLatin1String("temp")) {
@@ -867,7 +878,7 @@ void tst_QFiledialog::selectFile()
}
fd->selectFile(file);
- QCOMPARE(fd->selectedFiles().count(), count);
+ QCOMPARE(fd->selectedFiles().size(), count);
if (tempFile.isNull()) {
QCOMPARE(model->index(fd->directory().path()), model->index(QDir::currentPath()));
} else {
@@ -924,29 +935,29 @@ void tst_QFiledialog::selectFiles()
// Get a list of files in the view and then get the corresponding index's
QStringList list = fd.directory().entryList(QDir::Files);
QModelIndexList toSelect;
- QVERIFY(list.count() > 1);
+ QVERIFY(list.size() > 1);
QListView* listView = fd.findChild<QListView*>("listView");
QVERIFY(listView);
- for (int i = 0; i < list.count(); ++i) {
+ for (int i = 0; i < list.size(); ++i) {
fd.selectFile(fd.directory().path() + QLatin1Char('/') + list.at(i));
QTRY_VERIFY(!listView->selectionModel()->selectedRows().isEmpty());
toSelect.append(listView->selectionModel()->selectedRows().last());
}
- QCOMPARE(spyFilesSelected.count(), 0);
+ QCOMPARE(spyFilesSelected.size(), 0);
listView->selectionModel()->clear();
- QCOMPARE(spyFilesSelected.count(), 0);
+ QCOMPARE(spyFilesSelected.size(), 0);
// select the indexes
- for (int i = 0; i < toSelect.count(); ++i) {
+ for (int i = 0; i < toSelect.size(); ++i) {
listView->selectionModel()->select(toSelect.at(i),
QItemSelectionModel::Select | QItemSelectionModel::Rows);
}
- QCOMPARE(fd.selectedFiles().count(), toSelect.count());
- QCOMPARE(spyCurrentChanged.count(), 0);
- QCOMPARE(spyDirectoryEntered.count(), 0);
- QCOMPARE(spyFilesSelected.count(), 0);
- QCOMPARE(spyFilterSelected.count(), 0);
+ QCOMPARE(fd.selectedFiles().size(), toSelect.size());
+ QCOMPARE(spyCurrentChanged.size(), 0);
+ QCOMPARE(spyDirectoryEntered.size(), 0);
+ QCOMPARE(spyFilesSelected.size(), 0);
+ QCOMPARE(spyFilterSelected.size(), 0);
}
@@ -972,13 +983,13 @@ void tst_QFiledialog::viewMode()
// find widgets
QList<QTreeView*> treeView = fd.findChildren<QTreeView*>("treeView");
- QCOMPARE(treeView.count(), 1);
+ QCOMPARE(treeView.size(), 1);
QList<QListView*> listView = fd.findChildren<QListView*>("listView");
- QCOMPARE(listView.count(), 1);
+ QCOMPARE(listView.size(), 1);
QList<QToolButton*> listButton = fd.findChildren<QToolButton*>("listModeButton");
- QCOMPARE(listButton.count(), 1);
+ QCOMPARE(listButton.size(), 1);
QList<QToolButton*> treeButton = fd.findChildren<QToolButton*>("detailModeButton");
- QCOMPARE(treeButton.count(), 1);
+ QCOMPARE(treeButton.size(), 1);
// default value
QCOMPARE(fd.viewMode(), QFileDialog::List);
@@ -1117,7 +1128,7 @@ void tst_QFiledialog::focus()
QCursor::setPos(fd.geometry().center());
QList<QWidget*> treeView = fd.findChildren<QWidget*>("fileNameEdit");
- QCOMPARE(treeView.count(), 1);
+ QCOMPARE(treeView.size(), 1);
QVERIFY(treeView.at(0));
QTRY_COMPARE(treeView.at(0)->hasFocus(), true);
QCOMPARE(treeView.at(0)->hasFocus(), true);
@@ -1147,13 +1158,13 @@ void tst_QFiledialog::historyBack()
QCOMPARE(backButton->isEnabled(), true);
QCOMPARE(forwardButton->isEnabled(), false);
fd.setDirectory(desktop);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
backButton->click();
qApp->processEvents();
QCOMPARE(backButton->isEnabled(), true);
QCOMPARE(forwardButton->isEnabled(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
QString currentPath = qvariant_cast<QString>(spy.last().first());
QCOMPARE(model->index(currentPath), model->index(temp));
@@ -1162,11 +1173,11 @@ void tst_QFiledialog::historyBack()
QCOMPARE(currentPath, home);
QCOMPARE(backButton->isEnabled(), false);
QCOMPARE(forwardButton->isEnabled(), true);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
// nothing should change at this point
backButton->click();
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
QCOMPARE(backButton->isEnabled(), false);
QCOMPARE(forwardButton->isEnabled(), true);
}
@@ -1200,7 +1211,7 @@ void tst_QFiledialog::historyForward()
QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(desktop));
QCOMPARE(backButton->isEnabled(), true);
QCOMPARE(forwardButton->isEnabled(), false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
backButton->click();
QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp));
@@ -1210,13 +1221,13 @@ void tst_QFiledialog::historyForward()
QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(home));
QCOMPARE(backButton->isEnabled(), false);
QCOMPARE(forwardButton->isEnabled(), true);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
forwardButton->click();
QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp));
backButton->click();
QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(home));
- QCOMPARE(spy.count(), 8);
+ QCOMPARE(spy.size(), 8);
forwardButton->click();
QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp));
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index 6e98eb06ac..fc12b2dc82 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -35,9 +35,7 @@
#include <qpa/qplatformdialoghelper.h>
#include <qpa/qplatformintegration.h>
-#if defined(Q_OS_WIN)
-#include "../../../network-settings.h"
-#endif
+#include "../../../../shared/filesystem.h"
#if defined QT_BUILD_INTERNAL
QT_BEGIN_NAMESPACE
@@ -108,6 +106,10 @@ private slots:
void dontShowCompleterOnRoot();
void nameFilterParsing_data();
void nameFilterParsing();
+#if QT_CONFIG(settings)
+ void settingsCompatibility_data();
+ void settingsCompatibility();
+#endif
private:
void cleanupSettingsFile();
@@ -256,7 +258,7 @@ void tst_QFileDialog2::unc()
{
#if defined(Q_OS_WIN)
// Only test UNC on Windows./
- QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable");
+ QString dir("\\\\" + QTest::uncServerName() + "\\testsharewritable");
#else
QString dir(QDir::currentPath());
#endif
@@ -448,6 +450,44 @@ void tst_QFileDialog2::task180459_lastDirectory()
delete dlg;
}
+#if QT_CONFIG(settings)
+void tst_QFileDialog2::settingsCompatibility_data()
+{
+ QTest::addColumn<QString>("qtVersion");
+ QTest::addColumn<QDataStream::Version>("dsVersion");
+ QTest::newRow("6.2.3") << "6.2.3" << QDataStream::Qt_6_0;
+ QTest::newRow("6.5") << "6.5" << QDataStream::Qt_5_0;
+ QTest::newRow("15.5.2") << "5.15.2" << QDataStream::Qt_5_15;
+ QTest::newRow("15.5.9") << "5.15.9" << QDataStream::Qt_5_15;
+}
+
+void tst_QFileDialog2::settingsCompatibility()
+{
+ static const QByteArray ba32 = QByteArrayLiteral("\x00\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xF7\x00\x00\x00\x04\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00""d\xFF\xFF\xFF\xFF\x00\x00\x00\x81\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x01\t\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00>\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00""B\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00n\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\xE8\x00\xFF\xFF\xFF\xFF\x00\x00\x00\x00");
+ static const QByteArray ba64 = QByteArrayLiteral("\x00\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xF7\x00\x00\x00\x04\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00""d\xFF\xFF\xFF\xFF\x00\x00\x00\x81\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x01\t\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00>\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00""B\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00n\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\xE8\x00\xFF\xFF\xFF\xFF\x00\x00\x00\x00");
+ QFETCH(QString, qtVersion);
+ QFETCH(QDataStream::Version, dsVersion);
+ // Create a header view, convert template to target format and store it in settings
+ {
+ QSettings settings(QSettings::UserScope, "QtProject");
+ settings.beginGroup("FileDialog");
+ settings.setValue("sidebarWidth", 93); // random value
+ settings.setValue("shortcuts", QStringList({settings.fileName(), "/tmp"}));
+ settings.setValue("qtVersion", qtVersion);
+ settings.setValue("treeViewHeader", dsVersion < QDataStream::Qt_6_0 ? ba32 : ba64);
+ settings.endGroup();
+ }
+ // Create a file dialog, read settings write them back
+ {
+ QFileDialog fd;
+ }
+ // Read back settings and compare byte array
+ QSettings settings(QSettings::UserScope, "QtProject");
+ settings.beginGroup("FileDialog");
+ const QByteArray savedState = settings.value("treeViewHeader").toByteArray();
+ QCOMPARE(savedState, ba32);
+}
+#endif
class FilterDirModel : public QSortFilterProxyModel
@@ -671,6 +711,17 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
}
if (testDir.isEmpty())
QSKIP("This test requires to have a unique directory of at least six ascii characters under c:/");
+#elif defined(Q_OS_ANDROID)
+ // Android 11 and above doesn't allow accessing root filesystem as before,
+ // so let's opt int for the app's home.
+ const auto homePaths = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
+ QVERIFY(!homePaths.isEmpty());
+ fd.setFilter(QDir::Hidden | QDir::AllDirs | QDir::Files | QDir::System);
+ fd.setDirectory(homePaths.first());
+ QDir(homePaths.first()).mkdir("etc");
+ auto cleanup = qScopeGuard([&]() {
+ QDir(homePaths.first()).rmdir("etc");
+ });
#else
fd.setFilter(QDir::Hidden | QDir::AllDirs | QDir::Files | QDir::System);
fd.setDirectory("/");
@@ -752,8 +803,8 @@ void tst_QFileDialog2::task235069_hideOnEscape()
child->setFocus();
QTest::keyClick(child, Qt::Key_Escape);
QCOMPARE(fd.isVisible(), false);
- QCOMPARE(spyFinished.count(), 1); // QTBUG-7690
- QCOMPARE(spyRejected.count(), 1); // reject(), don't hide()
+ QCOMPARE(spyFinished.size(), 1); // QTBUG-7690
+ QCOMPARE(spyRejected.size(), 1); // reject(), don't hide()
}
#ifdef QT_BUILD_INTERNAL
@@ -975,10 +1026,10 @@ public :
void removeSelection() {
QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
+ for (int i = 0; i < idxs.size(); i++)
indexes.append(idxs.at(i));
- for (int i = 0; i < indexes.count(); ++i)
+ for (int i = 0; i < indexes.size(); ++i)
if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty())
model()->removeRow(indexes.at(i).row());
}
@@ -1080,7 +1131,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes()
QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt"));
QListView *list = fd.findChild<QListView*>("listView");
QVERIFY(list);
- QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0);
+ QCOMPARE(list->selectionModel()->selectedRows(0).size(), 0);
t->deleteLater();
}
@@ -1096,7 +1147,7 @@ void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls()
QFileDialog fd;
fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
- QCOMPARE(sidebar->urls().count(), 1);
+ QCOMPARE(sidebar->urls().size(), 1);
QVERIFY(sidebar->urls().first().toLocalFile() != url);
QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url));
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 828eaa7214..0a77bc3808 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -76,7 +76,7 @@ void tst_QFontDialog::cleanup()
void tst_QFontDialog::postKeyReturn() {
QWidgetList list = QApplication::topLevelWidgets();
- for (int i=0; i<list.count(); ++i) {
+ for (int i=0; i<list.size(); ++i) {
QFontDialog *dialog = qobject_cast<QFontDialog*>(list[i]);
if (dialog) {
QTest::keyClick( list[i], Qt::Key_Return, Qt::NoModifier );
@@ -215,7 +215,7 @@ void tst_QFontDialog::testNonStandardFontSize()
QList<int> standardSizesList = QFontDatabase::standardSizes();
int nonStandardFontSize;
if (!standardSizesList.isEmpty()) {
- nonStandardFontSize = standardSizesList.at(standardSizesList.count()-1); // get the maximum standard size.
+ nonStandardFontSize = standardSizesList.at(standardSizesList.size()-1); // get the maximum standard size.
nonStandardFontSize += 1; // the increment of 1 to mock a non-standard font size.
} else {
QSKIP("QFontDatabase::standardSizes() is empty.");
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index 5dbb47ce59..3336504f7a 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -636,7 +636,7 @@ void tst_QMessageBox::acceptedRejectedSignals()
button->click();
if (roles.contains(messageBox.buttonRole(button)))
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
else
QVERIFY(spy.isEmpty());
}
diff --git a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp
index c4a2ffa2fd..167c4bf8f1 100644
--- a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp
+++ b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp
@@ -38,9 +38,9 @@ void tst_QSidebar::setUrls()
QCOMPARE(model->rowCount(), 0);
qsidebar.setUrls(urls);
QCOMPARE(qsidebar.urls(), urls);
- QCOMPARE(model->rowCount(), urls.count());
+ QCOMPARE(model->rowCount(), urls.size());
qsidebar.setUrls(urls);
- QCOMPARE(model->rowCount(), urls.count());
+ QCOMPARE(model->rowCount(), urls.size());
}
void tst_QSidebar::selectUrls()
@@ -55,7 +55,7 @@ void tst_QSidebar::selectUrls()
QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(QUrl)));
qsidebar.selectUrl(urls.at(0));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QSidebar::addUrls()
@@ -171,7 +171,7 @@ void tst_QSidebar::goToUrl()
QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(QUrl)));
QTest::mousePress(qsidebar.viewport(), Qt::LeftButton, {},
qsidebar.visualRect(qsidebar.model()->index(0, 0)).center());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((spy.value(0)).at(0).toUrl(), urls.first());
}
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index 2a0ba93803..ad079889b2 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -522,7 +522,7 @@ void tst_QWizard::addPage()
QCOMPARE(wizard.addPage(pages[i]), i);
QCOMPARE(pages[i]->window(), (QWidget *)&wizard);
QCOMPARE(wizard.startId(), 0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), i);
}
@@ -535,29 +535,29 @@ void tst_QWizard::addPage()
QVERIFY(!wizard.page(N + 1));
wizard.setPage(N + 50, new QWizardPage);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), N + 50);
wizard.setPage(-3000, new QWizardPage);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), -3000);
QWizardPage *pageX = new QWizardPage;
QCOMPARE(wizard.addPage(pageX), N + 51);
QCOMPARE(wizard.page(N + 51), pageX);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), N + 51);
QCOMPARE(wizard.addPage(new QWizardPage), N + 52);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), N + 52);
QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert null page");
wizard.addPage(0); // generates a warning
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
delete parent;
}
@@ -584,7 +584,7 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert page with ID -1");
wizard.setPage(-1, page); // gives a warning and does nothing
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(!wizard.page(-2));
QVERIFY(!wizard.page(-1));
QVERIFY(!wizard.page(0));
@@ -596,7 +596,7 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(0, page);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 0);
QCOMPARE(page->window(), (QWidget *)&wizard);
@@ -609,7 +609,7 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(-2, page);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), -2);
QCOMPARE(page->window(), (QWidget *)&wizard);
@@ -630,7 +630,7 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(2, page);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.page(2), page);
@@ -649,7 +649,7 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(-3, page);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), -3);
QCOMPARE(wizard.page(-3), page);
@@ -720,7 +720,7 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
}
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
delete parent;
}
@@ -1693,7 +1693,7 @@ public:
void createTestRows()
{
- for (int i = 0; i < combinations.count(); ++i) {
+ for (int i = 0; i < combinations.size(); ++i) {
QTest::newRow((name.toLatin1() + ", row " + QByteArray::number(i)).constData())
<< (i == 0) << (type == Equality) << combinations.at(i);
++nRows_;
@@ -2129,19 +2129,19 @@ void tst_QWizard::showCurrentPageOnly()
wizard.show();
- QCOMPARE(pages.shown().count(), 1);
+ QCOMPARE(pages.shown().size(), 1);
QCOMPARE(pages.shown().first(), pages.all().first());
const int steps = 2;
for (int i = 0; i < steps; ++i)
wizard.next();
- QCOMPARE(pages.shown().count(), 1);
+ QCOMPARE(pages.shown().size(), 1);
QCOMPARE(pages.shown().first(), pages.all().at(steps));
wizard.restart();
- QCOMPARE(pages.shown().count(), 1);
+ QCOMPARE(pages.shown().size(), 1);
QCOMPARE(pages.shown().first(), pages.all().first());
}
@@ -2273,36 +2273,36 @@ void tst_QWizard::removePage()
wizard.restart();
QCOMPARE(wizard.pageIds().size(), 4);
QCOMPARE(wizard.visitedIds().size(), 1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// Removing a non-existent page
wizard.removePage(4);
QCOMPARE(wizard.pageIds().size(), 4);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// Removing and then reinserting a page
QCOMPARE(wizard.pageIds().size(), 4);
QVERIFY(wizard.pageIds().contains(2));
wizard.removePage(2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.pageIds().size(), 3);
QVERIFY(!wizard.pageIds().contains(2));
wizard.setPage(2, page2);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(wizard.pageIds().size(), 4);
QVERIFY(wizard.pageIds().contains(2));
// Removing the same page twice
wizard.removePage(2); // restore
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.pageIds().size(), 3);
QVERIFY(!wizard.pageIds().contains(2));
wizard.removePage(2);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(wizard.pageIds().size(), 3);
QVERIFY(!wizard.pageIds().contains(2));
@@ -2312,9 +2312,9 @@ void tst_QWizard::removePage()
wizard.next();
QCOMPARE(wizard.visitedIds().size(), 2);
QCOMPARE(wizard.currentPage(), page1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
wizard.removePage(2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.visitedIds().size(), 2);
@@ -2325,11 +2325,11 @@ void tst_QWizard::removePage()
wizard.setPage(2, page2); // restore
wizard.restart();
wizard.next();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(wizard.visitedIds().size(), 2);
QCOMPARE(wizard.currentPage(), page1);
wizard.removePage(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 0);
QCOMPARE(wizard.visitedIds().size(), 1);
@@ -2341,11 +2341,11 @@ void tst_QWizard::removePage()
wizard.setPage(0, page0); // restore
wizard.restart();
wizard.next();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(wizard.visitedIds().size(), 2);
QCOMPARE(wizard.currentPage(), page1);
wizard.removePage(1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 1);
QCOMPARE(wizard.visitedIds().size(), 1);
@@ -2355,7 +2355,7 @@ void tst_QWizard::removePage()
// Remove the current page which is the first (and only) one in the history
wizard.removePage(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 0);
QCOMPARE(wizard.visitedIds().size(), 1);
@@ -2365,7 +2365,7 @@ void tst_QWizard::removePage()
QCOMPARE(wizard.currentPage(), page2);
//
wizard.removePage(2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.visitedIds().size(), 1);
@@ -2375,7 +2375,7 @@ void tst_QWizard::removePage()
QCOMPARE(wizard.currentPage(), page3);
//
wizard.removePage(3);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 3);
QVERIFY(wizard.visitedIds().empty());
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST
index ce0e42b3c7..fef40194c3 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/BLACKLIST
@@ -1,2 +1,3 @@
[layoutDirection]
ubuntu-20.04
+ubuntu-22.04
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 8b4d8b0b68..e1cccaadc9 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -1663,7 +1663,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Determine amount of widgets to add.
int widgetCount = -1;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
widgetCount = qMax(widgetCount, item.firstIndex);
widgetCount = qMax(widgetCount, item.secondIndex);
@@ -1678,7 +1678,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Setup anchor layout
TheAnchorLayout *layout = new TheAnchorLayout;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
layout->setAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -1695,7 +1695,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
QCOMPARE(widget->size(), size);
// Validate
- for (int i = 0; i < result.count(); ++i) {
+ for (int i = 0; i < result.size(); ++i) {
const BasicLayoutTestResult item = result[i];
QRectF expected = item.rect;
QRectF actual = widgets[item.index]->geometry();
@@ -1707,7 +1707,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
widget->setLayoutDirection(Qt::RightToLeft);
layout->activate();
// Validate
- for (int j = 0; j < result.count(); ++j) {
+ for (int j = 0; j < result.size(); ++j) {
const BasicLayoutTestResult item = result[j];
QRectF mirroredRect(item.rect);
// only valid cases are mirrored
@@ -2168,7 +2168,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
// Determine amount of widgets to add.
int widgetCount = -1;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
widgetCount = qMax(widgetCount, item.firstIndex);
widgetCount = qMax(widgetCount, item.secondIndex);
@@ -2185,7 +2185,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
// Setup anchor layout
TheAnchorLayout *layout = new TheAnchorLayout;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
layout->setAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -2195,7 +2195,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
item.spacing );
}
- for (int i = 0; i < removeData.count(); ++i) {
+ for (int i = 0; i < removeData.size(); ++i) {
const BasicLayoutTestData item = removeData[i];
layout->removeAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -2211,7 +2211,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor()
QCOMPARE(widget->size(), size);
// Validate
- for (int i = 0; i < result.count(); ++i) {
+ for (int i = 0; i < result.size(); ++i) {
const BasicLayoutTestResult item = result[i];
QCOMPARE(widgets[item.index]->geometry(), item.rect);
@@ -2999,7 +2999,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
// Determine amount of widgets to add.
int widgetCount = -1;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
widgetCount = qMax(widgetCount, item.firstIndex);
widgetCount = qMax(widgetCount, item.secondIndex);
@@ -3025,7 +3025,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
// Setup anchor layout
TheAnchorLayout *layout = new TheAnchorLayout;
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const BasicLayoutTestData item = data[i];
layout->setAnchor(
getItem(item.firstIndex, widgets, layout),
@@ -3042,7 +3042,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
QCOMPARE(widget->size(), size);
// Validate
- for (int i = 0; i < result.count(); ++i) {
+ for (int i = 0; i < result.size(); ++i) {
const BasicLayoutTestResult item = result[i];
QCOMPARE(widgets[item.index]->geometry(), item.rect);
}
@@ -3051,7 +3051,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
widget->setLayoutDirection(Qt::RightToLeft);
layout->activate();
// Validate
- for (int j = 0; j < result.count(); ++j) {
+ for (int j = 0; j < result.size(); ++j) {
const BasicLayoutTestResult item = result[j];
QRectF mirroredRect(item.rect);
// only valid cases are mirrored
diff --git a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
index 10c550efc0..43bc24e93d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
@@ -154,11 +154,11 @@ void tst_QGraphicsEffectSource::init()
QVERIFY(effect);
QVERIFY(item);
QVERIFY(effect->source());
- effect->reset();
effect->storeDeviceDependentStuff = false;
effect->doNothingInDraw = false;
- item->reset();
QCoreApplication::processEvents(); // Process all queued paint events
+ effect->reset();
+ item->reset();
}
void tst_QGraphicsEffectSource::graphicsItem()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index f4b3a5ef99..9af5433388 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -1658,7 +1658,7 @@ void tst_QGraphicsGridLayout::sizeHint()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2159,7 +2159,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2174,7 +2174,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors()
widget->resize(newSize);
QApplication::sendPostedEvents(0, 0);
- for (i = 0; i < expectedSizes.count(); ++i) {
+ for (i = 0; i < expectedSizes.size(); ++i) {
QSizeF itemSize = layout->itemAt(i)->geometry().size();
QCOMPARE(itemSize, expectedSizes.at(i));
}
@@ -2318,7 +2318,7 @@ void tst_QGraphicsGridLayout::alignment2()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2333,7 +2333,7 @@ void tst_QGraphicsGridLayout::alignment2()
widget->resize(newSize);
QApplication::sendPostedEvents(0, 0);
- for (i = 0; i < expectedGeometries.count(); ++i) {
+ for (i = 0; i < expectedGeometries.size(); ++i) {
QRectF itemRect = layout->itemAt(i)->geometry();
QCOMPARE(itemRect, expectedGeometries.at(i));
}
@@ -2896,7 +2896,7 @@ void tst_QGraphicsGridLayout::geometries()
widget->setContentsMargins(0, 0, 0, 0);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
ItemDesc desc = itemDescriptions.at(i);
RectWidget *item = new RectWidget(widget);
desc.apply(layout, item);
@@ -2911,7 +2911,7 @@ void tst_QGraphicsGridLayout::geometries()
widget->resize(newSize);
QApplication::processEvents();
- for (i = 0; i < expectedGeometries.count(); ++i) {
+ for (i = 0; i < expectedGeometries.size(); ++i) {
QRectF itemRect = layout->itemAt(i)->geometry();
QCOMPARE(itemRect, expectedGeometries.at(i));
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index e848fa627d..8b7028810f 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -2206,7 +2206,7 @@ void tst_QGraphicsItem::setTransform()
scene.update(scene.sceneRect());
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.setTransform(QTransform().rotate(qreal(12.34)));
QRectF rotatedRect = scene.sceneRect();
@@ -2214,14 +2214,14 @@ void tst_QGraphicsItem::setTransform()
scene.update(scene.sceneRect());
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
item.setTransform(QTransform());
scene.update(scene.sceneRect());
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
QList<QRectF> rlist = qvariant_cast<QList<QRectF> >(spy.last().at(0));
QCOMPARE(rlist.size(), 2);
@@ -3601,7 +3601,7 @@ void tst_QGraphicsItem::group()
view.fitInView(scene.itemsBoundingRect());
- for (QGraphicsItem *item : qAsConst(newItems)) {
+ for (QGraphicsItem *item : std::as_const(newItems)) {
group->addToGroup(item);
QCOMPARE(item->group(), group);
}
@@ -5681,7 +5681,7 @@ void tst_QGraphicsItem::itemClipsChildrenToShape5()
}
const QList<QGraphicsItem *> children = parent->childItems();
- const int childrenCount = children.count();
+ const int childrenCount = children.size();
for (int i = 0; i < 5; ++i) {
QString clipString;
@@ -8221,7 +8221,7 @@ void tst_QGraphicsItem::sorting()
QVERIFY(QTest::qWaitForWindowActive(&view));
}
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTRY_VERIFY(_paintedItems.count() > 0);
+ QTRY_VERIFY(_paintedItems.size() > 0);
_paintedItems.clear();
@@ -11686,7 +11686,7 @@ public:
QLatin1String wiseWords("AZ BUKI VEDI");
QString sentence(wiseWords);
QStringList words = sentence.split(QLatin1Char(' '), Qt::SkipEmptyParts);
- for (int i = 0; i < words.count(); ++i) {
+ for (int i = 0; i < words.size(); ++i) {
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
QLabel *label = new QLabel(words.at(i));
proxy->setWidget(label);
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index b5ba1d8787..a0bc43e150 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -670,7 +670,7 @@ public:
private slots:
void valueChanged(qreal value) {
- for (int i = 0; i < fromGeoms.count(); ++i) {
+ for (int i = 0; i < fromGeoms.size(); ++i) {
QGraphicsLayoutItem *li = itemAt(i);
QRectF from = fromGeoms.at(i);
QRectF to = toGeoms.at(i);
@@ -825,7 +825,7 @@ CustomLayout(QGraphicsLayoutItem *parent)
int count() const override
{
- return items.count();
+ return items.size();
}
QGraphicsLayoutItem* itemAt(int index) const override
@@ -841,12 +841,12 @@ void removeAt(int index) override
void addItem(QGraphicsLayoutItem *item)
{
- insertItem(items.count(), item);
+ insertItem(items.size(), item);
}
void insertItem(int index, QGraphicsLayoutItem *item)
{
- index = qBound(0, index, items.count());
+ index = qBound(0, index, items.size());
item->setParentLayoutItem(this);
@@ -854,7 +854,7 @@ void insertItem(int index, QGraphicsLayoutItem *item)
updateParentWidget(widget);
- if (index == items.count()) {
+ if (index == items.size()) {
items.append(item);
} else {
items.insert(index, item);
@@ -922,7 +922,7 @@ void tst_QGraphicsLayout::ownership()
destructedSet.clear();
window->setLayout(0);
- QCOMPARE(destructedSet.count(), 0);
+ QCOMPARE(destructedSet.size(), 0);
delete window;
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index ff625dbc00..e8fc027117 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -723,7 +723,7 @@ void tst_QGraphicsLinearLayout::orientation()
// important to resize to preferredsize when orientation is switched
widget->resize(widget->effectiveSizeHint(Qt::PreferredSize));
qApp->processEvents();
- for (i = 0; i < positions.count(); ++i) {
+ for (i = 0; i < positions.size(); ++i) {
QGraphicsWidget *item = static_cast<QGraphicsWidget*>(layout.itemAt(i));
if (initialOrientation == Qt::Horizontal)
QCOMPARE(item->pos().y(), positions.at(i));
@@ -1121,7 +1121,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor()
int i;
- for (i = 0; i < stretches.count(); ++i) {
+ for (i = 0; i < stretches.size(); ++i) {
QGraphicsWidget *item = new RectWidget(widget);
item->setMinimumSize(5,5);
item->setPreferredSize(10,5);
@@ -1139,7 +1139,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor()
qreal firstStretch = -1;
qreal firstExtent = -1.;
qreal sumExtent = 0;
- for (i = 0; i < stretches.count(); ++i) {
+ for (i = 0; i < stretches.size(); ++i) {
QGraphicsWidget *item = static_cast<QGraphicsWidget*>(layout.itemAt(i));
qreal extent = item->size().width();
qreal stretch = (qreal)stretches.at(i);
@@ -1297,7 +1297,7 @@ void tst_QGraphicsLinearLayout::defaultStretchFactors()
QSizeF itemSize = layout->itemAt(i)->geometry().size();
if (orientation == Qt::Vertical)
itemSize.transpose();
- if (i < expectedSizes.count())
+ if (i < expectedSizes.size())
QCOMPARE(itemSize.width(), qreal(expectedSizes.at(i)));
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
index 849ac19d25..bade098023 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
@@ -41,28 +41,28 @@ void tst_QGraphicsObject::pos()
QSignalSpy ySpy(&object, SIGNAL(yChanged()));
QVERIFY(object.pos() == QPointF(0, 0));
object.setPos(10, 10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 1);
QCOMPARE(object.pos(), QPointF(10,10));
object.setPos(10, 10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 1);
object.setProperty("pos", QPointF(0, 0));
- QCOMPARE(xSpy.count(), 2);
- QCOMPARE(ySpy.count(), 2);
+ QCOMPARE(xSpy.size(), 2);
+ QCOMPARE(ySpy.size(), 2);
QCOMPARE(object.property("pos").toPointF(), QPointF(0,0));
object.setProperty("pos", QPointF(10, 0));
- QCOMPARE(xSpy.count(), 3);
- QCOMPARE(ySpy.count(), 2);
+ QCOMPARE(xSpy.size(), 3);
+ QCOMPARE(ySpy.size(), 2);
QCOMPARE(object.property("pos").toPointF(), QPointF(10,0));
object.setProperty("pos", QPointF(10, 10));
- QCOMPARE(xSpy.count(), 3);
- QCOMPARE(ySpy.count(), 3);
+ QCOMPARE(xSpy.size(), 3);
+ QCOMPARE(ySpy.size(), 3);
QVERIFY(object.property("pos") == QPointF(10, 10));
}
@@ -73,19 +73,19 @@ void tst_QGraphicsObject::x()
QSignalSpy ySpy(&object, SIGNAL(yChanged()));
QVERIFY(object.pos() == QPointF(0, 0));
object.setX(10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 0);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 0);
QVERIFY(object.pos() == QPointF(10, 0));
QCOMPARE(object.x(), qreal(10));
object.setX(10);
- QCOMPARE(xSpy.count(), 1);
- QCOMPARE(ySpy.count(), 0);
+ QCOMPARE(xSpy.size(), 1);
+ QCOMPARE(ySpy.size(), 0);
object.setProperty("x", 0);
- QCOMPARE(xSpy.count(), 2);
- QCOMPARE(ySpy.count(), 0);
+ QCOMPARE(xSpy.size(), 2);
+ QCOMPARE(ySpy.size(), 0);
QCOMPARE(object.property("x").toDouble(), double(0));
}
@@ -96,19 +96,19 @@ void tst_QGraphicsObject::y()
QSignalSpy ySpy(&object, SIGNAL(yChanged()));
QVERIFY(object.pos() == QPointF(0, 0));
object.setY(10);
- QCOMPARE(xSpy.count(), 0);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 0);
+ QCOMPARE(ySpy.size(), 1);
QVERIFY(object.pos() == QPointF(0, 10));
QCOMPARE(object.y(), qreal(10));
object.setY(10);
- QCOMPARE(xSpy.count(), 0);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(xSpy.size(), 0);
+ QCOMPARE(ySpy.size(), 1);
object.setProperty("y", 0);
- QCOMPARE(xSpy.count(), 0);
- QCOMPARE(ySpy.count(), 2);
+ QCOMPARE(xSpy.size(), 0);
+ QCOMPARE(ySpy.size(), 2);
QCOMPARE(object.property("y").toDouble(), qreal(0));
}
@@ -118,15 +118,15 @@ void tst_QGraphicsObject::z()
QSignalSpy zSpy(&object, SIGNAL(zChanged()));
QCOMPARE(object.zValue(), qreal(0));
object.setZValue(10);
- QCOMPARE(zSpy.count(), 1);
+ QCOMPARE(zSpy.size(), 1);
QCOMPARE(object.zValue(), qreal(10));
object.setZValue(10);
- QCOMPARE(zSpy.count(), 1);
+ QCOMPARE(zSpy.size(), 1);
object.setProperty("z", 0);
- QCOMPARE(zSpy.count(), 2);
+ QCOMPARE(zSpy.size(), 2);
QCOMPARE(object.property("z").toDouble(), double(0));
}
@@ -136,15 +136,15 @@ void tst_QGraphicsObject::opacity()
QSignalSpy spy(&object, SIGNAL(opacityChanged()));
QCOMPARE(object.opacity(), 1.);
object.setOpacity(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(object.opacity(), 0.);
object.setOpacity(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
object.setProperty("opacity", .5);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(object.property("opacity").toDouble(), .5);
}
@@ -154,15 +154,15 @@ void tst_QGraphicsObject::enabled()
QSignalSpy spy(&object, SIGNAL(enabledChanged()));
QVERIFY(object.isEnabled());
object.setEnabled(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!object.isEnabled());
object.setEnabled(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
object.setProperty("enabled", true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(object.property("enabled").toBool());
}
@@ -172,15 +172,15 @@ void tst_QGraphicsObject::visible()
QSignalSpy spy(&object, SIGNAL(visibleChanged()));
QVERIFY(object.isVisible());
object.setVisible(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!object.isVisible());
object.setVisible(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
object.setProperty("visible", true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(object.property("visible").toBool());
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index a73a736e5b..088d2146e4 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -804,6 +804,9 @@ void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856()
}
};
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene scene;
QGraphicsView view(&scene);
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
@@ -940,7 +943,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
proxy->setPos(50, 0);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
// outside graphics item
QTest::mouseMove(&view, QPoint(10, 10));
@@ -1038,9 +1041,9 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
proxy->setFocus();
QTest::keyPress(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::keyRelease(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
// protected void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
@@ -1068,7 +1071,7 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent()
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint pointInLineEdit = view.mapFromScene(proxy->mapToScene(15, proxy->boundingRect().center().y()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, pointInLineEdit);
@@ -1109,13 +1112,13 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
proxy->setFocus();
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint buttonCenter = view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
void tst_QGraphicsProxyWidget::resizeEvent_data()
@@ -1166,7 +1169,7 @@ void tst_QGraphicsProxyWidget::paintEvent()
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(&proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
proxy.paintCount = 0;
w->update();
@@ -1321,6 +1324,9 @@ static QList<QRect> rects(const QRegion &region)
void tst_QGraphicsProxyWidget::scrollUpdate()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
ScrollWidget *widget = new ScrollWidget;
QGraphicsScene scene;
@@ -2305,7 +2311,7 @@ void tst_QGraphicsProxyWidget::popup_basic()
box->setGeometry(0, 0, 320, 40);
box->addItems(QStringList() << "monday" << "tuesday" << "wednesday"
<< "thursday" << "saturday" << "sunday");
- QCOMPARE(proxy->childItems().count(), 0);
+ QCOMPARE(proxy->childItems().size(), 0);
proxy->setWidget(boxGuard.release());
proxy->show();
scene.addItem(proxy);
@@ -2322,7 +2328,7 @@ void tst_QGraphicsProxyWidget::popup_basic()
QTRY_COMPARE(box->pos(), QPoint());
- QCOMPARE(proxy->childItems().count(), 1);
+ QCOMPARE(proxy->childItems().size(), 1);
QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0];
QVERIFY(child->isWidget());
QVERIFY(child->widget());
@@ -2402,7 +2408,7 @@ void tst_QGraphicsProxyWidget::changingCursor_basic()
proxy->setWidget(widget);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
// in
QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
@@ -2620,7 +2626,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0);
QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints);
- QTRY_COMPARE(signalSpy.count(), 1);
+ QTRY_COMPARE(signalSpy.size(), 1);
const QList<QVariant> arguments = signalSpy.takeFirst();
const QList<QRectF> updateRects = qvariant_cast<QList<QRectF> >(arguments.at(0));
QCOMPARE(updateRects.size(), 1);
@@ -2895,10 +2901,10 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
QTest::mousePress(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
@@ -3063,6 +3069,9 @@ void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget_data()
void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QFETCH(bool, bypass);
std::unique_ptr<QWidget> widgetGuard(new QWidget);
@@ -3276,6 +3285,9 @@ public:
void tst_QGraphicsProxyWidget::inputMethod()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene scene;
// check that the proxy is initialized with the correct input method sensitivity
@@ -3688,27 +3700,27 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// accepted by the embedded widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// wheeling on the label, which ignores the event, should scroll the view
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// left the widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reached the nested widget, which accepts the wheel event, so no more scrolling
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
// remember this position for later
const int scrollBarValueOnNestedProxy = view.verticalScrollBar()->value();
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
QCOMPARE(nestedWidget->wheelEventCount, 1);
// reset, try with kinetic events
@@ -3719,41 +3731,41 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// no matter if the widget accepts wheel events - the view has the grab
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reset
view.verticalScrollBar()->setValue(0);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
// starting a scroll on a widget that doesn't accept wheel events
// should also scroll the view, which still gets the grab
wheelUp(Qt::NoScrollPhase);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// starting a scroll on a widget that does accept wheel events
// should not scroll the view
view.verticalScrollBar()->setValue(scrollBarValueOnNestedProxy);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
}
#endif // QT_CONFIG(wheelevent)
@@ -3851,7 +3863,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QHash<int, QList<TouchRecord>> records;
QWidget *mousePressReceiver = nullptr;
- int count(int id = 0) const { return records.value(id).count(); }
+ int count(int id = 0) const { return records.value(id).size(); }
TouchRecord at(int i, int id = 0) const { return records.value(id).at(i); }
void clear()
{
@@ -3955,7 +3967,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(record.receiver, view.windowHandle());
QCOMPARE(record.eventType, QEvent::TouchEnd);
QCOMPARE(eventSpy.mousePressReceiver, pushButton1);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
eventSpy.clear();
clickedSpy.clear();
@@ -4023,7 +4035,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(eventSpy.at(0, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(1, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(2, 3).receiver, touchWidget2);
- QCOMPARE(clickedSpy.count(), 0); // multi-touch event does not synthesize a mouse event
+ QCOMPARE(clickedSpy.size(), 0); // multi-touch event does not synthesize a mouse event
}
QTEST_MAIN(tst_QGraphicsProxyWidget)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 8389d8eab7..0a1c47925d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -319,27 +319,27 @@ void tst_QGraphicsScene::sceneRect()
QGraphicsScene scene;
QSignalSpy sceneRectChanged(&scene, &QGraphicsScene::sceneRectChanged);
QCOMPARE(scene.sceneRect(), QRectF());
- QCOMPARE(sceneRectChanged.count(), 0);
+ QCOMPARE(sceneRectChanged.size(), 0);
QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 10, 10));
item->setPen(QPen(Qt::black, 0));
item->setPos(-5, -5);
- QCOMPARE(sceneRectChanged.count(), 0);
+ QCOMPARE(sceneRectChanged.size(), 0);
QCOMPARE(itemAt(scene, 0, 0), item);
QVERIFY(scene.items(QPointF(10, 10)).isEmpty());
- QCOMPARE(sceneRectChanged.count(), 0);
+ QCOMPARE(sceneRectChanged.size(), 0);
QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 10, 10));
- QCOMPARE(sceneRectChanged.count(), 1);
+ QCOMPARE(sceneRectChanged.size(), 1);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
item->setPos(0, 0);
QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 15, 15));
- QCOMPARE(sceneRectChanged.count(), 2);
+ QCOMPARE(sceneRectChanged.size(), 2);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
scene.setSceneRect(-100, -100, 10, 10);
- QCOMPARE(sceneRectChanged.count(), 3);
+ QCOMPARE(sceneRectChanged.size(), 3);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
QCOMPARE(itemAt(scene, 0, 0), item);
@@ -347,16 +347,16 @@ void tst_QGraphicsScene::sceneRect()
QCOMPARE(scene.sceneRect(), QRectF(-100, -100, 10, 10));
item->setPos(10, 10);
QCOMPARE(scene.sceneRect(), QRectF(-100, -100, 10, 10));
- QCOMPARE(sceneRectChanged.count(), 3);
+ QCOMPARE(sceneRectChanged.size(), 3);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
scene.setSceneRect(QRectF());
QCOMPARE(itemAt(scene, 10, 10), item);
QVERIFY(scene.items(QPointF(20, 20)).isEmpty());
- QCOMPARE(sceneRectChanged.count(), 4);
+ QCOMPARE(sceneRectChanged.size(), 4);
QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 25, 25));
- QCOMPARE(sceneRectChanged.count(), 5);
+ QCOMPARE(sceneRectChanged.size(), 5);
QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect());
}
@@ -532,7 +532,7 @@ void tst_QGraphicsScene::itemsBoundingRect()
QGraphicsScene scene;
- for (const auto &rect : qAsConst(rects)) {
+ for (const auto &rect : std::as_const(rects)) {
QPainterPath path;
path.addRect(rect);
QGraphicsPathItem *item = scene.addPath(path);
@@ -597,7 +597,7 @@ void tst_QGraphicsScene::items_QPointF()
int n = 0;
QList<QGraphicsItem *> addedItems;
- for (const auto &rect : qAsConst(items)) {
+ for (const auto &rect : std::as_const(items)) {
QPainterPath path;
path.addRect(0, 0, rect.width(), rect.height());
@@ -944,32 +944,32 @@ void tst_QGraphicsScene::selectionChanged()
{
QGraphicsScene scene(0, 0, 1000, 1000);
QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QPainterPath path;
path.addRect(scene.sceneRect());
QCOMPARE(scene.selectionArea(), QPainterPath());
scene.setSelectionArea(path);
QCOMPARE(scene.selectionArea(), path);
- QCOMPARE(spy.count(), 0); // selection didn't change
+ QCOMPARE(spy.size(), 0); // selection didn't change
QVERIFY(scene.selectedItems().isEmpty());
QGraphicsItem *rect = scene.addRect(QRectF(0, 0, 100, 100));
- QCOMPARE(spy.count(), 0); // selection didn't change
+ QCOMPARE(spy.size(), 0); // selection didn't change
rect->setSelected(true);
QVERIFY(!rect->isSelected());
- QCOMPARE(spy.count(), 0); // selection didn't change, item isn't selectable
+ QCOMPARE(spy.size(), 0); // selection didn't change, item isn't selectable
rect->setFlag(QGraphicsItem::ItemIsSelectable);
rect->setSelected(true);
QVERIFY(rect->isSelected());
- QCOMPARE(spy.count(), 1); // selection changed
+ QCOMPARE(spy.size(), 1); // selection changed
QCOMPARE(scene.selectedItems(), {rect});
rect->setSelected(false);
QVERIFY(!rect->isSelected());
- QCOMPARE(spy.count(), 2); // selection changed
+ QCOMPARE(spy.size(), 2); // selection changed
QVERIFY(scene.selectedItems().isEmpty());
QGraphicsEllipseItem *parentItem = new QGraphicsEllipseItem(QRectF(0, 0, 100, 100));
@@ -981,33 +981,33 @@ void tst_QGraphicsScene::selectionChanged()
grandChildItem->setSelected(true);
scene.addItem(parentItem);
- QCOMPARE(spy.count(), 3); // the grandchild was added, so the selection changed once
+ QCOMPARE(spy.size(), 3); // the grandchild was added, so the selection changed once
scene.removeItem(parentItem);
- QCOMPARE(spy.count(), 4); // the grandchild was removed, so the selection changed
+ QCOMPARE(spy.size(), 4); // the grandchild was removed, so the selection changed
rect->setSelected(true);
- QCOMPARE(spy.count(), 5); // the rect was reselected, so the selection changed
+ QCOMPARE(spy.size(), 5); // the rect was reselected, so the selection changed
scene.clearSelection();
- QCOMPARE(spy.count(), 6); // the scene selection was cleared
+ QCOMPARE(spy.size(), 6); // the scene selection was cleared
rect->setSelected(true);
- QCOMPARE(spy.count(), 7); // the rect was reselected, so the selection changed
+ QCOMPARE(spy.size(), 7); // the rect was reselected, so the selection changed
rect->setFlag(QGraphicsItem::ItemIsSelectable, false);
- QCOMPARE(spy.count(), 8); // the rect was unselected, so the selection changed
+ QCOMPARE(spy.size(), 8); // the rect was unselected, so the selection changed
rect->setSelected(true);
- QCOMPARE(spy.count(), 8); // the rect is not longer selectable, so the selection does not change
+ QCOMPARE(spy.size(), 8); // the rect is not longer selectable, so the selection does not change
rect->setFlag(QGraphicsItem::ItemIsSelectable, true);
rect->setSelected(true);
- QCOMPARE(spy.count(), 9); // the rect is again selectable, so the selection changed
+ QCOMPARE(spy.size(), 9); // the rect is again selectable, so the selection changed
delete rect;
- QCOMPARE(spy.count(), 10); // a selected item was deleted; selection changed
+ QCOMPARE(spy.size(), 10); // a selected item was deleted; selection changed
}
void tst_QGraphicsScene::selectionChanged2()
@@ -1020,7 +1020,7 @@ void tst_QGraphicsScene::selectionChanged2()
item1->setFlag(QGraphicsItem::ItemIsSelectable);
item2->setFlag(QGraphicsItem::ItemIsSelectable);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
event.setScenePos(QPointF(50, 50));
@@ -1035,7 +1035,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
event.setScenePos(QPointF(150, 150));
@@ -1050,7 +1050,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
event.setScenePos(QPointF(50, 50));
@@ -1060,7 +1060,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease);
event.setScenePos(QPointF(50, 50));
@@ -1069,7 +1069,7 @@ void tst_QGraphicsScene::selectionChanged2()
}
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QGraphicsScene::addItem()
@@ -1732,7 +1732,7 @@ void tst_QGraphicsScene::createItemGroup()
// All items in children1 are children of parent1
QGraphicsItem *parent1 = scene.addRect(QRectF(-10, -10, 20, 20));
- for (QGraphicsItem *item : qAsConst(children1))
+ for (QGraphicsItem *item : std::as_const(children1))
item->setParentItem(parent1);
QGraphicsItemGroup *group = scene.createItemGroup(children1);
@@ -1748,7 +1748,7 @@ void tst_QGraphicsScene::createItemGroup()
// All items in children2 are children of parent2
QGraphicsItem *parent2 = scene.addRect(QRectF(-10, -10, 20, 20));
- for (QGraphicsItem *item : qAsConst(children2))
+ for (QGraphicsItem *item : std::as_const(children2))
item->setParentItem(parent2);
// Now make parent2 a child of parent1, so all children2 are also children
@@ -1772,7 +1772,7 @@ void tst_QGraphicsScene::createItemGroup()
QCOMPARE(children2.first()->parentItem(), parent1);
// Fixup the parent-child chain
- for (QGraphicsItem *item : qAsConst(children2))
+ for (QGraphicsItem *item : std::as_const(children2))
item->setParentItem(parent2);
// These share no common parent
@@ -1782,7 +1782,7 @@ void tst_QGraphicsScene::createItemGroup()
// Make children3 children of parent3
QGraphicsItem *parent3 = scene.addRect(QRectF(-10, -10, 20, 20));
- for (QGraphicsItem *item : qAsConst(children3))
+ for (QGraphicsItem *item : std::as_const(children3))
item->setParentItem(parent3);
// These should have parent3 as a parent
@@ -2832,7 +2832,7 @@ void tst_QGraphicsScene::update()
QCoreApplication::processEvents();
// Check that the update region is correct
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QRectF region;
const auto &rects = qvariant_cast<QList<QRectF> >(spy.at(0).at(0));
for (const auto &rectF : rects)
@@ -3531,7 +3531,7 @@ void tst_QGraphicsScene::task160653_selectionChanged()
QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::mouseClick(
view.viewport(), Qt::LeftButton, {}, view.mapFromScene(scene.items().first()->scenePos()));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QGraphicsScene::task250680_childClip()
@@ -3662,8 +3662,8 @@ void tst_QGraphicsScene::insertionOrder()
{
QList<QGraphicsItem*> itemList = scene.items();
- QCOMPARE(itemList.count(), numItems);
- for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(itemList.size(), numItems);
+ for (int i = 0; i < itemList.size(); ++i) {
QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
}
}
@@ -3676,8 +3676,8 @@ void tst_QGraphicsScene::insertionOrder()
{
QList<QGraphicsItem*> itemList = scene.items();
- QCOMPARE(itemList.count(), numItems);
- for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(itemList.size(), numItems);
+ for (int i = 0; i < itemList.size(); ++i) {
QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
}
}
@@ -4025,7 +4025,7 @@ void tst_QGraphicsScene::polishItems2()
// added 10 new children. These should be polished in the next
// event loop iteration.
const QList<QGraphicsItem *> children = item->childItems();
- QCOMPARE(children.count(), 10);
+ QCOMPARE(children.size(), 10);
for (QGraphicsItem *child : children)
QVERIFY(!static_cast<PolishItem *>(child)->polished);
@@ -4604,13 +4604,13 @@ void tst_QGraphicsScene::zeroScale()
rect1->setScale(0.00000001);
QApplication::processEvents();
- QTRY_COMPARE(cl.changes.count(), 1);
+ QTRY_COMPARE(cl.changes.size(), 1);
QGraphicsRectItem *rect2 = new QGraphicsRectItem(-0.0000001, -0.0000001, 0.0000001, 0.0000001);
rect2->setScale(0.00000001);
scene.addItem(rect2);
rect1->setPos(20,20);
QApplication::processEvents();
- QTRY_COMPARE(cl.changes.count(), 2);
+ QTRY_COMPARE(cl.changes.size(), 2);
}
void tst_QGraphicsScene::focusItemChangedSignal()
@@ -4621,17 +4621,17 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QGraphicsScene scene;
QSignalSpy spy(&scene, &QGraphicsScene::focusItemChanged);
QVERIFY(spy.isValid());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
scene.setFocus();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QEvent activateEvent(QEvent::WindowActivate);
QCoreApplication::sendEvent(&scene, &activateEvent);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QGraphicsRectItem *topLevelItem1 = new QGraphicsRectItem;
topLevelItem1->setFlag(QGraphicsItem::ItemIsFocusable);
scene.addItem(topLevelItem1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(!topLevelItem1->hasFocus());
QGraphicsRectItem *topLevelItem2 = new QGraphicsRectItem;
@@ -4639,7 +4639,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
topLevelItem2->setFocus();
QVERIFY(!topLevelItem2->hasFocus());
scene.addItem(topLevelItem2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2);
@@ -4648,7 +4648,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QVERIFY(topLevelItem2->hasFocus());
scene.clearFocus();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), nullptr);
@@ -4656,7 +4656,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason);
scene.setFocus(Qt::MenuBarFocusReason);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2);
@@ -4685,16 +4685,16 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QEvent deactivateEvent(QEvent::WindowDeactivate);
QCoreApplication::sendEvent(&scene, &deactivateEvent);
QEXPECT_FAIL("", "QTBUG-28346", Continue);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCoreApplication::sendEvent(&scene, &activateEvent);
QEXPECT_FAIL("", "QTBUG-28346", Continue);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QGraphicsRectItem *panel1 = new QGraphicsRectItem;
panel1->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable);
panel1->setFocus();
scene.addItem(panel1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1);
@@ -4704,11 +4704,11 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QGraphicsRectItem *panel2 = new QGraphicsRectItem;
panel2->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable);
scene.addItem(panel2);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
for (int i = 0; i < 3; ++i) {
scene.setActivePanel(panel2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel2);
@@ -4716,7 +4716,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason);
scene.setActivePanel(panel1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1);
@@ -4863,23 +4863,23 @@ void tst_QGraphicsScene::clearSelection()
scene.addItem(regularRect);
scene.addItem(selectedRect);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
- QCOMPARE(scene.selectedItems().count(), 2);
+ QCOMPARE(scene.selectedItems().size(), 2);
scene.clearSelection();
QVERIFY(!regularRect->isSelected());
QVERIFY(selectedRect->isSelected());
- QCOMPARE(scene.selectedItems().count(), 1);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(scene.selectedItems().size(), 1);
+ QCOMPARE(spy.size(), 3);
delete regularRect;
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
scene.clearSelection();
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
delete selectedRect;
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
}
void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache()
diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index 4cad9906bb..acfcde4798 100644
--- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -74,13 +74,13 @@ void tst_QGraphicsSceneIndex::scatteredItems()
for (int i = 0; i < 10; ++i)
scene.addRect(i*50, i*50, 40, 35);
- QCOMPARE(scene.items(QPointF(5, 5)).count(), 1);
- QCOMPARE(scene.items(QPointF(55, 55)).count(), 1);
- QCOMPARE(scene.items(QPointF(-100, -100)).count(), 0);
+ QCOMPARE(scene.items(QPointF(5, 5)).size(), 1);
+ QCOMPARE(scene.items(QPointF(55, 55)).size(), 1);
+ QCOMPARE(scene.items(QPointF(-100, -100)).size(), 0);
- QCOMPARE(scene.items(QRectF(0, 0, 10, 10)).count(), 1);
- QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 10);
- QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0);
+ QCOMPARE(scene.items(QRectF(0, 0, 10, 10)).size(), 1);
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 10);
+ QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).size(), 0);
}
void tst_QGraphicsSceneIndex::overlappedItems_data()
@@ -99,17 +99,17 @@ void tst_QGraphicsSceneIndex::overlappedItems()
for (int j = 0; j < 10; ++j)
scene.addRect(i*50, j*50, 200, 200)->setPen(QPen(Qt::black, 0));
- QCOMPARE(scene.items(QPointF(5, 5)).count(), 1);
- QCOMPARE(scene.items(QPointF(55, 55)).count(), 4);
- QCOMPARE(scene.items(QPointF(105, 105)).count(), 9);
- QCOMPARE(scene.items(QPointF(-100, -100)).count(), 0);
-
- QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 100);
- QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0);
- QCOMPARE(scene.items(QRectF(0, 0, 200, 200)).count(), 16);
- QCOMPARE(scene.items(QRectF(0, 0, 100, 100)).count(), 4);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 100)).count(), 2);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).count(), 10);
+ QCOMPARE(scene.items(QPointF(5, 5)).size(), 1);
+ QCOMPARE(scene.items(QPointF(55, 55)).size(), 4);
+ QCOMPARE(scene.items(QPointF(105, 105)).size(), 9);
+ QCOMPARE(scene.items(QPointF(-100, -100)).size(), 0);
+
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 100);
+ QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).size(), 0);
+ QCOMPARE(scene.items(QRectF(0, 0, 200, 200)).size(), 16);
+ QCOMPARE(scene.items(QRectF(0, 0, 100, 100)).size(), 4);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 100)).size(), 2);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).size(), 10);
}
void tst_QGraphicsSceneIndex::movingItems_data()
@@ -128,20 +128,20 @@ void tst_QGraphicsSceneIndex::movingItems()
scene.addRect(i*50, i*50, 40, 35);
QGraphicsRectItem *box = scene.addRect(0, 0, 10, 10);
- QCOMPARE(scene.items(QPointF(5, 5)).count(), 2);
- QCOMPARE(scene.items(QPointF(-1, -1)).count(), 0);
- QCOMPARE(scene.items(QRectF(0, 0, 5, 5)).count(), 2);
+ QCOMPARE(scene.items(QPointF(5, 5)).size(), 2);
+ QCOMPARE(scene.items(QPointF(-1, -1)).size(), 0);
+ QCOMPARE(scene.items(QRectF(0, 0, 5, 5)).size(), 2);
box->setPos(10, 10);
- QCOMPARE(scene.items(QPointF(9, 9)).count(), 1);
- QCOMPARE(scene.items(QPointF(15, 15)).count(), 2);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 1);
+ QCOMPARE(scene.items(QPointF(9, 9)).size(), 1);
+ QCOMPARE(scene.items(QPointF(15, 15)).size(), 2);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).size(), 1);
box->setPos(-5, -5);
- QCOMPARE(scene.items(QPointF(-1, -1)).count(), 1);
- QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 2);
+ QCOMPARE(scene.items(QPointF(-1, -1)).size(), 1);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).size(), 2);
- QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 11);
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 11);
}
void tst_QGraphicsSceneIndex::connectedToSceneRectChanged()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 849e290351..e0f7286c22 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -665,16 +665,16 @@ void tst_QGraphicsView::openGLViewport()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTRY_VERIFY(spy1.count() > 0);
- QTRY_VERIFY(spy2.count() >= spy1.count());
+ QTRY_VERIFY(spy1.size() > 0);
+ QTRY_VERIFY(spy2.size() >= spy1.size());
spy1.clear();
spy2.clear();
// Now test for resize (QTBUG-52419). This is special when the viewport is
// a QOpenGLWidget since the underlying FBO must also be maintained.
view.resize(300, 300);
- QTRY_VERIFY(spy1.count() > 0);
- QTRY_VERIFY(spy2.count() >= spy1.count());
+ QTRY_VERIFY(spy1.size() > 0);
+ QTRY_VERIFY(spy2.size() >= spy1.size());
// There is no sane way to check if the framebuffer contents got updated
// (grabFramebuffer is no good for the viewport case as that does not go
// through paintGL). So skip the actual verification.
@@ -1044,7 +1044,7 @@ void tst_QGraphicsView::rotated_rubberBand()
sendMousePress(view.viewport(), QPoint(midWidth - 2, 0), Qt::LeftButton);
sendMouseMove(view.viewport(), QPoint(midWidth + 2, view.viewport()->height()),
Qt::LeftButton, Qt::LeftButton);
- QCOMPARE(scene.selectedItems().count(), dim);
+ QCOMPARE(scene.selectedItems().size(), dim);
foreach (const QGraphicsItem *item, scene.items()) {
QCOMPARE(item->isSelected(), item->data(0).toBool());
}
@@ -3539,6 +3539,9 @@ void tst_QGraphicsView::embeddedViewsWithFocus()
void focusOutEvent(QFocusEvent *) override { --focusCount; }
};
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene innerScene;
FocusWidget *innerWidget = new FocusWidget;
innerScene.addWidget(innerWidget);
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 89548337aa..053a0d4376 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -17,6 +17,8 @@
#include <qstylefactory.h>
#include <qscreen.h>
#include <qsignalspy.h>
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
typedef QList<QGraphicsItem *> QGraphicsItemList;
@@ -144,8 +146,16 @@ private slots:
void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems();
void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems();
void QTBUG_45867_send_itemChildAddedChange_to_parent();
+
+private:
+ static bool hasWindowActivation();
};
+bool tst_QGraphicsWidget::hasWindowActivation()
+{
+ return (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation));
+}
+
// Subclass that exposes the protected functions.
class SubQGraphicsWidget : public QGraphicsWidget {
public:
@@ -940,9 +950,9 @@ void tst_QGraphicsWidget::geometry()
widget.setPos(pos);
widget.resize(size);
if (!size.isNull() && !pos.isNull())
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
if (!size.isNull() && pos.isNull())
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(widget.geometry(), QRectF(pos, size));
}
@@ -953,10 +963,10 @@ void tst_QGraphicsWidget::geometryChanged()
QCOMPARE(w.geometry(), QRectF(0, 0, 200, 200));
QSignalSpy spy(&w, SIGNAL(geometryChanged()));
w.setGeometry(0, 0, 100, 100);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(w.geometry(), QRectF(0, 0, 100, 100));
w.setPos(10, 10);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(w.geometry(), QRectF(10, 10, 100, 100));
}
@@ -968,10 +978,10 @@ void tst_QGraphicsWidget::width()
QSignalSpy spy(&w, SIGNAL(widthChanged()));
w.setProperty("width", qreal(50));
QCOMPARE(w.property("width").toReal(), qreal(50));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
//calling old school setGeometry should work too
w.setGeometry(0, 0, 200, 200);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QGraphicsWidget::height()
@@ -981,10 +991,10 @@ void tst_QGraphicsWidget::height()
QSignalSpy spy(&w, SIGNAL(heightChanged()));
w.setProperty("height", qreal(50));
QCOMPARE(w.property("height").toReal(), qreal(50));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
//calling old school setGeometry should work too
w.setGeometry(0, 0, 200, 200);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QGraphicsWidget::getContentsMargins_data()
@@ -1049,7 +1059,10 @@ void tst_QGraphicsWidget::initStyleOption()
QGraphicsView view(&scene);
view.resize(300, 300);
view.show();
- QVERIFY(QTest::qWaitForWindowActive(&view));
+ if (hasWindowActivation())
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+ else
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.setAlignment(Qt::AlignTop | Qt::AlignLeft);
SubQGraphicsWidget *widget = new SubQGraphicsWidget;
@@ -1063,10 +1076,12 @@ void tst_QGraphicsWidget::initStyleOption()
QFETCH(bool, enabled);
widget->setEnabled(enabled);
QFETCH(bool, focus);
- if (focus) {
- widget->setFlag(QGraphicsItem::ItemIsFocusable, true);
- widget->setFocus();
- QVERIFY(widget->hasFocus());
+ if (hasWindowActivation()) {
+ if (focus) {
+ widget->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ widget->setFocus();
+ QVERIFY(widget->hasFocus());
+ }
}
QFETCH(bool, underMouse);
if (underMouse) {
@@ -1085,8 +1100,10 @@ void tst_QGraphicsWidget::initStyleOption()
bool isEnabled = option.state & QStyle::State_Enabled;
QCOMPARE(isEnabled, enabled);
- bool hasFocus = option.state & QStyle::State_HasFocus;
- QCOMPARE(hasFocus, focus);
+ if (hasWindowActivation()) {
+ bool hasFocus = option.state & QStyle::State_HasFocus;
+ QCOMPARE(hasFocus, focus);
+ }
bool isUnderMouse = option.state & QStyle::State_MouseOver;
QCOMPARE(isUnderMouse, underMouse);
// if (layoutDirection != Qt::LeftToRight)
@@ -1123,12 +1140,12 @@ void tst_QGraphicsWidget::layout()
widget.setLayout(layout);
QTRY_COMPARE(widget.layout(), static_cast<QGraphicsLayout*>(layout));
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
SubQGraphicsWidget *item = children[i];
QCOMPARE(item->parentWidget(), (QGraphicsWidget *)&widget);
QVERIFY(item->geometry() != QRectF(0, 0, -1, -1));
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// don't crash
widget.setLayout(0);
}
@@ -1161,7 +1178,7 @@ void tst_QGraphicsWidget::layoutDirection()
QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), true);
view->show();
QVERIFY(QTest::qWaitForWindowExposed(view.data()));
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
QTRY_COMPARE(children[i]->layoutDirection(), layoutDirection);
QTRY_COMPARE(children[i]->testAttribute(Qt::WA_SetLayoutDirection), false);
view->update();
@@ -1399,7 +1416,7 @@ void tst_QGraphicsWidget::setTabOrder()
QVERIFY(view.viewport()->hasFocus());
int currentItem = 0;
- while (currentItem < children.count() - 1) {
+ while (currentItem < children.size() - 1) {
QTest::keyPress(view.viewport(), Qt::Key_Tab);
++currentItem;
QVERIFY(children[currentItem % children.size()]->hasFocus());
@@ -1548,7 +1565,7 @@ void tst_QGraphicsWidget::unsetLayoutDirection()
widget.setLayoutDirection(layoutDirection);
widget.unsetLayoutDirection();
QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), false);
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
QCOMPARE(children[i]->layoutDirection(), Qt::LeftToRight);
}
}
@@ -1713,13 +1730,16 @@ void tst_QGraphicsWidget::verifyFocusChain()
void tst_QGraphicsWidget::updateFocusChainWhenChildDie()
{
+ if (!hasWindowActivation())
+ QSKIP("Window activation is not supported");
+
const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
QGraphicsScene scene;
QGraphicsView view(&scene);
view.resize(200, 150);
view.move(availableGeometry.topLeft() + QPoint(50, 50));
view.show();
- QApplication::setActiveWindow(&view);
+ view.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
// delete item in focus chain with no focus and verify chain
@@ -1748,13 +1768,8 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie()
w->setParentItem(parent);
//We don't crash perfect
QVERIFY(w);
- const QPoint center(view.viewport()->width() / 2, view.viewport()->height() / 2);
- QTest::mouseMove(view.viewport(), center);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, center);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "QTBUG-23699", Continue);
-#endif
- QTRY_COMPARE(qApp->activeWindow(), static_cast<QWidget *>(&view));
+ view.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_COMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(w));
}
@@ -1840,7 +1855,7 @@ enum WhichSize {
MinimumSizeHint,
PreferredSizeHint,
MaximumSizeHint,
- Size,
+ WidgetSize,
None,
};
@@ -1855,48 +1870,48 @@ void tst_QGraphicsWidget::setSizes_data()
QTest::addColumn<QList<Inst>>("compareInstructions");
QTest::newRow("minSize1") << (QList<Inst>()
- << Inst(Size, QSize(25, 25)) << Inst(MinimumSize, QSize(10, 10)))
- << (QList<Inst>() << Inst(Size, QSize(25, 25)));
- QTest::newRow("minSize2") << (QList<Inst>() << Inst(Size, QSizeF(20, 20))
+ << Inst(WidgetSize, QSize(25, 25)) << Inst(MinimumSize, QSize(10, 10)))
+ << (QList<Inst>() << Inst(WidgetSize, QSize(25, 25)));
+ QTest::newRow("minSize2") << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 20))
<< Inst(MinimumSize, QSizeF(25, 25)))
- << (QList<Inst>() << Inst(Size, QSizeF(25, 25)));
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(25, 25)));
QTest::newRow("minWidth1") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumWidth, 5.0))
- << (QList<Inst>() << Inst(Size, QSizeF(20, 20)));
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumWidth, 5.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 20)));
QTest::newRow("minWidth2") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumWidth, 25.0))
- << (QList<Inst>() << Inst(Size, QSizeF(25, 20)));
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumWidth, 25.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(25, 20)));
QTest::newRow("minHeight1") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumHeight, 5.0))
- << (QList<Inst>() << Inst(Size, QSizeF(20, 20)));
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumHeight, 5.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 20)));
QTest::newRow("minHeight2") << (QList<Inst>()
- << Inst(Size, QSizeF(20, 20)) << Inst(MinimumHeight, 25.0))
- << (QList<Inst>() << Inst(Size, QSizeF(20, 25)));
- QTest::newRow("maxSize1") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << Inst(WidgetSize, QSizeF(20, 20)) << Inst(MinimumHeight, 25.0))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(20, 25)));
+ QTest::newRow("maxSize1") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(30, 30)))
- << (QList<Inst>() << Inst(Size, QSizeF(30, 30)));
- QTest::newRow("maxSize2") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(30, 30)));
+ QTest::newRow("maxSize2") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(30, -1)))
- << (QList<Inst>() << Inst(Size, QSizeF(30, 40)));
- QTest::newRow("maxSize3") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(30, 40)));
+ QTest::newRow("maxSize3") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(-1, 30)))
- << (QList<Inst>() << Inst(Size, QSizeF(40, 30)));
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 30)));
QTest::newRow("maxWidth1") << (QList<Inst>()
- << Inst(Size, QSizeF(40, 40)) << Inst(MaximumWidth, 30))
- << (QList<Inst>() << Inst(Size, QSizeF(30, 40)));
+ << Inst(WidgetSize, QSizeF(40, 40)) << Inst(MaximumWidth, 30))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(30, 40)));
QTest::newRow("maxHeight") << (QList<Inst>()
- << Inst(Size, QSizeF(40, 40)) << Inst(MaximumHeight, 20))
- << (QList<Inst>() << Inst(Size, QSizeF(40, 20)));
- QTest::newRow("unsetMinSize") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ << Inst(WidgetSize, QSizeF(40, 40)) << Inst(MaximumHeight, 20))
+ << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 20)));
+ QTest::newRow("unsetMinSize") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MinimumSize, QSizeF(-1, -1)))
<< (QList<Inst>() << Inst(MinimumSize, QSizeF(5, 5)));
- QTest::newRow("unsetMaxSize") << (QList<Inst>() << Inst(Size, QSizeF(40, 40))
+ QTest::newRow("unsetMaxSize") << (QList<Inst>() << Inst(WidgetSize, QSizeF(40, 40))
<< Inst(MaximumSize, QSizeF(-1, -1)))
<< (QList<Inst>() << Inst(MaximumSize, QSizeF(500, 500)));
QTest::newRow("unsetMinSize, expand size to minimumSizeHint")
- << (QList<Inst>() << Inst(MinimumSize, QSize(0, 0)) << Inst(Size, QSize(1, 1))
+ << (QList<Inst>() << Inst(MinimumSize, QSize(0, 0)) << Inst(WidgetSize, QSize(1, 1))
<< Inst(MinimumSize, QSize(-1.0, -1.0)))
- << (QList<Inst>() << Inst(Size, QSize(5, 5)) << Inst(MinimumSize, QSize(5, 5)));
+ << (QList<Inst>() << Inst(WidgetSize, QSize(5, 5)) << Inst(MinimumSize, QSize(5, 5)));
}
void tst_QGraphicsWidget::setSizes()
@@ -1912,7 +1927,7 @@ void tst_QGraphicsWidget::setSizes()
QSizeF max = QSizeF(50, 50);
int i;
- for (i = 0; i < inputInstructions.count(); ++i) {
+ for (i = 0; i < inputInstructions.size(); ++i) {
Inst input = inputInstructions.at(i);
// defaults
@@ -1926,7 +1941,7 @@ void tst_QGraphicsWidget::setSizes()
case MaximumSize:
max = input.second.toSizeF();
break;
- case Size:
+ case WidgetSize :
widget->resize(input.second.toSizeF());
break;
case MinimumWidth:
@@ -1966,7 +1981,7 @@ void tst_QGraphicsWidget::setSizes()
widget->setPreferredSize(pref);
widget->setMaximumSize(max);
- for (i = 0; i < compareInstructions.count(); ++i) {
+ for (i = 0; i < compareInstructions.size(); ++i) {
Inst input = compareInstructions.at(i);
switch (input.first) {
case MinimumSize:
@@ -1978,7 +1993,7 @@ void tst_QGraphicsWidget::setSizes()
case MaximumSize:
QTRY_COMPARE(widget->maximumSize(), input.second.toSizeF());
break;
- case Size:
+ case WidgetSize:
QTRY_COMPARE(widget->size(), input.second.toSizeF());
break;
case MinimumWidth:
@@ -2716,11 +2731,11 @@ void tst_QGraphicsWidget::task250119_shortcutContext()
w_signal.setFocus();
QTest::keyPress(&view, Qt::Key_B);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
w_signal.clearFocus();
QTest::keyPress(&view, Qt::Key_B);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
scene.removeItem(&w_signal);
}
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 6a99772c53..fc984cef6e 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -140,6 +140,7 @@ private slots:
void selectionCommand();
void mouseSelection_data();
void mouseSelection();
+ void keepSingleSelectionOnEmptyAreaClick();
void scrollerSmoothScroll();
void inputMethodOpensEditor_data();
void inputMethodOpensEditor();
@@ -424,12 +425,12 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view)
QVERIFY(spy.isValid());
view->setIconSize(QSize(32, 32));
QCOMPARE(view->iconSize(), QSize(32, 32));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).value<QSize>(), QSize(32, 32));
// Should this happen?
view->setIconSize(QSize(-1, -1));
QCOMPARE(view->iconSize(), QSize(-1, -1));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(view->currentIndex(), QModelIndex());
QCOMPARE(view->rootIndex(), QModelIndex());
@@ -663,9 +664,9 @@ void tst_QAbstractItemView::selectAll()
GeometriesTestView view;
view.setModel(&model);
- QCOMPARE(view.selectedIndexes().count(), 0);
+ QCOMPARE(view.selectedIndexes().size(), 0);
view.selectAll();
- QCOMPARE(view.selectedIndexes().count(), 4 * 4);
+ QCOMPARE(view.selectedIndexes().size(), 4 * 4);
}
void tst_QAbstractItemView::ctrlA()
@@ -674,9 +675,9 @@ void tst_QAbstractItemView::ctrlA()
GeometriesTestView view;
view.setModel(&model);
- QCOMPARE(view.selectedIndexes().count(), 0);
+ QCOMPARE(view.selectedIndexes().size(), 0);
QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier);
- QCOMPARE(view.selectedIndexes().count(), 4 * 4);
+ QCOMPARE(view.selectedIndexes().size(), 4 * 4);
}
void tst_QAbstractItemView::persistentEditorFocus()
@@ -693,7 +694,7 @@ void tst_QAbstractItemView::persistentEditorFocus()
//these are spinboxes because we put numbers inside
const QList<QSpinBox*> list = view.viewport()->findChildren<QSpinBox*>();
- QCOMPARE(list.count(), 2); //these should be the 2 editors
+ QCOMPARE(list.size(), 2); //these should be the 2 editors
view.setCurrentIndex(model.index(0, 0));
QCOMPARE(view.currentIndex(), model.index(0, 0));
@@ -753,22 +754,6 @@ void tst_QAbstractItemView::pressClosesReleaseDoesntOpenEditor()
QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::NoModifier, inChildOutsideEditor); // should not reopen editor
QTest::qWait(QApplication::doubleClickInterval() * 2);
QCOMPARE(view.state(), QAbstractItemView::NoState);
-
- // with multiple items selected, clicking from the currently edited item into another
- // selected item closes the current and reopens a new editor
- view.setSelectionMode(QAbstractItemView::ExtendedSelection);
- const QRect child2Rect = view.visualRect(model.indexFromItem(parent->child(1)));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, child2Rect.center()); // select
- QVERIFY(view.selectionModel()->selectedIndexes().contains(model.indexFromItem(parent->child(0))));
- QVERIFY(view.selectionModel()->selectedIndexes().contains(model.indexFromItem(parent->child(1))));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, child2Rect.center()); // edit
- QTRY_COMPARE(view.state(), QAbstractItemView::EditingState);
- QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::NoModifier, inChildOutsideEditor); // editor closes
- QCOMPARE(view.state(), QAbstractItemView::NoState);
- QTest::qWait(10); // process some events, let the internal timer time out
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::NoModifier, inChildOutsideEditor); // should open editor
- QTest::qWait(QApplication::doubleClickInterval() * 2);
- QCOMPARE(view.state(), QAbstractItemView::EditingState);
}
@@ -1354,7 +1339,7 @@ void tst_QAbstractItemView::task200665_itemEntered()
QSignalSpy spy(&view, &QAbstractItemView::entered);
view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum());
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
}
void tst_QAbstractItemView::task257481_emptyEditor()
@@ -1377,17 +1362,17 @@ void tst_QAbstractItemView::task257481_emptyEditor()
treeView.edit(model.index(0, 0));
QList<QLineEdit *> lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
- QCOMPARE(lineEditors.count(), 1);
+ QCOMPARE(lineEditors.size(), 1);
QVERIFY(!lineEditors.constFirst()->size().isEmpty());
treeView.edit(model.index(1, 0));
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
- QCOMPARE(lineEditors.count(), 1);
+ QCOMPARE(lineEditors.size(), 1);
QVERIFY(!lineEditors.constFirst()->size().isEmpty());
treeView.edit(model.index(2, 0));
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
- QCOMPARE(lineEditors.count(), 1);
+ QCOMPARE(lineEditors.size(), 1);
QVERIFY(!lineEditors.constFirst()->size().isEmpty());
}
@@ -1421,7 +1406,7 @@ void tst_QAbstractItemView::shiftArrowSelectionAfterScrolling()
QCOMPARE(view.currentIndex(), index1);
QModelIndexList selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 2);
+ QCOMPARE(selected.size(), 2);
QVERIFY(selected.contains(index0));
QVERIFY(selected.contains(index1));
}
@@ -1475,7 +1460,7 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection()
// Verify that the selection worked OK
QModelIndexList selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 2);
+ QCOMPARE(selected.size(), 2);
QVERIFY(selected.contains(index1));
QVERIFY(selected.contains(index2));
@@ -1498,7 +1483,7 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection()
// Verify that the selection worked OK
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 2);
+ QCOMPARE(selected.size(), 2);
QVERIFY(selected.contains(index1));
QVERIFY(selected.contains(index2));
}
@@ -1527,7 +1512,7 @@ void tst_QAbstractItemView::ctrlRubberbandSelection()
// Select item 1
view.setCurrentIndex(index1);
QModelIndexList selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 1);
+ QCOMPARE(selected.size(), 1);
QVERIFY(selected.contains(index1));
// Now press control and draw a rubberband around items 1 and 2.
@@ -1544,7 +1529,7 @@ void tst_QAbstractItemView::ctrlRubberbandSelection()
// Verify that item 2 is selected now
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 1);
+ QCOMPARE(selected.size(), 1);
QVERIFY(selected.contains(index2));
}
@@ -1577,21 +1562,21 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection()
QVERIFY(view.viewport()->rect().contains(p));
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, p);
QCOMPARE(view.currentIndex(), index49);
- QCOMPARE(view.selectedItems().count(), 1);
+ QCOMPARE(view.selectedItems().size(), 1);
QModelIndex index47 = view.model()->index(47,0);
p = view.visualRect(index47).center();
QVERIFY(view.viewport()->rect().contains(p));
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p);
QCOMPARE(view.currentIndex(), index47);
- QCOMPARE(view.selectedItems().count(), 3); //49, 48, 47;
+ QCOMPARE(view.selectedItems().size(), 3); //49, 48, 47;
QModelIndex index44 = view.model()->index(44,0);
p = view.visualRect(index44).center();
QVERIFY(view.viewport()->rect().contains(p));
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p);
QCOMPARE(view.currentIndex(), index44);
- QCOMPARE(view.selectedItems().count(), 6); //49 .. 44;
+ QCOMPARE(view.selectedItems().size(), 6); //49 .. 44;
}
@@ -1616,7 +1601,7 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection()
QTest::mouseMove(table.viewport(), itemRect.center());
QTest::mouseClick(table.viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center());
- QCOMPARE(table.selectedItems().count(), 1);
+ QCOMPARE(table.selectedItems().size(), 1);
QCOMPARE(table.selectedItems().first(), table.item(item.row(), item.column()));
}
@@ -1653,12 +1638,12 @@ void tst_QAbstractItemView::testClickedSignal()
QSignalSpy clickedSpy(&view, &QTableWidget::clicked);
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, p);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
QTest::mouseClick(view.viewport(), Qt::RightButton, {}, p);
// We expect that right-clicks do not cause the clicked() signal to
// be emitted.
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
}
@@ -1722,28 +1707,28 @@ void tst_QAbstractItemView::deselectInSingleSelection()
QPoint clickpos = rect22.center();
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
QCOMPARE(view.currentIndex(), index22);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, clickpos);
QCOMPARE(view.currentIndex(), index22);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0);
// second click with modifier however does select
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, clickpos);
QCOMPARE(view.currentIndex(), index22);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
// keyboard
QTest::keyClick(&view, Qt::Key_Space, Qt::NoModifier);
QCOMPARE(view.currentIndex(), index22);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
QTest::keyClick(&view, Qt::Key_Space, Qt::ControlModifier);
QCOMPARE(view.currentIndex(), index22);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0);
// second keypress with modifier however does select
QTest::keyClick(&view, Qt::Key_Space, Qt::ControlModifier);
QCOMPARE(view.currentIndex(), index22);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
}
void tst_QAbstractItemView::testNoActivateOnDisabledItem()
@@ -1771,7 +1756,7 @@ void tst_QAbstractItemView::testNoActivateOnDisabledItem()
QPoint clickPos = treeView.visualRect(itemIndex).center();
QTest::mouseClick(treeView.viewport(), Qt::LeftButton, {}, clickPos);
- QCOMPARE(activatedSpy.count(), 0);
+ QCOMPARE(activatedSpy.size(), 0);
}
void tst_QAbstractItemView::testFocusPolicy_data()
@@ -1865,7 +1850,7 @@ void tst_QAbstractItemView::QTBUG31411_noSelection()
QVERIFY(editor2);
QTest::keyClick(editor2, Qt::Key_Escape, Qt::NoModifier);
- QCOMPARE(selectionChangeSpy.count(), 0);
+ QCOMPARE(selectionChangeSpy.size(), 0);
}
void tst_QAbstractItemView::QTBUG39324_settingSameInstanceOfIndexWidget()
@@ -1907,7 +1892,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
// Click "C"
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexC).center());
QModelIndexList selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 1);
+ QCOMPARE(selected.size(), 1);
QVERIFY(selected.contains(indexC));
// Insert new item "B1"
@@ -1917,14 +1902,14 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
// Shift-click "D" -> we expect that "C" and "D" are selected
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, view.visualRect(indexD).center());
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 2);
+ QCOMPARE(selected.size(), 2);
QVERIFY(selected.contains(indexC));
QVERIFY(selected.contains(indexD));
// Click "D"
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexD).center());
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 1);
+ QCOMPARE(selected.size(), 1);
QVERIFY(selected.contains(indexD));
// Remove items "B" and "C"
@@ -1936,7 +1921,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
// Shift-click "F" -> we expect that "D", "E", and "F" are selected
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, view.visualRect(indexF).center());
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 3);
+ QCOMPARE(selected.size(), 3);
QVERIFY(selected.contains(indexD));
QVERIFY(selected.contains(indexE));
QVERIFY(selected.contains(indexF));
@@ -1945,7 +1930,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
while (view.currentIndex() != indexA)
QTest::keyClick(&view, Qt::Key_Up);
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 1);
+ QCOMPARE(selected.size(), 1);
QVERIFY(selected.contains(indexA));
// Change the sort order
@@ -1954,7 +1939,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
// Shift-click "F" -> All items should be selected
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, view.visualRect(indexF).center());
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), model.rowCount());
+ QCOMPARE(selected.size(), model.rowCount());
// Restore the old sort order
proxyModel.sort(0, Qt::AscendingOrder);
@@ -1962,7 +1947,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
// Click "D"
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexD).center());
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 1);
+ QCOMPARE(selected.size(), 1);
QVERIFY(selected.contains(indexD));
// Insert new item "B2"
@@ -1972,7 +1957,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
// Press Shift+Down -> "D" and "E" should be selected.
QTest::keyClick(&view, Qt::Key_Down, Qt::ShiftModifier);
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 2);
+ QCOMPARE(selected.size(), 2);
QVERIFY(selected.contains(indexD));
QVERIFY(selected.contains(indexE));
@@ -1981,7 +1966,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexA).center());
view.setCurrentIndex(indexD);
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 1);
+ QCOMPARE(selected.size(), 1);
QVERIFY(selected.contains(indexD));
// Insert new item "B3"
@@ -1991,7 +1976,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
// Press Shift+Down -> "D" and "E" should be selected.
QTest::keyClick(&view, Qt::Key_Down, Qt::ShiftModifier);
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 2);
+ QCOMPARE(selected.size(), 2);
QVERIFY(selected.contains(indexD));
QVERIFY(selected.contains(indexE));
}
@@ -2269,14 +2254,14 @@ void tst_QAbstractItemView::testClickToSelect()
// Click the center of the visualRect of item "A"
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, centerA);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.back().front().value<QRect>(), QRect(centerA, QSize(1, 1)));
// Click a point slightly away from the center
const QPoint nearCenterA = centerA + QPoint(1, 1);
QVERIFY(visualRectA.contains(nearCenterA));
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, nearCenterA);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(spy.back().front().value<QRect>(), QRect(nearCenterA, QSize(1, 1)));
}
@@ -2634,7 +2619,7 @@ void tst_QAbstractItemView::dragSelectAfterNewPress()
// Verify that the selection worked OK
QModelIndexList selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 3);
+ QCOMPARE(selected.size(), 3);
for (int i = 0; i < 2; ++i)
QVERIFY(selected.contains(model.index(i, 0)));
@@ -2651,7 +2636,7 @@ void tst_QAbstractItemView::dragSelectAfterNewPress()
// Verify that the selection worked OK
selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 6);
+ QCOMPARE(selected.size(), 6);
for (int i = 0; i < 5; ++i)
QVERIFY(selected.contains(model.index(i, 0)));
}
@@ -2846,32 +2831,40 @@ void tst_QAbstractItemView::mouseSelection_data()
{
QTest::addColumn<QAbstractItemView::SelectionMode>("selectionMode");
QTest::addColumn<bool>("dragEnabled");
+ QTest::addColumn<QAbstractItemView::EditTrigger>("editTrigger");
QTest::addColumn<QList<SelectionEvent>>("selectionEvents");
QTest::addColumn<QList<int>>("selectedRows");
// single selection mode - always one row selected, modifiers ignored
QTest::addRow("Single:Press") << QAbstractItemView::SingleSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1)}
<< QList{1};
QTest::addRow("Single:Click") << QAbstractItemView::SingleSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent{SelectionEvent::Click, 1}}
<< QList{1};
QTest::addRow("Single:Press+Drag") << QAbstractItemView::SingleSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent{SelectionEvent::Move, 2},
SelectionEvent{SelectionEvent::Release}}
<< QList{2};
QTest::addRow("Single:Shift+Click") << QAbstractItemView::SingleSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent{SelectionEvent::Click, Qt::ShiftModifier, 2}}
<< QList{2};
QTest::addRow("Single:Press;Ctrl+Press") << QAbstractItemView::SingleSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent{SelectionEvent::Press, 3},
SelectionEvent{SelectionEvent::Press, Qt::ControlModifier, 3}}
<< QList{3};
QTest::addRow("Single:Ctrl+Click") << QAbstractItemView::SingleSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent{SelectionEvent::Click, Qt::ControlModifier, 3}}
<< QList{3};
QTest::addRow("Single:Click;Ctrl+Click") << QAbstractItemView::SingleSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent{SelectionEvent::Click, 3},
SelectionEvent{SelectionEvent::Click, Qt::ControlModifier, 3}}
<< QList<int>{};
@@ -2879,30 +2872,37 @@ void tst_QAbstractItemView::mouseSelection_data()
// multi selection mode - selection toggles on press, selection can be drag-extended
// modifiers ignored
QTest::addRow("Multi:Press") << QAbstractItemView::MultiSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1)}
<< QList{1};
QTest::addRow("Multi:Press twice") << QAbstractItemView::MultiSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent(SelectionEvent::Press, 1)}
<< QList<int>{};
QTest::addRow("Multi:Press twice with drag enabled") << QAbstractItemView::MultiSelection << true
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Click, 1),
SelectionEvent(SelectionEvent::Press, 1)}
<< QList{1};
QTest::addRow("Multi:Press and click with drag enabled") << QAbstractItemView::MultiSelection << true
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent(SelectionEvent::Click, 1)}
<< QList<int>{};
QTest::addRow("Multi:Press,Press") << QAbstractItemView::MultiSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 2),
SelectionEvent(SelectionEvent::Press, 3)}
<< QList{2, 3};
QTest::addRow("Multi:Press,Drag") << QAbstractItemView::MultiSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent(SelectionEvent::Move, 5),
SelectionEvent(SelectionEvent::Release)}
<< QList{1, 2, 3, 4, 5};
QTest::addRow("Multi:Press,Drag,Deselect") << QAbstractItemView::MultiSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent(SelectionEvent::Move, 5),
SelectionEvent(SelectionEvent::Release),
@@ -2910,6 +2910,7 @@ void tst_QAbstractItemView::mouseSelection_data()
<< QList{1, 2, 4, 5};
// drag-select a few indices; then drag-select a larger area that includes the first
QTest::addRow("Multi:Press,Drag;Surround") << QAbstractItemView::MultiSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 3),
SelectionEvent(SelectionEvent::Move, 5),
SelectionEvent(SelectionEvent::Release),
@@ -2919,6 +2920,7 @@ void tst_QAbstractItemView::mouseSelection_data()
<< QList{1, 2, 3, 4, 5, 6, 7, 8};
// drag-select a few indices; then try to select more starting with the last -> not working
QTest::addRow("Multi:Press,Drag;Expand") << QAbstractItemView::MultiSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 3),
SelectionEvent(SelectionEvent::Move, 5),
SelectionEvent(SelectionEvent::Release),
@@ -2929,6 +2931,7 @@ void tst_QAbstractItemView::mouseSelection_data()
// Multi: Press-dragging a selection should not deselect #QTBUG-59888
QTest::addRow("Multi:Press-Drag selection") << QAbstractItemView::MultiSelection << true
// with drag'n'drop enabled, we cannot drag a selection
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Click, 2),
SelectionEvent(SelectionEvent::Click, 3),
SelectionEvent(SelectionEvent::Click, 4),
@@ -2941,42 +2944,51 @@ void tst_QAbstractItemView::mouseSelection_data()
// Extended selection: Press selects a single item
QTest::addRow("Extended:Press") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 3)}
<< QList{3};
QTest::addRow("Extended:Press twice") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 3),
SelectionEvent(SelectionEvent::Press, 3)}
<< QList{3};
QTest::addRow("Extended:Press,Press") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 2),
SelectionEvent(SelectionEvent::Press, 3)}
<< QList{3};
// Extended selection: press with Ctrl toggles item
QTest::addRow("Extended:Press,Toggle") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 3),
SelectionEvent(SelectionEvent::Click, Qt::ControlModifier, 3)}
<< QList<int>{};
QTest::addRow("Extended:Press,Add") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent(SelectionEvent::Click, Qt::ControlModifier, 3)}
<< QList{1, 3};
// Extended selection: Shift creates a range between first and last pressed
QTest::addRow("Extended:Press,Range") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent(SelectionEvent::Press, Qt::ShiftModifier, 5)}
<< QList{1, 2, 3, 4, 5};
QTest::addRow("Extended:Press,Range,Fix Range") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 1),
SelectionEvent(SelectionEvent::Press, Qt::ShiftModifier, 5),
SelectionEvent(SelectionEvent::Press, Qt::ShiftModifier, 3)}
<< QList{1, 2, 3};
// Extended: dragging extends the selection
QTest::addRow("Extended:Press,Drag") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 2),
SelectionEvent(SelectionEvent::Move, 5)}
<< QList{2, 3, 4, 5};
// Extended: Ctrl+Press-dragging extends the selection
QTest::addRow("Extended:Press,Drag;Ctrl-Press,Drag") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Press, 2),
SelectionEvent(SelectionEvent::Move, 5),
SelectionEvent(SelectionEvent::Release),
@@ -2986,6 +2998,7 @@ void tst_QAbstractItemView::mouseSelection_data()
<< QList{2, 3, 4, 5, 6, 7, 8};
// Extended: Ctrl+Press-dragging in a selection should not deselect #QTBUG-59888
QTest::addRow("Extended:Ctrl-Drag selection") << QAbstractItemView::ExtendedSelection << true
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Click, 2),
SelectionEvent(SelectionEvent::Click, Qt::ShiftModifier, 5),
SelectionEvent(SelectionEvent::Press, Qt::ControlModifier, 3),
@@ -2995,6 +3008,7 @@ void tst_QAbstractItemView::mouseSelection_data()
<< QList{2, 3, 4, 5};
// Extended: Ctrl+Press-dragging with a selection extends, then drags #QTBUG-59888
QTest::addRow("Extended:Ctrl-Drag selection") << QAbstractItemView::ExtendedSelection << true
+ << QAbstractItemView::NoEditTriggers
<< QList{SelectionEvent(SelectionEvent::Click, 2),
SelectionEvent(SelectionEvent::Click, Qt::ShiftModifier, 5),
SelectionEvent(SelectionEvent::Press, Qt::ControlModifier, 6),
@@ -3002,12 +3016,37 @@ void tst_QAbstractItemView::mouseSelection_data()
// two moves needed because of distance and state logic in 7QAbstractItemView
SelectionEvent(SelectionEvent::Move, Qt::ControlModifier, 8)}
<< QList{2, 3, 4, 5, 6};
+ // Extended: when drag is enabled, click with Ctrl toggles item instead of editing # QTBUG-111131
+ QTest::addRow("Extended:Click,Toggle,editable") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::SelectedClicked
+ << QList{SelectionEvent(SelectionEvent::Click, 3),
+ SelectionEvent(SelectionEvent::Click, Qt::ControlModifier, 3)}
+ << QList<int>{};
+ QTest::addRow("Extended:Click,Toggle,dragable,editable") << QAbstractItemView::ExtendedSelection << true
+ << QAbstractItemView::SelectedClicked
+ << QList{SelectionEvent(SelectionEvent::Click, 3),
+ SelectionEvent(SelectionEvent::Click, Qt::ControlModifier, 3)}
+ << QList<int>{};
+ // Extended: when drag is enabled, click on selected without Ctrl clears before editing
+ QTest::addRow("Extended:Range,Click,editable") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::SelectedClicked
+ << QList{SelectionEvent(SelectionEvent::Click, 1),
+ SelectionEvent(SelectionEvent::Click, Qt::ShiftModifier, 3),
+ SelectionEvent(SelectionEvent::Click, 2)}
+ << QList<int>{2};
+ QTest::addRow("Extended:Range,Click,dragable,editable") << QAbstractItemView::ExtendedSelection << true
+ << QAbstractItemView::SelectedClicked
+ << QList{SelectionEvent(SelectionEvent::Click, 1),
+ SelectionEvent(SelectionEvent::Click, Qt::ShiftModifier, 3),
+ SelectionEvent(SelectionEvent::Click, 2)}
+ << QList<int>{2};
}
void tst_QAbstractItemView::mouseSelection()
{
QFETCH(QAbstractItemView::SelectionMode, selectionMode);
QFETCH(bool, dragEnabled);
+ QFETCH(QAbstractItemView::EditTrigger, editTrigger);
QFETCH(QList<SelectionEvent>, selectionEvents);
QFETCH(QList<int>, selectedRows);
@@ -3016,7 +3055,7 @@ void tst_QAbstractItemView::mouseSelection()
for (int i = 0; i < 10; ++i) {
QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
item->setDragEnabled(dragEnabled);
- item->setEditable(false);
+ item->setEditable(editTrigger != QAbstractItemView::NoEditTriggers);
parentItem->appendRow(item);
}
@@ -3026,13 +3065,14 @@ void tst_QAbstractItemView::mouseSelection()
view->setModel(&model);
view->setDragEnabled(dragEnabled);
view->setSelectionMode(selectionMode);
+ view->setEditTriggers(editTrigger);
view->show();
QVERIFY(QTest::qWaitForWindowActive(view));
Qt::MouseButton buttonDown = Qt::NoButton;
int targetRow = -1;
QModelIndex pressedIndex;
- for (const auto &event : qAsConst(selectionEvents)) {
+ for (const auto &event : std::as_const(selectionEvents)) {
if (event.row != -1)
targetRow = event.row;
const QModelIndex targetIndex = model.index(targetRow, 0);
@@ -3077,6 +3117,37 @@ void tst_QAbstractItemView::mouseSelection()
}
/*!
+ Make sure that when clicking on empty space in the view, we don't
+ unselect the current row.
+ QTBUG-105870
+*/
+void tst_QAbstractItemView::keepSingleSelectionOnEmptyAreaClick()
+{
+ QListWidget view;
+ view.setSelectionMode(QAbstractItemView::SingleSelection);
+ QListWidgetItem *lastItem;
+ for (int i = 0; i < 5; i++)
+ lastItem = new QListWidgetItem("item " + QString::number(i), &view);
+
+ // Make widget large enough so that there is empty area below the last item
+ view.setFixedSize(300, 500);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ // Select third row
+ view.setCurrentRow(2);
+
+ // Click below the last row
+ QPoint targetPoint = view.visualItemRect(lastItem).bottomLeft();
+ targetPoint += QPoint(10, 10);
+
+ QTest::mouseClick(view.viewport(), Qt::MouseButton::LeftButton, Qt::NoModifier, targetPoint);
+
+ QCOMPARE(view.currentRow(), 2);
+ QVERIFY(view.currentItem()->isSelected());
+}
+
+/*!
Verify that scrolling an autoScroll enabled itemview with a QScroller
produces a continuous, smooth scroll without any jumping around due to
the currentItem negotiation between QAbstractItemView and QScroller.
@@ -3084,6 +3155,9 @@ void tst_QAbstractItemView::mouseSelection()
*/
void tst_QAbstractItemView::scrollerSmoothScroll()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QListWidget view;
view.setAutoScroll(true);
view.setVerticalScrollMode(QListView::ScrollPerPixel);
@@ -3153,6 +3227,9 @@ void tst_QAbstractItemView::inputMethodOpensEditor_data()
void tst_QAbstractItemView::inputMethodOpensEditor()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QTableWidget tableWidget(50, 50);
tableWidget.setEditTriggers(QAbstractItemView::AnyKeyPressed);
for (int r = 0; r < 50; ++r) {
@@ -3321,7 +3398,7 @@ void tst_QAbstractItemView::selectionAutoScrolling()
QTRY_COMPARE(scrollBar->value(), 0);
else
QTRY_COMPARE(scrollBar->value(), scrollBar->maximum());
- QVERIFY(listview.selectionModel()->selectedIndexes().count() > 0);
+ QVERIFY(listview.selectionModel()->selectedIndexes().size() > 0);
QTest::mouseRelease(listview.viewport(), Qt::LeftButton, Qt::NoModifier, dragPoint);
}
diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
index 9c37e0af6d..8bdbc08467 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
@@ -497,11 +497,11 @@ void tst_QColumnView::selectAll()
view.setModel(&m_fakeDirModel);
view.selectAll();
- QVERIFY(view.selectionModel()->selectedIndexes().count() >= 0);
+ QVERIFY(view.selectionModel()->selectedIndexes().size() >= 0);
view.setCurrentIndex(m_fakeDirHomeIndex);
view.selectAll();
- QVERIFY(view.selectionModel()->selectedIndexes().count() > 0);
+ QVERIFY(view.selectionModel()->selectedIndexes().size() > 0);
QModelIndex file;
for (int i = 0; i < m_fakeDirModel.rowCount(m_fakeDirHomeIndex); ++i) {
@@ -512,10 +512,10 @@ void tst_QColumnView::selectAll()
}
view.setCurrentIndex(file);
view.selectAll();
- QVERIFY(view.selectionModel()->selectedIndexes().count() > 0);
+ QVERIFY(view.selectionModel()->selectedIndexes().size() > 0);
view.setCurrentIndex(QModelIndex());
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0);
}
void tst_QColumnView::clicked()
@@ -536,13 +536,13 @@ void tst_QColumnView::clicked()
QPoint localPoint = view.visualRect(m_fakeDirHomeIndex).center();
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, localPoint);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
QCoreApplication::processEvents();
if (sizeof(qreal) != sizeof(double))
QSKIP("Skipped due to rounding errors");
- for (int i = 0; i < view.createdColumns.count(); ++i) {
+ for (int i = 0; i < view.createdColumns.size(); ++i) {
QAbstractItemView *column = view.createdColumns.at(i);
if (column && column->selectionModel() && (column->rootIndex() == m_fakeDirHomeIndex))
QVERIFY(column->selectionModel()->selectedIndexes().isEmpty());
@@ -560,7 +560,7 @@ void tst_QColumnView::selectedColumns()
QTest::qWait(ANIMATION_DELAY);
- for (int i = 0; i < view.createdColumns.count(); ++i) {
+ for (int i = 0; i < view.createdColumns.size(); ++i) {
QAbstractItemView *column = view.createdColumns.at(i);
if (!column)
continue;
@@ -591,7 +591,7 @@ void tst_QColumnView::setSelectionModel()
view.setSelectionModel(selectionModel);
bool found = false;
- for (int i = 0; i < view.createdColumns.count(); ++i) {
+ for (int i = 0; i < view.createdColumns.size(); ++i) {
if (view.createdColumns.at(i)->selectionModel() == selectionModel) {
found = true;
break;
@@ -631,7 +631,7 @@ void tst_QColumnView::moveGrip_basic()
view.setMinimumWidth(200);
grip->moveGrip(-800);
QCOMPARE(view.width(), 200);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
}
void tst_QColumnView::moveGrip_data()
@@ -659,7 +659,7 @@ void tst_QColumnView::moveGrip()
topLevel.show();
QVERIFY(QTest::qWaitForWindowActive(&topLevel));
- int columnNum = view.createdColumns.count() - 2;
+ int columnNum = view.createdColumns.size() - 2;
QVERIFY(columnNum >= 0);
const QObjectList list = view.createdColumns[columnNum]->children();
QColumnViewGrip *grip = nullptr;
@@ -687,7 +687,7 @@ void tst_QColumnView::doubleClick()
QCOMPARE(view.width(), 200);
QTest::mouseDClick(grip, Qt::LeftButton);
QCOMPARE(view.width(), view.sizeHint().width());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QColumnView::gripMoved()
@@ -711,7 +711,7 @@ void tst_QColumnView::gripMoved()
QCoreApplication::processEvents();
QTest::mouseRelease(grip, Qt::LeftButton);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QCOMPARE(view.width(), oldWidth + 65);
}
@@ -776,7 +776,7 @@ void tst_QColumnView::setPreviewWidget()
void tst_QColumnView::sizes()
{
QColumnView view;
- QCOMPARE(view.columnWidths().count(), 0);
+ QCOMPARE(view.columnWidths().size(), 0);
const QList<int> newSizes{ 10, 4, 50, 6 };
@@ -787,16 +787,16 @@ void tst_QColumnView::sizes()
view.setModel(&m_fakeDirModel);
view.setCurrentIndex(m_fakeDirHomeIndex);
- QList<int> postSizes = view.columnWidths().mid(0, newSizes.count());
- QCOMPARE(postSizes, newSizes.mid(0, postSizes.count()));
+ QList<int> postSizes = view.columnWidths().mid(0, newSizes.size());
+ QCOMPARE(postSizes, newSizes.mid(0, postSizes.size()));
- QVERIFY(view.columnWidths().count() > 1);
+ QVERIFY(view.columnWidths().size() > 1);
QList<int> smallerSizes{ 6 };
view.setColumnWidths(smallerSizes);
QList<int> expectedSizes = newSizes;
expectedSizes[0] = 6;
- postSizes = view.columnWidths().mid(0, newSizes.count());
- QCOMPARE(postSizes, expectedSizes.mid(0, postSizes.count()));
+ postSizes = view.columnWidths().mid(0, newSizes.size());
+ QCOMPARE(postSizes, expectedSizes.mid(0, postSizes.size()));
}
void tst_QColumnView::rowDelegate()
@@ -806,7 +806,7 @@ void tst_QColumnView::rowDelegate()
view.setItemDelegateForRow(3, d);
view.setModel(&m_fakeDirModel);
- for (int i = 0; i < view.createdColumns.count(); ++i) {
+ for (int i = 0; i < view.createdColumns.size(); ++i) {
QAbstractItemView *column = view.createdColumns.at(i);
QCOMPARE(column->itemDelegateForRow(3), d);
}
@@ -956,7 +956,7 @@ void tst_QColumnView::dynamicModelChanges()
model.appendRow(item);
QVERIFY(QTest::qWaitForWindowExposed(&view)); //let the time for painting to occur
- QTRY_COMPARE(delegate.paintedIndexes.count(), 1);
+ QTRY_COMPARE(delegate.paintedIndexes.size(), 1);
QCOMPARE(*delegate.paintedIndexes.begin(), model.index(0,0));
}
diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
index 41db835f0f..c95d179542 100644
--- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
+++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
@@ -252,22 +252,22 @@ void tst_QDataWidgetMapper::currentIndexChanged()
QSignalSpy spy(&mapper, &QDataWidgetMapper::currentIndexChanged);
mapper.toFirst();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.takeFirst().at(0).toInt(), 0);
mapper.toNext();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.takeFirst().at(0).toInt(), 1);
mapper.setCurrentIndex(7);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.takeFirst().at(0).toInt(), 7);
mapper.setCurrentIndex(-1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
mapper.setCurrentIndex(42);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QDataWidgetMapper::changingValues()
@@ -424,21 +424,21 @@ void tst_QDataWidgetMapper::textEditDoesntChangeFocusOnTab_qtbug3305()
int closeEditorSpyCount = 0;
const QString textEditContents = textEdit->toPlainText();
- QCOMPARE(closeEditorSpy.count(), closeEditorSpyCount);
+ QCOMPARE(closeEditorSpy.size(), closeEditorSpyCount);
QVERIFY(lineEdit->hasFocus());
QVERIFY(!textEdit->hasFocus());
// this will generate a closeEditor for the tab key, and another for the focus out
QTest::keyClick(QApplication::focusWidget(), Qt::Key_Tab);
closeEditorSpyCount += 2;
- QTRY_COMPARE(closeEditorSpy.count(), closeEditorSpyCount);
+ QTRY_COMPARE(closeEditorSpy.size(), closeEditorSpyCount);
QTRY_VERIFY(textEdit->hasFocus());
QVERIFY(!lineEdit->hasFocus());
// now that the text edit is focused, a tab keypress will insert a tab, not change focus
QTest::keyClick(QApplication::focusWidget(), Qt::Key_Tab);
- QTRY_COMPARE(closeEditorSpy.count(), closeEditorSpyCount);
+ QTRY_COMPARE(closeEditorSpy.size(), closeEditorSpyCount);
QVERIFY(!lineEdit->hasFocus());
QVERIFY(textEdit->hasFocus());
@@ -449,7 +449,7 @@ void tst_QDataWidgetMapper::textEditDoesntChangeFocusOnTab_qtbug3305()
QTRY_VERIFY(lineEdit->hasFocus());
QVERIFY(!textEdit->hasFocus());
++closeEditorSpyCount;
- QCOMPARE(closeEditorSpy.count(), closeEditorSpyCount);
+ QCOMPARE(closeEditorSpy.size(), closeEditorSpyCount);
}
QTEST_MAIN(tst_QDataWidgetMapper)
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 93f991b0fe..a0aeb0cc12 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -474,7 +474,7 @@ void tst_QHeaderView::init()
QSignalSpy spy(view, &QHeaderView::sectionCountChanged);
view->setModel(model);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
view->resize(200,200);
}
@@ -795,10 +795,10 @@ void tst_QHeaderView::visualIndexAt()
for (int i : hidden)
view->setSectionHidden(i, true);
- for (int j = 0; j < from.count(); ++j)
+ for (int j = 0; j < from.size(); ++j)
view->moveSection(from.at(j), to.at(j));
- for (int k = 0; k < coordinate.count(); ++k)
+ for (int k = 0; k < coordinate.size(); ++k)
QTRY_COMPARE(view->visualIndexAt(coordinate.at(k)), visual.at(k));
}
@@ -910,14 +910,14 @@ void tst_QHeaderView::swapSections()
QCOMPARE(view->sectionsMoved(), true);
for (int i = 0; i < view->count(); ++i)
QCOMPARE(view->logicalIndex(i), logical.at(i));
- QCOMPARE(spy1.count(), 4);
+ QCOMPARE(spy1.size(), 4);
logical = { 3, 1, 2, 0 };
view->swapSections(3, 0);
QCOMPARE(view->sectionsMoved(), true);
for (int j = 0; j < view->count(); ++j)
QCOMPARE(view->logicalIndex(j), logical.at(j));
- QCOMPARE(spy1.count(), 6);
+ QCOMPARE(spy1.size(), 6);
}
void tst_QHeaderView::moveSection_data()
@@ -963,9 +963,9 @@ void tst_QHeaderView::moveSection()
QFETCH(const IntList, logical);
QFETCH(int, count);
- QCOMPARE(from.count(), to.count());
- QCOMPARE(from.count(), moved.count());
- QCOMPARE(view->count(), logical.count());
+ QCOMPARE(from.size(), to.size());
+ QCOMPARE(from.size(), moved.size());
+ QCOMPARE(view->count(), logical.size());
QSignalSpy spy1(view, &QHeaderView::sectionMoved);
QCOMPARE(view->sectionsMoved(), false);
@@ -973,7 +973,7 @@ void tst_QHeaderView::moveSection()
for (int h : hidden)
view->setSectionHidden(h, true);
- for (int i = 0; i < from.count(); ++i) {
+ for (int i = 0; i < from.size(); ++i) {
view->moveSection(from.at(i), to.at(i));
QCOMPARE(view->sectionsMoved(), moved.at(i));
}
@@ -981,7 +981,7 @@ void tst_QHeaderView::moveSection()
for (int j = 0; j < view->count(); ++j)
QCOMPARE(view->logicalIndex(j), logical.at(j));
- QCOMPARE(spy1.count(), count);
+ QCOMPARE(spy1.size(), count);
}
void tst_QHeaderView::resizeAndMoveSection_data()
@@ -1166,14 +1166,14 @@ void tst_QHeaderView::resizeWithResizeModes()
QFETCH(const IntList, expected);
view->setStretchLastSection(false);
- for (int i = 0; i < sections.count(); ++i) {
+ for (int i = 0; i < sections.size(); ++i) {
view->resizeSection(i, sections.at(i));
view->setSectionResizeMode(i, modes.at(i));
}
topLevel->show();
QVERIFY(QTest::qWaitForWindowExposed(topLevel));
view->resize(size, size);
- for (int j = 0; j < expected.count(); ++j)
+ for (int j = 0; j < expected.size(); ++j)
QCOMPARE(view->sectionSize(j), expected.at(j));
}
@@ -1200,7 +1200,7 @@ void tst_QHeaderView::moveAndInsertSection()
view->moveSection(from, to);
model->insertRow(insert);
- for (int i = 0; i < mapping.count(); ++i)
+ for (int i = 0; i < mapping.size(); ++i)
QCOMPARE(view->logicalIndex(i), mapping.at(i));
}
@@ -1271,21 +1271,21 @@ void tst_QHeaderView::resizeSection()
view->setSectionsMovable(true);
view->setStretchLastSection(false);
- for (int i = 0; i < logical.count(); ++i)
+ for (int i = 0; i < logical.size(); ++i)
if (logical.at(i) > -1 && logical.at(i) < view->count()) // for now
view->setSectionResizeMode(logical.at(i), mode.at(i));
- for (int j = 0; j < logical.count(); ++j)
+ for (int j = 0; j < logical.size(); ++j)
view->resizeSection(logical.at(j), initial);
QSignalSpy spy(view, &QHeaderView::sectionResized);
- for (int k = 0; k < logical.count(); ++k)
+ for (int k = 0; k < logical.size(); ++k)
view->resizeSection(logical.at(k), size.at(k));
- QCOMPARE(spy.count(), resized);
+ QCOMPARE(spy.size(), resized);
- for (int l = 0; l < logical.count(); ++l)
+ for (int l = 0; l < logical.size(); ++l)
QCOMPARE(view->sectionSize(logical.at(l)), expected.at(l));
}
@@ -1338,19 +1338,19 @@ void tst_QHeaderView::clearSectionSorting()
QSignalSpy sectionClickedSpy(&h, &QHeaderView::sectionClicked);
QVERIFY(sectionClickedSpy.isValid());
- QCOMPARE(sectionClickedSpy.count(), 0);
+ QCOMPARE(sectionClickedSpy.size(), 0);
QSignalSpy sortIndicatorChangedSpy(&h, &QHeaderView::sortIndicatorChanged);
QVERIFY(sortIndicatorChangedSpy.isValid());
- QCOMPARE(sortIndicatorChangedSpy.count(), 0);
+ QCOMPARE(sortIndicatorChangedSpy.size(), 0);
enum { Count = 30 };
// normal behavior: clicking multiple times will just toggle the sort indicator
for (int i = 0; i < Count; ++i) {
QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5));
- QCOMPARE(sectionClickedSpy.count(), i + 1);
- QCOMPARE(sortIndicatorChangedSpy.count(), i + 1);
+ QCOMPARE(sectionClickedSpy.size(), i + 1);
+ QCOMPARE(sortIndicatorChangedSpy.size(), i + 1);
QCOMPARE(h.sortIndicatorSection(), 0);
const auto expectedOrder = (i % 2) == 0 ? Qt::AscendingOrder : Qt::DescendingOrder;
QCOMPARE(h.sortIndicatorOrder(), expectedOrder);
@@ -1367,8 +1367,8 @@ void tst_QHeaderView::clearSectionSorting()
// clearing behavior: clicking multiple times will be tristate (asc, desc, nothing)
for (int i = 0; i < Count; ++i) {
QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5));
- QCOMPARE(sectionClickedSpy.count(), i + 1);
- QCOMPARE(sortIndicatorChangedSpy.count(), i + 1);
+ QCOMPARE(sectionClickedSpy.size(), i + 1);
+ QCOMPARE(sortIndicatorChangedSpy.size(), i + 1);
switch (i % 3) {
case 0:
QCOMPARE(h.sortIndicatorSection(), 0);
@@ -1736,7 +1736,7 @@ static void saveRestoreImpl(const QByteArray &state, SaveRestoreOption option)
h2.setModel(&m);
QVERIFY(h2.restoreState(state));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), 2);
QCOMPARE(h2.logicalIndex(0), 2);
@@ -2040,9 +2040,9 @@ void tst_QHeaderView::sectionPressedSignal()
QSignalSpy spy(&h, &QHeaderView::sectionPressed);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QTest::mousePress(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5));
- QCOMPARE(spy.count(), count);
+ QCOMPARE(spy.size(), count);
}
void tst_QHeaderView::sectionClickedSignal()
@@ -2062,19 +2062,19 @@ void tst_QHeaderView::sectionClickedSignal()
QSignalSpy spy(&h, &QHeaderView::sectionClicked);
QSignalSpy spy2(&h, &QHeaderView::sortIndicatorChanged);
- QCOMPARE(spy.count(), 0);
- QCOMPARE(spy2.count(), 0);
+ QCOMPARE(spy.size(), 0);
+ QCOMPARE(spy2.size(), 0);
QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5));
- QCOMPARE(spy.count(), count);
- QCOMPARE(spy2.count(), count);
+ QCOMPARE(spy.size(), count);
+ QCOMPARE(spy2.size(), count);
//now let's try with the sort indicator hidden (the result should be the same
spy.clear();
spy2.clear();
h.setSortIndicatorShown(false);
QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5));
- QCOMPARE(spy.count(), count);
- QCOMPARE(spy2.count(), count);
+ QCOMPARE(spy.size(), count);
+ QCOMPARE(spy2.size(), count);
}
void tst_QHeaderView::defaultSectionSize_data()
@@ -2255,7 +2255,7 @@ void tst_QHeaderView::task236450_hidden()
for (int i : hide1)
view.hideSection(i);
- QCOMPARE(view.hiddenSectionCount(), hide1.count());
+ QCOMPARE(view.hiddenSectionCount(), hide1.size());
for (int i = 0; i < 6; i++)
QCOMPARE(!view.isSectionHidden(i), !hide1.contains(i));
@@ -2263,13 +2263,13 @@ void tst_QHeaderView::task236450_hidden()
view.scheduleDelayedItemsLayout();
view.executeDelayedItemsLayout(); //force to do a relayout
- QCOMPARE(view.hiddenSectionCount(), hide1.count());
+ QCOMPARE(view.hiddenSectionCount(), hide1.size());
for (int i = 0; i < 6; i++) {
QCOMPARE(!view.isSectionHidden(i), !hide1.contains(i));
view.setSectionHidden(i, hide2.contains(i));
}
- QCOMPARE(view.hiddenSectionCount(), hide2.count());
+ QCOMPARE(view.hiddenSectionCount(), hide2.size());
for (int i = 0; i < 6; i++)
QCOMPARE(!view.isSectionHidden(i), !hide2.contains(i));
}
@@ -2301,10 +2301,10 @@ void tst_QHeaderView::task248050_hideRow()
//returns 0 if everything is fine.
static int checkHeaderViewOrder(const QHeaderView *view, const IntList &expected)
{
- if (view->count() != expected.count())
+ if (view->count() != expected.size())
return 1;
- for (int i = 0; i < expected.count(); i++) {
+ for (int i = 0; i < expected.size(); i++) {
if (view->logicalIndex(i) != expected.at(i))
return i + 10;
if (view->visualIndex(expected.at(i)) != i)
@@ -2395,8 +2395,8 @@ void tst_QHeaderView::QTBUG7833_sectionClicked()
QTest::mouseClick(tv.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier,
QPoint(tv.horizontalHeader()->sectionViewportPosition(11) +
tv.horizontalHeader()->sectionSize(11) / 2, 5));
- QCOMPARE(clickedSpy.count(), 1);
- QCOMPARE(pressedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
+ QCOMPARE(pressedSpy.size(), 1);
QCOMPARE(clickedSpy.at(0).at(0).toInt(), 11);
QCOMPARE(pressedSpy.at(0).at(0).toInt(), 11);
@@ -2404,8 +2404,8 @@ void tst_QHeaderView::QTBUG7833_sectionClicked()
QPoint(tv.horizontalHeader()->sectionViewportPosition(8) +
tv.horizontalHeader()->sectionSize(0) / 2, 5));
- QCOMPARE(clickedSpy.count(), 2);
- QCOMPARE(pressedSpy.count(), 2);
+ QCOMPARE(clickedSpy.size(), 2);
+ QCOMPARE(pressedSpy.size(), 2);
QCOMPARE(clickedSpy.at(1).at(0).toInt(), 8);
QCOMPARE(pressedSpy.at(1).at(0).toInt(), 8);
@@ -2413,8 +2413,8 @@ void tst_QHeaderView::QTBUG7833_sectionClicked()
QPoint(tv.horizontalHeader()->sectionViewportPosition(0) +
tv.horizontalHeader()->sectionSize(0) / 2, 5));
- QCOMPARE(clickedSpy.count(), 3);
- QCOMPARE(pressedSpy.count(), 3);
+ QCOMPARE(clickedSpy.size(), 3);
+ QCOMPARE(pressedSpy.size(), 3);
QCOMPARE(clickedSpy.at(2).at(0).toInt(), 0);
QCOMPARE(pressedSpy.at(2).at(0).toInt(), 0);
}
@@ -2541,7 +2541,7 @@ public:
void insertRowAtBeginning()
{
Q_EMIT layoutAboutToBeChanged();
- m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.count()));
+ m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.size()));
// Rows are always inserted at the beginning, so move all others.
const auto pl = persistentIndexList();
// The vertical header view will have a persistent index stored here on the second call to insertRowAtBeginning.
@@ -2557,7 +2557,7 @@ public:
QModelIndex index(int row, int column, const QModelIndex &) const override { return createIndex(row, column); }
QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); }
- int rowCount(const QModelIndex &) const override { return m_displayNames.count(); }
+ int rowCount(const QModelIndex &) const override { return m_displayNames.size(); }
int columnCount(const QModelIndex &) const override { return 1; }
private:
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 68a7268473..aa17026daf 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -205,6 +205,8 @@ private slots:
void dateTextForRole_data();
void dateTextForRole();
+ void reuseEditor();
+
private:
#ifdef QT_BUILD_INTERNAL
struct RoleDelegate : public QItemDelegate
@@ -325,7 +327,7 @@ void tst_QItemDelegate::editorKeyPress()
view.edit(index);
QList<QLineEdit*> lineEditors = view.viewport()->findChildren<QLineEdit *>();
- QCOMPARE(lineEditors.count(), 1);
+ QCOMPARE(lineEditors.size(), 1);
QLineEdit *editor = lineEditors.at(0);
QCOMPARE(editor->selectedText(), initial);
@@ -353,7 +355,7 @@ void tst_QItemDelegate::doubleEditorNegativeInput()
view.edit(index);
QList<QDoubleSpinBox*> editors = view.viewport()->findChildren<QDoubleSpinBox *>();
- QCOMPARE(editors.count(), 1);
+ QCOMPARE(editors.size(), 1);
QDoubleSpinBox *editor = editors.at(0);
QCOMPARE(editor->value(), double(10));
@@ -670,33 +672,33 @@ void tst_QItemDelegate::testEventFilter()
//For each test we send a key event and check if signals were emitted.
event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);
QVERIFY(delegate.eventFilter(&widget, event));
- QCOMPARE(closeEditorSpy.count(), 1);
- QCOMPARE(commitDataSpy.count(), 1);
+ QCOMPARE(closeEditorSpy.size(), 1);
+ QCOMPARE(commitDataSpy.size(), 1);
delete event;
event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier);
QVERIFY(delegate.eventFilter(&widget, event));
- QCOMPARE(closeEditorSpy.count(), 2);
- QCOMPARE(commitDataSpy.count(), 2);
+ QCOMPARE(closeEditorSpy.size(), 2);
+ QCOMPARE(commitDataSpy.size(), 2);
delete event;
event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
QVERIFY(delegate.eventFilter(&widget, event));
- QCOMPARE(closeEditorSpy.count(), 3);
- QCOMPARE(commitDataSpy.count(), 2);
+ QCOMPARE(closeEditorSpy.size(), 3);
+ QCOMPARE(commitDataSpy.size(), 2);
delete event;
event = new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier);
QVERIFY(!delegate.eventFilter(&widget, event));
- QCOMPARE(closeEditorSpy.count(), 3);
- QCOMPARE(commitDataSpy.count(), 2);
+ QCOMPARE(closeEditorSpy.size(), 3);
+ QCOMPARE(commitDataSpy.size(), 2);
delete event;
//Subtest focusEvent
event = new QFocusEvent(QEvent::FocusOut);
QVERIFY(!delegate.eventFilter(&widget, event));
- QCOMPARE(closeEditorSpy.count(), 4);
- QCOMPARE(commitDataSpy.count(), 3);
+ QCOMPARE(closeEditorSpy.size(), 4);
+ QCOMPARE(commitDataSpy.size(), 3);
delete event;
}
@@ -1312,7 +1314,7 @@ void tst_QItemDelegate::enterKey()
view.edit(index);
QList<QWidget*> lineEditors = view.viewport()->findChildren<QWidget *>(QString::fromLatin1("TheEditor"));
- QCOMPARE(lineEditors.count(), 1);
+ QCOMPARE(lineEditors.size(), 1);
QPointer<QWidget> editor = lineEditors.at(0);
QCOMPARE(editor->hasFocus(), true);
@@ -1346,7 +1348,7 @@ void tst_QItemDelegate::task257859_finalizeEdit()
view.edit(index);
QList<QLineEdit *> lineEditors = view.viewport()->findChildren<QLineEdit *>();
- QCOMPARE(lineEditors.count(), 1);
+ QCOMPARE(lineEditors.size(), 1);
QPointer<QWidget> editor = lineEditors.at(0);
QCOMPARE(editor->hasFocus(), true);
@@ -1477,7 +1479,7 @@ void tst_QItemDelegate::testLineEditValidation()
const auto findEditors = [&]() {
return view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
};
- QCOMPARE(findEditors().count(), 1);
+ QCOMPARE(findEditors().size(), 1);
editor = findEditors().at(0);
editor->clear();
@@ -1497,7 +1499,7 @@ void tst_QItemDelegate::testLineEditValidation()
view.setCurrentIndex(index);
view.edit(index);
- QTRY_COMPARE(findEditors().count(), 1);
+ QTRY_COMPARE(findEditors().size(), 1);
editor = findEditors().at(0);
editor->clear();
@@ -1519,13 +1521,13 @@ void tst_QItemDelegate::testLineEditValidation()
// reset the view to forcibly close the editor
view.reset();
- QTRY_COMPARE(findEditors().count(), 0);
+ QTRY_COMPARE(findEditors().size(), 0);
// set a valid text again
view.setCurrentIndex(index);
view.edit(index);
- QTRY_COMPARE(findEditors().count(), 1);
+ QTRY_COMPARE(findEditors().size(), 1);
editor = findEditors().at(0);
editor->clear();
@@ -1617,6 +1619,74 @@ void tst_QItemDelegate::dateTextForRole()
#endif
}
+void tst_QItemDelegate::reuseEditor()
+{
+ class ReusingDelegate: public QItemDelegate {
+ public:
+ using QItemDelegate::QItemDelegate;
+ ~ReusingDelegate()
+ {
+ cached->deleteLater();
+ }
+
+ QWidget* createEditor(QWidget* parent,
+ const QStyleOptionViewItem&,
+ const QModelIndex&) const override
+ {
+ auto *cb = new QComboBox(parent);
+ cb->addItem("One");
+ cb->addItem("Two");
+ cb->setEditable(true);
+ return cb;
+ }
+
+ void setEditorData(QWidget* editor, const QModelIndex& index)
+ const override
+ {
+ auto *cb = qobject_cast<QComboBox*>(editor);
+ cb->setCurrentText(index.data(Qt::DisplayRole).toString());
+ }
+
+ void setModelData(QWidget* editor,
+ QAbstractItemModel* model,
+ const QModelIndex& index) const override
+ {
+ auto *cb = qobject_cast<QComboBox*>(editor);
+ model->setData(index, cb->currentText(), Qt::DisplayRole);
+ }
+
+ void destroyEditor(QWidget* editor, const QModelIndex&) const override
+ {
+ auto *cb = qobject_cast<QComboBox*>(editor);
+ cb->setParent(nullptr); // How to completely detach the editor from treeview ?
+ cb->hide();
+ cb->setEnabled(false);
+ cached = cb;
+ }
+
+ private:
+ mutable QComboBox* cached = nullptr;
+ };
+
+ QStandardItemModel model;
+ model.appendRow(new QStandardItem("One"));
+ model.appendRow(new QStandardItem("Two"));
+
+ ReusingDelegate delegate;
+
+ QTreeView tree;
+ tree.setModel(&model);
+ tree.setItemDelegate(&delegate);
+
+ tree.show();
+ QVERIFY(QTest::qWaitForWindowActive(&tree));
+
+ tree.edit(model.index(0, 0));
+ QTRY_VERIFY(qobject_cast<QComboBox *>(tree.focusWidget()));
+
+ tree.close();
+}
+
// ### _not_ covered:
// editing with a custom editor factory
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index ad52e40254..a154baad46 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -718,7 +718,7 @@ void tst_QListView::clicked()
continue;
QSignalSpy spy(&view, &QListView::clicked);
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
}
@@ -1147,7 +1147,7 @@ void tst_QListView::selection()
v.setSelection(selectionRect, QItemSelectionModel::ClearAndSelect);
const QModelIndexList selected = v.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), expectedItems.count());
+ QCOMPARE(selected.size(), expectedItems.size());
for (const auto &idx : selected)
QVERIFY(expectedItems.contains(idx.row()));
}
@@ -1557,7 +1557,7 @@ void tst_QListView::task203585_selectAll()
QVERIFY(view.selectionModel()->selectedIndexes().isEmpty());
view.setRowHidden(0, false);
view.selectAll();
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
}
void tst_QListView::task228566_infiniteRelayout()
@@ -1642,7 +1642,7 @@ void tst_QListView::task196118_visualRegionForSelection()
view.selectionModel()->select(top1.index(), QItemSelectionModel::Select);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
QVERIFY(view.getVisualRegionForSelection().isEmpty());
}
@@ -1740,7 +1740,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
QTRY_COMPARE(view.currentIndex(), model.index(1, 0));
QModelIndexList selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 3);
+ QCOMPARE(selected.size(), 3);
QVERIFY(!selected.contains(model.index(0, 0)));
}
{ // Second test: QListView::TopToBottom flow
@@ -1767,7 +1767,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
QTRY_COMPARE(view.currentIndex(), model.index(1, 0));
QModelIndexList selected = view.selectionModel()->selectedIndexes();
- QCOMPARE(selected.count(), 3);
+ QCOMPARE(selected.size(), 3);
QVERIFY(!selected.contains(model.index(0, 0)));
}
}
@@ -1829,7 +1829,7 @@ void tst_QListView::clickOnViewportClearsSelection()
view.selectAll();
QModelIndex index = model.index(0);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
QVERIFY(view.selectionModel()->isSelected(index));
//we try to click outside of the index
@@ -1837,7 +1837,7 @@ void tst_QListView::clickOnViewportClearsSelection()
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, point);
//at this point, the selection shouldn't have changed
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
QVERIFY(view.selectionModel()->isSelected(index));
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, point);
@@ -1946,7 +1946,7 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick()
view.setModel(&model);
view.setSelectionMode(QAbstractItemView::ExtendedSelection);
view.selectAll();
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount());
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), model.rowCount());
const QRect itemRect = view.visualRect(model.index(model.rowCount() - 1));
@@ -1956,7 +1956,7 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick()
QVERIFY(!view.selectionModel()->hasSelection());
view.selectAll();
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount());
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), model.rowCount());
//and now the right button
QTest::mouseClick(view.viewport(), Qt::RightButton, {}, p);
@@ -2715,9 +2715,9 @@ public:
if (idxPar.isValid()) {
TstMoveItem *parentItem = static_cast<TstMoveItem *>(idxPar.internalPointer());
Q_ASSERT(parentItem);
- cnt = parentItem->childItems.count();
+ cnt = parentItem->childItems.size();
} else {
- cnt = rootItem->childItems.count();
+ cnt = rootItem->childItems.size();
}
return cnt;
}
@@ -2734,9 +2734,9 @@ public:
if (parent.isValid()) {
TstMoveItem *parentItem = static_cast<TstMoveItem *>(parent.internalPointer());
Q_ASSERT(parentItem);
- ret = parentItem->childItems.count() > 0;
+ ret = parentItem->childItems.size() > 0;
} else {
- ret = rootItem->childItems.count() > 0;
+ ret = rootItem->childItems.size() > 0;
}
return ret;
}
@@ -2758,8 +2758,8 @@ public:
TstMoveItem *itmDestParent = itemAt(destinationParent);
if (itmSrcParent && sourceRow >= 0
- && sourceRow + count <= itmSrcParent->childItems.count()
- && itmDestParent && destinationChild <= itmDestParent->childItems.count()) {
+ && sourceRow + count <= itmSrcParent->childItems.size()
+ && itmDestParent && destinationChild <= itmDestParent->childItems.size()) {
beginMoveRows(sourceParent, sourceRow, sourceRow + count - 1,
destinationParent, destinationChild);
QList<TstMoveItem *> itemsToMove;
@@ -2767,7 +2767,7 @@ public:
TstMoveItem *itm = itmSrcParent->childItems.at(sourceRow+i);
itemsToMove.append(itm);
}
- for (int i = itemsToMove.count() -1; i >= 0; --i) {
+ for (int i = itemsToMove.size() -1; i >= 0; --i) {
TstMoveItem *itm = itemsToMove.at(i);
itm->parentItem->childItems.removeAll(itm);
itm->parentItem = itmDestParent;
@@ -3056,6 +3056,11 @@ void tst_QListView::spacingWithWordWrap()
}
};
+ QStyle *oldStyle = QApplication::style();
+ oldStyle->setParent(nullptr);
+ const auto resetStyle = qScopeGuard([oldStyle]{
+ QApplication::setStyle(oldStyle);
+ });
QApplication::setStyle(new MyStyle(scrollBarOverlap));
const int listViewResizeCount = 200;
@@ -3169,7 +3174,7 @@ void tst_QListView::scrollOnRemove()
model.removeRow(25);
// if nothing is selected now, then the view should not have scrolled
- if (!view.selectionModel()->selectedIndexes().count())
+ if (!view.selectionModel()->selectedIndexes().size())
QTRY_COMPARE(view.verticalScrollBar()->value(), item25Position);
}
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index 3fe14c682c..9ff0ac91e1 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -344,7 +344,7 @@ void tst_QListWidget::addItems()
QString::number(testWidget->count() + 3),
label};
testWidget->addItems(stringList);
- QCOMPARE(testWidget->count(), count + stringList.count());
+ QCOMPARE(testWidget->count(), count + stringList.size());
QCOMPARE(testWidget->item(testWidget->count()-1)->text(), label);
}
@@ -356,30 +356,30 @@ void tst_QListWidget::openPersistentEditor()
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
testWidget->openPersistentEditor(item);
- int childCount = testWidget->viewport()->children().count();
+ int childCount = testWidget->viewport()->children().size();
testWidget->addItem(item);
testWidget->openPersistentEditor(item);
- QCOMPARE(childCount + 1, testWidget->viewport()->children().count());
+ QCOMPARE(childCount + 1, testWidget->viewport()->children().size());
}
void tst_QListWidget::closePersistentEditor()
{
// Boundary checking
- int childCount = testWidget->viewport()->children().count();
+ int childCount = testWidget->viewport()->children().size();
testWidget->closePersistentEditor(nullptr);
QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count()));
testWidget->closePersistentEditor(item);
- QCOMPARE(childCount, testWidget->viewport()->children().count());
+ QCOMPARE(childCount, testWidget->viewport()->children().size());
// Create something
testWidget->addItem(item);
testWidget->openPersistentEditor(item);
// actual test
- childCount = testWidget->viewport()->children().count();
+ childCount = testWidget->viewport()->children().size();
testWidget->closePersistentEditor(item);
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
- QCOMPARE(testWidget->viewport()->children().count(), childCount - 1);
+ QCOMPARE(testWidget->viewport()->children().size(), childCount - 1);
}
void tst_QListWidget::setItemHidden()
@@ -529,7 +529,7 @@ void tst_QListWidget::editItem()
item->setFlags(item->flags() | Qt::ItemIsEditable);
testWidget->addItem(item);
- int childCount = testWidget->viewport()->children().count();
+ int childCount = testWidget->viewport()->children().size();
QWidget *existsAlready = testWidget->indexWidget(testWidget->model()->index(testWidget->row(item), 0));
testWidget->editItem(item);
Qt::ItemFlags flags = item->flags();
@@ -537,7 +537,7 @@ void tst_QListWidget::editItem()
// There doesn't seem to be a way to detect if the item has already been edited...
if (!existsAlready && flags & Qt::ItemIsEditable && flags & Qt::ItemIsEnabled) {
QList<QObject *> children = testWidget->viewport()->children();
- QVERIFY(children.count() > childCount);
+ QVERIFY(children.size() > childCount);
bool found = false;
for (int i = 0; i < children.size(); ++i) {
if (children.at(i)->inherits("QExpandingLineEdit"))
@@ -545,7 +545,7 @@ void tst_QListWidget::editItem()
}
QVERIFY(found);
} else {
- QCOMPARE(testWidget->viewport()->children().count(), childCount);
+ QCOMPARE(testWidget->viewport()->children().size(), childCount);
}
}
@@ -554,12 +554,12 @@ void tst_QListWidget::findItems()
// This really just tests that the items that are returned are converted from index's to items correctly.
// Boundary checking
- QCOMPARE(testWidget->findItems("GirlsCanWearJeansAndCutTheirHairShort", Qt::MatchExactly).count(), 0);
+ QCOMPARE(testWidget->findItems("GirlsCanWearJeansAndCutTheirHairShort", Qt::MatchExactly).size(), 0);
populate();
for (int i = 0; i < testWidget->count(); ++i)
- QCOMPARE(testWidget->findItems(testWidget->item(i)->text(), Qt::MatchExactly).count(), 1);
+ QCOMPARE(testWidget->findItems(testWidget->item(i)->text(), Qt::MatchExactly).size(), 1);
}
@@ -574,8 +574,8 @@ void tst_QListWidget::insertItem_data()
QTest::newRow("Insert less then 0") << initialItems << -1 << "inserted" << 0;
QTest::newRow("Insert at 0") << initialItems << 0 << "inserted" << 0;
- QTest::newRow("Insert beyond count") << initialItems << initialItems.count()+1 << "inserted" << initialItems.count();
- QTest::newRow("Insert at count") << initialItems << initialItems.count() << "inserted" << initialItems.count();
+ QTest::newRow("Insert beyond count") << initialItems << initialItems.size()+1 << "inserted" << initialItems.size();
+ QTest::newRow("Insert at count") << initialItems << initialItems.size() << "inserted" << initialItems.size();
QTest::newRow("Insert in the middle") << initialItems << 1 << "inserted" << 1;
}
@@ -587,7 +587,7 @@ void tst_QListWidget::insertItem()
QFETCH(int, expectedIndex);
testWidget->insertItems(0, initialItems);
- QCOMPARE(testWidget->count(), initialItems.count());
+ QCOMPARE(testWidget->count(), initialItems.size());
testWidget->insertItem(insertIndex, itemLabel);
@@ -596,7 +596,7 @@ void tst_QListWidget::insertItem()
QCOMPARE(rcFirst[RowsInserted], expectedIndex);
QCOMPARE(rcLast[RowsInserted], expectedIndex);
- QCOMPARE(testWidget->count(), initialItems.count() + 1);
+ QCOMPARE(testWidget->count(), initialItems.size() + 1);
QCOMPARE(testWidget->item(expectedIndex)->text(), itemLabel);
}
@@ -669,8 +669,8 @@ void tst_QListWidget::insertItems()
for (int i = 0; i < testWidget->count(); ++i)
QCOMPARE(testWidget->item(i)->listWidget(), testWidget);
- QCOMPARE(itemChangedSpy.count(), 0);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
}
void tst_QListWidget::itemAssignment()
@@ -825,7 +825,7 @@ void tst_QListWidget::selectedItems()
QListWidgetItem *item = testWidget->item(i);
item->setSelected(true);
QVERIFY(item->isSelected());
- QCOMPARE(testWidget->selectedItems().count(), 1);
+ QCOMPARE(testWidget->selectedItems().size(), 1);
}
//let's clear the selection
testWidget->clearSelection();
@@ -843,7 +843,7 @@ void tst_QListWidget::selectedItems()
// check that the correct number of items and the expected items are there
QList<QListWidgetItem *> selectedItems = testWidget->selectedItems();
- QCOMPARE(selectedItems.count(), expectedRows.count());
+ QCOMPARE(selectedItems.size(), expectedRows.size());
for (int row : expectedRows)
QVERIFY(selectedItems.contains(testWidget->item(row)));
@@ -939,20 +939,20 @@ void tst_QListWidget::moveItemsPriv()
else
QCOMPARE(testWidget->item(dstRow)->text(), QString::number(srcRow));
- QCOMPARE(beginMoveSpy.count(), 1);
+ QCOMPARE(beginMoveSpy.size(), 1);
const QList<QVariant> &beginMoveArgs = beginMoveSpy.takeFirst();
QCOMPARE(beginMoveArgs.at(1).toInt(), srcRow);
QCOMPARE(beginMoveArgs.at(2).toInt(), srcRow);
QCOMPARE(beginMoveArgs.at(4).toInt(), dstRow);
- QCOMPARE(movedSpy.count(), 1);
+ QCOMPARE(movedSpy.size(), 1);
const QList<QVariant> &movedArgs = movedSpy.takeFirst();
QCOMPARE(movedArgs.at(1).toInt(), srcRow);
QCOMPARE(movedArgs.at(2).toInt(), srcRow);
QCOMPARE(movedArgs.at(4).toInt(), dstRow);
} else {
- QCOMPARE(beginMoveSpy.count(), 0);
- QCOMPARE(movedSpy.count(), 0);
+ QCOMPARE(beginMoveSpy.size(), 0);
+ QCOMPARE(movedSpy.size(), 0);
}
}
@@ -1045,7 +1045,7 @@ void tst_QListWidget::sortItems()
testWidget->sortItems(order);
- QCOMPARE(testWidget->count(), expectedList.count());
+ QCOMPARE(testWidget->count(), expectedList.size());
for (int i = 0; i < testWidget->count(); ++i)
QCOMPARE(testWidget->item(i)->text(), expectedList.at(i).toString());
@@ -1115,7 +1115,7 @@ void tst_QListWidget::sortHiddenItems()
tw->setSortingEnabled(true);
tw->sortItems(order);
- QCOMPARE(tw->count(), expectedList.count());
+ QCOMPARE(tw->count(), expectedList.size());
for (int i = 0; i < tw->count(); ++i) {
QCOMPARE(tw->item(i)->text(), expectedList.at(i));
QCOMPARE(tw->item(i)->isHidden(), !expectedVisibility.at(i));
@@ -1212,17 +1212,17 @@ void tst_QListWidget::setData()
QFETCH(QVariantList, values);
QFETCH(int, expectedSignalCount);
- QCOMPARE(roles.count(), values.count());
+ QCOMPARE(roles.size(), values.size());
for (int manipulateModel = 0; manipulateModel < 2; ++manipulateModel) {
testWidget->clear();
testWidget->insertItems(0, initialItems);
- QCOMPARE(testWidget->count(), initialItems.count());
+ QCOMPARE(testWidget->count(), initialItems.size());
QSignalSpy itemChanged(testWidget, &QListWidget::itemChanged);
QSignalSpy dataChanged(testWidget->model(), &QAbstractItemModel::dataChanged);
- for (int i = 0; i < roles.count(); ++i) {
+ for (int i = 0; i < roles.size(); ++i) {
if (manipulateModel)
testWidget->model()->setData(
testWidget->model()->index(itemIndex, 0, testWidget->rootIndex()),
@@ -1233,12 +1233,12 @@ void tst_QListWidget::setData()
}
// make sure the data is actually set
- for (int i = 0; i < roles.count(); ++i)
+ for (int i = 0; i < roles.size(); ++i)
QCOMPARE(testWidget->item(itemIndex)->data(roles.at(i)), values.at(i));
// make sure we get the right number of emits
- QCOMPARE(itemChanged.count(), expectedSignalCount);
- QCOMPARE(dataChanged.count(), expectedSignalCount);
+ QCOMPARE(itemChanged.size(), expectedSignalCount);
+ QCOMPARE(dataChanged.size(), expectedSignalCount);
}
}
@@ -1380,11 +1380,11 @@ void tst_QListWidget::insertItemsWithSorting()
w.addItem(str);
break;
}
- QCOMPARE(w.count(), expectedItems.count());
+ QCOMPARE(w.count(), expectedItems.size());
for (int i = 0; i < w.count(); ++i)
QCOMPARE(w.item(i)->text(), expectedItems.at(i));
- for (int k = 0; k < persistent.count(); ++k)
+ for (int k = 0; k < persistent.size(); ++k)
QCOMPARE(persistent.at(k).row(), expectedRows.at(k));
}
}
@@ -1480,7 +1480,7 @@ void tst_QListWidget::itemData()
QCOMPARE(widget.currentRoles, QList<int> { Qt::UserRole + i });
}
QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0));
- QCOMPARE(flags.count(), 6);
+ QCOMPARE(flags.size(), 6);
for (int i = 0; i < 4; ++i)
QCOMPARE(flags[Qt::UserRole + i].toString(), QString::number(i + 1));
@@ -1524,19 +1524,19 @@ void tst_QListWidget::changeDataWithSorting()
QListWidgetItem *item = w.item(itemIndex);
item->setText(newValue);
- for (int i = 0; i < expectedItems.count(); ++i) {
+ for (int i = 0; i < expectedItems.size(); ++i) {
QCOMPARE(w.item(i)->text(), expectedItems.at(i));
- for (int j = 0; j < persistent.count(); ++j) {
+ for (int j = 0; j < persistent.size(); ++j) {
if (persistent.at(j).row() == i) // the same toplevel row
QCOMPARE(persistent.at(j).internalPointer(), static_cast<void *>(w.item(i)));
}
}
- for (int k = 0; k < persistent.count(); ++k)
+ for (int k = 0; k < persistent.size(); ++k)
QCOMPARE(persistent.at(k).row(), expectedRows.at(k));
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0);
}
void tst_QListWidget::itemWidget()
@@ -1615,7 +1615,7 @@ void tst_QListWidget::insertUnchanged()
QListWidget w;
QSignalSpy itemChangedSpy(&w, &QListWidget::itemChanged);
QListWidgetItem item("foo", &w);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
}
void tst_QListWidget::setSortingEnabled()
@@ -1706,12 +1706,12 @@ void tst_QListWidget::QTBUG8086_currentItemChangedOnClick()
QVERIFY(QTest::qWaitForWindowExposed(&win));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QTest::mouseClick(list.viewport(), Qt::LeftButton, {},
list.visualItemRect(list.item(2)).center());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
@@ -1810,14 +1810,14 @@ void tst_QListWidget::QTBUG50891_ensureSelectionModelSignalConnectionsAreSet()
QSignalSpy currentItemChangedSpy(&list, &QListWidget::currentItemChanged);
QSignalSpy itemSelectionChangedSpy(&list, &QListWidget::itemSelectionChanged);
- QCOMPARE(currentItemChangedSpy.count(), 0);
- QCOMPARE(itemSelectionChangedSpy.count(), 0);
+ QCOMPARE(currentItemChangedSpy.size(), 0);
+ QCOMPARE(itemSelectionChangedSpy.size(), 0);
QTest::mouseClick(list.viewport(), Qt::LeftButton, {},
list.visualItemRect(list.item(2)).center());
- QCOMPARE(currentItemChangedSpy.count(), 1);
- QCOMPARE(itemSelectionChangedSpy.count(), 1);
+ QCOMPARE(currentItemChangedSpy.size(), 1);
+ QCOMPARE(itemSelectionChangedSpy.size(), 1);
}
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index edd5453259..50d22addac 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -503,7 +503,7 @@ void tst_QTableView::emptyModel()
QSignalSpy spy(&model, &QtTestTableModel::invalidIndexEncountered);
view.setModel(&model);
view.show();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTableView::removeRows_data()
@@ -528,10 +528,10 @@ void tst_QTableView::removeRows()
view.show();
model.removeLastRow();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
model.removeAllRows();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTableView::removeColumns_data()
@@ -556,10 +556,10 @@ void tst_QTableView::removeColumns()
view.show();
model.removeLastColumn();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
model.removeAllColumns();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTableView::keyboardNavigation_data()
@@ -1597,7 +1597,7 @@ void tst_QTableView::selection()
view.setSelection(QRect(x, y, width, height), command);
- QCOMPARE(view.selectedIndexes().count(), selectedCount);
+ QCOMPARE(view.selectedIndexes().size(), selectedCount);
}
void tst_QTableView::selectRow_data()
@@ -1710,12 +1710,12 @@ void tst_QTableView::selectRow()
view.setSelectionMode(mode);
view.setSelectionBehavior(behavior);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0);
view.selectRow(row);
//test we have 10 items selected
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), selectedItems);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), selectedItems);
//test that all 10 items are in the same row
for (int i = 0; selectedItems > 0 && i < rowCount; ++i)
QCOMPARE(view.selectionModel()->selectedIndexes().at(i).row(), row);
@@ -1831,11 +1831,11 @@ void tst_QTableView::selectColumn()
view.setSelectionMode(mode);
view.setSelectionBehavior(behavior);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0);
view.selectColumn(column);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), selectedItems);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), selectedItems);
for (int i = 0; selectedItems > 0 && i < columnCount; ++i)
QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column);
}
@@ -1980,22 +1980,22 @@ void tst_QTableView::selectall()
// try slot first
view.clearSelection();
- QCOMPARE(view.selectedIndexes().count(), 0);
+ QCOMPARE(view.selectedIndexes().size(), 0);
view.selectAll();
- QCOMPARE(view.selectedIndexes().count(), selectedCount);
+ QCOMPARE(view.selectedIndexes().size(), selectedCount);
// try by key sequence
view.clearSelection();
- QCOMPARE(view.selectedIndexes().count(), 0);
+ QCOMPARE(view.selectedIndexes().size(), 0);
QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll));
- QCOMPARE(view.selectedIndexes().count(), selectedCount);
+ QCOMPARE(view.selectedIndexes().size(), selectedCount);
// check again with no selection mode
view.clearSelection();
view.setSelectionMode(QAbstractItemView::NoSelection);
- QCOMPARE(view.selectedIndexes().count(), 0);
+ QCOMPARE(view.selectedIndexes().size(), 0);
QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll));
- QCOMPARE(view.selectedIndexes().count(), 0);
+ QCOMPARE(view.selectedIndexes().size(), 0);
}
#endif // QT_CONFIG(shortcut)
@@ -2188,7 +2188,7 @@ void tst_QTableView::resizeRowsToContents()
QSignalSpy resizedSpy(view.verticalHeader(), &QHeaderView::sectionResized);
view.resizeRowsToContents();
- QCOMPARE(resizedSpy.count(), model.rowCount());
+ QCOMPARE(resizedSpy.size(), model.rowCount());
for (int r = 0; r < model.rowCount(); ++r)
QCOMPARE(view.rowHeight(r), rowHeight);
}
@@ -2234,7 +2234,7 @@ void tst_QTableView::resizeColumnsToContents()
QSignalSpy resizedSpy(view.horizontalHeader(), &QHeaderView::sectionResized);
view.resizeColumnsToContents();
- QCOMPARE(resizedSpy.count(), model.columnCount());
+ QCOMPARE(resizedSpy.size(), model.columnCount());
for (int c = 0; c < model.columnCount(); ++c)
QCOMPARE(view.columnWidth(c), columnWidth);
}
@@ -2348,7 +2348,7 @@ void tst_QTableView::rowAt()
for (int r = 0; r < rowCount; ++r)
view.setRowHeight(r, rowHeight);
- for (int i = 0; i < hiddenRows.count(); ++i)
+ for (int i = 0; i < hiddenRows.size(); ++i)
view.hideRow(hiddenRows.at(i));
QCOMPARE(view.rowAt(coordinate), row);
@@ -2511,7 +2511,7 @@ void tst_QTableView::columnAt()
for (int c = 0; c < columnCount; ++c)
view.setColumnWidth(c, columnWidth);
- for (int i = 0; i < hiddenColumns.count(); ++i)
+ for (int i = 0; i < hiddenColumns.size(); ++i)
view.hideColumn(hiddenColumns.at(i));
QCOMPARE(view.columnAt(coordinate), column);
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 39cbe0ab66..02d93bd356 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -192,8 +192,8 @@ void tst_QTableWidget::clear()
QVERIFY(bla.isNull());
QVERIFY(!testWidget->item(0,0));
- QVERIFY(!testWidget->selectedRanges().count());
- QVERIFY(!testWidget->selectedItems().count());
+ QVERIFY(!testWidget->selectedRanges().size());
+ QVERIFY(!testWidget->selectedItems().size());
}
void tst_QTableWidget::rowCount()
@@ -360,7 +360,7 @@ void tst_QTableWidget::takeItem()
QCOMPARE(item->text(), QString::number(row * column + column));
delete item;
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
const QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 2);
QCOMPARE(arguments.at(0).toInt(), row);
@@ -525,24 +525,24 @@ void tst_QTableWidget::selectedItems()
testWidget->setColumnHidden(column, true);
// make sure we don't have any previous selections hanging around
- QVERIFY(!testWidget->selectedRanges().count());
- QVERIFY(!testWidget->selectedItems().count());
+ QVERIFY(!testWidget->selectedRanges().size());
+ QVERIFY(!testWidget->selectedItems().size());
// select range and check that it is set correctly
testWidget->setRangeSelected(selectionRange, true);
if (selectionRange.topRow() >= 0) {
- QCOMPARE(testWidget->selectedRanges().count(), 1);
+ QCOMPARE(testWidget->selectedRanges().size(), 1);
QCOMPARE(testWidget->selectedRanges().at(0).topRow(), selectionRange.topRow());
QCOMPARE(testWidget->selectedRanges().at(0).bottomRow(), selectionRange.bottomRow());
QCOMPARE(testWidget->selectedRanges().at(0).leftColumn(), selectionRange.leftColumn());
QCOMPARE(testWidget->selectedRanges().at(0).rightColumn(), selectionRange.rightColumn());
} else {
- QCOMPARE(testWidget->selectedRanges().count(), 0);
+ QCOMPARE(testWidget->selectedRanges().size(), 0);
}
// check that the correct number of items and the expected items are there
const QList<QTableWidgetItem *> selectedItems = testWidget->selectedItems();
- QCOMPARE(selectedItems.count(), expectedItems.count());
+ QCOMPARE(selectedItems.size(), expectedItems.size());
for (const auto &intPair : expectedItems)
QVERIFY(selectedItems.contains(testWidget->item(intPair.first, intPair.second)));
@@ -627,7 +627,7 @@ void tst_QTableWidget::selectedSpannedCells() // QTBUG-255
testWidget.visualRect(testWidget.model()->index(selectionEndCell.y(), selectionEndCell.x())).center());
auto ranges = testWidget.selectedRanges();
- QCOMPARE(ranges.count(), expectedSelectionRangeCount);
+ QCOMPARE(ranges.size(), expectedSelectionRangeCount);
QCOMPARE(ranges.first(), expectedFirstSelectionRange);
}
@@ -1194,15 +1194,15 @@ void tst_QTableWidget::sortItems()
persistent << model->index(r, sortColumn, QModelIndex());
}
- for (int h = 0; h < initialHidden.count(); ++h)
+ for (int h = 0; h < initialHidden.size(); ++h)
testWidget->hideRow(initialHidden.at(h));
- QCOMPARE(testWidget->verticalHeader()->hiddenSectionCount(), initialHidden.count());
+ QCOMPARE(testWidget->verticalHeader()->hiddenSectionCount(), initialHidden.size());
testWidget->sortItems(sortColumn, sortOrder);
int te = 0;
- for (int i = 0; i < rows.count(); ++i) {
+ for (int i = 0; i < rows.size(); ++i) {
for (int j = 0; j < columnCount; ++j) {
QString value;
QTableWidgetItem *itm = testWidget->item(i, j);
@@ -1216,7 +1216,7 @@ void tst_QTableWidget::sortItems()
// << "expected" << rows.at(i);
}
- for (int k = 0; k < expectedHidden.count(); ++k)
+ for (int k = 0; k < expectedHidden.size(); ++k)
QVERIFY(testWidget->isRowHidden(expectedHidden.at(k)));
}
@@ -1397,18 +1397,18 @@ void tst_QTableWidget::setItemWithSorting()
}
}
- for (int k = 0; k < persistent.count(); ++k) {
+ for (int k = 0; k < persistent.size(); ++k) {
QCOMPARE(persistent.at(k).row(), expectedRows.at(k));
int i = (persistent.at(k).row() * columnCount) + sortColumn;
QCOMPARE(persistent.at(k).data().toString(), expectedValues.at(i));
}
if (i == 0)
- QCOMPARE(dataChangedSpy.count(), reorderingExpected ? 0 : 1);
+ QCOMPARE(dataChangedSpy.size(), reorderingExpected ? 0 : 1);
else
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
- QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0);
+ QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0);
}
}
@@ -1444,7 +1444,7 @@ void tst_QTableWidget::itemData()
QCOMPARE(widget.currentRoles, QList<int> { Qt::UserRole + i });
}
QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0));
- QCOMPARE(flags.count(), 6);
+ QCOMPARE(flags.size(), 6);
for (int i = 0; i < 4; ++i)
QCOMPARE(flags[Qt::UserRole + i].toString(), QString::number(i + 1));
}
@@ -1457,7 +1457,7 @@ void tst_QTableWidget::setItemData()
QTableWidgetItem *item = new QTableWidgetItem;
table.setItem(0, 0, item);
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
QModelIndex idx = qvariant_cast<QModelIndex>(dataChangedSpy.takeFirst().at(0));
QMap<int, QVariant> data;
@@ -1469,7 +1469,7 @@ void tst_QTableWidget::setItemData()
QCOMPARE(table.model()->data(idx, Qt::DisplayRole).toString(), QLatin1String("Display"));
QCOMPARE(table.model()->data(idx, Qt::EditRole).toString(), QLatin1String("Display"));
QCOMPARE(table.model()->data(idx, Qt::ToolTipRole).toString(), QLatin1String("ToolTip"));
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
QCOMPARE(idx, qvariant_cast<QModelIndex>(dataChangedSpy.first().at(0)));
QCOMPARE(idx, qvariant_cast<QModelIndex>(dataChangedSpy.first().at(1)));
const auto roles = qvariant_cast<QList<int>>(dataChangedSpy.first().at(2));
@@ -1480,13 +1480,13 @@ void tst_QTableWidget::setItemData()
dataChangedSpy.clear();
table.model()->setItemData(idx, data);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
data.clear();
data.insert(Qt::DisplayRole, QLatin1String("dizplaye"));
table.model()->setItemData(idx, data);
QCOMPARE(table.model()->data(idx, Qt::DisplayRole).toString(), QLatin1String("dizplaye"));
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
QCOMPARE(QList<int>({ Qt::DisplayRole, Qt::EditRole }),
qvariant_cast<QList<int>>(dataChangedSpy.first().at(2)));
@@ -1649,7 +1649,7 @@ void tst_QTableWidget::task262056_sortDuplicate()
QSignalSpy layoutChangedSpy(testWidget->model(), &QAbstractItemModel::layoutChanged);
testWidget->item(3,0)->setBackground(Qt::red);
- QCOMPARE(layoutChangedSpy.count(),0);
+ QCOMPARE(layoutChangedSpy.size(),0);
}
@@ -1746,7 +1746,7 @@ void tst_QTableWidget::selectedRowAfterSorting()
table.setProperty("sortingEnabled",true);
table.selectRow(1);
table.item(1,1)->setText("9");
- QCOMPARE(table.selectedItems().count(),3);
+ QCOMPARE(table.selectedItems().size(),3);
const auto selectedItems = table.selectedItems();
for (QTableWidgetItem *item : selectedItems)
QCOMPARE(item->row(), 0);
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 8fa942dd06..2a540feb66 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -1279,7 +1279,7 @@ void tst_QTreeView::setModel()
QCOMPARE(view.header()->model(), model);
QCOMPARE(view.selectionModel() != oldSelectionModel, (i == 0));
}
- QTRY_COMPARE(modelDestroyedSpy.count(), 0);
+ QTRY_COMPARE(modelDestroyedSpy.size(), 0);
view.setModel(nullptr);
QCOMPARE(view.model(), nullptr);
@@ -1334,7 +1334,7 @@ void tst_QTreeView::setHeader()
Qt::Orientation orient = x ? Qt::Vertical : Qt::Horizontal;
QHeaderView *head = new QHeaderView(orient);
view.setHeader(head);
- QCOMPARE(destroyedSpy.count(), 1);
+ QCOMPARE(destroyedSpy.size(), 1);
QCOMPARE(head->parent(), &view);
QCOMPARE(view.header(), head);
view.setHeader(head);
@@ -1517,10 +1517,10 @@ void tst_QTreeView::limitedExpand()
QVERIFY(spy.isValid());
view.expand(model.index(0, 0));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
view.expand(model.index(1, 0));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
{
QStringListModel model(QStringList() << "one" << "two");
@@ -1531,9 +1531,9 @@ void tst_QTreeView::limitedExpand()
QVERIFY(spy.isValid());
view.expand(model.index(0, 0));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
view.expandAll();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
}
@@ -1572,58 +1572,58 @@ void tst_QTreeView::expandAndCollapse()
view.expand(QModelIndex());
QCOMPARE(view.isExpanded(QModelIndex()), false);
view.collapse(QModelIndex());
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 0);
// expand a first level item
QVERIFY(!view.isExpanded(a));
view.expand(a);
QVERIFY(view.isExpanded(a));
- QCOMPARE(expandedSpy.count(), 1);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 1);
+ QCOMPARE(collapsedSpy.size(), 0);
args = expandedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a);
view.expand(a);
QVERIFY(view.isExpanded(a));
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 0);
// expand a second level item
QVERIFY(!view.isExpanded(b));
view.expand(b);
QVERIFY(view.isExpanded(a));
QVERIFY(view.isExpanded(b));
- QCOMPARE(expandedSpy.count(), 1);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 1);
+ QCOMPARE(collapsedSpy.size(), 0);
args = expandedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), b);
view.expand(b);
QVERIFY(view.isExpanded(b));
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 0);
// collapse the first level item
view.collapse(a);
QVERIFY(!view.isExpanded(a));
QVERIFY(view.isExpanded(b));
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 1);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 1);
args = collapsedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a);
view.collapse(a);
QVERIFY(!view.isExpanded(a));
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 0);
// expand the first level item again
view.expand(a);
QVERIFY(view.isExpanded(a));
QVERIFY(view.isExpanded(b));
- QCOMPARE(expandedSpy.count(), 1);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 1);
+ QCOMPARE(collapsedSpy.size(), 0);
args = expandedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a);
@@ -1631,8 +1631,8 @@ void tst_QTreeView::expandAndCollapse()
view.collapse(b);
QVERIFY(view.isExpanded(a));
QVERIFY(!view.isExpanded(b));
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 1);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 1);
args = collapsedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), b);
@@ -1640,8 +1640,8 @@ void tst_QTreeView::expandAndCollapse()
view.collapse(a);
QVERIFY(!view.isExpanded(a));
QVERIFY(!view.isExpanded(b));
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 1);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 1);
args = collapsedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a);
@@ -1653,8 +1653,8 @@ void tst_QTreeView::expandAndCollapse()
QVERIFY(view.isExpanded(a));
QVERIFY(view.isExpanded(b));
QVERIFY(!view.isExpanded(c));
- QCOMPARE(expandedSpy.count(), 2);
- QCOMPARE(collapsedSpy.count(), 0);
+ QCOMPARE(expandedSpy.size(), 2);
+ QCOMPARE(collapsedSpy.size(), 0);
args = expandedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a);
args = expandedSpy.takeFirst();
@@ -1665,8 +1665,8 @@ void tst_QTreeView::expandAndCollapse()
QVERIFY(!view.isExpanded(a));
QVERIFY(!view.isExpanded(b));
QVERIFY(!view.isExpanded(c));
- QCOMPARE(expandedSpy.count(), 0);
- QCOMPARE(collapsedSpy.count(), 2);
+ QCOMPARE(expandedSpy.size(), 0);
+ QCOMPARE(collapsedSpy.size(), 2);
args = collapsedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a);
args = collapsedSpy.takeFirst();
@@ -1728,22 +1728,22 @@ void tst_QTreeView::expandAndCollapseAll()
view.expandAll();
checkExpandState(model, view, QModelIndex(), true, &count);
- QCOMPARE(collapsedSpy.count(), 0);
- QCOMPARE(expandedSpy.count(), 39); // == 3 (first) + 9 (second) + 27 (third level)
+ QCOMPARE(collapsedSpy.size(), 0);
+ QCOMPARE(expandedSpy.size(), 39); // == 3 (first) + 9 (second) + 27 (third level)
QCOMPARE(count, 39);
collapsedSpy.clear();
expandedSpy.clear();
view.collapseAll();
checkExpandState(model, view, QModelIndex(), false, &count);
- QCOMPARE(collapsedSpy.count(), 39);
- QCOMPARE(expandedSpy.count(), 0);
+ QCOMPARE(collapsedSpy.size(), 39);
+ QCOMPARE(expandedSpy.size(), 0);
QCOMPARE(count, 39);
collapsedSpy.clear();
expandedSpy.clear();
view.expandRecursively(model.index(0, 0));
- QCOMPARE(expandedSpy.count(), 13); // 1 + 3 + 9
+ QCOMPARE(expandedSpy.size(), 13); // 1 + 3 + 9
checkExpandState(model, view, model.index(0, 0), true, &count);
QCOMPARE(count, 13);
@@ -1755,9 +1755,9 @@ void tst_QTreeView::expandAndCollapseAll()
expandedSpy.clear();
view.collapseAll();
view.expandRecursively(model.index(0, 0), 1);
- QCOMPARE(expandedSpy.count(), 4); // 1 + 3
+ QCOMPARE(expandedSpy.size(), 4); // 1 + 3
view.expandRecursively(model.index(0, 0), 2);
- QCOMPARE(expandedSpy.count(), 13); // (1 + 3) + 9
+ QCOMPARE(expandedSpy.size(), 13); // (1 + 3) + 9
checkExpandState(model, view, model.index(0, 0), true, &count);
QCOMPARE(count, 13);
@@ -2043,7 +2043,7 @@ void tst_QTreeView::setSelection()
QVERIFY(selectionModel);
const QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
- QCOMPARE(selectedIndexes.count(), expectedItems.count());
+ QCOMPARE(selectedIndexes.size(), expectedItems.size());
for (const QModelIndex &idx : selectedIndexes)
QVERIFY(expectedItems.contains(QPoint(idx.column(), idx.row())));
}
@@ -2147,7 +2147,7 @@ void tst_QTreeView::clicked()
continue;
QSignalSpy spy(&view, &QTreeView::clicked);
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
}
}
@@ -2228,7 +2228,7 @@ void tst_QTreeView::rowsAboutToBeRemoved()
model.removeRows(1,1);
QCOMPARE((view.state()), 0);
// Should not be 5 (or any other number for that sake :)
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
}
@@ -2540,28 +2540,28 @@ void tst_QTreeView::selectionWithHiddenItems()
//child should not be selected as it is hidden (its parent is not expanded)
view.selectAll();
- QCOMPARE(view.selectionModel()->selection().count(), 1); //one range
- QCOMPARE(view.selectionModel()->selectedRows().count(), 4);
+ QCOMPARE(view.selectionModel()->selection().size(), 1); //one range
+ QCOMPARE(view.selectionModel()->selectedRows().size(), 4);
view.expandAll();
QVERIFY(view.isExpanded(item1.index()));
- QCOMPARE(view.selectionModel()->selection().count(), 1);
- QCOMPARE(view.selectionModel()->selectedRows().count(), 4);
+ QCOMPARE(view.selectionModel()->selection().size(), 1);
+ QCOMPARE(view.selectionModel()->selectedRows().size(), 4);
QVERIFY( !view.selectionModel()->isSelected(model.indexFromItem(&child)));
view.clearSelection();
QVERIFY(view.isExpanded(item1.index()));
//child should be selected as it is visible (its parent is expanded)
view.selectAll();
- QCOMPARE(view.selectionModel()->selection().count(), 2);
- QCOMPARE(view.selectionModel()->selectedRows().count(), 5); //everything is selected
+ QCOMPARE(view.selectionModel()->selection().size(), 2);
+ QCOMPARE(view.selectionModel()->selectedRows().size(), 5); //everything is selected
view.clearSelection();
//we hide the node with a child (there should then be 3 items selected in 2 ranges)
view.setRowHidden(1, QModelIndex(), true);
QVERIFY(view.isExpanded(item1.index()));
view.selectAll();
- QCOMPARE(view.selectionModel()->selection().count(), 2);
- QCOMPARE(view.selectionModel()->selectedRows().count(), 3);
+ QCOMPARE(view.selectionModel()->selection().size(), 2);
+ QCOMPARE(view.selectionModel()->selectedRows().size(), 3);
QVERIFY(!view.selectionModel()->isSelected(model.indexFromItem(&item1)));
QVERIFY(!view.selectionModel()->isSelected(model.indexFromItem(&child)));
@@ -2574,8 +2574,8 @@ void tst_QTreeView::selectionWithHiddenItems()
QVERIFY(view.isExpanded(item1.index()));
view.selectAll();
QVERIFY(view.isExpanded(item1.index()));
- QCOMPARE(view.selectionModel()->selection().count(), 3);
- QCOMPARE(view.selectionModel()->selectedRows().count(), 4);
+ QCOMPARE(view.selectionModel()->selection().size(), 3);
+ QCOMPARE(view.selectionModel()->selectedRows().size(), 4);
QVERIFY( !view.selectionModel()->isSelected(model.indexFromItem(&item2)));
view.setRowHidden(2, QModelIndex(), false);
QVERIFY(view.isExpanded(item1.index()));
@@ -2590,21 +2590,21 @@ void tst_QTreeView::selectAll()
view2.setSelectionMode(QAbstractItemView::ExtendedSelection);
view2.selectAll(); // Should work with an empty model
//everything should be selected since we are in ExtendedSelection mode
- QCOMPARE(view2.selectedIndexes().count(), model.rowCount() * model.columnCount());
+ QCOMPARE(view2.selectedIndexes().size(), model.rowCount() * model.columnCount());
for (int i = 0; i < model.rowCount(); ++i)
model.setData(model.index(i,0), QLatin1String("row ") + QString::number(i));
QTreeView view;
view.setModel(&model);
- int selectedCount = view.selectedIndexes().count();
+ int selectedCount = view.selectedIndexes().size();
view.selectAll();
- QCOMPARE(view.selectedIndexes().count(), selectedCount);
+ QCOMPARE(view.selectedIndexes().size(), selectedCount);
QTreeView view3;
view3.setModel(&model);
view3.setSelectionMode(QAbstractItemView::NoSelection);
view3.selectAll();
- QCOMPARE(view3.selectedIndexes().count(), 0);
+ QCOMPARE(view3.selectedIndexes().size(), 0);
}
void tst_QTreeView::extendedSelection_data()
@@ -2630,7 +2630,7 @@ void tst_QTreeView::extendedSelection()
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, mousePressPos);
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), selectedCount);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), selectedCount);
}
void tst_QTreeView::rowSizeHint()
@@ -2870,7 +2870,7 @@ public:
}
void kill()
{
- for (int i = children.count() -1; i >= 0; --i) {
+ for (int i = children.size() -1; i >= 0; --i) {
children.at(i)->kill();
if (parent == nullptr) {
deadChildren.append(children.at(i));
@@ -2912,7 +2912,7 @@ public:
emit layoutAboutToBeChanged();
QModelIndexList oldList = persistentIndexList();
QList<QStack<int>> oldListPath;
- for (int i = 0; i < oldList.count(); ++i) {
+ for (int i = 0; i < oldList.size(); ++i) {
QModelIndex idx = oldList.at(i);
QStack<int> path;
while (idx.isValid()) {
@@ -2924,7 +2924,7 @@ public:
root->kill();
QModelIndexList newList;
- for (auto path : qAsConst(oldListPath)) {
+ for (auto path : std::as_const(oldListPath)) {
QModelIndex idx;
while (!path.isEmpty())
idx = index(path.pop(), 0, idx);
@@ -2943,7 +2943,7 @@ public:
if (parentNode->isDead)
qFatal("%s: parentNode is dead!", Q_FUNC_INFO);
}
- return parentNode->children.count();
+ return parentNode->children.size();
}
int columnCount(const QModelIndex &parent = QModelIndex()) const override
{
@@ -3534,7 +3534,7 @@ void tst_QTreeView::task174627_moveLeftToRoot()
QSignalSpy spy(&view, &task174627_TreeView::signalCurrentChanged);
QTest::keyClick(&view, Qt::Key_Left);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QTreeView::task171902_expandWith1stColHidden()
@@ -4040,7 +4040,7 @@ void tst_QTreeView::task248022_changeSelection()
&view, &TreeView::handleSelectionChanged);
QTest::mouseClick(view.viewport(), Qt::LeftButton, {},
view.visualRect(model.index(1)).center());
- QCOMPARE(view.selectionModel()->selectedIndexes().count(), list.count());
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), list.size());
}
void tst_QTreeView::task245654_changeModelAndExpandAll()
@@ -4089,7 +4089,7 @@ void tst_QTreeView::doubleClickedWithSpans()
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, p);
QTest::mouseDClick(view.viewport(), Qt::LeftButton, {}, p);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, p);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
//let's click on the 2nd column
p.setX(p.x() + view.header()->sectionSize(0));
@@ -4100,7 +4100,7 @@ void tst_QTreeView::doubleClickedWithSpans()
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, p);
QTest::mouseDClick(view.viewport(), Qt::LeftButton, {}, p);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, p);
- QTRY_COMPARE(spy.count(), 2);
+ QTRY_COMPARE(spy.size(), 2);
}
void tst_QTreeView::taskQTBUG_6450_selectAllWith1stColumnHidden()
@@ -5117,7 +5117,7 @@ void tst_QTreeView::fetchUntilScreenFull()
TreeItem* parentItem = parent.isValid() ? static_cast<TreeItem*>(parent.internalPointer())
: m_root;
- return parentItem->children.count();
+ return parentItem->children.size();
}
int columnCount(const QModelIndex&) const override { return 2; }
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index 652d6f76d9..03c36260c1 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -281,8 +281,8 @@ void tst_QTreeWidget::addTopLevelItem()
while (!tops.isEmpty()) {
TreeItem *ti = tops.takeFirst();
delete ti;
- QCOMPARE(tree.topLevelItemCount(), tops.count());
- for (int i = 0; i < tops.count(); ++i)
+ QCOMPARE(tree.topLevelItemCount(), tops.size());
+ for (int i = 0; i < tops.size(); ++i)
QCOMPARE(tree.topLevelItem(i), tops.at(i));
}
@@ -378,12 +378,12 @@ void tst_QTreeWidget::currentItem()
tree.setCurrentItem(item);
QCOMPARE(tree.currentItem(), item);
- QCOMPARE(currentItemChangedSpy.count(), 1);
+ QCOMPARE(currentItemChangedSpy.size(), 1);
QVariantList args = currentItemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(1)), previous);
- QCOMPARE(itemSelectionChangedSpy.count(), 1);
+ QCOMPARE(itemSelectionChangedSpy.size(), 1);
itemSelectionChangedSpy.clear();
previous = item;
@@ -396,15 +396,15 @@ void tst_QTreeWidget::currentItem()
if (!currentItemChangedSpy.isEmpty()) {
// ### we get a currentItemChanged() when what really
// changed was just currentColumn(). Should it be like this?
- QCOMPARE(currentItemChangedSpy.count(), 1);
+ QCOMPARE(currentItemChangedSpy.size(), 1);
QVariantList args = currentItemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(1)), item);
if (tree.selectionBehavior() == QAbstractItemView::SelectItems) {
- QCOMPARE(itemSelectionChangedSpy.count(), 1);
+ QCOMPARE(itemSelectionChangedSpy.size(), 1);
itemSelectionChangedSpy.clear();
} else {
- QCOMPARE(itemSelectionChangedSpy.count(), 0);
+ QCOMPARE(itemSelectionChangedSpy.size(), 0);
}
}
}
@@ -464,7 +464,7 @@ void tst_QTreeWidget::editItem()
QTest::keyClick(editor, Qt::Key_A);
QTest::keyClick(editor, Qt::Key_Enter);
QCoreApplication::processEvents();
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
QVariantList args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem *>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), col);
@@ -620,7 +620,7 @@ void tst_QTreeWidget::setItemHidden2()
{
// From Task 78587
const QStringList hl({"ID", "Desc"});
- testWidget->setColumnCount(hl.count());
+ testWidget->setColumnCount(hl.size());
testWidget->setHeaderLabels(hl);
testWidget->setSortingEnabled(true);
@@ -821,7 +821,7 @@ void tst_QTreeWidget::selectedItems()
// check selectedItems
const auto sel = testWidget->selectedItems();
- QCOMPARE(sel.count(), expectedItems.count());
+ QCOMPARE(sel.size(), expectedItems.size());
for (const auto &itemPath : expectedItems) {
QTreeWidgetItem *item = nullptr;
for (int index : itemPath) {
@@ -857,7 +857,7 @@ void tst_QTreeWidget::selectedItems()
}
item->setSelected(false);
}
- QCOMPARE(testWidget->selectedItems().count(), 0);
+ QCOMPARE(testWidget->selectedItems().size(), 0);
}
void tst_QTreeWidget::itemAssignment()
@@ -1090,9 +1090,9 @@ void tst_QTreeWidget::findItems()
QList<QTreeWidgetItem*> result = testWidget->findItems(pattern,
Qt::MatchExactly|Qt::MatchRecursive);
- QCOMPARE(result.count(), resultCount);
+ QCOMPARE(result.size(), resultCount);
- for (int k = 0; k < result.count() && k < resultText.count(); ++k)
+ for (int k = 0; k < result.size() && k < resultText.size(); ++k)
QCOMPARE(result.at(k)->text(column), resultText.at(k));
}
@@ -1110,7 +1110,7 @@ void tst_QTreeWidget::findItemsInColumn()
// Recursively search column one for 400.
QList<QTreeWidgetItem*> items = testWidget->findItems("400", Qt::MatchExactly|Qt::MatchRecursive, 1);
- QCOMPARE(items.count(), 1);
+ QCOMPARE(items.size(), 1);
}
void tst_QTreeWidget::sortItems_data()
@@ -1177,16 +1177,16 @@ void tst_QTreeWidget::sortItems()
testWidget->sortItems(column, order);
QCOMPARE(testWidget->sortColumn(), column);
- for (int k = 0; k < topLevelResult.count(); ++k) {
+ for (int k = 0; k < topLevelResult.size(); ++k) {
QTreeWidgetItem *item = testWidget->topLevelItem(k);
QCOMPARE(item->text(column), topLevelResult.at(k));
- for (int l = 0; l < childResult.count(); ++l)
+ for (int l = 0; l < childResult.size(); ++l)
QCOMPARE(item->child(l)->text(column), childResult.at(l));
}
- for (int m = 0; m < tops.count(); ++m)
+ for (int m = 0; m < tops.size(); ++m)
QCOMPARE(tops.at(m).row(), expectedTopRows.at(m));
- for (int n = 0; n < children.count(); ++n)
+ for (int n = 0; n < children.size(); ++n)
QCOMPARE(children.at(n).row(), expectedChildRows.at(n));
}
@@ -1346,17 +1346,17 @@ void tst_QTreeWidget::insertTopLevelItems_data()
const QStringList insert{ "baz" };
QTest::newRow("Insert at count") << initial << insert
- << initial.count() << initial.count()
- << initial.count() << initial.count();
+ << initial.size() << initial.size()
+ << initial.size() << initial.size();
QTest::newRow("Insert in the middle") << initial << insert
- << (initial.count() / 2) << (initial.count() / 2)
- << (initial.count() / 2) << (initial.count() / 2);
+ << (initial.size() / 2) << (initial.size() / 2)
+ << (initial.size() / 2) << (initial.size() / 2);
QTest::newRow("Insert less than 0") << initial << insert
<< -1 << -1
<< -1 << -1;
QTest::newRow("Insert beyond count") << initial << insert
- << initial.count() + 1 << -1
- << initial.count() + 1 << -1;
+ << initial.size() + 1 << -1
+ << initial.size() + 1 << -1;
}
void tst_QTreeWidget::insertTopLevelItems()
@@ -1371,26 +1371,26 @@ void tst_QTreeWidget::insertTopLevelItems()
{ // insert the initial items
QCOMPARE(testWidget->topLevelItemCount(), 0);
- for (int i = 0; i < initialText.count(); ++i) {
+ for (int i = 0; i < initialText.size(); ++i) {
QTreeWidgetItem *top = new QTreeWidgetItem(QStringList(initialText.at(i)));
testWidget->addTopLevelItem(top);
QCOMPARE(testWidget->indexOfTopLevelItem(top), i);
}
- QCOMPARE(testWidget->topLevelItemCount(), initialText.count());
+ QCOMPARE(testWidget->topLevelItemCount(), initialText.size());
}
{ // test adding children
QTreeWidgetItem *topLevel = testWidget->topLevelItem(0);
- for (int i = 0; i < initialText.count(); ++i)
+ for (int i = 0; i < initialText.size(); ++i)
topLevel->addChild(new QTreeWidgetItem(QStringList(initialText.at(i))));
- QCOMPARE(topLevel->childCount(), initialText.count());
+ QCOMPARE(topLevel->childCount(), initialText.size());
}
{ // test adding more top level items
QTreeWidgetItem *topsy = new QTreeWidgetItem(QStringList(insertText.at(0)));
testWidget->insertTopLevelItem(insertTopLevelIndex, topsy);
if (expectedTopLevelIndex == -1) {
- QCOMPARE(testWidget->topLevelItemCount(), initialText.count());
+ QCOMPARE(testWidget->topLevelItemCount(), initialText.size());
delete topsy;
} else {
QTreeWidgetItem *item = testWidget->topLevelItem(expectedTopLevelIndex);
@@ -1406,7 +1406,7 @@ void tst_QTreeWidget::insertTopLevelItems()
QTreeWidgetItem *child = new QTreeWidgetItem(QStringList(insertText.at(0)));
topLevel->insertChild(insertChildIndex, child);
if (expectedChildIndex == -1) {
- QCOMPARE(topLevel->childCount(), initialText.count());
+ QCOMPARE(topLevel->childCount(), initialText.size());
delete child;
} else {
QTreeWidgetItem *item = topLevel->child(expectedChildIndex);
@@ -1592,7 +1592,7 @@ void tst_QTreeWidget::scrollToItem()
void tst_QTreeWidget::setSortingEnabled()
{
const QStringList hl{ "ID" };
- testWidget->setColumnCount(hl.count());
+ testWidget->setColumnCount(hl.size());
testWidget->setHeaderLabels(hl);
QTreeWidgetItem *item1 = new QTreeWidgetItem(testWidget);
@@ -1661,7 +1661,7 @@ void tst_QTreeWidget::addChild()
QList<QTreeWidgetItem*> taken = item->takeChildren();
QCOMPARE(taken, children);
QCOMPARE(item->childCount(), 0);
- for (int i = 0; i < taken.count(); ++i) {
+ for (int i = 0; i < taken.size(); ++i) {
QCOMPARE(taken.at(i)->parent(), nullptr);
QCOMPARE(taken.at(i)->treeWidget(), nullptr);
item->addChild(taken.at(i)); // re-add
@@ -1671,8 +1671,8 @@ void tst_QTreeWidget::addChild()
while (!children.isEmpty()) {
QTreeWidgetItem *ti = children.takeFirst();
delete ti;
- QCOMPARE(item->childCount(), children.count());
- for (int i = 0; i < children.count(); ++i)
+ QCOMPARE(item->childCount(), children.size());
+ for (int i = 0; i < children.size(); ++i)
QCOMPARE(item->child(i), children.at(i));
}
@@ -1719,9 +1719,9 @@ void tst_QTreeWidget::setData()
QSignalSpy itemChangedSpy(
testWidget, &QTreeWidget::itemChanged);
headerItem->setText(0, "test");
- QCOMPARE(dataChangedSpy.count(), 0);
- QCOMPARE(headerDataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 0); // no itemChanged() signal for header item
+ QCOMPARE(dataChangedSpy.size(), 0);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 0); // no itemChanged() signal for header item
headerItem->setData(-1, -1, QVariant());
}
@@ -1739,24 +1739,24 @@ void tst_QTreeWidget::setData()
const QString text = QLatin1String("text ") + iS;
item->setText(j, text);
QCOMPARE(item->text(j), text);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setText(j, text);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
QPixmap pixmap(32, 32);
pixmap.fill((i == 1) ? Qt::red : Qt::green);
QIcon icon(pixmap);
item->setIcon(j, icon);
QCOMPARE(item->icon(j), icon);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setIcon(j, icon);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
@@ -1764,94 +1764,94 @@ void tst_QTreeWidget::setData()
const QString toolTip = QLatin1String("toolTip ") + iS;
item->setToolTip(j, toolTip);
QCOMPARE(item->toolTip(j), toolTip);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setToolTip(j, toolTip);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
const QString statusTip = QLatin1String("statusTip ") + iS;
item->setStatusTip(j, statusTip);
QCOMPARE(item->statusTip(j), statusTip);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setStatusTip(j, statusTip);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
const QString whatsThis = QLatin1String("whatsThis ") + iS;
item->setWhatsThis(j, whatsThis);
QCOMPARE(item->whatsThis(j), whatsThis);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setWhatsThis(j, whatsThis);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
QSize sizeHint(64*i, 48*i);
item->setSizeHint(j, sizeHint);
QCOMPARE(item->sizeHint(j), sizeHint);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setSizeHint(j, sizeHint);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
QFont font;
item->setFont(j, font);
QCOMPARE(item->font(j), font);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setFont(j, font);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
Qt::Alignment textAlignment((i == 1)
? Qt::AlignLeft|Qt::AlignVCenter
: Qt::AlignRight);
item->setTextAlignment(j, textAlignment);
QCOMPARE(item->textAlignment(j), int(textAlignment));
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setTextAlignment(j, textAlignment);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
QColor backgroundColor((i == 1) ? Qt::blue : Qt::yellow);
item->setBackground(j, backgroundColor);
QCOMPARE(item->background(j).color(), backgroundColor);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setBackground(j, backgroundColor);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
const QColor foregroundColor((i == 1) ? Qt::green : Qt::cyan);
item->setForeground(j, foregroundColor);
QCOMPARE(item->foreground(j), foregroundColor);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setForeground(j, foregroundColor);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked);
item->setCheckState(j, checkState);
QCOMPARE(item->checkState(j), checkState);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = itemChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setCheckState(j, checkState);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
QCOMPARE(item->text(j), text);
QCOMPARE(item->icon(j), icon);
@@ -1884,7 +1884,7 @@ void tst_QTreeWidget::setData()
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setBackground(j, pixmap);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
item->setData(j, Qt::DisplayRole, QVariant());
item->setData(j, Qt::DecorationRole, QVariant());
@@ -1897,7 +1897,7 @@ void tst_QTreeWidget::setData()
item->setData(j, Qt::BackgroundRole, QVariant());
item->setData(j, Qt::ForegroundRole, QVariant());
item->setData(j, Qt::CheckStateRole, QVariant());
- QCOMPARE(itemChangedSpy.count(), 11);
+ QCOMPARE(itemChangedSpy.size(), 11);
itemChangedSpy.clear();
QCOMPARE(item->data(j, Qt::DisplayRole).toString(), QString());
@@ -1960,11 +1960,11 @@ void tst_QTreeWidget::itemData()
QCOMPARE(widget.currentRoles, QList<int> { Qt::UserRole + i });
}
QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0));
- QCOMPARE(flags.count(), 6);
+ QCOMPARE(flags.size(), 6);
for (int i = 0; i < 4; ++i)
QCOMPARE(flags[Qt::UserRole + i].toString(), QString::number(i + 1));
flags = widget.model()->itemData(widget.model()->index(0, 1));
- QCOMPARE(flags.count(), 0);
+ QCOMPARE(flags.size(), 0);
item.setBackground(0, QBrush(Qt::red));
item.setForeground(0, QBrush(Qt::green));
@@ -2033,7 +2033,7 @@ void tst_QTreeWidget::setHeaderLabels()
{
QStringList list = QString("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z").split(QLatin1Char(','));
testWidget->setHeaderLabels(list);
- QCOMPARE(testWidget->header()->count(), list.count());
+ QCOMPARE(testWidget->header()->count(), list.size());
}
void tst_QTreeWidget::setHeaderItem()
@@ -2263,11 +2263,11 @@ void tst_QTreeWidget::insertItemsWithSorting()
w.addTopLevelItem(new QTreeWidgetItem({ txt }));
break;
}
- QCOMPARE(w.topLevelItemCount(), expectedItems.count());
+ QCOMPARE(w.topLevelItemCount(), expectedItems.size());
for (int i = 0; i < w.topLevelItemCount(); ++i)
QCOMPARE(w.topLevelItem(i)->text(0), expectedItems.at(i));
- for (int k = 0; k < persistent.count(); ++k)
+ for (int k = 0; k < persistent.size(); ++k)
QCOMPARE(persistent.at(k).row(), expectedRows.at(k));
}
}
@@ -2308,13 +2308,13 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting()
QTreeWidgetItem *child = new QTreeWidgetItem(parent, {text});
items << child;
}
- QCOMPARE(parent->childCount(), childTexts.count());
+ QCOMPARE(parent->childCount(), childTexts.size());
QVERIFY(parent->isExpanded());
}
- QCOMPARE(tree.model()->rowCount(), parentTexts.count());
+ QCOMPARE(tree.model()->rowCount(), parentTexts.size());
// verify that the items are still expanded
- for (const QTreeWidgetItem *item : qAsConst(items)) {
+ for (const QTreeWidgetItem *item : std::as_const(items)) {
if (item->childCount() > 0)
QVERIFY(item->isExpanded());
QModelIndex idx = tree.indexFromItem(item);
@@ -2332,10 +2332,10 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting()
PersistentModelIndexVec children;
for (int i = 0; i < model->rowCount(parents.constFirst()); ++i)
children.push_back(model->index(i, 0, parents.constFirst()));
- for (int i = 0; i < parentResult.count(); ++i) {
+ for (int i = 0; i < parentResult.size(); ++i) {
QTreeWidgetItem *item = tree.topLevelItem(i);
QCOMPARE(item->text(0), parentResult.at(i));
- for (int j = 0; j < childResult.count(); ++j)
+ for (int j = 0; j < childResult.size(); ++j)
QCOMPARE(item->child(j)->text(0), childResult.at(j));
}
}
@@ -2427,19 +2427,19 @@ void tst_QTreeWidget::changeDataWithSorting()
QTreeWidgetItem *item = w.topLevelItem(itemIndex);
item->setText(0, newValue);
- for (int i = 0; i < expectedItems.count(); ++i) {
+ for (int i = 0; i < expectedItems.size(); ++i) {
QCOMPARE(w.topLevelItem(i)->text(0), expectedItems.at(i));
- for (const QPersistentModelIndex &p : qAsConst(persistent)) {
+ for (const QPersistentModelIndex &p : std::as_const(persistent)) {
if (p.row() == i) // the same toplevel row
QCOMPARE(p.internalPointer(), static_cast<void *>(w.topLevelItem(i)));
}
}
- for (int k = 0; k < persistent.count(); ++k)
+ for (int k = 0; k < persistent.size(); ++k)
QCOMPARE(persistent.at(k).row(), expectedRows.at(k));
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0);
}
void tst_QTreeWidget::changeDataWithStableSorting_data()
@@ -2596,19 +2596,19 @@ void tst_QTreeWidget::changeDataWithStableSorting()
item->setText(0, newValue);
if (forceChange)
item->emitDataChanged();
- for (int i = 0; i < expectedItems.count(); ++i) {
+ for (int i = 0; i < expectedItems.size(); ++i) {
QCOMPARE(w.topLevelItem(i)->text(0), expectedItems.at(i));
- for (const QPersistentModelIndex &p : qAsConst(persistent)) {
+ for (const QPersistentModelIndex &p : std::as_const(persistent)) {
if (p.row() == i) // the same toplevel row
QCOMPARE(p.internalPointer(), static_cast<void *>(w.topLevelItem(i)));
}
}
- for (int k = 0; k < persistent.count(); ++k)
+ for (int k = 0; k < persistent.size(); ++k)
QCOMPARE(persistent.at(k).row(), expectedRows.at(k));
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0);
}
void tst_QTreeWidget::sizeHint_data()
@@ -2714,8 +2714,8 @@ void tst_QTreeWidget::sortedIndexOfChild()
tw.sortItems(0, sortOrder);
tw.expandAll();
- QCOMPARE(itms.count(), expectedIndexes.count());
- for (int j = 0; j < expectedIndexes.count(); ++j)
+ QCOMPARE(itms.size(), expectedIndexes.size());
+ for (int j = 0; j < expectedIndexes.size(); ++j)
QCOMPARE(top->indexOfChild(itms.at(j)), expectedIndexes.at(j));
}
@@ -2740,8 +2740,8 @@ void tst_QTreeWidget::expandAndCallapse()
tw.collapseItem(top);
tw.collapseItem(top);
- QCOMPARE(spy0.count(), 3);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy0.size(), 3);
+ QCOMPARE(spy1.size(), 2);
}
void tst_QTreeWidget::setDisabled()
@@ -2854,13 +2854,13 @@ void tst_QTreeWidget::removeSelectedItem()
QItemSelectionModel *selModel = w->selectionModel();
QCOMPARE(selModel->hasSelection(), true);
- QCOMPARE(selModel->selectedRows().count(), 1);
+ QCOMPARE(selModel->selectedRows().size(), 1);
const QScopedPointer<QTreeWidgetItem> taken(w->takeTopLevelItem(2));
QCOMPARE(taken->text(0), QLatin1String("C"));
QCOMPARE(selModel->hasSelection(), false);
- QCOMPARE(selModel->selectedRows().count(), 0);
+ QCOMPARE(selModel->selectedRows().size(), 0);
QItemSelection sel = selModel->selection();
QCOMPARE(selModel->isSelected(w->model()->index(0,0)), false);
}
@@ -2971,7 +2971,7 @@ protected:
auto newItem = new QTreeWidgetItem({QString::number(i++)});
m_list.append(newItem);
insertTopLevelItem(0, newItem);
- while (m_list.count() > 10)
+ while (m_list.size() > 10)
delete m_list.takeFirst();
}
QTreeWidget::timerEvent(event);
@@ -3285,7 +3285,7 @@ void tst_QTreeWidget::emitDataChanged()
auto item = new PublicTreeItem;
tree.insertTopLevelItem(0, item);
item->emitDataChanged();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QTreeWidget::setCurrentItemExpandsParent()
diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
index 7c1ce7c426..76ebb499f9 100644
--- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
@@ -866,7 +866,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags()
QTreeWidgetItemIterator it(testWidget, iteratorflags);
it += start;
int iMatch = 0;
- while (*it && iMatch < matches.count()) {
+ while (*it && iMatch < matches.size()) {
QTreeWidgetItem *item = *it;
QCOMPARE(item->text(0), matches[iMatch]);
++it;
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 49123c33d5..2ceef58fac 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -153,11 +153,11 @@ void tst_QAction::alternateShortcuts()
act.setAutoRepeat(true);
QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
- QCOMPARE(spy.count(), 1); //act should have been triggered
+ QCOMPARE(spy.size(), 1); //act should have been triggered
act.setAutoRepeat(false);
QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
- QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time
+ QCOMPARE(spy.size(), 2); //act should have been triggered a 2nd time
//end of the scope of the action, it will be destroyed and removed from wid
//This action should also unregister its shortcuts
@@ -187,12 +187,12 @@ void tst_QAction::keysequence()
act.setAutoRepeat(true);
QTest::keySequence(&testWidget, ks);
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 1); // act should have been triggered
+ QCOMPARE(spy.size(), 1); // act should have been triggered
act.setAutoRepeat(false);
QTest::keySequence(&testWidget, ks);
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time
+ QCOMPARE(spy.size(), 2); //act should have been triggered a 2nd time
// end of the scope of the action, it will be destroyed and removed from widget
// This action should also unregister its shortcuts
@@ -228,15 +228,15 @@ void tst_QAction::enabledVisibleInteraction()
act.setEnabled(true);
act.setVisible(false);
QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
- QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger
+ QCOMPARE(spy.size(), 0); //act is not visible, so don't trigger
act.setVisible(false);
act.setEnabled(true);
QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
- QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger
+ QCOMPARE(spy.size(), 0); //act is not visible, so don't trigger
act.setVisible(true);
act.setEnabled(true);
QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
- QCOMPARE(spy.count(), 1); //act is visible and enabled, so trigger
+ QCOMPARE(spy.size(), 1); //act is visible and enabled, so trigger
}
#endif // QT_CONFIG(shortcut)
@@ -254,12 +254,12 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup()
QSignalSpy actionSpy(checkedAction, QOverload<bool>::of(&QAction::triggered));
QSignalSpy actionGroupSpy(&ag, QOverload<QAction*>::of(&QActionGroup::triggered));
- QCOMPARE(actionGroupSpy.count(), 0);
- QCOMPARE(actionSpy.count(), 0);
+ QCOMPARE(actionGroupSpy.size(), 0);
+ QCOMPARE(actionSpy.size(), 0);
checkedAction->trigger();
// check that both the group and the action have emitted the signal
- QCOMPARE(actionGroupSpy.count(), 1);
- QCOMPARE(actionSpy.count(), 1);
+ QCOMPARE(actionGroupSpy.size(), 1);
+ QCOMPARE(actionSpy.size(), 1);
}
#if QT_CONFIG(shortcut)
@@ -282,7 +282,7 @@ void tst_QAction::repeat()
act.setAutoRepeat(true);
QTest::keyPress(&testWidget, Qt::Key_F);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QTest::keyPress(&testWidget, Qt::Key_F);
@@ -290,7 +290,7 @@ void tst_QAction::repeat()
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
spy.clear();
act.setAutoRepeat(false);
@@ -298,14 +298,14 @@ void tst_QAction::repeat()
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
act.setAutoRepeat(true);
QTest::keyPress(&testWidget, Qt::Key_F);
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QAction::disableShortcutsWithBlockedWidgets_data()
@@ -355,7 +355,7 @@ void tst_QAction::disableShortcutsWithBlockedWidgets()
QSignalSpy spy(&action, &QAction::triggered);
QTest::keyPress(&window, Qt::Key_1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
class ShortcutOverrideWidget : public QWidget
@@ -393,7 +393,7 @@ void tst_QAction::shortcutFromKeyEvent()
// shortcut route for us
QKeyEvent e(QEvent::KeyPress, Qt::Key_1, Qt::NoModifier);
QApplication::sendEvent(&testWidget, &e);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(testWidget.shortcutOverrideCount, 1);
}
@@ -412,6 +412,9 @@ void tst_QAction::disableShortcutInMenuAction_data()
void tst_QAction::disableShortcutInMenuAction()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QFETCH(QByteArray, property);
QMainWindow mw;
@@ -429,42 +432,42 @@ void tst_QAction::disableShortcutInMenuAction()
QKeyEvent event(QEvent::KeyPress, Qt::Key_A, Qt::ControlModifier);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
testMenu->menuAction()->setProperty(property, false);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), expectedTriggerCount);
+ QCOMPARE(spy.size(), expectedTriggerCount);
testMenu->menuAction()->setProperty(property, true);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
// If the action lives somewhere else, then keep firing even
// if the menu has been hidden or disabled.
toolBar->addAction(testAction);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
testMenu->menuAction()->setProperty(property, false);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
// unless all other widgets in which the action lives have
// been hidden...
toolBar->hide();
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), expectedTriggerCount);
+ QCOMPARE(spy.size(), expectedTriggerCount);
// ... or disabled
toolBar->show();
toolBar->setEnabled(false);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), expectedTriggerCount);
+ QCOMPARE(spy.size(), expectedTriggerCount);
// back to normal
toolBar->setEnabled(true);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
}
#endif // QT_CONFIG(shortcut)
diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST
index 364a2abe4f..7f4dd88261 100644
--- a/tests/auto/widgets/kernel/qapplication/BLACKLIST
+++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST
@@ -1,6 +1,7 @@
[sendEventsOnProcessEvents]
ubuntu-20.04
ubuntu-22.04
+rhel-9.0
[touchEventPropagation]
# QTBUG-66745
opensuse-leap
diff --git a/tests/auto/widgets/kernel/qapplication/CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/CMakeLists.txt
index 3bb7e31691..ab87a66a8b 100644
--- a/tests/auto/widgets/kernel/qapplication/CMakeLists.txt
+++ b/tests/auto/widgets/kernel/qapplication/CMakeLists.txt
@@ -3,3 +3,8 @@
add_subdirectory(desktopsettingsaware)
add_subdirectory(modal)
add_subdirectory(test)
+
+add_dependencies(tst_qapplication
+ desktopsettingsaware_helper
+ modal_helper
+)
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 3db9953471..6d563b446b 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -128,6 +128,7 @@ private slots:
void wheelEventPropagation();
void qtbug_12673();
+ void qtbug_103611();
void noQuitOnHide();
void globalStaticObjectDestruction(); // run this last
@@ -485,7 +486,7 @@ static char **QString2cstrings(const QString &args)
static QByteArrayList cache;
const auto &list = QStringView{ args }.split(' ');
- auto argarray = new char*[list.count() + 1];
+ auto argarray = new char*[list.size() + 1];
int i = 0;
for (; i < list.size(); ++i ) {
@@ -574,7 +575,7 @@ void tst_QApplication::lastWindowClosed()
QTimer::singleShot(1000, dialog.data(), &QDialog::accept);
dialog->exec();
QVERIFY(dialog);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QPointer<CloseWidget>widget = new CloseWidget;
widget->setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("CloseWidget"));
@@ -583,7 +584,7 @@ void tst_QApplication::lastWindowClosed()
QObject::connect(&app, &QGuiApplication::lastWindowClosed, widget.data(), &QObject::deleteLater);
QCoreApplication::exec();
QVERIFY(!widget);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
delete dialog;
@@ -601,7 +602,7 @@ void tst_QApplication::lastWindowClosed()
QTimer::singleShot(1000, &app, &QApplication::closeAllWindows);
QCoreApplication::exec();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
class QuitOnLastWindowClosedDialog : public QDialog
@@ -634,8 +635,8 @@ public slots:
other.exec();
// verify that the eventloop ran and let the timer fire
- QCOMPARE(spy.count(), 1);
- QCOMPARE(appSpy.count(), 1);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(appSpy.size(), 1);
}
private:
@@ -660,7 +661,7 @@ public slots:
timer1.setSingleShot(true);
timer1.start(1000);
dialog.exec();
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
show();
}
@@ -681,7 +682,7 @@ void tst_QApplication::quitOnLastWindowClosed()
QCoreApplication::exec();
// lastWindowClosed() signal should only be sent after the last dialog is closed
- QCOMPARE(appSpy.count(), 2);
+ QCOMPARE(appSpy.size(), 2);
}
{
int argc = 0;
@@ -696,8 +697,8 @@ void tst_QApplication::quitOnLastWindowClosed()
timer1.setSingleShot(true);
timer1.start(1000);
dialog.exec();
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(appSpy.count(), 0);
+ QCOMPARE(spy1.size(), 1);
+ QCOMPARE(appSpy.size(), 0);
QTimer timer2;
connect(&timer2, &QTimer::timeout, &app, &QCoreApplication::quit);
@@ -706,8 +707,8 @@ void tst_QApplication::quitOnLastWindowClosed()
timer2.start(1000);
int returnValue = QCoreApplication::exec();
QCOMPARE(returnValue, 0);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(appSpy.count(), 0);
+ QCOMPARE(spy2.size(), 1);
+ QCOMPARE(appSpy.size(), 0);
}
{
int argc = 0;
@@ -738,8 +739,8 @@ void tst_QApplication::quitOnLastWindowClosed()
QCoreApplication::exec();
- QCOMPARE(spy.count(), 1);
- QVERIFY(spy2.count() < 15); // Should be around 10 if closing caused the quit
+ QCOMPARE(spy.size(), 1);
+ QVERIFY(spy2.size() < 15); // Should be around 10 if closing caused the quit
}
bool quitApplicationTriggered = false;
@@ -769,7 +770,7 @@ void tst_QApplication::quitOnLastWindowClosed()
QCoreApplication::exec();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(quitApplicationTriggered);
}
{
@@ -791,8 +792,8 @@ void tst_QApplication::quitOnLastWindowClosed()
QCOMPARE(returnValue, 0);
// failure here means the timer above didn't fire, and the
// quit was caused the dialog being closed (not the window)
- QCOMPARE(timerSpy.count(), 1);
- QCOMPARE(appSpy.count(), 2);
+ QCOMPARE(timerSpy.size(), 1);
+ QCOMPARE(appSpy.size(), 2);
}
{
int argc = 0;
@@ -841,7 +842,7 @@ void tst_QApplication::quitOnLastWindowClosed()
QTimer::singleShot(100, &w1, &QWidget::close);
QCoreApplication::exec();
- QVERIFY(timerSpy.count() < 10);
+ QVERIFY(timerSpy.size() < 10);
}
}
@@ -893,7 +894,7 @@ void tst_QApplication::closeAllWindows()
// show all windows
auto topLevels = QApplication::topLevelWidgets();
- for (QWidget *w : qAsConst(topLevels)) {
+ for (QWidget *w : std::as_const(topLevels)) {
w->show();
QVERIFY(QTest::qWaitForWindowExposed(w));
}
@@ -910,14 +911,14 @@ void tst_QApplication::closeAllWindows()
PromptOnCloseWidget *promptOnCloseWidget = new PromptOnCloseWidget;
// show all windows
topLevels = QApplication::topLevelWidgets();
- for (QWidget *w : qAsConst(topLevels)) {
+ for (QWidget *w : std::as_const(topLevels)) {
w->show();
QVERIFY(QTest::qWaitForWindowExposed(w));
}
// close the last window to open the prompt (eventloop recurses)
promptOnCloseWidget->close();
// all windows should not be visible, except the one that opened the prompt
- for (QWidget *w : qAsConst(topLevels)) {
+ for (QWidget *w : std::as_const(topLevels)) {
if (w == promptOnCloseWidget)
QVERIFY(w->isVisible());
else
@@ -929,8 +930,8 @@ void tst_QApplication::closeAllWindows()
bool isPathListIncluded(const QStringList &l, const QStringList &r)
{
- int size = r.count();
- if (size > l.count())
+ int size = r.size();
+ if (size > l.size())
return false;
#if defined (Q_OS_WIN)
Qt::CaseSensitivity cs = Qt::CaseInsensitive;
@@ -938,13 +939,13 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r)
Qt::CaseSensitivity cs = Qt::CaseSensitive;
#endif
int i = 0, j = 0;
- for ( ; i < l.count() && j < r.count(); ++i) {
+ for ( ; i < l.size() && j < r.size(); ++i) {
if (QDir::toNativeSeparators(l[i]).compare(QDir::toNativeSeparators(r[j]), cs) == 0) {
++j;
i = -1;
}
}
- return j == r.count();
+ return j == r.size();
}
#if QT_CONFIG(library)
@@ -1004,7 +1005,7 @@ void tst_QApplication::libraryPaths()
{
qCDebug(lcTests) << "Initial library path:" << QApplication::libraryPaths();
- int count = QApplication::libraryPaths().count();
+ int count = QApplication::libraryPaths().size();
#if 0
// this test doesn't work if KDE 4 is installed
QCOMPARE(count, 1); // before creating QApplication, only the PluginsPath is in the libraryPaths()
@@ -1013,9 +1014,9 @@ void tst_QApplication::libraryPaths()
QApplication::addLibraryPath(installPathPlugins);
qCDebug(lcTests) << "installPathPlugins" << installPathPlugins;
qCDebug(lcTests) << "After adding plugins path:" << QApplication::libraryPaths();
- QCOMPARE(QApplication::libraryPaths().count(), count);
+ QCOMPARE(QApplication::libraryPaths().size(), count);
QApplication::addLibraryPath(testDir);
- QCOMPARE(QApplication::libraryPaths().count(), count + 1);
+ QCOMPARE(QApplication::libraryPaths().size(), count + 1);
// creating QApplication adds the applicationDirPath to the libraryPath
int argc = 1;
@@ -1025,19 +1026,19 @@ void tst_QApplication::libraryPaths()
// On Windows CE these are identical and might also be the case for other
// systems too
if (appDirPath != installPathPlugins)
- QCOMPARE(QApplication::libraryPaths().count(), count + 2);
+ QCOMPARE(QApplication::libraryPaths().size(), count + 2);
}
{
int argc = 1;
QApplication app(argc, &argv0);
qCDebug(lcTests) << "Initial library path:" << QCoreApplication::libraryPaths();
- int count = QCoreApplication::libraryPaths().count();
+ int count = QCoreApplication::libraryPaths().size();
QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
QCoreApplication::addLibraryPath(installPathPlugins);
qCDebug(lcTests) << "installPathPlugins" << installPathPlugins;
qCDebug(lcTests) << "After adding plugins path:" << QCoreApplication::libraryPaths();
- QCOMPARE(QCoreApplication::libraryPaths().count(), count);
+ QCOMPARE(QCoreApplication::libraryPaths().size(), count);
QString appDirPath = QCoreApplication::applicationDirPath();
@@ -1045,14 +1046,14 @@ void tst_QApplication::libraryPaths()
QCoreApplication::addLibraryPath(appDirPath + "/..");
qCDebug(lcTests) << "appDirPath" << appDirPath;
qCDebug(lcTests) << "After adding appDirPath && appDirPath + /..:" << QCoreApplication::libraryPaths();
- QCOMPARE(QCoreApplication::libraryPaths().count(), count + 1);
+ QCOMPARE(QCoreApplication::libraryPaths().size(), count + 1);
#ifdef Q_OS_MACOS
QCoreApplication::addLibraryPath(appDirPath + "/../MacOS");
#else
QCoreApplication::addLibraryPath(appDirPath + "/tmp/..");
#endif
qCDebug(lcTests) << "After adding appDirPath + /tmp/..:" << QCoreApplication::libraryPaths();
- QCOMPARE(QCoreApplication::libraryPaths().count(), count + 1);
+ QCOMPARE(QCoreApplication::libraryPaths().size(), count + 1);
}
}
@@ -1152,7 +1153,7 @@ void SendPostedEventsTester::doTest()
eventLoop.exec();
QVERIFY(p != nullptr);
- QCOMPARE(eventSpy.count(), 2);
+ QCOMPARE(eventSpy.size(), 2);
QCOMPARE(eventSpy.at(0), int(QEvent::MetaCall));
QCOMPARE(eventSpy.at(1), int(QEvent::User));
eventSpy.clear();
@@ -1577,6 +1578,9 @@ void tst_QApplication::activateDeactivateEvent()
int argc = 0;
QApplication app(argc, nullptr);
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
Window w1;
Window w2;
@@ -1652,22 +1656,22 @@ void tst_QApplication::focusChanged()
hbox1.addWidget(&le1);
hbox1.addWidget(&pb1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
parent1.show();
QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse)
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).count(), 2);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.at(0).size(), 2);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &le1);
QCOMPARE(now, QApplication::focusWidget());
QVERIFY(!old);
spy.clear();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
pb1.setFocus();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &pb1);
@@ -1676,7 +1680,7 @@ void tst_QApplication::focusChanged()
spy.clear();
lb1.setFocus();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &lb1);
@@ -1685,7 +1689,7 @@ void tst_QApplication::focusChanged()
spy.clear();
lb1.clearFocus();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QVERIFY(!now);
@@ -1705,9 +1709,9 @@ void tst_QApplication::focusChanged()
parent2.show();
QApplication::setActiveWindow(&parent2); // needs this on twm (focus follows mouse)
- QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows
- old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0));
- now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1));
+ QVERIFY(spy.size() > 0); // one for deactivation, one for activation on Windows
+ old = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(0));
+ now = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(1));
QCOMPARE(now, &le2);
QCOMPARE(now, QApplication::focusWidget());
QVERIFY(!old);
@@ -1732,10 +1736,10 @@ void tst_QApplication::focusChanged()
tab.simulate(now);
if (!tabAllControls) {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(now, QApplication::focusWidget());
} else {
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &pb2);
@@ -1745,11 +1749,11 @@ void tst_QApplication::focusChanged()
}
if (!tabAllControls) {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(now, QApplication::focusWidget());
} else {
tab.simulate(now);
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &le2);
@@ -1759,11 +1763,11 @@ void tst_QApplication::focusChanged()
}
if (!tabAllControls) {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(now, QApplication::focusWidget());
} else {
backtab.simulate(now);
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &pb2);
@@ -1774,12 +1778,12 @@ void tst_QApplication::focusChanged()
if (!tabAllControls) {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(now, QApplication::focusWidget());
old = &pb2;
} else {
backtab.simulate(now);
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &le2);
@@ -1790,10 +1794,10 @@ void tst_QApplication::focusChanged()
click.simulate(old);
if (!(pb2.focusPolicy() & Qt::ClickFocus)) {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(now, QApplication::focusWidget());
} else {
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &pb2);
@@ -1802,7 +1806,7 @@ void tst_QApplication::focusChanged()
spy.clear();
click.simulate(old);
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
QCOMPARE(now, &le2);
@@ -1813,15 +1817,15 @@ void tst_QApplication::focusChanged()
parent1.activateWindow();
QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse)
- QVERIFY(spy.count() == 1 || spy.count() == 2); // one for deactivation, one for activation on Windows
+ QVERIFY(spy.size() == 1 || spy.size() == 2); // one for deactivation, one for activation on Windows
//on windows, the change of focus is made in 2 steps
//(the focusChanged SIGNAL is emitted twice)
- if (spy.count()==1)
- old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0));
+ if (spy.size()==1)
+ old = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(0));
else
- old = qvariant_cast<QWidget*>(spy.at(spy.count()-2).at(0));
- now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1));
+ old = qvariant_cast<QWidget*>(spy.at(spy.size()-2).at(0));
+ now = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(1));
QCOMPARE(now, &le1);
QCOMPARE(now, QApplication::focusWidget());
QCOMPARE(old, &le2);
@@ -2056,11 +2060,11 @@ void tst_QApplication::topLevelWidgets()
#endif
QCoreApplication::processEvents();
QVERIFY(QApplication::topLevelWidgets().contains(w));
- QCOMPARE(QApplication::topLevelWidgets().count(), 1);
+ QCOMPARE(QApplication::topLevelWidgets().size(), 1);
delete w;
w = nullptr;
QCoreApplication::processEvents();
- QCOMPARE(QApplication::topLevelWidgets().count(), 0);
+ QCOMPARE(QApplication::topLevelWidgets().size(), 0);
}
@@ -2477,7 +2481,7 @@ void tst_QApplication::wheelEventPropagation()
int vcount = 0;
int hcount = 0;
- for (const auto &event : qAsConst(events)) {
+ for (const auto &event : std::as_const(events)) {
const QPoint pixelDelta = event.orientation == Qt::Vertical ? QPoint(0, -scrollStep) : QPoint(-scrollStep, 0);
const QPoint angleDelta = event.orientation == Qt::Vertical ? QPoint(0, -120) : QPoint(-120, 0);
QWindowSystemInterface::handleWheelEvent(outerArea.windowHandle(), center, global,
@@ -2488,10 +2492,10 @@ void tst_QApplication::wheelEventPropagation()
else
++hcount;
QCoreApplication::processEvents();
- QCOMPARE(innerVSpy.count(), innerScrolls ? vcount : 0);
- QCOMPARE(innerHSpy.count(), innerScrolls ? hcount : 0);
- QCOMPARE(outerVSpy.count(), innerScrolls ? 0 : vcount);
- QCOMPARE(outerHSpy.count(), innerScrolls ? 0 : hcount);
+ QCOMPARE(innerVSpy.size(), innerScrolls ? vcount : 0);
+ QCOMPARE(innerHSpy.size(), innerScrolls ? hcount : 0);
+ QCOMPARE(outerVSpy.size(), innerScrolls ? 0 : vcount);
+ QCOMPARE(outerHSpy.size(), innerScrolls ? 0 : hcount);
}
}
@@ -2510,6 +2514,20 @@ void tst_QApplication::qtbug_12673()
#endif
}
+void tst_QApplication::qtbug_103611()
+{
+ {
+ int argc = 0;
+ QApplication app(argc, nullptr);
+ auto ll = QLocale().uiLanguages();
+ }
+ {
+ int argc = 0;
+ QApplication app(argc, nullptr);
+ auto ll = QLocale().uiLanguages();
+ }
+}
+
class NoQuitOnHideWidget : public QWidget
{
Q_OBJECT
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 3a7f33228b..febb517638 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -517,14 +517,14 @@ void tst_QBoxLayout::testLayoutEngine()
QHBoxLayout box;
box.setSpacing(spacing);
int i;
- for (i = 0; i < itemDescriptions.count(); ++i) {
+ for (i = 0; i < itemDescriptions.size(); ++i) {
Descr descr = itemDescriptions.at(i);
LayoutItem *li = new LayoutItem(descr);
box.addItem(li);
box.setStretch(i, descr.stretch);
}
box.setGeometry(QRect(0,0,size,100));
- for (i = 0; i < expectedSizes.count(); ++i) {
+ for (i = 0; i < expectedSizes.size(); ++i) {
int xSize = expectedSizes.at(i);
int xPos = expectedPositions.at(i);
QLayoutItem *item = box.itemAt(i);
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 33e6bd64db..44b716bb34 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -112,6 +112,7 @@ private slots:
void setLayout();
void hideShowRow();
void showWithHiddenRow();
+ void hiddenRowAndStretch();
/*
QLayoutItem *itemAt(int row, ItemRole role) const;
@@ -1253,6 +1254,49 @@ void tst_QFormLayout::showWithHiddenRow()
topLevel.show();
}
+/*
+ Test that hiding rows does not leave outdated layout data behind
+ in hidden items that results in out-of-bounds array access. See
+ QTBUG-109237.
+*/
+void tst_QFormLayout::hiddenRowAndStretch()
+{
+ QWidget topLevel;
+ QFormLayout layout;
+ layout.setRowWrapPolicy(QFormLayout::WrapAllRows);
+
+ // We need our own stretcher item so that QFormLayout doesn't insert
+ // it's own, as that would grow the size of the layout data array again.
+ QSpacerItem *stretch = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
+ layout.setItem(0, QFormLayout::FieldRole, stretch);
+
+ QLabel *lastLabel = nullptr;
+ QLineEdit *lastField = nullptr;
+ for (int row = 1; row < 4; ++row) {
+ QLabel *label = new QLabel(QString("Label %1").arg(row));
+ label->setWordWrap(true);
+ QLineEdit *field = new QLineEdit;
+ layout.setWidget(row, QFormLayout::LabelRole, label);
+ layout.setWidget(row, QFormLayout::FieldRole, field);
+ if (row == 3) {
+ lastLabel = label;
+ lastField = field;
+ }
+ }
+
+ Q_ASSERT(lastLabel);
+ Q_ASSERT(lastField);
+
+ topLevel.setLayout(&layout);
+ topLevel.sizeHint();
+
+ lastLabel->setVisible(false);
+ lastField->setVisible(false);
+
+ // should not assert here
+ topLevel.show();
+}
+
void tst_QFormLayout::itemAt()
{
QWidget topLevel;
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index fda88fcd83..3871079da7 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -210,6 +210,9 @@ void tst_QGridLayout::badDistributionBug()
void tst_QGridLayout::setMinAndMaxSize()
{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("This test crashes on Wayland, see also QTBUG-107184");
+
QWidget widget;
setFrameless(&widget);
QGridLayout layout(&widget);
@@ -658,7 +661,7 @@ void tst_QGridLayout::spacingsAndMargins()
QSKIP("The screen is too small to run this test case");
// We are relying on the order here...
- for (int pi = 0; pi < sizehinters.count(); ++pi) {
+ for (int pi = 0; pi < sizehinters.size(); ++pi) {
QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0));
QCOMPARE(pt, expectedpositions.at(pi));
}
@@ -828,7 +831,7 @@ void tst_QGridLayout::minMaxSize()
QList<QPointer<SizeHinterFrame> > sizehinters;
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < columns; ++j) {
- SizeInfo si = sizeinfos.at(sizehinters.count());
+ SizeInfo si = sizeinfos.at(sizehinters.size());
int numpixels = si.hfwNumPixels;
if (pass == 1 && numpixels == -1)
numpixels = -2; //### yuk, (and don't fake it if it already tests sizehint)
@@ -857,7 +860,7 @@ void tst_QGridLayout::minMaxSize()
QTRY_COMPARE(toplevel.size(), toplevel.sizeHint());
}
// We are relying on the order here...
- for (int pi = 0; pi < sizehinters.count(); ++pi) {
+ for (int pi = 0; pi < sizehinters.size(); ++pi) {
QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0));
QCOMPARE(pt, sizeinfos.at(pi).expectedPos);
}
@@ -1027,7 +1030,7 @@ void tst_QGridLayout::styleDependentSpacingsAndMargins()
widget.adjustSize();
QApplication::processEvents();
- for (int pi = 0; pi < expectedpositions.count(); ++pi) {
+ for (int pi = 0; pi < expectedpositions.size(); ++pi) {
QCOMPARE(sizehinters.at(pi)->pos(), expectedpositions.at(pi));
}
}
@@ -1417,7 +1420,7 @@ void tst_QGridLayout::layoutSpacing()
QLayout *layout = widget->layout();
QVERIFY(layout);
- for (int pi = 0; pi < expectedpositions.count(); ++pi) {
+ for (int pi = 0; pi < expectedpositions.size(); ++pi) {
QLayoutItem *item = layout->itemAt(pi);
//qDebug() << item->widget()->pos();
QCOMPARE(item->widget()->pos(), expectedpositions.at(pi));
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 2beecc7112..17f007e8f8 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -313,11 +313,11 @@ void tst_QShortcut::number_data()
Shift + Qt::Key_Plus on Shift + Qt::Key_Pluss
Qt::Key_Plus on Shift + Qt::Key_Pluss
*/
- QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_M).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_M).toCombined() << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_Plus) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Plus).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Plus).toCombined() << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -335,8 +335,8 @@ void tst_QShortcut::number_data()
Qt::Key_F1 on Shift + Qt::Key_F1
*/
- QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_F1).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_F1).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -352,7 +352,7 @@ void tst_QShortcut::number_data()
//QTest::newRow("N005a:Shift+Tab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
// (Shift+)BackTab != Tab, but Shift+BackTab == Shift+Tab
QTest::newRow("N005a:Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Backtab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N005a - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -361,11 +361,11 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Shift + Qt::Key_Tab
Shift + Qt::Key_Backtab on Shift + Qt::Key_Tab
*/
- QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Tab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N005b:Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Tab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N005b:BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Backtab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N005b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -378,10 +378,10 @@ void tst_QShortcut::number_data()
QTest::newRow("N006a:Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
// This should work, since platform dependent code will transform the
// Shift+Tab into a Shift+BackTab, which should trigger the shortcut
- QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
+ QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Tab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
QTest::newRow("N006a:BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
//commented out because the behaviour changed, those tests should be updated
- //QTest::newRow("N006a:Shift+BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ //QTest::newRow("N006a:Shift+BackTab - [BackTab]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Backtab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N006a - clear") << ClearAll << NoWidget<< QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -390,11 +390,11 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Shift + Qt::Key_Backtab
Shift + Qt::Key_Backtab on Shift + Qt::Key_Backtab
*/
- QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Backtab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N006b:Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Tab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N006b:BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
+ QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Backtab).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
QTest::newRow("N006b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
//===========================================
@@ -407,9 +407,9 @@ void tst_QShortcut::number_data()
Shift + Qt::Key_F1
*/
QTest::newRow("N007 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_F1).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_F1).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -419,13 +419,13 @@ void tst_QShortcut::number_data()
Alt + Qt::Key_M
*/
QTest::newRow("N01 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::CTRL | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::ALT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_M).toCombined() << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString() << QKeyCombination(Qt::CTRL, Qt::Key_M).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString() << QKeyCombination(Qt::ALT, Qt::Key_M).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_M).toCombined() << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::CTRL, Qt::Key_M).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::ALT, Qt::Key_M).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
/* Testing Single Sequence Ambiguity
Qt::Key_M on shortcut2
@@ -440,11 +440,11 @@ void tst_QShortcut::number_data()
Qt::Key_K
*/
QTest::newRow("N06 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Aring).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Aring).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N:Qt::Qt::Key_K") << TestAccel << NoWidget << QString() << int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
@@ -457,11 +457,11 @@ void tst_QShortcut::number_data()
*/
QTest::newRow("N10 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N11 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_I).toCombined() << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_I).toCombined() << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
}
@@ -503,10 +503,10 @@ void tst_QShortcut::text_data()
Ctrl + Qt::Key_Plus on Ctrl + Qt::Key_Pluss
*/
QTest::newRow("T002 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_M).toCombined() << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T002 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Plus).toCombined() << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -518,7 +518,7 @@ void tst_QShortcut::text_data()
QTest::newRow("T002b - slot1") << SetupAccel << TriggerSlot1 << QString("Ctrl++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
//QTest::newRow("T002b:Shift+Ctrl++ [Ctrl++]")<< TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::CTRL | Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::CTRL, Qt::Key_Plus).toCombined() << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T002b:+ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T002b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -537,7 +537,7 @@ void tst_QShortcut::text_data()
Qt::Key_F1 on Shift + Qt::Key_F1
*/
QTest::newRow("T004 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_F1).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -553,7 +553,7 @@ void tst_QShortcut::text_data()
QTest::newRow("T007 - slot1") << SetupAccel << TriggerSlot1 << QString("F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T007 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_F1).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -568,9 +568,9 @@ void tst_QShortcut::text_data()
QTest::newRow("T04 - slot2") << SetupAccel << TriggerSlot2 << QString("Alt+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_M).toCombined() << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::CTRL, Qt::Key_M).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::ALT, Qt::Key_M).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
/* Testing Single Sequence Ambiguity
Qt::Key_M on shortcut2
@@ -589,7 +589,7 @@ void tst_QShortcut::text_data()
QTest::newRow("T07 - slot2") << SetupAccel << TriggerSlot2 << QString::fromLatin1("Shift+\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T08 - slot2") << SetupAccel << TriggerSlot1 << QString("K") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_Aring).toCombined() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T:Qt::Key_K") << TestAccel << NoWidget << QString() << int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
@@ -605,7 +605,7 @@ void tst_QShortcut::text_data()
QTest::newRow("T12 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+I, M")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << QKeyCombination(Qt::SHIFT, Qt::Key_I).toCombined() << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
}
@@ -1350,10 +1350,10 @@ void tst_QShortcut::keys()
QCOMPARE(QApplication::focusWidget(), &le);
QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Enter);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Return);
- QTRY_COMPARE(spy.count(), 2);
+ QTRY_COMPARE(spy.size(), 2);
}
QTEST_MAIN(tst_QShortcut)
diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
index 06e97e69b6..15651d44b3 100644
--- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
@@ -107,7 +107,7 @@ void tst_QStackedLayout::testCase()
// One widget added to layout
QWidget *w1 = new QWidget(testWidget);
testLayout->addWidget(w1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), 0);
spy.clear();
QCOMPARE(testLayout->currentIndex(), 0);
@@ -124,7 +124,7 @@ void tst_QStackedLayout::testCase()
// Change the current index
testLayout->setCurrentIndex(1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), 1);
spy.clear();
QCOMPARE(testLayout->currentIndex(), 1);
@@ -138,7 +138,7 @@ void tst_QStackedLayout::testCase()
// Second widget removed from layout; back to nothing
testLayout->removeWidget(w2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), -1);
spy.clear();
QCOMPARE(testLayout->currentIndex(), -1);
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 24387635b4..7bd4c0a304 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -3,11 +3,6 @@
ubuntu-16.04
[restoreVersion1Geometry]
ubuntu-16.04
-[focusProxyAndInputMethods]
-rhel-7.6
-centos
-opensuse-leap
-ubuntu
[raise]
opensuse-leap
# QTBUG-68175
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index b43494ab54..febea8d821 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -166,6 +166,7 @@ private slots:
void reverseTabOrder();
void tabOrderWithProxy();
void tabOrderWithProxyDisabled();
+ void tabOrderWithProxyOutOfOrder();
void tabOrderWithCompoundWidgets();
void tabOrderWithCompoundWidgetsNoFocusPolicy();
void tabOrderNoChange();
@@ -345,6 +346,7 @@ private slots:
void enterLeaveOnWindowShowHide_data();
void enterLeaveOnWindowShowHide();
void taskQTBUG_4055_sendSyntheticEnterLeave();
+ void hoverPosition();
void underMouse();
void taskQTBUG_27643_enterEvents();
#endif
@@ -368,7 +370,6 @@ private slots:
void openModal_taskQTBUG_5804();
void focusProxy();
- void focusProxyAndInputMethods();
void imEnabledNotImplemented();
#ifdef QT_BUILD_INTERNAL
@@ -436,6 +437,7 @@ private:
const bool m_windowsAnimationsEnabled;
QPointingDevice *m_touchScreen;
const int m_fuzz;
+ QPalette simplePalette();
};
// Testing get/set functions
@@ -1899,8 +1901,11 @@ public:
setObjectName(name);
lineEdit1 = new QLineEdit;
+ lineEdit1->setObjectName(name + "/lineEdit1");
lineEdit2 = new QLineEdit;
+ lineEdit2->setObjectName(name + "/lineEdit2");
lineEdit3 = new QLineEdit;
+ lineEdit3->setObjectName(name + "/lineEdit3");
lineEdit3->setEnabled(false);
QHBoxLayout* hbox = new QHBoxLayout(this);
@@ -2146,6 +2151,24 @@ void tst_QWidget::tabOrderWithProxyDisabled()
qPrintable(QApplication::focusWidget()->objectName()));
}
+//#define DEBUG_FOCUS_CHAIN
+static void dumpFocusChain(QWidget *start, bool bForward, const char *desc = nullptr)
+{
+#ifdef DEBUG_FOCUS_CHAIN
+ qDebug() << "Dump focus chain, start:" << start << "isForward:" << bForward << desc;
+ QWidget *cur = start;
+ do {
+ qDebug() << "-" << cur;
+ auto widgetPrivate = static_cast<QWidgetPrivate *>(qt_widget_private(cur));
+ cur = bForward ? widgetPrivate->focus_next : widgetPrivate->focus_prev;
+ } while (cur != start);
+#else
+ Q_UNUSED(start);
+ Q_UNUSED(bForward);
+ Q_UNUSED(desc);
+#endif
+}
+
void tst_QWidget::tabOrderWithCompoundWidgets()
{
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
@@ -2249,22 +2272,65 @@ static QList<QWidget *> getFocusChain(QWidget *start, bool bForward)
return ret;
}
-//#define DEBUG_FOCUS_CHAIN
-static void dumpFocusChain(QWidget *start, bool bForward, const char *desc = nullptr)
+void tst_QWidget::tabOrderWithProxyOutOfOrder()
{
-#ifdef DEBUG_FOCUS_CHAIN
- qDebug() << "Dump focus chain, start:" << start << "isForward:" << bForward << desc;
- QWidget *cur = start;
- do {
- qDebug() << cur;
- auto widgetPrivate = static_cast<QWidgetPrivate *>(qt_widget_private(cur));
- cur = bForward ? widgetPrivate->focus_next : widgetPrivate->focus_prev;
- } while (cur != start);
-#else
- Q_UNUSED(start);
- Q_UNUSED(bForward);
- Q_UNUSED(desc);
-#endif
+ Container container;
+ container.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+
+ // important to create the widgets with parent so that they are
+ // added to the focus chain already now, and with the buttonBox
+ // before the outsideButton.
+ QWidget buttonBox(&container);
+ buttonBox.setObjectName("buttonBox");
+ QPushButton outsideButton(&container);
+ outsideButton.setObjectName("outsideButton");
+
+ container.box->addWidget(&outsideButton);
+ container.box->addWidget(&buttonBox);
+ QCOMPARE(getFocusChain(&container, true),
+ QList<QWidget*>({&container, &buttonBox, &outsideButton}));
+
+ // this now adds okButon and cancelButton to the focus chain,
+ // after the outsideButton - so the outsideButton is in between
+ // the buttonBox and the children of the buttonBox!
+ QPushButton okButton(&buttonBox);
+ okButton.setObjectName("okButton");
+ QPushButton cancelButton(&buttonBox);
+ cancelButton.setObjectName("cancelButton");
+ QCOMPARE(getFocusChain(&container, true),
+ QList<QWidget*>({&container, &buttonBox, &outsideButton, &okButton, &cancelButton}));
+
+ // by setting the okButton as the focusProxy, the outsideButton becomes
+ // unreachable when navigating the focus chain as the buttonBox is in front
+ // of, and proxies to the okButton behind the outsideButton. setFocusProxy
+ // must fix that by moving the buttonBox in front of the first sibling of
+ // the proxy.
+ buttonBox.setFocusProxy(&okButton);
+ QCOMPARE(getFocusChain(&container, true),
+ QList<QWidget*>({&container, &outsideButton, &buttonBox, &okButton, &cancelButton}));
+
+ container.show();
+ container.activateWindow();
+ QApplication::setActiveWindow(&container);
+ if (!QTest::qWaitForWindowActive(&container))
+ QSKIP("Window failed to activate, skipping test");
+
+ QCOMPARE(QApplication::focusWidget(), &outsideButton);
+ container.tab();
+ QCOMPARE(QApplication::focusWidget(), &okButton);
+ container.tab();
+ QCOMPARE(QApplication::focusWidget(), &cancelButton);
+ container.tab();
+ QCOMPARE(QApplication::focusWidget(), &outsideButton);
+
+ container.backTab();
+ QCOMPARE(QApplication::focusWidget(), &cancelButton);
+ container.backTab();
+ QCOMPARE(QApplication::focusWidget(), &okButton);
+ container.backTab();
+ QCOMPARE(QApplication::focusWidget(), &outsideButton);
+ container.backTab();
+ QCOMPARE(QApplication::focusWidget(), &cancelButton);
}
void tst_QWidget::tabOrderWithCompoundWidgetsNoFocusPolicy()
@@ -2716,7 +2782,7 @@ void tst_QWidget::resizePropagation()
{
// Capture count of latest async signals
if (!checkCountIncrement)
- count = spy.count();
+ count = spy.size();
// Resize if required
if (size.isValid())
@@ -2727,12 +2793,12 @@ void tst_QWidget::resizePropagation()
// Check signal count and qDebug output for fail analysis
if (checkCountIncrement) {
- QTRY_VERIFY(spy.count() > count);
- qDebug() << "spy count:" << spy.count() << "previous count:" << count;
- count = spy.count();
+ QTRY_VERIFY(spy.size() > count);
+ qDebug() << "spy count:" << spy.size() << "previous count:" << count;
+ count = spy.size();
} else {
qDebug() << spy << widget.windowState() << window->windowState();
- QCOMPARE(spy.count(), count);
+ QCOMPARE(spy.size(), count);
}
// QTRY necessary because state changes are propagated async
@@ -3231,7 +3297,7 @@ void tst_QWidget::reparent()
void tst_QWidget::setScreen()
{
const auto screens = QApplication::screens();
- if (screens.count() < 2)
+ if (screens.size() < 2)
QSKIP("This test tests nothing on a machine with a single screen.");
QScreen *screen0 = screens.at(0);
@@ -3625,9 +3691,9 @@ void tst_QWidget::raise()
QObjectList list1{child1, child2, child3, child4};
QCOMPARE(parentPtr->children(), list1);
- QCOMPARE(allChildren.count(), list1.count());
+ QCOMPARE(allChildren.size(), list1.size());
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = child == child4 ? 1 : 0;
if (expectedPaintEvents == 0) {
QCOMPARE(child->numPaintEvents, 0);
@@ -3641,9 +3707,10 @@ void tst_QWidget::raise()
for (int i = 0; i < 5; ++i)
child2->raise();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowExposed(child2));
+ QApplication::processEvents(); // process events that could be triggered by raise();
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = child == child2 ? 1 : 0;
int expectedZOrderChangeEvents = child == child2 ? 1 : 0;
QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents);
@@ -3670,15 +3737,17 @@ void tst_QWidget::raise()
onTop->show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QTRY_VERIFY(onTop->numPaintEvents > 0);
+ QApplication::processEvents(); // process remaining paint events if there's more than one
onTop->reset();
// Reset all the children.
- for (UpdateWidget *child : qAsConst(allChildren))
+ for (UpdateWidget *child : std::as_const(allChildren))
child->reset();
for (int i = 0; i < 5; ++i)
child3->raise();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowExposed(child3));
+ QApplication::processEvents(); // process events that could be triggered by raise();
QCOMPARE(onTop->numPaintEvents, 0);
QCOMPARE(onTop->numZOrderChangeEvents, 0);
@@ -3686,7 +3755,7 @@ void tst_QWidget::raise()
QObjectList list3{child1, child4, child2, child3};
QCOMPARE(parent->children(), list3);
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = 0;
int expectedZOrderChangeEvents = child == child3 ? 1 : 0;
QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents);
@@ -3724,9 +3793,9 @@ void tst_QWidget::lower()
QObjectList list1{child1, child2, child3, child4};
QCOMPARE(parent->children(), list1);
- QCOMPARE(allChildren.count(), list1.count());
+ QCOMPARE(allChildren.size(), list1.size());
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = child == child4 ? 1 : 0;
if (expectedPaintEvents == 0) {
QCOMPARE(child->numPaintEvents, 0);
@@ -3743,7 +3812,7 @@ void tst_QWidget::lower()
QTest::qWait(100);
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = child == child3 ? 1 : 0;
int expectedZOrderChangeEvents = child == child4 ? 1 : 0;
QTRY_COMPARE(child->numZOrderChangeEvents, expectedZOrderChangeEvents);
@@ -3789,7 +3858,7 @@ void tst_QWidget::stackUnder()
QObjectList list1{child1, child2, child3, child4};
QCOMPARE(parent->children(), list1);
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = child == child4 ? 1 : 0;
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
if (expectedPaintEvents == 1 && child->numPaintEvents == 2)
@@ -3807,7 +3876,7 @@ void tst_QWidget::stackUnder()
QObjectList list2{child1, child4, child2, child3};
QCOMPARE(parent->children(), list2);
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedPaintEvents = child == child3 ? 1 : 0;
int expectedZOrderChangeEvents = child == child4 ? 1 : 0;
QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents);
@@ -3822,7 +3891,7 @@ void tst_QWidget::stackUnder()
QObjectList list3{child4, child2, child1, child3};
QCOMPARE(parent->children(), list3);
- for (UpdateWidget *child : qAsConst(allChildren)) {
+ for (UpdateWidget *child : std::as_const(allChildren)) {
int expectedZOrderChangeEvents = child == child1 ? 1 : 0;
if (child == child3) {
#ifndef Q_OS_MACOS
@@ -3944,6 +4013,13 @@ void tst_QWidget::saveRestoreGeometry()
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
+
+ /* ---------------------------------------------------------------------
+ * This test function is likely to flake when debugged with Qt Creator.
+ * (29px offset making the following QTRY_VERIFY2 fail)
+ * ---------------------------------------------------------------------
+ */
+
QTRY_VERIFY2(HighDpi::fuzzyCompare(widget.pos(), position, m_fuzz),
qPrintable(HighDpi::msgPointMismatch(widget.pos(), position)));
QCOMPARE(widget.size(), size);
@@ -4421,22 +4497,20 @@ class StaticWidget : public QWidget
Q_OBJECT
public:
bool partial = false;
- bool gotPaintEvent = false;
QRegion paintedRegion;
- explicit StaticWidget(QWidget *parent = nullptr) : QWidget(parent)
+ explicit StaticWidget(const QPalette &palette, QWidget *parent = nullptr) : QWidget(parent)
{
setAttribute(Qt::WA_StaticContents);
setAttribute(Qt::WA_OpaquePaintEvent);
- setPalette(Qt::red); // Make sure we have an opaque palette.
+ setPalette(palette);
setAutoFillBackground(true);
}
void paintEvent(QPaintEvent *e) override
{
paintedRegion += e->region();
- gotPaintEvent = true;
-// qDebug() << "paint" << e->region();
+ ++paintEvents;
// Look for a full update, set partial to false if found.
for (QRect r : e->region()) {
partial = (r != rect());
@@ -4444,6 +4518,28 @@ public:
break;
}
}
+
+ // Wait timeout ms until at least one paint event has been consumed
+ // and the counter is no longer increasing.
+ // => making sure to consume multiple paint events relating to one operation
+ // before returning true.
+ bool waitForPaintEvent(int timeout = 100)
+ {
+ QDeadlineTimer deadline(timeout);
+ int count = -1;
+ while (!deadline.hasExpired() && count != paintEvents) {
+ count = paintEvents;
+ QCoreApplication::processEvents();
+ if (count == paintEvents && count > 0) {
+ paintEvents = 0;
+ return true;
+ }
+ }
+ paintEvents = 0;
+ return false;
+ }
+private:
+ int paintEvents = 0;
};
/*
@@ -4452,99 +4548,84 @@ public:
*/
void tst_QWidget::optimizedResizeMove()
{
- if (m_platform == QStringLiteral("wayland"))
- QSKIP("Wayland: This fails. Figure out why.");
+ const bool wayland = QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive);
+
QWidget parent;
- parent.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+ parent.setPalette(simplePalette());
+ parent.setWindowTitle(QTest::currentTestFunction());
parent.resize(400, 400);
- StaticWidget staticWidget(&parent);
- staticWidget.gotPaintEvent = false;
+ StaticWidget staticWidget(simplePalette(), &parent);
staticWidget.move(150, 150);
staticWidget.resize(150, 150);
parent.show();
QVERIFY(QTest::qWaitForWindowExposed(&parent));
- QTRY_VERIFY(staticWidget.gotPaintEvent);
+ QVERIFY(staticWidget.waitForPaintEvent());
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(10, 10));
- QTest::qWait(20);
- QCOMPARE(staticWidget.gotPaintEvent, false);
+ if (!wayland) {
+ QVERIFY(!staticWidget.waitForPaintEvent());
+ } else {
+ if (staticWidget.waitForPaintEvent())
+ QSKIP("Wayland is not optimising paint events. Skipping test.");
+ }
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(-10, -10));
- QTest::qWait(20);
- QCOMPARE(staticWidget.gotPaintEvent, false);
+ QVERIFY(!staticWidget.waitForPaintEvent());
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(-10, 10));
- QTest::qWait(20);
- QCOMPARE(staticWidget.gotPaintEvent, false);
+ QVERIFY(!staticWidget.waitForPaintEvent());
- staticWidget.gotPaintEvent = false;
staticWidget.resize(staticWidget.size() + QSize(10, 10));
- QTRY_VERIFY(staticWidget.gotPaintEvent);
+ QVERIFY(staticWidget.waitForPaintEvent());
QCOMPARE(staticWidget.partial, true);
- staticWidget.gotPaintEvent = false;
staticWidget.resize(staticWidget.size() + QSize(-10, -10));
- QTest::qWait(20);
- QCOMPARE(staticWidget.gotPaintEvent, false);
+ QVERIFY(!staticWidget.waitForPaintEvent());
- staticWidget.gotPaintEvent = false;
staticWidget.resize(staticWidget.size() + QSize(10, -10));
- QTRY_VERIFY(staticWidget.gotPaintEvent);
+ QVERIFY(staticWidget.waitForPaintEvent());
QCOMPARE(staticWidget.partial, true);
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(10, 10));
staticWidget.resize(staticWidget.size() + QSize(-10, -10));
- QTest::qWait(20);
- QCOMPARE(staticWidget.gotPaintEvent, false);
+ QVERIFY(!staticWidget.waitForPaintEvent());
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(10, 10));
staticWidget.resize(staticWidget.size() + QSize(10, 10));
- QTRY_VERIFY(staticWidget.gotPaintEvent);
+ QVERIFY(staticWidget.waitForPaintEvent());
QCOMPARE(staticWidget.partial, true);
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(-10, -10));
staticWidget.resize(staticWidget.size() + QSize(-10, -10));
- QTest::qWait(20);
- QCOMPARE(staticWidget.gotPaintEvent, false);
+ QVERIFY(!staticWidget.waitForPaintEvent());
staticWidget.setAttribute(Qt::WA_StaticContents, false);
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(-10, -10));
staticWidget.resize(staticWidget.size() + QSize(-10, -10));
- QTRY_VERIFY(staticWidget.gotPaintEvent);
+ QVERIFY(staticWidget.waitForPaintEvent());
QCOMPARE(staticWidget.partial, false);
staticWidget.setAttribute(Qt::WA_StaticContents, true);
staticWidget.setAttribute(Qt::WA_StaticContents, false);
- staticWidget.gotPaintEvent = false;
staticWidget.move(staticWidget.pos() + QPoint(10, 10));
- QTest::qWait(20);
- QCOMPARE(staticWidget.gotPaintEvent, false);
+ QVERIFY(!staticWidget.waitForPaintEvent());
staticWidget.setAttribute(Qt::WA_StaticContents, true);
}
void tst_QWidget::optimizedResize_topLevel()
{
- if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
- QSKIP("Wayland: This fails. Figure out why.");
+ const bool wayland = QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive);
if (QHighDpiScaling::isActive())
QSKIP("Skip due to rounding errors in the regions.");
- StaticWidget topLevel;
+ StaticWidget topLevel(simplePalette());
+ topLevel.setPalette(simplePalette());
topLevel.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- topLevel.gotPaintEvent = false;
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
- QTRY_VERIFY(topLevel.gotPaintEvent);
+ QVERIFY(topLevel.waitForPaintEvent());
- topLevel.gotPaintEvent = false;
topLevel.partial = false;
topLevel.paintedRegion = QRegion();
@@ -4569,10 +4650,15 @@ void tst_QWidget::optimizedResize_topLevel()
QRegion expectedUpdateRegion(topLevel.rect());
expectedUpdateRegion -= QRect(QPoint(), topLevel.size() - QSize(10, 10));
- QTRY_VERIFY(topLevel.gotPaintEvent);
+ QVERIFY(topLevel.waitForPaintEvent());
if (m_platform == QStringLiteral("xcb") || m_platform == QStringLiteral("offscreen"))
QSKIP("QTBUG-26424");
- QCOMPARE(topLevel.partial, true);
+ if (!wayland) {
+ QCOMPARE(topLevel.partial, true);
+ } else {
+ if (!topLevel.partial)
+ QSKIP("Wayland does repaint partially. Skipping test.");
+ }
QCOMPARE(topLevel.paintedRegion, expectedUpdateRegion);
}
@@ -4742,7 +4828,7 @@ protected:
}
public:
QList<WId> m_winIdList;
- int winIdChangeEventCount() const { return m_winIdList.count(); }
+ int winIdChangeEventCount() const { return m_winIdList.size(); }
};
class CreateDestroyWidget : public WinIdChangeWidget
@@ -5149,6 +5235,7 @@ void tst_QWidget::update()
Q_CHECK_PAINTEVENTS
UpdateWidget w;
+ w.setPalette(simplePalette());
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
w.resize(100, 100);
centerOnScreen(&w);
@@ -5162,6 +5249,7 @@ void tst_QWidget::update()
w.reset();
UpdateWidget child(&w);
+ child.setPalette(simplePalette());
child.setGeometry(10, 10, 80, 80);
child.show();
@@ -5233,6 +5321,7 @@ void tst_QWidget::update()
// overlapping sibling
UpdateWidget sibling(&w);
+ sibling.setPalette(simplePalette());
child.setGeometry(10, 10, 20, 20);
sibling.setGeometry(15, 15, 20, 20);
sibling.show();
@@ -5312,9 +5401,11 @@ void tst_QWidget::isOpaque()
{
#ifndef Q_OS_MACOS
QWidget w;
+ w.setPalette(simplePalette());
QVERIFY(::isOpaque(&w));
QWidget child(&w);
+ child.setPalette(simplePalette());
QVERIFY(!::isOpaque(&child));
child.setAutoFillBackground(true);
@@ -5396,6 +5487,7 @@ void tst_QWidget::scroll()
const int h = qMin(500, screen->availableGeometry().height() / 2);
UpdateWidget updateWidget;
+ updateWidget.setPalette(simplePalette());
updateWidget.resize(w, h);
updateWidget.reset();
updateWidget.move(m_availableTopLeft);
@@ -5588,7 +5680,7 @@ void tst_QWidget::setWindowGeometry_data()
const Qt::WindowFlags windowFlags[] = {Qt::WindowFlags(), Qt::FramelessWindowHint};
const bool skipEmptyRects = (m_platform == QStringLiteral("windows"));
- for (Rects l : qAsConst(rects)) {
+ for (Rects l : std::as_const(rects)) {
if (skipEmptyRects)
l.removeIf([] (const QRect &r) { return r.isEmpty(); });
const QRect &rect = l.constFirst();
@@ -5607,8 +5699,8 @@ void tst_QWidget::setWindowGeometry_data()
void tst_QWidget::setWindowGeometry()
{
- if (m_platform == QStringLiteral("xcb"))
- QSKIP("X11: Skip this test due to Window manager positioning issues.");
+ if (m_platform == QStringLiteral("xcb") || m_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("X11/Wayland: Skip this test due to Window manager positioning issues.");
QFETCH(Rects, rects);
QFETCH(int, windowFlags);
@@ -5625,7 +5717,7 @@ void tst_QWidget::setWindowGeometry()
QCOMPARE(widget.geometry(), rect);
// setGeometry() without showing
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.setGeometry(r);
QTest::qWait(100);
QCOMPARE(widget.geometry(), r);
@@ -5651,7 +5743,7 @@ void tst_QWidget::setWindowGeometry()
QTRY_COMPARE(widget.geometry(), rect);
// setGeometry() while shown
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.setGeometry(r);
QTest::qWait(10);
QTRY_COMPARE(widget.geometry(), r);
@@ -5666,7 +5758,7 @@ void tst_QWidget::setWindowGeometry()
QTRY_COMPARE(widget.geometry(), rect);
// setGeometry() after hide()
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.setGeometry(r);
QTest::qWait(10);
QTRY_COMPARE(widget.geometry(), r);
@@ -5702,7 +5794,7 @@ void tst_QWidget::setWindowGeometry()
QTRY_COMPARE(widget.geometry(), rect);
// setGeometry() while shown
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.setGeometry(r);
QTest::qWait(10);
QTRY_COMPARE(widget.geometry(), r);
@@ -5717,7 +5809,7 @@ void tst_QWidget::setWindowGeometry()
QTRY_COMPARE(widget.geometry(), rect);
// setGeometry() after hide()
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.setGeometry(r);
QTest::qWait(10);
QTRY_COMPARE(widget.geometry(), r);
@@ -5796,7 +5888,7 @@ void tst_QWidget::windowMoveResize()
QTRY_COMPARE(widget.size(), rect.size());
// move() without showing
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.move(r.topLeft());
widget.resize(r.size());
QApplication::processEvents();
@@ -5826,7 +5918,7 @@ void tst_QWidget::windowMoveResize()
QTRY_COMPARE(widget.size(), rect.size());
// move() while shown
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
// XCB: First resize after show of zero-sized gets wrong win_gravity.
const bool expectMoveFail = !windowFlags
&& ((widget.width() == 0 || widget.height() == 0) && r.width() != 0 && r.height() != 0)
@@ -5855,7 +5947,7 @@ void tst_QWidget::windowMoveResize()
QTRY_COMPARE(widget.size(), rect.size());
// move() after hide()
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.move(r.topLeft());
widget.resize(r.size());
QApplication::processEvents();
@@ -5906,7 +5998,7 @@ void tst_QWidget::windowMoveResize()
QTRY_COMPARE(widget.size(), rect.size());
// move() while shown
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.move(r.topLeft());
widget.resize(r.size());
QApplication::processEvents();
@@ -5926,7 +6018,7 @@ void tst_QWidget::windowMoveResize()
QTRY_COMPARE(widget.size(), rect.size());
// move() after hide()
- for (const QRect &r : qAsConst(rects)) {
+ for (const QRect &r : std::as_const(rects)) {
widget.move(r.topLeft());
widget.resize(r.size());
QApplication::processEvents();
@@ -6812,7 +6904,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation()
QWidgetList widgets;
widgets << &topLevelWidget << &topLevelChild
<< &dialog << &dialogChild;
- QCOMPARE(widgets.count(), 4);
+ QCOMPARE(widgets.size(), 4);
topLevelWidget.show();
dialog.show();
@@ -6826,13 +6918,13 @@ void tst_QWidget::testWindowIconChangeEventPropagation()
// Create spy lists.
QList <EventSpyPtr> applicationEventSpies;
QList <EventSpyPtr> widgetEventSpies;
- for (QWidget *widget : qAsConst(widgets)) {
+ for (QWidget *widget : std::as_const(widgets)) {
applicationEventSpies.append(EventSpyPtr::create(widget, QEvent::ApplicationWindowIconChange));
widgetEventSpies.append(EventSpyPtr::create(widget, QEvent::WindowIconChange));
}
QList <WindowEventSpyPtr> appWindowEventSpies;
QList <WindowEventSpyPtr> windowEventSpies;
- for (QWindow *window : qAsConst(windows)) {
+ for (QWindow *window : std::as_const(windows)) {
appWindowEventSpies.append(WindowEventSpyPtr::create(window, QEvent::ApplicationWindowIconChange));
windowEventSpies.append(WindowEventSpyPtr::create(window, QEvent::WindowIconChange));
}
@@ -6841,7 +6933,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation()
const QIcon windowIcon = qApp->style()->standardIcon(QStyle::SP_TitleBarMenuButton);
qApp->setWindowIcon(windowIcon);
- for (int i = 0; i < widgets.count(); ++i) {
+ for (int i = 0; i < widgets.size(); ++i) {
// Check QEvent::ApplicationWindowIconChange
EventSpyPtr spy = applicationEventSpies.at(i);
QWidget *widget = spy->widget();
@@ -6858,7 +6950,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation()
QCOMPARE(spy->count(), 1);
spy->clear();
}
- for (int i = 0; i < windows.count(); ++i) {
+ for (int i = 0; i < windows.size(); ++i) {
// Check QEvent::ApplicationWindowIconChange (sent to QWindow)
// QWidgetWindows don't get this event, since the widget takes care of changing the icon
WindowEventSpyPtr spy = appWindowEventSpies.at(i);
@@ -6876,7 +6968,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation()
// Set icon on a top-level widget.
topLevelWidget.setWindowIcon(QIcon());
- for (int i = 0; i < widgets.count(); ++i) {
+ for (int i = 0; i < widgets.size(); ++i) {
// Check QEvent::ApplicationWindowIconChange
EventSpyPtr spy = applicationEventSpies.at(i);
QCOMPARE(spy->count(), 0);
@@ -7466,7 +7558,8 @@ void tst_QWidget::renderChildFillsBackground()
#ifndef Q_OS_ANDROID
// On Android all widgets are shown maximized, so the pixmaps
// will be similar
- QEXPECT_FAIL("", "This test fails on all platforms", Continue);
+ if (!m_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QEXPECT_FAIL("", "This test fails on all platforms", Continue);
#endif
QCOMPARE(childPixmap, windowPixmap);
}
@@ -7530,6 +7623,9 @@ void tst_QWidget::renderInvisible()
if (m_platform == QStringLiteral("xcb"))
QSKIP("QTBUG-26424");
+ if (m_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Wayland: Skip this test, see also QTBUG-107157");
+
QScopedPointer<QCalendarWidget> calendar(new QCalendarWidget);
calendar->move(m_availableTopLeft + QPoint(100, 100));
calendar->setWindowTitle(QLatin1String(QTest::currentTestFunction()));
@@ -8493,6 +8589,7 @@ void tst_QWidget::updateWhileMinimized()
QSKIP("Platform does not support showMinimized()");
#endif
UpdateWidget widget;
+ widget.setPalette(simplePalette());
widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
// Filter out activation change and focus events to avoid update() calls in QWidget.
widget.updateOnActivationChangeAndFocusIn = false;
@@ -9066,6 +9163,7 @@ void tst_QWidget::doubleRepaint()
QSKIP("Not having window server access causes the wrong number of repaints to be issues");
#endif
UpdateWidget widget;
+ widget.setPalette(simplePalette());
widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
centerOnScreen(&widget);
widget.setFocusPolicy(Qt::StrongFocus);
@@ -9097,6 +9195,7 @@ void tst_QWidget::resizeInPaintEvent()
QWidget window;
window.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
UpdateWidget widget(&window);
+ widget.setPalette(simplePalette());
window.resize(200, 200);
window.show();
QApplication::setActiveWindow(&window);
@@ -9155,6 +9254,9 @@ void tst_QWidget::opaqueChildren()
void tst_QWidget::dumpObjectTree()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QWidget w;
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
Q_SET_OBJECT_NAME(w);
@@ -9225,6 +9327,7 @@ public slots:
void tst_QWidget::setMaskInResizeEvent()
{
UpdateWidget w;
+ w.setPalette(simplePalette());
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
w.reset();
w.resize(200, 200);
@@ -9304,6 +9407,7 @@ void tst_QWidget::immediateRepaintAfterInvalidateBackingStore()
QSKIP("We don't support immediate repaint right after show on other platforms.");
QScopedPointer<UpdateWidget> widget(new UpdateWidget);
+ widget->setPalette(simplePalette());
widget->setWindowTitle(QLatin1String(QTest::currentTestFunction()));
centerOnScreen(widget.data());
widget->show();
@@ -9755,6 +9859,7 @@ void tst_QWidget::setClearAndResizeMask()
QSKIP("Wayland: This fails. Figure out why.");
UpdateWidget topLevel;
+ topLevel.setPalette(simplePalette());
topLevel.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
topLevel.resize(160, 160);
centerOnScreen(&topLevel);
@@ -9789,6 +9894,7 @@ void tst_QWidget::setClearAndResizeMask()
}
UpdateWidget child(&topLevel);
+ child.setPalette(simplePalette());
child.setAutoFillBackground(true); // NB! Opaque child.
child.setPalette(Qt::red);
child.resize(100, 100);
@@ -10182,6 +10288,9 @@ void tst_QWidget::enterLeaveOnWindowShowHide_data()
*/
void tst_QWidget::enterLeaveOnWindowShowHide()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QFETCH(Qt::WindowType, windowType);
class Widget : public QWidget
{
@@ -10381,6 +10490,106 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
QTRY_COMPARE(child.numEnterEvents, 1);
QCOMPARE(child.numMouseMoveEvents, 0);
}
+
+void tst_QWidget::hoverPosition()
+{
+ if (m_platform == QStringLiteral("wayland"))
+ QSKIP("Wayland: Clients can't set cursor position on wayland.");
+
+ class HoverWidget : public QWidget
+ {
+ public:
+ HoverWidget(QWidget *parent = nullptr) : QWidget(parent) {
+ setMouseTracking(true);
+ setAttribute(Qt::WA_Hover);
+ }
+ bool event(QEvent *ev) override {
+ switch (ev->type()) {
+ case QEvent::HoverMove:
+ // The docs say that WA_Hover will cause a paint event on enter and leave, but not on move.
+ update();
+ Q_FALLTHROUGH();
+ case QEvent::HoverEnter:
+ case QEvent::HoverLeave: {
+ qCDebug(lcTests) << ev;
+ lastHoverType = ev->type();
+ ++hoverEventCount;
+ QHoverEvent *hov = static_cast<QHoverEvent *>(ev);
+ mousePos = hov->position().toPoint();
+ mouseScenePos = hov->scenePosition().toPoint();
+ if (ev->type() == QEvent::HoverEnter)
+ mouseEnterScenePos = hov->scenePosition().toPoint();
+ break;
+ }
+ default:
+ break;
+ }
+ return QWidget::event(ev);
+ }
+ void paintEvent(QPaintEvent *) override {
+ ++paintEventCount;
+ QPainter painter(this);
+ if (mousePos.x() > 0)
+ painter.setPen(Qt::red);
+ painter.drawRect(0, 0, width(), height());
+ painter.setPen(Qt::darkGreen);
+ painter.drawLine(mousePos - QPoint(crossHalfWidth, 0), mousePos + QPoint(crossHalfWidth, 0));
+ painter.drawLine(mousePos - QPoint(0, crossHalfWidth), mousePos + QPoint(0, crossHalfWidth));
+ }
+
+ QEvent::Type lastHoverType = QEvent::None;
+ int hoverEventCount = 0;
+ int paintEventCount = 0;
+ QPoint mousePos;
+ QPoint mouseScenePos;
+ QPoint mouseEnterScenePos;
+
+ private:
+ const int crossHalfWidth = 5;
+ };
+
+ QCursor::setPos(m_safeCursorPos);
+ if (!QTest::qWaitFor([this]{ return QCursor::pos() == m_safeCursorPos; }))
+ QSKIP("Can't move cursor");
+
+ QWidget root;
+ root.resize(300, 300);
+ HoverWidget h(&root);
+ h.setGeometry(100, 100, 100, 100);
+ root.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&root));
+
+ const QPoint middle(50, 50);
+ QPoint curpos = h.mapToGlobal(middle);
+ QCursor::setPos(curpos);
+ if (!QTest::qWaitFor([curpos]{ return QCursor::pos() == curpos; }))
+ QSKIP("Can't move cursor");
+ QTRY_COMPARE_GE(h.hoverEventCount, 1); // HoverEnter and then probably HoverMove, so usually 2
+ QTRY_COMPARE_GE(h.paintEventCount, 2);
+ const int enterHoverEventCount = h.hoverEventCount;
+ qCDebug(lcTests) << "hover enter events:" << enterHoverEventCount << "last was" << h.lastHoverType
+ << "; paint events:" << h.paintEventCount;
+ QCOMPARE(h.mousePos, middle);
+ QCOMPARE(h.mouseEnterScenePos, h.mapToParent(middle));
+ QCOMPARE(h.mouseScenePos, h.mapToParent(middle));
+ QCOMPARE(h.lastHoverType, enterHoverEventCount == 1 ? QEvent::HoverEnter : QEvent::HoverMove);
+
+ curpos += {10, 10};
+ QCursor::setPos(curpos);
+ if (!QTest::qWaitFor([curpos]{ return QCursor::pos() == curpos; }))
+ QSKIP("Can't move cursor");
+ QTRY_COMPARE(h.hoverEventCount, enterHoverEventCount + 1);
+ QCOMPARE(h.lastHoverType, QEvent::HoverMove);
+ QTRY_COMPARE_GE(h.paintEventCount, 3);
+
+ curpos += {50, 50}; // in the outer widget, but leaving the inner widget
+ QCursor::setPos(curpos);
+ if (!QTest::qWaitFor([curpos]{ return QCursor::pos() == curpos; }))
+ QSKIP("Can't move cursor");
+ QTRY_COMPARE(h.lastHoverType, QEvent::HoverLeave);
+ QCOMPARE_GE(h.hoverEventCount, enterHoverEventCount + 2);
+ QTRY_COMPARE_GE(h.paintEventCount, 4);
+}
#endif
void tst_QWidget::windowFlags()
@@ -10486,6 +10695,7 @@ void tst_QWidget::focusWidget_task254563()
void tst_QWidget::destroyBackingStore()
{
UpdateWidget w;
+ w.setPalette(simplePalette());
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
centerOnScreen(&w);
w.reset();
@@ -10956,36 +11166,11 @@ void tst_QWidget::focusProxy()
QCOMPARE(container2->focusOutCount, 1);
}
-void tst_QWidget::focusProxyAndInputMethods()
+void tst_QWidget::imEnabledNotImplemented()
{
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
- QSKIP("Window activation is not supported.");
- QScopedPointer<QWidget> toplevel(new QWidget(nullptr, Qt::X11BypassWindowManagerHint));
- toplevel->setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- toplevel->resize(200, 200);
- toplevel->setAttribute(Qt::WA_InputMethodEnabled, true);
-
- QWidget *child = new QWidget(toplevel.data());
- child->setFocusProxy(toplevel.data());
- child->setAttribute(Qt::WA_InputMethodEnabled, true);
-
- toplevel->setFocusPolicy(Qt::WheelFocus);
- child->setFocusPolicy(Qt::WheelFocus);
-
- QVERIFY(!child->hasFocus());
- QVERIFY(!toplevel->hasFocus());
+ QSKIP("QWindow::requestActivate() is not supported.");
- toplevel->show();
- QVERIFY(QTest::qWaitForWindowExposed(toplevel.data()));
- QApplication::setActiveWindow(toplevel.data());
- QVERIFY(QTest::qWaitForWindowActive(toplevel.data()));
- QVERIFY(toplevel->hasFocus());
- QVERIFY(child->hasFocus());
- QCOMPARE(qApp->focusObject(), toplevel.data());
-}
-
-void tst_QWidget::imEnabledNotImplemented()
-{
// Check that a plain widget doesn't report that it supports IM. Only
// widgets that implements either Qt::ImEnabled, or the Qt4 backup
// solution, Qt::ImSurroundingText, should do so.
@@ -11506,6 +11691,9 @@ public:
void tst_QWidget::touchEventSynthesizedMouseEvent()
{
+ if (m_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("This test failed on Wayland. See also QTBUG-107157.");
+
{
// Simple case, we ignore the touch events, we get mouse events instead
TouchMouseWidget widget;
@@ -12214,6 +12402,7 @@ void tst_QWidget::resizeStaticContentsChildWidget_QTBUG35282()
widget.resize(200,200);
UpdateWidget childWidget(&widget);
+ childWidget.setPalette(simplePalette());
childWidget.setAttribute(Qt::WA_StaticContents);
childWidget.setAttribute(Qt::WA_OpaquePaintEvent);
childWidget.setGeometry(250, 250, 500, 500);
@@ -12312,60 +12501,54 @@ void tst_QWidget::testForOutsideWSRangeFlag()
}
}
-class TabletWidget : public QWidget
+void tst_QWidget::tabletTracking()
{
-public:
- TabletWidget(QWidget *parent) : QWidget(parent) { }
+ class TabletWidget : public QWidget
+ {
+ public:
+ using QWidget::QWidget;
- int tabletEventCount = 0;
- int pressEventCount = 0;
- int moveEventCount = 0;
- int releaseEventCount = 0;
- int trackingChangeEventCount = 0;
- qint64 uid = -1;
+ int tabletEventCount = 0;
+ int pressEventCount = 0;
+ int moveEventCount = 0;
+ int releaseEventCount = 0;
+ int trackingChangeEventCount = 0;
+ qint64 uid = -1;
-protected:
- void tabletEvent(QTabletEvent *event) override {
- ++tabletEventCount;
- uid = event->pointingDevice()->uniqueId().numericId();
- switch (event->type()) {
- case QEvent::TabletMove:
- ++moveEventCount;
- break;
- case QEvent::TabletPress:
- ++pressEventCount;
- break;
- case QEvent::TabletRelease:
- ++releaseEventCount;
- break;
- default:
- break;
+ protected:
+ void tabletEvent(QTabletEvent *event) override {
+ ++tabletEventCount;
+ uid = event->pointingDevice()->uniqueId().numericId();
+ switch (event->type()) {
+ case QEvent::TabletMove:
+ ++moveEventCount;
+ break;
+ case QEvent::TabletPress:
+ ++pressEventCount;
+ break;
+ case QEvent::TabletRelease:
+ ++releaseEventCount;
+ break;
+ default:
+ break;
+ }
}
- }
-
- bool event(QEvent *ev) override {
- if (ev->type() == QEvent::TabletTrackingChange)
- ++trackingChangeEventCount;
- return QWidget::event(ev);
- }
-};
-void tst_QWidget::tabletTracking()
-{
- QWidget parent;
- parent.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
- parent.resize(200,200);
- // QWidgetWindow::handleTabletEvent doesn't deliver tablet events to the window's widget, only to a child.
- // So it doesn't do any good to show a TabletWidget directly: it needs a parent.
- TabletWidget widget(&parent);
+ bool event(QEvent *ev) override {
+ if (ev->type() == QEvent::TabletTrackingChange)
+ ++trackingChangeEventCount;
+ return QWidget::event(ev);
+ }
+ } widget;
+ widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
widget.resize(200,200);
- parent.showNormal();
- QVERIFY(QTest::qWaitForWindowExposed(&parent));
+ widget.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
widget.setAttribute(Qt::WA_TabletTracking);
QTRY_COMPARE(widget.trackingChangeEventCount, 1);
QVERIFY(widget.hasTabletTracking());
- QWindow *window = parent.windowHandle();
+ QWindow *window = widget.windowHandle();
QPointF local(10, 10);
QPointF global = window->mapToGlobal(local.toPoint());
QPointF deviceLocal = QHighDpi::toNativeLocalPosition(local, window);
@@ -12687,7 +12870,7 @@ void tst_QWidget::deleteWindowInCloseEvent()
QApplication::exec();
// It should still result in a single lastWindowClosed emit
- QCOMPARE(quitSpy.count(), 1);
+ QCOMPARE(quitSpy.size(), 1);
}
/*!
@@ -12708,7 +12891,7 @@ void tst_QWidget::quitOnClose()
widget->close();
});
QApplication::exec();
- QCOMPARE(quitSpy.count(), 1);
+ QCOMPARE(quitSpy.size(), 1);
widget->show();
QVERIFY(QTest::qWaitForWindowExposed(widget.get()));
@@ -12716,7 +12899,7 @@ void tst_QWidget::quitOnClose()
widget.reset();
});
QApplication::exec();
- QCOMPARE(quitSpy.count(), 2);
+ QCOMPARE(quitSpy.size(), 2);
}
void tst_QWidget::setParentChangesFocus_data()
@@ -12790,6 +12973,9 @@ void tst_QWidget::setParentChangesFocus()
void tst_QWidget::activateWhileModalHidden()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QDialog dialog;
dialog.setWindowModality(Qt::ApplicationModal);
dialog.show();
@@ -12807,6 +12993,35 @@ void tst_QWidget::activateWhileModalHidden()
QCOMPARE(QApplication::activeWindow(), &window);
}
+// Create a simple palette to prevent multiple paint events
+QPalette tst_QWidget::simplePalette()
+{
+ static QPalette simplePalette = []{
+ const QColor windowText = Qt::black;
+ const QColor backGround = QColor(239, 239, 239);
+ const QColor light = backGround.lighter(150);
+ const QColor mid = (backGround.darker(130));
+ const QColor midLight = mid.lighter(110);
+ const QColor base = Qt::white;
+ const QColor dark = backGround.darker(150);
+ const QColor text = Qt::black;
+ const QColor highlight = QColor(48, 140, 198);
+ const QColor hightlightedText = Qt::white;
+ const QColor button = backGround;
+ const QColor shadow = dark.darker(135);
+
+ QPalette defaultPalette(windowText, backGround, light, dark, mid, text, base);
+ defaultPalette.setBrush(QPalette::Midlight, midLight);
+ defaultPalette.setBrush(QPalette::Button, button);
+ defaultPalette.setBrush(QPalette::Shadow, shadow);
+ defaultPalette.setBrush(QPalette::HighlightedText, hightlightedText);
+ defaultPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
+ return defaultPalette;
+ }();
+
+ return simplePalette;
+}
+
#ifdef Q_OS_ANDROID
void tst_QWidget::showFullscreenAndroid()
{
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 09956e69a2..19cb8c2a81 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -1450,6 +1450,9 @@ void tst_QWidget_window::mouseMoveWithPopup_data()
void tst_QWidget_window::mouseMoveWithPopup()
{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Wayland: Skip this test, see also QTBUG-107154");
+
QFETCH(Qt::WindowType, windowType);
class Window : public QWidget
@@ -1627,6 +1630,9 @@ void tst_QWidget_window::mouseMoveWithPopup()
void tst_QWidget_window::resetFocusObjectOnDestruction()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QSignalSpy focusObjectChangedSpy(qApp, &QGuiApplication::focusObjectChanged);
// single top level widget that has focus
@@ -1636,9 +1642,9 @@ void tst_QWidget_window::resetFocusObjectOnDestruction()
widget->show();
QVERIFY(QTest::qWaitForWindowActive(widget.get()));
- int activeCount = focusObjectChangedSpy.count();
+ int activeCount = focusObjectChangedSpy.size();
widget.reset();
- QVERIFY(focusObjectChangedSpy.count() > activeCount);
+ QVERIFY(focusObjectChangedSpy.size() > activeCount);
QCOMPARE(focusObjectChangedSpy.last().last().value<QObject*>(), nullptr);
focusObjectChangedSpy.clear();
@@ -1651,10 +1657,10 @@ void tst_QWidget_window::resetFocusObjectOnDestruction()
widget->show();
QVERIFY(QTest::qWaitForWindowActive(widget.get()));
- activeCount = focusObjectChangedSpy.count();
+ activeCount = focusObjectChangedSpy.size();
widget.reset();
// we might get more than one signal emission
- QVERIFY(focusObjectChangedSpy.count() > activeCount);
+ QVERIFY(focusObjectChangedSpy.size() > activeCount);
QCOMPARE(focusObjectChangedSpy.last().last().value<QObject*>(), nullptr);
}
diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
index 031856e0f9..0e0f84dbb1 100644
--- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
@@ -222,7 +222,7 @@ void tst_QWidgetAction::customWidget()
tb1.addAction(action);
QList<QWidget *> combos = action->createdWidgets();
- QCOMPARE(combos.count(), 1);
+ QCOMPARE(combos.size(), 1);
QPointer<QComboBox> combo1 = qobject_cast<QComboBox *>(combos.at(0));
QVERIFY(combo1);
@@ -230,7 +230,7 @@ void tst_QWidgetAction::customWidget()
tb2.addAction(action);
combos = action->createdWidgets();
- QCOMPARE(combos.count(), 2);
+ QCOMPARE(combos.size(), 2);
QCOMPARE(combos.at(0), combo1.data());
QPointer<QComboBox> combo2 = qobject_cast<QComboBox *>(combos.at(1));
diff --git a/tests/auto/widgets/kernel/qwidgetrepaintmanager/BLACKLIST b/tests/auto/widgets/kernel/qwidgetrepaintmanager/BLACKLIST
new file mode 100644
index 0000000000..94692ee20a
--- /dev/null
+++ b/tests/auto/widgets/kernel/qwidgetrepaintmanager/BLACKLIST
@@ -0,0 +1,11 @@
+# Temporary for QTBUG-109036
+[fastMove]
+opensuse-leap
+
+# Temporary for QTBUG-109036
+[moveAccross]
+opensuse-leap
+
+# Temporary for QTBUG-109036
+[moveInOutOverlapped]
+opensuse-leap
diff --git a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
index fb959821bc..f53d5aeb05 100644
--- a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
+++ b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
@@ -33,14 +33,33 @@ public:
void initialShow()
{
show();
- if (isWindow())
+ if (isWindow()) {
QVERIFY(QTest::qWaitForWindowExposed(this));
+ QVERIFY(waitForPainted());
+ }
paintedRegions = {};
}
bool waitForPainted(int timeout = 5000)
{
- return QTest::qWaitFor([this]{ return !paintedRegions.isEmpty(); }, timeout);
+ int remaining = timeout;
+ QDeadlineTimer deadline(remaining, Qt::PreciseTimer);
+ if (!QTest::qWaitFor([this]{ return !paintedRegions.isEmpty(); }, timeout))
+ return false;
+
+ // In case of multiple paint events:
+ // Process events and wait until all have been consumed,
+ // i.e. paintedRegions no longer changes.
+ QRegion reg;
+ while (remaining > 0 && reg != paintedRegions) {
+ reg = paintedRegions;
+ QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
+ if (reg == paintedRegions)
+ return true;
+
+ remaining = int(deadline.remainingTime());
+ }
+ return false;
}
QRegion takePaintedRegions()
@@ -51,6 +70,14 @@ public:
}
QRegion paintedRegions;
+ bool event(QEvent *event) override
+ {
+ const auto type = event->type();
+ if (type == QEvent::WindowActivate || type == QEvent::WindowDeactivate)
+ return true;
+ return QWidget::event(event);
+ }
+
protected:
void paintEvent(QPaintEvent *event) override
{
@@ -71,6 +98,14 @@ public:
setAttribute(Qt::WA_OpaquePaintEvent);
}
+ bool event(QEvent *event) override
+ {
+ const auto type = event->type();
+ if (type == QEvent::WindowActivate || type == QEvent::WindowDeactivate)
+ return true;
+ return QWidget::event(event);
+ }
+
protected:
void paintEvent(QPaintEvent *e) override
{
@@ -186,6 +221,14 @@ public:
QSize sizeHint() const override { return QSize(400, 400); }
+ bool event(QEvent *event) override
+ {
+ const auto type = event->type();
+ if (type == QEvent::WindowActivate || type == QEvent::WindowDeactivate)
+ return true;
+ return QWidget::event(event);
+ }
+
protected:
void resizeEvent(QResizeEvent *) override
{
@@ -226,13 +269,14 @@ protected:
*/
bool compareWidget(QWidget *w)
{
+ QBackingStore *backingStore = w->window()->backingStore();
+ Q_ASSERT(backingStore && backingStore->handle());
+ QPlatformBackingStore *platformBackingStore = backingStore->handle();
+
if (!waitForFlush(w)) {
qWarning() << "Widget" << w << "failed to flush";
return false;
}
- QBackingStore *backingStore = w->window()->backingStore();
- Q_ASSERT(backingStore && backingStore->handle());
- QPlatformBackingStore *platformBackingStore = backingStore->handle();
QImage backingstoreContent = platformBackingStore->toImage();
if (!w->isWindow()) {
@@ -259,7 +303,14 @@ protected:
}
bool waitForFlush(QWidget *widget) const
{
+ if (!widget)
+ return true;
+
auto *repaintManager = QWidgetPrivate::get(widget->window())->maybeRepaintManager();
+
+ if (!repaintManager)
+ return true;
+
return QTest::qWaitFor([repaintManager]{ return !repaintManager->isDirty(); } );
};
#endif // QT_BUILD_INTERNAL
@@ -282,7 +333,7 @@ void tst_QWidgetRepaintManager::initTestCase()
QVERIFY(QTest::qWaitForWindowExposed(&widget));
m_implementsScroll = widget.backingStore()->handle()->scroll(QRegion(widget.rect()), 1, 1);
- qDebug() << QGuiApplication::platformName() << "QPA backend implements scroll:" << m_implementsScroll;
+ qInfo() << QGuiApplication::platformName() << "QPA backend implements scroll:" << m_implementsScroll;
}
void tst_QWidgetRepaintManager::cleanup()
@@ -321,6 +372,7 @@ void tst_QWidgetRepaintManager::children()
TestWidget *child1 = new TestWidget(&widget);
child1->move(20, 20);
child1->show();
+ QVERIFY(QTest::qWaitForWindowExposed(child1));
QVERIFY(child1->waitForPainted());
QCOMPARE(widget.takePaintedRegions(), QRegion(child1->geometry()));
QCOMPARE(child1->takePaintedRegions(), QRegion(child1->rect()));
@@ -594,6 +646,7 @@ void tst_QWidgetRepaintManager::fastMove()
QCOMPARE(dirtyRegion(scene.yellowChild), QRect(0, 0, 100, 100));
}
QCOMPARE(dirtyRegion(&scene), QRect(0, 0, 25, 100));
+ QTRY_VERIFY(dirtyRegion(&scene).isEmpty());
QVERIFY(compareWidget(&scene));
}
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
index fc182ae0f2..ce6ca20eb7 100644
--- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
+++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
@@ -633,7 +633,7 @@ void tst_QStyle::testStyleOptionInit()
QStringList keys = QStyleFactory::keys();
keys.prepend(QString()); // QCommonStyle marker
- for (const QString &key : qAsConst(keys)) {
+ for (const QString &key : std::as_const(keys)) {
QStyle* style = key.isEmpty() ? new QCommonStyle : QStyleFactory::create(key);
TestStyleOptionInitProxy testStyle;
testStyle.setBaseStyle(style);
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 82d48b1692..b4170452c8 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -1707,7 +1707,7 @@ void tst_QStyleSheetStyle::toolTip()
normalToolTip };
QWidgetList topLevels;
- for (int i = 0; i < widgets.count() ; ++i) {
+ for (int i = 0; i < widgets.size() ; ++i) {
QWidget *wid = widgets.at(i);
QColor col = colors.at(i);
@@ -1715,7 +1715,7 @@ void tst_QStyleSheetStyle::toolTip()
topLevels = QApplication::topLevelWidgets();
QWidget *tooltip = nullptr;
- for (QWidget *widget : qAsConst(topLevels)) {
+ for (QWidget *widget : std::as_const(topLevels)) {
if (widget->inherits("QTipLabel")) {
tooltip = widget;
break;
@@ -1731,7 +1731,7 @@ void tst_QStyleSheetStyle::toolTip()
delete wid3; //should not crash;
QTest::qWait(10);
topLevels = QApplication::topLevelWidgets();
- for (QWidget *widget : qAsConst(topLevels))
+ for (QWidget *widget : std::as_const(topLevels))
widget->update(); //should not crash either
}
@@ -2339,11 +2339,19 @@ void tst_QStyleSheetStyle::placeholderColor()
QLineEdit le2;
le2.setEnabled(false);
le1.ensurePolished();
- QCOMPARE(le1.palette().placeholderText(), red);
+ QColor phColor = le1.palette().placeholderText().color();
+ QCOMPARE(phColor.rgb(), red.rgb());
+ QVERIFY(phColor.alpha() < red.alpha());
+
le2.ensurePolished();
- QCOMPARE(le2.palette().placeholderText(), red);
+ phColor = le2.palette().placeholderText().color();
+ QCOMPARE(phColor.rgb(), red.rgb());
+ QVERIFY(phColor.alpha() < red.alpha());
+
le2.setEnabled(true);
- QCOMPARE(le2.palette().placeholderText(), red);
+ phColor = le2.palette().placeholderText().color();
+ QCOMPARE(phColor.rgb(), red.rgb());
+ QVERIFY(phColor.alpha() < red.alpha());
}
void tst_QStyleSheetStyle::enumPropertySelector_data()
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 76b12d7aea..b33c819ee0 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -57,7 +57,7 @@ QString CsvCompleter::pathFromIndex(const QModelIndex &sourceIndex) const
idx = parent.sibling(parent.row(), sourceIndex.column());
} while (idx.isValid());
- return list.count() == 1 ? list.constFirst() : list.join(QLatin1Char(','));
+ return list.size() == 1 ? list.constFirst() : list.join(QLatin1Char(','));
}
class tst_QCompleter : public QObject
@@ -151,6 +151,16 @@ tst_QCompleter::~tst_QCompleter()
delete completer;
}
+#ifdef Q_OS_ANDROID
+static QString androidHomePath()
+{
+ const auto homePaths = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
+ QDir dir = homePaths.isEmpty() ? QDir() : homePaths.first();
+ dir.cdUp();
+ return dir.path();
+}
+#endif
+
void tst_QCompleter::setSourceModel(ModelType type)
{
QTreeWidgetItem *parent, *child;
@@ -203,7 +213,13 @@ void tst_QCompleter::setSourceModel(ModelType type)
completer->setCsvCompletion(false);
{
auto m = new QFileSystemModel(completer);
+#ifdef Q_OS_ANDROID
+ // Android 11 and above doesn't allow accessing root filesystem as before,
+ // so let's opt int for the app's home.
+ m->setRootPath(androidHomePath());
+#else
m->setRootPath("/");
+#endif
completer->setModel(m);
}
completer->setCompletionColumn(0);
@@ -590,7 +606,9 @@ void tst_QCompleter::fileSystemModel_data()
// QTest::newRow("(/d)") << "/d" << "" << "Developer" << "/Developer";
#elif defined(Q_OS_ANDROID)
QTest::newRow("()") << "" << "" << "/" << "/";
- QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc";
+ const QString androidDir = androidHomePath();
+ const QString tag = QStringLiteral("%1/fil").arg(androidDir);
+ QTest::newRow(tag.toUtf8().data()) << tag << "" << "files" << androidDir + "/files";
#else
QTest::newRow("()") << "" << "" << "/" << "/";
#if !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX)
@@ -1158,10 +1176,10 @@ void tst_QCompleter::disabledItems()
QAbstractItemView *view = lineEdit.completer()->popup();
QVERIFY(view->isVisible());
QTest::mouseClick(view->viewport(), Qt::LeftButton, {}, view->visualRect(view->model()->index(0, 0)).center());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(view->isVisible());
QTest::mouseClick(view->viewport(), Qt::LeftButton, {}, view->visualRect(view->model()->index(1, 0)).center());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!view->isVisible());
}
@@ -1175,7 +1193,7 @@ void tst_QCompleter::task178797_activatedOnReturn()
auto completer = new QCompleter({"foobar1", "foobar2"}, &ledit);
ledit.setCompleter(completer);
QSignalSpy spy(completer, QOverload<const QString &>::of(&QCompleter::activated));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
ledit.move(200, 200);
ledit.show();
QApplication::setActiveWindow(&ledit);
@@ -1187,7 +1205,7 @@ void tst_QCompleter::task178797_activatedOnReturn()
QCoreApplication::processEvents();
QTest::keyClick(QApplication::activePopupWidget(), Qt::Key_Return);
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
class task189564_StringListModel : public QStringListModel
@@ -1269,7 +1287,7 @@ void tst_QCompleter::task246056_setCompletionPrefix()
QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down);
QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down);
QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Enter); // don't crash!
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
const auto index = spy.at(0).constFirst().toModelIndex();
QVERIFY(!index.isValid());
}
@@ -1743,10 +1761,10 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes()
QTRY_VERIFY(cbox.completer()->popup()->isVisible());
QTest::keyClick(cbox.completer()->popup(), Qt::Key_Tab);
QCOMPARE(cbox.completer()->currentCompletion(), QLatin1String("hux"));
- QCOMPARE(activatedSpy.count(), 0);
+ QCOMPARE(activatedSpy.size(), 0);
QEXPECT_FAIL("", "QTBUG-52028 will not be fixed today.", Abort);
QCOMPARE(cbox.currentText(), QLatin1String("hux"));
- QCOMPARE(activatedSpy.count(), 0);
+ QCOMPARE(activatedSpy.size(), 0);
QVERIFY(!le->hasFocus());
}
@@ -1787,7 +1805,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice()
QTRY_VERIFY(cbox.completer()->popup()->isVisible());
QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down);
QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return);
- QTRY_COMPARE(activatedSpy.count(), 1);
+ QTRY_COMPARE(activatedSpy.size(), 1);
// Navigate + enter activates only once (non-first item)
cbox.lineEdit()->clear();
@@ -1797,7 +1815,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice()
QTRY_VERIFY(cbox.completer()->popup()->isVisible());
QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down);
QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return);
- QTRY_COMPARE(activatedSpy.count(), 1);
+ QTRY_COMPARE(activatedSpy.size(), 1);
// Full text + enter activates only once
cbox.lineEdit()->clear();
@@ -1806,11 +1824,14 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice()
QVERIFY(cbox.completer()->popup());
QTRY_VERIFY(cbox.completer()->popup()->isVisible());
QTest::keyClick(&cbox, Qt::Key_Return);
- QTRY_COMPARE(activatedSpy.count(), 1);
+ QTRY_COMPARE(activatedSpy.size(), 1);
}
void tst_QCompleter::showPopupInGraphicsView()
{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Wayland: Skip this test, see also QTBUG-107186");
+
QGraphicsView view;
QGraphicsScene scene;
view.setScene(&scene);
diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
index 491d5d48e3..1b64a34593 100644
--- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
+++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
@@ -103,6 +103,7 @@ private slots:
void scroll();
void overshoot();
void multipleWindows();
+ void mouseEventTimestamp();
private:
QPointingDevice *m_touchScreen = QTest::createTouchDevice();
@@ -516,6 +517,67 @@ void tst_QScroller::multipleWindows()
#endif
}
+/*!
+ This test verifies that mouse events arrive at the target widget
+ with valid timestamp, even if there is a gesture filtering (and then
+ replaying a copy of) the event. QTBUG-102010
+
+ We cannot truly simulate the double click here, as simulated events don't
+ go through the exact same event machinery as real events, so double clicks
+ don't get generated by Qt here. But we can verify that the timestamps of
+ the eventually delivered events are maintained.
+*/
+void tst_QScroller::mouseEventTimestamp()
+{
+#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
+ QScopedPointer<tst_QScrollerWidget> sw(new tst_QScrollerWidget());
+ sw->scrollArea = QRectF(0, 0, 1000, 1000);
+ QScroller::grabGesture(sw.data(), QScroller::LeftMouseButtonGesture);
+ sw->setGeometry(100, 100, 400, 300);
+ sw->show();
+ QApplication::setActiveWindow(sw.data());
+ if (!QTest::qWaitForWindowExposed(sw.data()) || !QTest::qWaitForWindowActive(sw.data()))
+ QSKIP("Failed to show and activate window");
+
+ QScroller *s1 = QScroller::scroller(sw.data());
+
+ struct EventFilter : QObject
+ {
+ QList<int> timestamps;
+ protected:
+ bool eventFilter(QObject *o, QEvent *e) override
+ {
+ if (e->isInputEvent())
+ timestamps << static_cast<QInputEvent *>(e)->timestamp();
+ return QObject::eventFilter(o, e);
+ }
+
+ } eventFilter;
+ sw->installEventFilter(&eventFilter);
+
+ const int interval = QGuiApplication::styleHints()->mouseDoubleClickInterval() / 10;
+ const QPoint point = sw->geometry().center();
+ // Simulate double by pressing twice within the double click interval.
+ // Presses are filtered and then delayed by the scroller/gesture machinery,
+ // so we first record all events, and then make sure that the relative timestamps
+ // are maintained also for the replayed or synthesized events.
+ QTest::mousePress(sw->windowHandle(), Qt::LeftButton, {}, point);
+ QCOMPARE(s1->state(), QScroller::Pressed);
+ QTest::mouseRelease(sw->windowHandle(), Qt::LeftButton, {}, point, interval);
+ QCOMPARE(s1->state(), QScroller::Inactive);
+ QTest::mousePress(sw->windowHandle(), Qt::LeftButton, {}, point, interval);
+ QCOMPARE(s1->state(), QScroller::Pressed);
+ // also filtered and delayed by the scroller
+ QTest::mouseRelease(sw->windowHandle(), Qt::LeftButton, {}, point, interval);
+ QCOMPARE(s1->state(), QScroller::Inactive);
+ int lastTimestamp = -1;
+ for (int timestamp : std::as_const(eventFilter.timestamps)) {
+ QCOMPARE_GE(timestamp, lastTimestamp);
+ lastTimestamp = timestamp + interval;
+ }
+#endif
+}
+
QTEST_MAIN(tst_QScroller)
#include "tst_qscroller.moc"
diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
index 5348942857..2b04fc5104 100644
--- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
+++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
@@ -110,7 +110,7 @@ void tst_QSystemTrayIcon::lastWindowClosed()
QTimer::singleShot(2500, &window, SLOT(close()));
QTimer::singleShot(20000, qApp, SLOT(quit())); // in case the test fails
qApp->exec();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
QTEST_MAIN(tst_QSystemTrayIcon)
diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
index ec916925a3..533b91c608 100644
--- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
@@ -516,24 +516,24 @@ void tst_QAbstractButton::animateClick()
button.animateClick();
QVERIFY(button.isDown());
- QCOMPARE(pressedSpy.count(), 1);
- QCOMPARE(releasedSpy.count(), 0);
- QCOMPARE(clickedSpy.count(), 0);
+ QCOMPARE(pressedSpy.size(), 1);
+ QCOMPARE(releasedSpy.size(), 0);
+ QCOMPARE(clickedSpy.size(), 0);
qApp->processEvents(QEventLoop::AllEvents, 10);
// QAbstractButton starts a 100ms timer which performs the click. If it
// took more than 100ms to get here, then the button might no longer be down.
if (elapsed.elapsed() < 100) {
QVERIFY(button.isDown());
- QCOMPARE(pressedSpy.count(), 1);
- QCOMPARE(releasedSpy.count(), 0);
- QCOMPARE(clickedSpy.count(), 0);
+ QCOMPARE(pressedSpy.size(), 1);
+ QCOMPARE(releasedSpy.size(), 0);
+ QCOMPARE(clickedSpy.size(), 0);
}
QTRY_VERIFY(!button.isDown());
// but once the button has been clicked, it must have taken at least 100ms
QVERIFY(elapsed.elapsed() >= 100);
- QCOMPARE(pressedSpy.count(), 1);
- QCOMPARE(releasedSpy.count(), 1);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(pressedSpy.size(), 1);
+ QCOMPARE(releasedSpy.size(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
}
#if QT_CONFIG(shortcut)
@@ -556,9 +556,9 @@ void tst_QAbstractButton::shortcutEvents()
QTest::qWait(1000); // ensure animate timer is expired
- QCOMPARE(pressedSpy.count(), 3);
- QCOMPARE(releasedSpy.count(), 3);
- QCOMPARE(clickedSpy.count(), 3);
+ QCOMPARE(pressedSpy.size(), 3);
+ QCOMPARE(releasedSpy.size(), 3);
+ QCOMPARE(clickedSpy.size(), 3);
}
#endif // QT_CONFIG(shortcut)
@@ -600,14 +600,14 @@ void tst_QAbstractButton::mouseReleased() // QTBUG-53244
QSignalSpy spyRelease(&button, &QAbstractButton::released);
QTest::mousePress(&button, Qt::LeftButton);
- QCOMPARE(spyPress.count(), 1);
+ QCOMPARE(spyPress.size(), 1);
QCOMPARE(button.isDown(), true);
- QCOMPARE(spyRelease.count(), 0);
+ QCOMPARE(spyRelease.size(), 0);
QTest::mouseClick(&button, Qt::RightButton);
- QCOMPARE(spyPress.count(), 1);
+ QCOMPARE(spyPress.size(), 1);
QCOMPARE(button.isDown(), true);
- QCOMPARE(spyRelease.count(), 0);
+ QCOMPARE(spyRelease.size(), 0);
QPointF posOutOfWidget = QPointF(30, 30);
QMouseEvent me(QEvent::MouseMove,
@@ -617,9 +617,9 @@ void tst_QAbstractButton::mouseReleased() // QTBUG-53244
qApp->sendEvent(&button, &me);
// should emit released signal once mouse is dragging out of boundary
- QCOMPARE(spyPress.count(), 1);
+ QCOMPARE(spyPress.size(), 1);
QCOMPARE(button.isDown(), false);
- QCOMPARE(spyRelease.count(), 1);
+ QCOMPARE(spyRelease.size(), 1);
}
#ifdef QT_KEYPAD_NAVIGATION
@@ -684,7 +684,7 @@ void tst_QAbstractButton::buttonPressKeys()
const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
->themeHint(QPlatformTheme::ButtonPressKeys)
.value<QList<Qt::Key>>();
- for (uint i = 0; i < buttonPressKeys.length(); ++i) {
+ for (uint i = 0; i < buttonPressKeys.size(); ++i) {
QTest::keyClick(testWidget, buttonPressKeys[i]);
QCOMPARE(click_count, i + 1);
}
diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
index edca1954fd..170c29922a 100644
--- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
@@ -1459,7 +1459,7 @@ void tst_QAbstractSlider::keyPressed()
slider->setOrientation(Qt::Horizontal);
slider->setInvertedAppearance(invertedAppearance);
slider->setInvertedControls(invertedControls);
- for (int i=0;i<keySequence.count();i++) {
+ for (int i=0;i<keySequence.size();i++) {
QTest::keyClick(slider, keySequence.at(i));
}
QCOMPARE(slider->sliderPosition(), expectedSliderPosition);
@@ -1666,8 +1666,8 @@ void tst_QAbstractSlider::wheelEvent()
#endif
QCOMPARE(slider->sliderPosition(),expectedSliderPosition);
int expectedSignalCount = (initialSliderPosition == expectedSliderPosition) ? 0 : 1;
- QCOMPARE(spy1.count(), expectedSignalCount);
- QCOMPARE(spy2.count(), expectedSignalCount);
+ QCOMPARE(spy1.size(), expectedSignalCount);
+ QCOMPARE(spy2.size(), expectedSignalCount);
if (expectedSignalCount)
QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp);
}
@@ -1814,9 +1814,9 @@ void tst_QAbstractSlider::sliderPressedReleased()
QTest::mousePress(slider, Qt::LeftButton, {},
QPoint(rect.center().x() + 2, rect.center().y() + 2));
- QCOMPARE(spy1.count(), expectedCount);
+ QCOMPARE(spy1.size(), expectedCount);
QTest::mouseRelease(slider, Qt::LeftButton, {}, rect.center());
- QCOMPARE(spy2.count(), expectedCount);
+ QCOMPARE(spy2.size(), expectedCount);
delete slider;
}
@@ -1885,7 +1885,7 @@ void tst_QAbstractSlider::sliderMoved()
slider->setMaximum(maximum);
slider->setSliderDown(sliderDown);
slider->setSliderPosition(position);
- QCOMPARE(spy.count(), expectedCount);
+ QCOMPARE(spy.size(), expectedCount);
delete slider;
}
@@ -1957,7 +1957,7 @@ void tst_QAbstractSlider::rangeChanged()
slider.setRange(minimum, maximum);
QSignalSpy spy(&slider, SIGNAL(rangeChanged(int,int)));
slider.setRange(newMin, newMax);
- QCOMPARE(spy.count(), expectedCount);
+ QCOMPARE(spy.size(), expectedCount);
}
void tst_QAbstractSlider::setSliderPosition_data()
@@ -1996,8 +1996,8 @@ void tst_QAbstractSlider::setSliderPosition()
QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
slider->setSliderPosition(targetPosition);
QCOMPARE(slider->sliderPosition(), targetPosition);
- QCOMPARE(spy1.count(), down ? 1 : 0);
- QCOMPARE(spy2.count(), tracking ? 1 : 0);
+ QCOMPARE(spy1.size(), down ? 1 : 0);
+ QCOMPARE(spy2.size(), tracking ? 1 : 0);
QCOMPARE(slider->value(), tracking ? targetPosition : initialValue);
if (tracking && down)
QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp);
@@ -2021,17 +2021,21 @@ void tst_QAbstractSlider::setValue()
slider->setRange(minimum, maximum);
slider->setSliderDown(down);
slider->setValue(49); // to force a valueChanged() below
- QSignalSpy spy1(slider, SIGNAL(sliderMoved(int)));
- QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
- QSignalSpy spy3(slider, SIGNAL(actionTriggered(int)));
+ QSignalSpy spy1(slider, &QAbstractSlider::sliderMoved);
+ QSignalSpy spy2(slider, &QAbstractSlider::valueChanged);
+ QSignalSpy spy3(slider, &QAbstractSlider::actionTriggered);
slider->setValue(50);
- QCOMPARE(spy1.count(), down ? 1 : 0);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy3.count(), 0);
+ QCOMPARE(spy1.size(), down ? 1 : 0);
+ QCOMPARE(spy2.size(), 1);
+ QCOMPARE(spy3.size(), 0);
QCOMPARE(slider->value(), reportedValue);
QCOMPARE(slider->sliderPosition(), reportedSliderPosition);
if (down)
QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp);
+
+ slider->setValue(50);
+ QApplication::processEvents();
+ QCOMPARE(spy2.size(), 1);
}
void tst_QAbstractSlider::waitUntilTimeElapsed(const QElapsedTimer &t, int ms)
@@ -2051,37 +2055,37 @@ void tst_QAbstractSlider::setRepeatAction()
// Start repeat action with initial delay of 500 ms, and then repeating
// every 250 ms.
slider->setRepeatAction(QAbstractSlider::SliderPageStepAdd, 500, 250);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(slider->value(), 55);
QElapsedTimer t;
t.start();
QTest::qWait(300);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(slider->value(), 55);
waitUntilTimeElapsed(t, 550);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QCOMPARE(slider->value(), 65);
QCOMPARE(spy.at(0).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
waitUntilTimeElapsed(t, 790);
- QTRY_COMPARE(spy.count(), 2);
+ QTRY_COMPARE(spy.size(), 2);
QCOMPARE(slider->value(), 75);
QCOMPARE(spy.at(1).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
waitUntilTimeElapsed(t, 1790);
- QTRY_COMPARE(spy.count(), 6);
+ QTRY_COMPARE(spy.size(), 6);
QCOMPARE(slider->value(), 115);
QCOMPARE(spy.at(4).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
QCOMPARE(spy.at(5).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
slider->setRepeatAction(QAbstractSlider::SliderNoAction);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
QCOMPARE(slider->value(), 115);
QTest::qWait(300);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
QCOMPARE(slider->value(), 115);
}
diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
index f95f017d6b..c8151a3b24 100644
--- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
@@ -349,17 +349,17 @@ void tst_QButtonGroup::testSignals()
pb1.animateClick();
QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(clickedSpy.count(), 1);
- QCOMPARE(clickedIdSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
+ QCOMPARE(clickedIdSpy.size(), 1);
int expectedId = -2;
QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId);
- QCOMPARE(pressedSpy.count(), 1);
- QCOMPARE(pressedIdSpy.count(), 1);
+ QCOMPARE(pressedSpy.size(), 1);
+ QCOMPARE(pressedIdSpy.size(), 1);
QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId);
- QCOMPARE(releasedSpy.count(), 1);
- QCOMPARE(releasedIdSpy.count(), 1);
+ QCOMPARE(releasedSpy.size(), 1);
+ QCOMPARE(releasedIdSpy.size(), 1);
QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId);
clickedSpy.clear();
@@ -372,14 +372,14 @@ void tst_QButtonGroup::testSignals()
pb2.animateClick();
QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(clickedSpy.count(), 1);
- QCOMPARE(clickedIdSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
+ QCOMPARE(clickedIdSpy.size(), 1);
QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23);
- QCOMPARE(pressedSpy.count(), 1);
- QCOMPARE(pressedIdSpy.count(), 1);
+ QCOMPARE(pressedSpy.size(), 1);
+ QCOMPARE(pressedIdSpy.size(), 1);
QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23);
- QCOMPARE(releasedSpy.count(), 1);
- QCOMPARE(releasedIdSpy.count(), 1);
+ QCOMPARE(releasedSpy.size(), 1);
+ QCOMPARE(releasedIdSpy.size(), 1);
QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23);
@@ -389,18 +389,18 @@ void tst_QButtonGroup::testSignals()
pb1.setCheckable(true);
pb2.setCheckable(true);
pb1.toggle();
- QCOMPARE(toggledSpy.count(), 1);
- QCOMPARE(toggledIdSpy.count(), 1);
+ QCOMPARE(toggledSpy.size(), 1);
+ QCOMPARE(toggledIdSpy.size(), 1);
pb2.toggle();
- QCOMPARE(toggledSpy.count(), 3); // equals 3 since pb1 and pb2 are both toggled
- QCOMPARE(toggledIdSpy.count(), 3);
+ QCOMPARE(toggledSpy.size(), 3); // equals 3 since pb1 and pb2 are both toggled
+ QCOMPARE(toggledIdSpy.size(), 3);
pb1.setCheckable(false);
pb2.setCheckable(false);
pb1.toggle();
- QCOMPARE(toggledSpy.count(), 3);
- QCOMPARE(toggledIdSpy.count(), 3);
+ QCOMPARE(toggledSpy.size(), 3);
+ QCOMPARE(toggledIdSpy.size(), 3);
}
void tst_QButtonGroup::task106609()
@@ -440,7 +440,7 @@ void tst_QButtonGroup::task106609()
radio1->setChecked(true);
QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.size(), 2);
}
void tst_QButtonGroup::checkedButton()
@@ -525,7 +525,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
// NOTE: Reintroducing the bug of this task will cause the following line to crash:
QTest::mouseClick(button, Qt::LeftButton);
- QCOMPARE(spy1.count(), signalCount);
+ QCOMPARE(spy1.size(), signalCount);
}
void tst_QButtonGroup::autoIncrementId()
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
index 064b539f22..31da429a8f 100644
--- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -84,7 +84,7 @@ void tst_QCalendarWidget::getSetCheck()
QDate selectedDate(2005, 7, 3);
QSignalSpy spy(&object, SIGNAL(selectionChanged()));
object.setSelectedDate(selectedDate);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(selectedDate, object.selectedDate());
//month and year
object.setCurrentPage(2004, 1);
diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
index b0b34ee3fa..7a54a6e5e6 100644
--- a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
+++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
@@ -208,10 +208,10 @@ void tst_QCheckBox::stateChanged()
QCoreApplication::processEvents();
QCOMPARE(cur_state, 1);
- QCOMPARE(stateChangedSpy.count(), 3);
+ QCOMPARE(stateChangedSpy.size(), 3);
testWidget.setCheckState(Qt::PartiallyChecked);
QCoreApplication::processEvents();
- QCOMPARE(stateChangedSpy.count(), 3);
+ QCOMPARE(stateChangedSpy.size(), 3);
}
void tst_QCheckBox::isToggleButton()
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 4ca3a1b5a5..4b7ed29fff 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -8,6 +8,7 @@
#include "qcombobox.h"
#include <private/qcombobox_p.h>
#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
#include <qpa/qplatformtheme.h>
#include <qfontcombobox.h>
@@ -24,6 +25,7 @@
#include <qtablewidget.h>
#include <qscrollbar.h>
#include <qboxlayout.h>
+#include <qshortcut.h>
#include <qstackedwidget.h>
#include <qstandarditemmodel.h>
@@ -147,6 +149,7 @@ private slots:
void propagateStyleChanges();
void buttonPressKeys();
void clearModel();
+ void cancelClosesPopupNotDialog();
private:
PlatformInputContext m_platformInputContext;
@@ -747,7 +750,7 @@ void tst_QComboBox::insertPolicy()
testWidget->setInsertPolicy(insertPolicy);
testWidget->addItems(initialEntries);
testWidget->setEditable(true);
- if (initialEntries.count() > 0)
+ if (initialEntries.size() > 0)
testWidget->setCurrentIndex(currentIndex);
// clear
@@ -759,10 +762,10 @@ void tst_QComboBox::insertPolicy()
// First check that there is the right number of entries, or
// we may unwittingly pass
- QCOMPARE((int)result.count(), testWidget->count());
+ QCOMPARE((int)result.size(), testWidget->count());
// No need to compare if there are no strings to compare
- if (result.count() > 0) {
+ if (result.size() > 0) {
for (int i=0; i<testWidget->count(); ++i) {
QCOMPARE(testWidget->itemText(i), result.at(i));
}
@@ -859,18 +862,18 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
qApp->processEvents();
QCOMPARE(testWidget->currentText(), QString("aww"));
- QCOMPARE(spyReturn.count(), 0);
+ QCOMPARE(spyReturn.size(), 0);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_B);
qApp->processEvents();
// autocompletions preserve userkey-case from 4.2
QCOMPARE(testWidget->currentText(), QString("abCDEF"));
- QCOMPARE(spyReturn.count(), 0);
+ QCOMPARE(spyReturn.size(), 0);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
qApp->processEvents();
QCOMPARE(testWidget->currentText(), QString("aBCDEF")); // case restored to item's case
- QCOMPARE(spyReturn.count(), 1);
+ QCOMPARE(spyReturn.size(), 1);
testWidget->clearEditText();
QTest::keyClick(testWidget->lineEdit(), 'c');
@@ -1169,7 +1172,7 @@ void tst_QComboBox::currentIndex()
foreach(QString text, initialItems) {
testWidget->addItem(text);
}
- QCOMPARE(testWidget->count(), initialItems.count());
+ QCOMPARE(testWidget->count(), initialItems.size());
// set current index, remove and/or insert
if (setCurrentIndex >= -1) {
@@ -1187,11 +1190,11 @@ void tst_QComboBox::currentIndex()
QCOMPARE(testWidget->currentText(), expectedCurrentText);
// check that signal count is correct
- QCOMPARE(indexChangedInt.count(), expectedSignalCount);
+ QCOMPARE(indexChangedInt.size(), expectedSignalCount);
// compare with last sent signal values
- if (indexChangedInt.count())
- QCOMPARE(indexChangedInt.at(indexChangedInt.count() - 1).at(0).toInt(),
+ if (indexChangedInt.size())
+ QCOMPARE(indexChangedInt.at(indexChangedInt.size() - 1).at(0).toInt(),
testWidget->currentIndex());
if (edit) {
@@ -1228,8 +1231,8 @@ void tst_QComboBox::insertItems_data()
QTest::newRow("prepend") << initialItems << insertedItems << 0 << 0;
QTest::newRow("prepend with negative value") << initialItems << insertedItems << -1 << 0;
- QTest::newRow("append") << initialItems << insertedItems << initialItems.count() << initialItems.count();
- QTest::newRow("append with too high value") << initialItems << insertedItems << 999 << initialItems.count();
+ QTest::newRow("append") << initialItems << insertedItems << initialItems.size() << initialItems.size();
+ QTest::newRow("append with too high value") << initialItems << insertedItems << 999 << initialItems.size();
QTest::newRow("insert") << initialItems << insertedItems << 1 << 1;
}
@@ -1245,12 +1248,12 @@ void tst_QComboBox::insertItems()
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QComboBox *testWidget = topLevel.comboBox();
testWidget->insertItems(0, initialItems);
- QCOMPARE(testWidget->count(), initialItems.count());
+ QCOMPARE(testWidget->count(), initialItems.size());
testWidget->insertItems(insertIndex, insertedItems);
- QCOMPARE(testWidget->count(), initialItems.count() + insertedItems.count());
- for (int i=0; i<insertedItems.count(); ++i)
+ QCOMPARE(testWidget->count(), initialItems.size() + insertedItems.size());
+ for (int i=0; i<insertedItems.size(); ++i)
QCOMPARE(testWidget->itemText(expectedIndex + i), insertedItems.at(i));
}
@@ -1287,14 +1290,14 @@ void tst_QComboBox::insertItem()
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QComboBox *testWidget = topLevel.comboBox();
testWidget->insertItems(0, initialItems);
- QCOMPARE(testWidget->count(), initialItems.count());
+ QCOMPARE(testWidget->count(), initialItems.size());
testWidget->setEditable(true);
if (editable)
testWidget->setEditText("FOO");
testWidget->insertItem(insertIndex, itemLabel);
- QCOMPARE(testWidget->count(), initialItems.count() + 1);
+ QCOMPARE(testWidget->count(), initialItems.size() + 1);
QCOMPARE(testWidget->itemText(expectedIndex), itemLabel);
if (editable)
@@ -1362,21 +1365,21 @@ void tst_QComboBox::textpixmapdata()
QFETCH(IconList, icons);
QFETCH(VariantList, variant);
- QVERIFY(text.count() == icons.count() && text.count() == variant.count());
+ QVERIFY(text.size() == icons.size() && text.size() == variant.size());
TestWidget topLevel;
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QComboBox *testWidget = topLevel.comboBox();
- for (int i = 0; i<text.count(); ++i) {
+ for (int i = 0; i<text.size(); ++i) {
testWidget->insertItem(i, text.at(i));
testWidget->setItemIcon(i, icons.at(i));
testWidget->setItemData(i, variant.at(i), Qt::UserRole);
}
- QCOMPARE(testWidget->count(), text.count());
+ QCOMPARE(testWidget->count(), text.size());
- for (int i = 0; i<text.count(); ++i) {
+ for (int i = 0; i<text.size(); ++i) {
QIcon icon = testWidget->itemIcon(i);
QCOMPARE(icon.cacheKey(), icons.at(i).cacheKey());
QPixmap original = icons.at(i).pixmap(1024);
@@ -1384,7 +1387,7 @@ void tst_QComboBox::textpixmapdata()
QCOMPARE(pixmap.toImage(), original.toImage());
}
- for (int i = 0; i<text.count(); ++i) {
+ for (int i = 0; i<text.size(); ++i) {
QCOMPARE(testWidget->itemText(i), text.at(i));
// ### we should test icons/pixmap as well, but I need to fix the api mismatch first
QCOMPARE(testWidget->itemData(i, Qt::UserRole), variant.at(i));
@@ -1494,7 +1497,7 @@ void tst_QComboBox::currentTextChanged()
QCOMPARE(testWidget->currentIndex(), 0);
spy.clear();
testWidget->setCurrentText(QString("bar"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("bar"));
// set text not in list
@@ -1503,10 +1506,10 @@ void tst_QComboBox::currentTextChanged()
spy.clear();
testWidget->setCurrentText(QString("qt"));
if (editable) {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("qt"));
} else {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
// item changed
@@ -1514,12 +1517,12 @@ void tst_QComboBox::currentTextChanged()
QCOMPARE(testWidget->currentIndex(), 0);
spy.clear();
testWidget->setItemText(0, QString("ape"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("ape"));
// change it back
spy.clear();
testWidget->setItemText(0, QString("foo"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("foo"));
}
@@ -1544,13 +1547,13 @@ void tst_QComboBox::editTextChanged()
QCOMPARE(testWidget->currentIndex(), 0);
testWidget->setCurrentIndex(0);
QCOMPARE(testWidget->currentIndex(), 0);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// no signal should be sent when changing to other index because we are not editable
QCOMPARE(testWidget->currentIndex(), 0);
testWidget->setCurrentIndex(1);
QCOMPARE(testWidget->currentIndex(), 1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// now set to editable and reset current index
testWidget->setEditable(true);
@@ -1562,20 +1565,20 @@ void tst_QComboBox::editTextChanged()
QCOMPARE(testWidget->currentIndex(), 0);
testWidget->setCurrentIndex(0);
QCOMPARE(testWidget->currentIndex(), 0);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// signal should be sent when changing to other index
QCOMPARE(testWidget->currentIndex(), 0);
testWidget->setCurrentIndex(1);
QCOMPARE(testWidget->currentIndex(), 1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("bar"));
// insert some keys and notice they are all signaled
spy.clear();
QTest::keyClicks(testWidget, "bingo");
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
QCOMPARE(qvariant_cast<QString>(spy.at(4).at(0)), QString("barbingo"));
}
@@ -1742,7 +1745,7 @@ void tst_QComboBox::setMaxCount()
// insert 5 items at pos 2. Make sure only two get inserted
QSignalSpy spy(box.model(), SIGNAL(rowsInserted(QModelIndex,int,int)));
box.insertItems(2, items);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(1).toInt(), 2);
QCOMPARE(spy.at(0).at(2).toInt(), 3);
@@ -2016,7 +2019,7 @@ void tst_QComboBox::flaggedItems()
if (editable)
comboBox.lineEdit()->selectAll();
- for (int i = 0; i < keyMovementList.count(); ++i) {
+ for (int i = 0; i < keyMovementList.size(); ++i) {
Qt::Key key = keyMovementList[i];
QTest::keyClick(&comboBox, key);
}
@@ -2237,7 +2240,7 @@ void tst_QComboBox::separatorItem()
box.addItems(items);
foreach(int index, separators)
box.insertSeparator(index);
- QCOMPARE(box.count(), (items.count() + separators.count()));
+ QCOMPARE(box.count(), (items.size() + separators.size()));
for (int i = 0, s = 0; i < box.count(); ++i) {
if (i == separators.at(s)) {
QCOMPARE(box.itemText(i), QString());
@@ -2445,7 +2448,7 @@ void tst_QComboBox::task247863_keyBoardSelection()
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter);
QCOMPARE(combo.currentText(), QLatin1String("222"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QComboBox::task220195_keyBoardSelection2()
@@ -2720,16 +2723,16 @@ void tst_QComboBox::resetModel()
QComboBox cb;
StringListModel model({"1", "2"});
QSignalSpy spy(&cb, &QComboBox::currentIndexChanged);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(cb.currentIndex(), -1); //no selection
cb.setModel(&model);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(cb.currentIndex(), 0); //first item selected
model.reset();
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(cb.currentIndex(), 0); //first item selected
}
@@ -2810,10 +2813,10 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
QApplication::processEvents();
QTRY_VERIFY(cb.hasFocus());
QTest::keyClick(static_cast<QWidget *>(0), '1');
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
edit.setFocus();
QTRY_VERIFY(edit.hasFocus());
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
}
void tst_QComboBox::maxVisibleItems_data()
@@ -3231,11 +3234,11 @@ void tst_QComboBox::respectChangedOwnershipOfItemView()
QTableView *v2 = new QTableView(&box1);
box1.setView(v2); // Here we do not expect v1 to be deleted
QApplication::processEvents();
- QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy1.size(), 0);
QSignalSpy spy2(v2, SIGNAL(destroyed()));
box1.setView(v1);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
}
void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated()
@@ -3263,7 +3266,7 @@ void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated()
if (scroller->isVisible()) {
QSignalSpy doScrollSpy(scroller, SIGNAL(doScroll(int)));
QTest::mouseMove(scroller, QPoint(5, 5), 500);
- QTRY_VERIFY(doScrollSpy.count() > 0);
+ QTRY_VERIFY(doScrollSpy.size() > 0);
}
}
}
@@ -3420,7 +3423,7 @@ void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex()
cbox.setCompleter(completer);
QSignalSpy spy(&cbox, SIGNAL(activated(int)));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
cbox.move(200, 200);
cbox.show();
QApplication::setActiveWindow(&cbox);
@@ -3584,7 +3587,7 @@ void tst_QComboBox::buttonPressKeys()
const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
->themeHint(QPlatformTheme::ButtonPressKeys)
.value<QList<Qt::Key>>();
- for (int i = 0; i < buttonPressKeys.length(); ++i) {
+ for (int i = 0; i < buttonPressKeys.size(); ++i) {
QTest::keyClick(&comboBox, buttonPressKeys[i]);
// On some platforms, a window will not be immediately visible,
// but take some event-loop iterations to complete.
@@ -3614,11 +3617,11 @@ void tst_QComboBox::clearModel()
model.setStringList({});
- QCOMPARE(indexSpy.count(), 1);
+ QCOMPARE(indexSpy.size(), 1);
const int index = indexSpy.takeFirst().at(0).toInt();
QCOMPARE(index, -1);
- QCOMPARE(textSpy.count(), 1);
+ QCOMPARE(textSpy.size(), 1);
const QString text = textSpy.takeFirst().at(0).toString();
QCOMPARE(text, QString());
@@ -3626,5 +3629,58 @@ void tst_QComboBox::clearModel()
QCOMPARE(combo.currentText(), QString());
}
+void tst_QComboBox::cancelClosesPopupNotDialog()
+{
+ if (QGuiApplication::platformName() == "offscreen")
+ QSKIP("The offscreen platform plugin doesn't activate popups.");
+
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
+ QDialog dialog;
+ QComboBox combobox;
+ combobox.addItems({"A", "B", "C"});
+
+ std::unique_ptr<QShortcut> shortcut(new QShortcut(QKeySequence::Cancel, &dialog));
+ bool shortcutTriggered = false;
+ connect(shortcut.get(), &QShortcut::activated, [&shortcutTriggered]{
+ shortcutTriggered = true;
+ });
+
+ QVBoxLayout vbox;
+ vbox.addWidget(&combobox);
+ dialog.setLayout(&vbox);
+
+ dialog.show();
+ QVERIFY(QTest::qWaitForWindowActive(&dialog));
+
+ // while the combobox is closed, escape key triggers the shortcut
+ QTest::keyClick(dialog.window()->windowHandle(), Qt::Key_Escape);
+ QVERIFY(shortcutTriggered);
+ shortcutTriggered = false;
+
+ combobox.showPopup();
+ QTRY_VERIFY(combobox.view()->isVisible());
+
+ // an open combobox overrides and accepts the escape key to close
+ QTest::keyClick(dialog.window()->windowHandle(), Qt::Key_Escape);
+ QVERIFY(!shortcutTriggered);
+ shortcutTriggered = false;
+ QTRY_VERIFY(!combobox.view()->isVisible());
+ QVERIFY(dialog.isVisible());
+
+ // once closed, escape key triggers the shortcut again
+ QTest::keyClick(dialog.window()->windowHandle(), Qt::Key_Escape);
+ QVERIFY(shortcutTriggered);
+ shortcutTriggered = false;
+ QVERIFY(dialog.isVisible());
+
+ shortcut.reset();
+
+ // without shortcut, escape key propagates to the parent
+ QTest::keyClick(dialog.window()->windowHandle(), Qt::Key_Escape);
+ QVERIFY(!dialog.isVisible());
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index 354a5f182f..972934a4ce 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -524,13 +524,24 @@ void tst_QDateTimeEdit::constructor_qdate()
testWidget->hide();
- QDateTimeEdit dte(parameter);
- dte.show();
- QCOMPARE(dte.dateTime(), displayDateTime);
- QCOMPARE(dte.minimumDate(), minimumDate);
- QCOMPARE(dte.minimumTime(), minimumTime);
- QCOMPARE(dte.maximumDate(), maximumDate);
- QCOMPARE(dte.maximumTime(), maximumTime);
+ {
+ QDateTimeEdit dte(parameter);
+ dte.show();
+ QCOMPARE(dte.dateTime(), displayDateTime);
+ QCOMPARE(dte.minimumDate(), minimumDate);
+ QCOMPARE(dte.minimumTime(), minimumTime);
+ QCOMPARE(dte.maximumDate(), maximumDate);
+ QCOMPARE(dte.maximumTime(), maximumTime);
+ }
+ {
+ QDateEdit dte(parameter);
+ dte.show();
+ QCOMPARE(dte.date(), displayDateTime.date());
+ QCOMPARE(dte.minimumDate(), minimumDate);
+ QCOMPARE(dte.minimumTime(), minimumTime);
+ QCOMPARE(dte.maximumDate(), maximumDate);
+ QCOMPARE(dte.maximumTime(), maximumTime);
+ }
}
void tst_QDateTimeEdit::constructor_qtime_data()
@@ -564,13 +575,24 @@ void tst_QDateTimeEdit::constructor_qtime()
testWidget->hide();
- QDateTimeEdit dte(parameter);
- dte.show();
- QCOMPARE(dte.dateTime(), displayDateTime);
- QCOMPARE(dte.minimumDate(), minimumDate);
- QCOMPARE(dte.minimumTime(), minimumTime);
- QCOMPARE(dte.maximumDate(), maximumDate);
- QCOMPARE(dte.maximumTime(), maximumTime);
+ {
+ QDateTimeEdit dte(parameter);
+ dte.show();
+ QCOMPARE(dte.dateTime(), displayDateTime);
+ QCOMPARE(dte.minimumDate(), minimumDate);
+ QCOMPARE(dte.minimumTime(), minimumTime);
+ QCOMPARE(dte.maximumDate(), maximumDate);
+ QCOMPARE(dte.maximumTime(), maximumTime);
+ }
+ {
+ QTimeEdit dte(parameter);
+ dte.show();
+ QCOMPARE(dte.time(), displayDateTime.time());
+ QCOMPARE(dte.minimumDate(), minimumDate);
+ QCOMPARE(dte.minimumTime(), minimumTime);
+ QCOMPARE(dte.maximumDate(), maximumDate);
+ QCOMPARE(dte.maximumTime(), maximumTime);
+ }
}
void tst_QDateTimeEdit::minimumDate_data()
@@ -1137,7 +1159,7 @@ void tst_QDateTimeEdit::enterKey()
// we include this test so a change to the behaviour can't go unnoticed.
QSignalSpy enterSpy(testWidget, SIGNAL(dateChanged(QDate)));
QTest::keyClick(testWidget, Qt::Key_Enter);
- QCOMPARE(enterSpy.count(), 1);
+ QCOMPARE(enterSpy.size(), 1);
QVariantList list = enterSpy.takeFirst();
QCOMPARE(list.at(0).toDate(), QDate(2004, 5, 9));
}
@@ -2212,7 +2234,7 @@ void tst_QDateTimeEdit::dateSignalChecking()
QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime)));
testWidget->setDate(newDate);
- QCOMPARE(dateSpy.count(), timesEmitted);
+ QCOMPARE(dateSpy.size(), timesEmitted);
if (timesEmitted > 0) {
QList<QVariant> list = dateSpy.takeFirst();
@@ -2220,8 +2242,8 @@ void tst_QDateTimeEdit::dateSignalChecking()
d = qvariant_cast<QDate>(list.at(0));
QCOMPARE(d, newDate);
}
- QCOMPARE(dateTimeSpy.count(), timesEmitted);
- QCOMPARE(timeSpy.count(), 0);
+ QCOMPARE(dateTimeSpy.size(), timesEmitted);
+ QCOMPARE(timeSpy.size(), 0);
}
void tst_QDateTimeEdit::timeSignalChecking_data()
@@ -2248,7 +2270,7 @@ void tst_QDateTimeEdit::timeSignalChecking()
QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime)));
testWidget->setTime(newTime);
- QCOMPARE(timeSpy.count(), timesEmitted);
+ QCOMPARE(timeSpy.size(), timesEmitted);
if (timesEmitted > 0) {
QList<QVariant> list = timeSpy.takeFirst();
@@ -2256,8 +2278,8 @@ void tst_QDateTimeEdit::timeSignalChecking()
t = qvariant_cast<QTime>(list.at(0));
QCOMPARE(t, newTime);
}
- QCOMPARE(dateTimeSpy.count(), timesEmitted);
- QCOMPARE(dateSpy.count(), 0);
+ QCOMPARE(dateTimeSpy.size(), timesEmitted);
+ QCOMPARE(dateSpy.size(), 0);
}
void tst_QDateTimeEdit::dateTimeSignalChecking_data()
@@ -2298,7 +2320,7 @@ void tst_QDateTimeEdit::dateTimeSignalChecking()
QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(QDateTime)));
testWidget->setDateTime(newDateTime);
- QCOMPARE(dateSpy.count(), timesDateEmitted);
+ QCOMPARE(dateSpy.size(), timesDateEmitted);
if (timesDateEmitted > 0) {
QCOMPARE(timesDateEmitted, 1);
QList<QVariant> list = dateSpy.takeFirst();
@@ -2306,14 +2328,14 @@ void tst_QDateTimeEdit::dateTimeSignalChecking()
d = qvariant_cast<QDate>(list.at(0));
QCOMPARE(d, newDateTime.date());
}
- QCOMPARE(timeSpy.count(), timesTimeEmitted);
+ QCOMPARE(timeSpy.size(), timesTimeEmitted);
if (timesTimeEmitted > 0) {
QList<QVariant> list = timeSpy.takeFirst();
QTime t;
t = qvariant_cast<QTime>(list.at(0));
QCOMPARE(t, newDateTime.time());
}
- QCOMPARE(dateTimeSpy.count(), timesDateTimeEmitted);
+ QCOMPARE(dateTimeSpy.size(), timesDateTimeEmitted);
if (timesDateTimeEmitted > 0) {
QList<QVariant> list = dateTimeSpy.takeFirst();
QDateTime dt;
@@ -3177,22 +3199,22 @@ void tst_QDateTimeEdit::task149097()
testWidget->setDisplayFormat("yyyy/MM/dd hh:mm:ss");
testWidget->setDateTime(QDateTime(QDate(2001, 02, 03), QTime(5, 1, 2)));
// QTest::keyClick(testWidget, Qt::Key_Enter);
- QCOMPARE(dtSpy.count(), 1);
- QCOMPARE(dSpy.count(), 1);
- QCOMPARE(tSpy.count(), 1);
+ QCOMPARE(dtSpy.size(), 1);
+ QCOMPARE(dSpy.size(), 1);
+ QCOMPARE(tSpy.size(), 1);
testWidget->setCurrentSection(QDateTimeEdit::YearSection);
testWidget->stepBy(1);
- QCOMPARE(dtSpy.count(), 2);
- QCOMPARE(dSpy.count(), 2);
- QCOMPARE(tSpy.count(), 1);
+ QCOMPARE(dtSpy.size(), 2);
+ QCOMPARE(dSpy.size(), 2);
+ QCOMPARE(tSpy.size(), 1);
testWidget->setCurrentSection(QDateTimeEdit::MinuteSection);
testWidget->stepBy(1);
- QCOMPARE(dtSpy.count(), 3);
- QCOMPARE(dSpy.count(), 2);
- QCOMPARE(tSpy.count(), 2);
+ QCOMPARE(dtSpy.size(), 3);
+ QCOMPARE(dSpy.size(), 2);
+ QCOMPARE(tSpy.size(), 2);
}
void tst_QDateTimeEdit::task148725()
@@ -4570,12 +4592,12 @@ void tst_QDateTimeEdit::stepModifierPressAndHold()
QStyle::CC_SpinBox, &spinBoxStyleOption, subControl, &edit);
QTest::mousePress(&edit, Qt::LeftButton, modifiers, buttonRect.center());
- QTRY_VERIFY(spy.length() >= 3);
+ QTRY_VERIFY(spy.size() >= 3);
QTest::mouseRelease(&edit, Qt::LeftButton, modifiers, buttonRect.center());
const auto value = spy.last().at(0);
QVERIFY(value.userType() == QMetaType::QDate);
- const QDate expectedDate = startDate.addYears(spy.length() *
+ const QDate expectedDate = startDate.addYears(spy.size() *
expectedStepModifier);
QCOMPARE(value.toDate(), expectedDate);
}
diff --git a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
index 3008714576..1d8c970ef4 100644
--- a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
+++ b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
@@ -52,14 +52,14 @@ void tst_QDial::valueChanged()
dial.setMaximum(100);
QSignalSpy spy(&dial, SIGNAL(valueChanged(int)));
dial.setValue(50);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
dial.setValue(25);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
// repeat!
dial.setValue(25);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QDial::sliderMoved()
@@ -88,8 +88,8 @@ void tst_QDial::sliderMoved()
QMouseEvent moveevent(QEvent::MouseMove, init, dial.mapToGlobal(init),
Qt::LeftButton, Qt::LeftButton, {});
qApp->sendEvent(&dial, &moveevent);
- QCOMPARE( sliderspy.count(), 1);
- QCOMPARE( valuespy.count(), 0);
+ QCOMPARE( sliderspy.size(), 1);
+ QCOMPARE( valuespy.size(), 0);
}
@@ -98,14 +98,14 @@ void tst_QDial::sliderMoved()
QMouseEvent moveevent(QEvent::MouseMove, init, dial.mapToGlobal(init),
Qt::LeftButton, Qt::LeftButton, {});
qApp->sendEvent(&dial, &moveevent);
- QCOMPARE( sliderspy.count(), 2);
- QCOMPARE( valuespy.count(), 0);
+ QCOMPARE( sliderspy.size(), 2);
+ QCOMPARE( valuespy.size(), 0);
}
QMouseEvent releaseevent(QEvent::MouseButtonRelease, init, dial.mapToGlobal(init),
Qt::LeftButton, Qt::LeftButton, {});
qApp->sendEvent(&dial, &releaseevent);
- QCOMPARE( valuespy.count(), 1); // valuechanged signal should be called at this point
+ QCOMPARE( valuespy.size(), 1); // valuechanged signal should be called at this point
}
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
index c2a9f27295..df26b4c5da 100644
--- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
@@ -97,7 +97,7 @@ void tst_QDialogButtonBox::testConstructor1()
QDialogButtonBox buttonbox;
QCOMPARE(buttonbox.orientation(), Qt::Horizontal);
- QCOMPARE(buttonbox.buttons().count(), 0);
+ QCOMPARE(buttonbox.buttons().size(), 0);
}
void tst_QDialogButtonBox::layoutReuse()
@@ -130,7 +130,7 @@ void tst_QDialogButtonBox::testConstructor2()
QDialogButtonBox buttonBox(orient);
QCOMPARE(buttonBox.orientation(), orient);
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
}
void tst_QDialogButtonBox::testConstructor3_data()
@@ -167,7 +167,7 @@ void tst_QDialogButtonBox::testConstructor3()
QDialogButtonBox buttonBox(buttons, (Qt::Orientation)orientation);
QCOMPARE(int(buttonBox.orientation()), orientation);
- QTEST(int(buttonBox.buttons().count()), "buttonCount");
+ QTEST(int(buttonBox.buttons().size()), "buttonCount");
}
void tst_QDialogButtonBox::testConstructor4_data()
@@ -202,7 +202,7 @@ void tst_QDialogButtonBox::testConstructor4()
QDialogButtonBox buttonBox(buttons);
QCOMPARE(buttonBox.orientation(), Qt::Horizontal);
- QTEST(int(buttonBox.buttons().count()), "buttonCount");
+ QTEST(int(buttonBox.buttons().size()), "buttonCount");
}
void tst_QDialogButtonBox::setOrientation_data()
@@ -265,12 +265,12 @@ void tst_QDialogButtonBox::addButton1()
{
QFETCH(QDialogButtonBox::ButtonRole, role);
QDialogButtonBox buttonBox;
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
QPushButton *button = new QPushButton();
buttonBox.addButton(button, role);
- QTEST(int(buttonBox.buttons().count()), "totalCount");
+ QTEST(int(buttonBox.buttons().size()), "totalCount");
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
- QTEST(int(children.count()), "totalCount");
+ QTEST(int(children.size()), "totalCount");
delete button;
}
@@ -293,11 +293,11 @@ void tst_QDialogButtonBox::addButton2()
QFETCH(QString, text);
QFETCH(QDialogButtonBox::ButtonRole, role);
QDialogButtonBox buttonBox;
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
buttonBox.addButton(text, role);
- QTEST(int(buttonBox.buttons().count()), "totalCount");
+ QTEST(int(buttonBox.buttons().size()), "totalCount");
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
- QTEST(int(children.count()), "totalCount");
+ QTEST(int(children.size()), "totalCount");
}
void tst_QDialogButtonBox::addButton3_data()
@@ -320,11 +320,11 @@ void tst_QDialogButtonBox::addButton3()
{
QFETCH(QDialogButtonBox::StandardButton, button);
QDialogButtonBox buttonBox;
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
buttonBox.addButton(button);
- QTEST(int(buttonBox.buttons().count()), "totalCount");
+ QTEST(int(buttonBox.buttons().size()), "totalCount");
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
- QTEST(int(children.count()), "totalCount");
+ QTEST(int(children.size()), "totalCount");
}
void tst_QDialogButtonBox::clear_data()
@@ -344,9 +344,9 @@ void tst_QDialogButtonBox::clear()
for (int i = 1; i < rolesToAdd; ++i)
buttonBox.addButton("Happy", QDialogButtonBox::ButtonRole(i));
buttonBox.clear();
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
- QCOMPARE(children.count(), 0);
+ QCOMPARE(children.size(), 0);
}
void tst_QDialogButtonBox::removeButton_data()
@@ -362,31 +362,31 @@ void tst_QDialogButtonBox::removeButton()
QFETCH(QDialogButtonBox::ButtonRole, roleToAdd);
QDialogButtonBox buttonBox;
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
QPushButton *button = new QPushButton("RemoveButton test");
buttonBox.addButton(button, roleToAdd);
- QTEST(int(buttonBox.buttons().count()), "expectedCount");
+ QTEST(int(buttonBox.buttons().size()), "expectedCount");
buttonBox.removeButton(button);
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
delete button;
}
void tst_QDialogButtonBox::testDelete()
{
QDialogButtonBox buttonBox;
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
QPushButton *deleteMe = new QPushButton("Happy");
buttonBox.addButton(deleteMe, QDialogButtonBox::HelpRole);
- QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttons().size(), 1);
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
- QCOMPARE(children.count(), 1);
+ QCOMPARE(children.size(), 1);
delete deleteMe;
children = buttonBox.findChildren<QAbstractButton *>();
- QCOMPARE(children.count(), 0);
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(children.size(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
}
class ObjectDeleter : public QObject
@@ -408,7 +408,7 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835()
{
{
QDialogButtonBox buttonBox;
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
QSignalSpy buttonClickedSpy(&buttonBox, &QDialogButtonBox::clicked);
QVERIFY(buttonClickedSpy.isValid());
@@ -417,21 +417,21 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835()
QVERIFY(buttonBoxAcceptedSpy.isValid());
QPushButton *button = buttonBox.addButton("Test", QDialogButtonBox::AcceptRole);
- QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttons().size(), 1);
ObjectDeleter objectDeleter;
connect(&buttonBox, &QDialogButtonBox::clicked, &objectDeleter, &ObjectDeleter::deleteButton);
button->click();
- QCOMPARE(buttonBox.buttons().count(), 0);
- QCOMPARE(buttonClickedSpy.count(), 1);
- QCOMPARE(buttonBoxAcceptedSpy.count(), 1);
+ QCOMPARE(buttonBox.buttons().size(), 0);
+ QCOMPARE(buttonClickedSpy.size(), 1);
+ QCOMPARE(buttonBoxAcceptedSpy.size(), 1);
}
{
QPointer<QDialogButtonBox> buttonBox(new QDialogButtonBox);
- QCOMPARE(buttonBox->buttons().count(), 0);
+ QCOMPARE(buttonBox->buttons().size(), 0);
QSignalSpy buttonClickedSpy(buttonBox.data(), &QDialogButtonBox::clicked);
QVERIFY(buttonClickedSpy.isValid());
@@ -440,7 +440,7 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835()
QVERIFY(buttonBoxAcceptedSpy.isValid());
QPushButton *button = buttonBox->addButton("Test", QDialogButtonBox::AcceptRole);
- QCOMPARE(buttonBox->buttons().count(), 1);
+ QCOMPARE(buttonBox->buttons().size(), 1);
ObjectDeleter objectDeleter;
connect(buttonBox.data(), &QDialogButtonBox::clicked, &objectDeleter, &ObjectDeleter::deleteSender);
@@ -448,8 +448,8 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835()
button->click();
QVERIFY(buttonBox.isNull());
- QCOMPARE(buttonClickedSpy.count(), 1);
- QCOMPARE(buttonBoxAcceptedSpy.count(), 0);
+ QCOMPARE(buttonClickedSpy.size(), 1);
+ QCOMPARE(buttonBoxAcceptedSpy.size(), 0);
}
}
@@ -457,24 +457,24 @@ void tst_QDialogButtonBox::testMultipleAdd()
{
// Add a button into the thing multiple times.
QDialogButtonBox buttonBox;
- QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonBox.buttons().size(), 0);
QPushButton *button = new QPushButton("Foo away");
buttonBox.addButton(button, QDialogButtonBox::AcceptRole);
- QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttons().size(), 1);
QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::AcceptRole);
buttonBox.addButton(button, QDialogButtonBox::AcceptRole);
- QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttons().size(), 1);
QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::AcceptRole);
// Add it again with a different role
buttonBox.addButton(button, QDialogButtonBox::RejectRole);
- QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttons().size(), 1);
QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::RejectRole);
// Add it as an "invalid" role
buttonBox.addButton(button, QDialogButtonBox::InvalidRole);
- QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttons().size(), 1);
QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::RejectRole);
}
@@ -594,13 +594,13 @@ void tst_QDialogButtonBox::testSignals()
if (clickMe)
clickMe->click();
- QTRY_COMPARE(clicked2.count(), clicked2Count);
- if (clicked2.count() > 0)
+ QTRY_COMPARE(clicked2.size(), clicked2Count);
+ if (clicked2.size() > 0)
QCOMPARE(qvariant_cast<QAbstractButton *>(clicked2.at(0).at(0)), clickMe);
- QTEST(int(accept.count()), "acceptCount");
- QTEST(int(reject.count()), "rejectCount");
- QTEST(int(helpRequested.count()), "helpRequestedCount");
+ QTEST(int(accept.size()), "acceptCount");
+ QTEST(int(reject.size()), "rejectCount");
+ QTEST(int(helpRequested.size()), "helpRequestedCount");
}
void tst_QDialogButtonBox::testSignalOrder()
@@ -756,7 +756,7 @@ void tst_QDialogButtonBox::testRemove()
button->click();
QTest::qWait(100);
- QCOMPARE(clicked.count(), 0);
+ QCOMPARE(clicked.size(), 0);
delete button;
}
@@ -818,7 +818,7 @@ void tst_QDialogButtonBox::task191642_default()
QVERIFY(QTest::qWaitForWindowActive(&dlg));
QVERIFY(def->isDefault());
QTest::keyPress( &dlg, Qt::Key_Enter );
- QCOMPARE(clicked.count(), 1);
+ QCOMPARE(clicked.size(), 1);
}
void tst_QDialogButtonBox::testDeletedStandardButton()
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 2229f5da55..0456573b96 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -16,11 +16,7 @@
#include <QtGui/QPainter>
#include <QLabel>
-#ifdef QT_BUILD_INTERNAL
-QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(lcQpaDockWidgets, "qt.widgets.dockwidgets");
-QT_END_NAMESPACE
-#endif
+Q_LOGGING_CATEGORY(lcTestDockWidget, "qt.widgets.tests.qdockwidget")
bool hasFeature(QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature)
{ return (dockwidget->features() & feature) == feature; }
@@ -76,6 +72,9 @@ private slots:
// test closing and deleting consistency
void closeAndDelete();
+ // test save and restore consistency
+ void saveAndRestore();
+
private:
// helpers and consts for dockPermissions, hideAndShow, closeAndDelete
#ifdef QT_BUILD_INTERNAL
@@ -271,12 +270,12 @@ void tst_QDockWidget::features()
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*(static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData())),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
setFeature(&dw, QDockWidget::DockWidgetClosable);
@@ -284,12 +283,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
setFeature(&dw, QDockWidget::DockWidgetMovable, false);
@@ -297,12 +296,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
setFeature(&dw, QDockWidget::DockWidgetMovable);
@@ -310,12 +309,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
setFeature(&dw, QDockWidget::DockWidgetFloatable, false);
@@ -323,12 +322,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
setFeature(&dw, QDockWidget::DockWidgetFloatable);
@@ -336,12 +335,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
// set all at once
@@ -350,12 +349,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
dw.setFeatures(QDockWidget::DockWidgetClosable);
@@ -363,12 +362,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
dw.setFeatures(allDockWidgetFeatures);
@@ -376,12 +375,12 @@ void tst_QDockWidget::features()
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
(int)dw.features());
spy.clear();
dw.setFeatures(dw.features());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
}
@@ -408,20 +407,20 @@ void tst_QDockWidget::setFloating()
QVERIFY((dockedPosition - floatingPosition).manhattanLength() < 50);
QVERIFY(dw.isFloating());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
spy.clear();
dw.setFloating(dw.isFloating());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
dw.setFloating(false);
QVERIFY(!dw.isFloating());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
spy.clear();
dw.setFloating(dw.isFloating());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
}
@@ -445,12 +444,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw.setAllowedAreas(Qt::RightDockWidgetArea);
QCOMPARE(dw.allowedAreas(), Qt::RightDockWidgetArea);
@@ -458,12 +457,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw.setAllowedAreas(Qt::TopDockWidgetArea);
QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea);
@@ -471,12 +470,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw.setAllowedAreas(Qt::BottomDockWidgetArea);
QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea);
@@ -484,12 +483,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// multiple dock window areas
dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
@@ -499,12 +498,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
//QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw.setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
@@ -513,12 +512,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
//QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea);
QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea);
@@ -527,12 +526,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
//QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
//dw.setAllowedAreas(Qt::BottomDockWidgetArea | Qt::FloatingDockWidgetArea);
dw.setAllowedAreas(Qt::BottomDockWidgetArea);
@@ -542,12 +541,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
//QVERIFY(dw.isAreaAllowed(Qt::FloatingDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw.setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
@@ -556,12 +555,12 @@ void tst_QDockWidget::allowedAreas()
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
//QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
dw.allowedAreas());
spy.clear();
dw.setAllowedAreas(dw.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QDockWidget::toggleViewAction()
@@ -589,65 +588,65 @@ void tst_QDockWidget::visibilityChanged()
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
mw.show();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
spy.clear();
dw.hide();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), false);
spy.clear();
dw.hide();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw.show();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
spy.clear();
dw.show();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QDockWidget dw2;
mw.tabifyDockWidget(&dw, &dw2);
dw2.show();
dw2.raise();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), false);
spy.clear();
dw2.hide();
qApp->processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
spy.clear();
dw2.show();
dw2.raise();
qApp->processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), false);
spy.clear();
dw.raise();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
spy.clear();
dw.raise();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
dw2.raise();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), false);
spy.clear();
dw2.raise();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
mw.addDockWidget(Qt::RightDockWidgetArea, &dw2);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
}
@@ -701,56 +700,56 @@ void tst_QDockWidget::dockLocationChanged()
QSignalSpy spy(&dw, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)));
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::LeftDockWidgetArea);
spy.clear();
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::LeftDockWidgetArea);
spy.clear();
mw.addDockWidget(Qt::RightDockWidgetArea, &dw);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::RightDockWidgetArea);
spy.clear();
mw.removeDockWidget(&dw);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QDockWidget dw2;
dw2.setObjectName("dock2");
mw.addDockWidget(Qt::TopDockWidgetArea, &dw2);
mw.tabifyDockWidget(&dw2, &dw);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::TopDockWidgetArea);
spy.clear();
mw.splitDockWidget(&dw2, &dw, Qt::Horizontal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::TopDockWidgetArea);
spy.clear();
dw.setFloating(true);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::NoDockWidgetArea);
spy.clear();
dw.setFloating(false);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::TopDockWidgetArea);
spy.clear();
QByteArray ba = mw.saveState();
mw.restoreState(ba);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::TopDockWidgetArea);
}
@@ -1021,9 +1020,9 @@ void tst_QDockWidget::task258459_visibilityChanged()
QSignalSpy spy2(&dock2, SIGNAL(visibilityChanged(bool)));
win.show();
QVERIFY(QTest::qWaitForWindowActive(&win));
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
QCOMPARE(spy1.first().first().toBool(), false); //dock1 is invisible
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible
}
@@ -1141,13 +1140,17 @@ void tst_QDockWidget::createTestWidgets(QMainWindow* &mainWindow, QPointer<QWidg
mainWindow->setDockOptions(QMainWindow::AllowTabbedDocks | QMainWindow::GroupedDragging);
mainWindow->move(m_topLeft);
+ const int minWidth = QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight);
+ const QSize minSize(minWidth, 2 * minWidth);
d1 = new QDockWidget(mainWindow);
+ d1->setMinimumSize(minSize);
d1->setWindowTitle("I am D1");
d1->setObjectName("D1");
d1->setFeatures(QDockWidget::DockWidgetFeatureMask);
d1->setAllowedAreas(Qt::DockWidgetArea::AllDockWidgetAreas);
d2 = new QDockWidget(mainWindow);
+ d2->setMinimumSize(minSize);
d2->setWindowTitle("I am D2");
d2->setObjectName("D2");
d2->setFeatures(QDockWidget::DockWidgetFeatureMask);
@@ -1181,12 +1184,12 @@ void tst_QDockWidget::moveDockWidget(QDockWidget* dw, QPoint to, QPoint from) co
// move and log
const QPoint source = dw->mapFromGlobal(from);
const QPoint target = dw->mapFromGlobal(to);
- qCDebug(lcQpaDockWidgets) << "Move" << dw->objectName() << "from" << source;
- qCDebug(lcQpaDockWidgets) << "Move" << dw->objectName() << "from" << from;
+ qCDebug(lcTestDockWidget) << "Move" << dw->objectName() << "from" << source;
+ qCDebug(lcTestDockWidget) << "Move" << dw->objectName() << "from" << from;
QTest::mousePress(dw, Qt::LeftButton, Qt::KeyboardModifiers(), source);
QTest::mouseMove(dw, target);
- qCDebug(lcQpaDockWidgets) << "Move" << dw->objectName() << "to" << target;
- qCDebug(lcQpaDockWidgets) << "Move" << dw->objectName() << "to" << to;
+ qCDebug(lcTestDockWidget) << "Move" << dw->objectName() << "to" << target;
+ qCDebug(lcTestDockWidget) << "Move" << dw->objectName() << "to" << to;
QTest::mouseRelease(dw, Qt::LeftButton, Qt::KeyboardModifiers(), target);
QTest::qWait(waitingTime);
@@ -1229,21 +1232,33 @@ void tst_QDockWidget::unplugAndResize(QMainWindow* mainWindow, QDockWidget* dw,
return;
}
+ // Remember size for comparison with unplugged object
+#ifdef Q_OS_LINUX
+ const int pluggedWidth = dw->width();
+ const int pluggedHeight = dw->height();
+#endif
+
// unplug and resize a dock Widget
- qCDebug(lcQpaDockWidgets) << "*** unplug and resize" << dw->objectName();
+ qCDebug(lcTestDockWidget) << "*** unplug and resize" << dw->objectName();
QPoint pos1 = dw->mapToGlobal(dw->rect().center());
pos1.rx() += mx;
pos1.ry() += my;
moveDockWidget(dw, pos1, dw->mapToGlobal(dw->rect().center()));
- //QTest::mousePress(dw, Qt::LeftButton, Qt::KeyboardModifiers(), dw->mapFromGlobal(pos1));
QTRY_VERIFY(dw->isFloating());
- qCDebug(lcQpaDockWidgets) << "Resizing" << dw->objectName() << "to" << size;
+ // Unplugged object's size may differ max. by 2x frame size
+#ifdef Q_OS_LINUX
+ const int xMargin = 2 * dw->frameSize().width();
+ const int yMargin = 2 * dw->frameSize().height();
+ QVERIFY(dw->height() - pluggedHeight <= xMargin);
+ QVERIFY(dw->width() - pluggedWidth <= yMargin);
+#endif
+
+ qCDebug(lcTestDockWidget) << "Resizing" << dw->objectName() << "to" << size;
dw->setFixedSize(size);
QTest::qWait(waitingTime);
- qCDebug(lcQpaDockWidgets) << "Move" << dw->objectName() << "to its home" << dw->mapFromGlobal(home);
+ qCDebug(lcTestDockWidget) << "Move" << dw->objectName() << "to its home" << dw->mapFromGlobal(home);
dw->move(home);
- //moveDockWidget(dw, home);
}
bool tst_QDockWidget::checkFloatingTabs(QMainWindow* mainWindow, QPointer<QDockWidgetGroupWindow> &ftabs, const QList<QDockWidget*> &dwList) const
@@ -1253,39 +1268,39 @@ bool tst_QDockWidget::checkFloatingTabs(QMainWindow* mainWindow, QPointer<QDockW
// Check if mainWindow has a floatingTab child
ftabs = mainWindow->findChild<QDockWidgetGroupWindow*>();
if (ftabs.isNull()) {
- qCDebug(lcQpaDockWidgets) << "MainWindow has no DockWidgetGroupWindow" << mainWindow;
+ qCDebug(lcTestDockWidget) << "MainWindow has no DockWidgetGroupWindow" << mainWindow;
return false;
}
QTabBar* tab = ftabs->findChild<QTabBar*>();
if (!tab) {
- qCDebug(lcQpaDockWidgets) << "DockWidgetGroupWindow has no tab bar" << ftabs;
+ qCDebug(lcTestDockWidget) << "DockWidgetGroupWindow has no tab bar" << ftabs;
return false;
}
// both dock widgets must be direct children of the main window
const QList<QDockWidget*> children = ftabs->findChildren<QDockWidget*>(QString(), Qt::FindDirectChildrenOnly);
- if (dwList.count() > 0)
+ if (dwList.size() > 0)
{
- if (dwList.count() != children.count()) {
- qCDebug(lcQpaDockWidgets) << "Expected DockWidgetGroupWindow children:" << dwList.count()
- << "Children found:" << children.count();
+ if (dwList.size() != children.size()) {
+ qCDebug(lcTestDockWidget) << "Expected DockWidgetGroupWindow children:" << dwList.size()
+ << "Children found:" << children.size();
- qCDebug(lcQpaDockWidgets) << "Expected:" << dwList;
- qCDebug(lcQpaDockWidgets) << "Found in" << ftabs << ":" << children.count();
+ qCDebug(lcTestDockWidget) << "Expected:" << dwList;
+ qCDebug(lcTestDockWidget) << "Found in" << ftabs << ":" << children.size();
return false;
}
for (const QDockWidget* child : dwList) {
if (!children.contains(child)) {
- qCDebug(lcQpaDockWidgets) << "Expected child" << child << "not found in" << children;
+ qCDebug(lcTestDockWidget) << "Expected child" << child << "not found in" << children;
return false;
}
}
}
// Always select first tab position
- qCDebug(lcQpaDockWidgets) << "click on first tab";
+ qCDebug(lcTestDockWidget) << "click on first tab";
QTest::mouseClick(tab, Qt::LeftButton, Qt::KeyboardModifiers(), tab->tabRect(0).center());
return true;
}
@@ -1309,6 +1324,8 @@ void tst_QDockWidget::xcbMessageHandler(QtMsgType type, const QMessageLogContext
// test floating tabs and item_tree consistency
void tst_QDockWidget::floatingTabs()
{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Test skipped on Wayland.");
#ifdef Q_OS_WIN
QSKIP("Test skipped on Windows platforms");
#endif // Q_OS_WIN
@@ -1336,9 +1353,9 @@ void tst_QDockWidget::floatingTabs()
unplugAndResize(mainWindow, d2, home2(mainWindow), size2(mainWindow));
// Test plugging
- qCDebug(lcQpaDockWidgets) << "*** move d1 dock over d2 dock ***";
- qCDebug(lcQpaDockWidgets) << "**********(test plugging)*************";
- qCDebug(lcQpaDockWidgets) << "Move d1 over d2";
+ qCDebug(lcTestDockWidget) << "*** move d1 dock over d2 dock ***";
+ qCDebug(lcTestDockWidget) << "**********(test plugging)*************";
+ qCDebug(lcTestDockWidget) << "Move d1 over d2";
moveDockWidget(d1, d2->mapToGlobal(d2->rect().center()));
// Both dock widgets must no longer be floating
@@ -1363,13 +1380,13 @@ void tst_QDockWidget::floatingTabs()
// limitation: QTest cannot handle drag to unplug.
// reason: Object under mouse mutates from QTabBar::tab to QDockWidget. QTest cannot handle that.
// => click float button to unplug
- qCDebug(lcQpaDockWidgets) << "*** test unplugging from floating dock ***";
+ qCDebug(lcTestDockWidget) << "*** test unplugging from floating dock ***";
// QDockWidget must have a QAbstractButton with object name "qt_dockwidget_floatbutton"
QAbstractButton* floatButton = d1->findChild<QAbstractButton*>("qt_dockwidget_floatbutton", Qt::FindDirectChildrenOnly);
QTRY_VERIFY(floatButton != nullptr);
QPoint pos1 = floatButton->rect().center();
- qCDebug(lcQpaDockWidgets) << "unplug d1" << pos1;
+ qCDebug(lcTestDockWidget) << "unplug d1" << pos1;
QTest::mouseClick(floatButton, Qt::LeftButton, Qt::KeyboardModifiers(), pos1);
QTest::qWait(waitingTime);
@@ -1378,14 +1395,14 @@ void tst_QDockWidget::floatingTabs()
QTRY_VERIFY(!d2->isFloating());
// Plug back into dock areas
- qCDebug(lcQpaDockWidgets) << "*** test plugging back to dock areas ***";
- qCDebug(lcQpaDockWidgets) << "Move d1 to left dock";
+ qCDebug(lcTestDockWidget) << "*** test plugging back to dock areas ***";
+ qCDebug(lcTestDockWidget) << "Move d1 to left dock";
//moveDockWidget(d1, d1->mapFrom(MainWindow, dockPoint(MainWindow, Qt::LeftDockWidgetArea)));
moveDockWidget(d1, dockPoint(mainWindow, Qt::LeftDockWidgetArea));
- qCDebug(lcQpaDockWidgets) << "Move d2 to right dock";
+ qCDebug(lcTestDockWidget) << "Move d2 to right dock";
moveDockWidget(d2, dockPoint(mainWindow, Qt::RightDockWidgetArea));
- qCDebug(lcQpaDockWidgets) << "Waiting" << waitBeforeClose << "ms before plugging back.";
+ qCDebug(lcTestDockWidget) << "Waiting" << waitBeforeClose << "ms before plugging back.";
QTest::qWait(waitBeforeClose);
// Both dock widgets must no longer be floating
@@ -1397,7 +1414,7 @@ void tst_QDockWidget::floatingTabs()
QTRY_VERIFY(ftabs.isNull());
// Check if paths are consistent
- qCDebug(lcQpaDockWidgets) << "Checking path consistency" << layout->layoutState.indexOf(d1) << layout->layoutState.indexOf(d2);
+ qCDebug(lcTestDockWidget) << "Checking path consistency" << layout->layoutState.indexOf(d1) << layout->layoutState.indexOf(d2);
// Path1 must be identical
QTRY_VERIFY(path1 == layout->layoutState.indexOf(d1));
@@ -1427,14 +1444,14 @@ void tst_QDockWidget::hideAndShow()
std::unique_ptr<QMainWindow> up_mainWindow(mainWindow);
// Check hiding of docked widgets
- qCDebug(lcQpaDockWidgets) << "Hiding mainWindow with plugged dock widgets" << mainWindow;
+ qCDebug(lcTestDockWidget) << "Hiding mainWindow with plugged dock widgets" << mainWindow;
mainWindow->hide();
QXCBVERIFY(!mainWindow->isVisible());
QXCBVERIFY(!d1->isVisible());
QXCBVERIFY(!d2->isVisible());
// Check showing everything again
- qCDebug(lcQpaDockWidgets) << "Showing mainWindow with plugged dock widgets" << mainWindow;
+ qCDebug(lcTestDockWidget) << "Showing mainWindow with plugged dock widgets" << mainWindow;
mainWindow->show();
QXCBVERIFY(QTest::qWaitForWindowActive(mainWindow));
QXCBVERIFY(QTest::qWaitForWindowExposed(mainWindow));
@@ -1455,7 +1472,7 @@ void tst_QDockWidget::hideAndShow()
unplugAndResize(mainWindow, d2, home2(mainWindow), size2(mainWindow));
// Check hiding of undocked widgets
- qCDebug(lcQpaDockWidgets) << "Hiding mainWindow with unplugged dock widgets" << mainWindow;
+ qCDebug(lcTestDockWidget) << "Hiding mainWindow with unplugged dock widgets" << mainWindow;
mainWindow->hide();
QTRY_VERIFY(!mainWindow->isVisible());
QTRY_VERIFY(d1->isVisible());
@@ -1465,7 +1482,7 @@ void tst_QDockWidget::hideAndShow()
QTRY_VERIFY(!d1->isVisible());
QTRY_VERIFY(!d2->isVisible());
- qCDebug(lcQpaDockWidgets) << "Waiting" << waitBeforeClose << "ms before closing.";
+ qCDebug(lcTestDockWidget) << "Waiting" << waitBeforeClose << "ms before closing.";
QTest::qWait(waitBeforeClose);
#else
QSKIP("test requires -developer-build option");
@@ -1489,7 +1506,7 @@ void tst_QDockWidget::closeAndDelete()
unplugAndResize(mainWindow, d2, home2(mainWindow), size2(mainWindow));
// Create a floating tab and unplug it again
- qCDebug(lcQpaDockWidgets) << "Move d1 over d2";
+ qCDebug(lcTestDockWidget) << "Move d1 over d2";
moveDockWidget(d1, d2->mapToGlobal(d2->rect().center()));
// Both dock widgets must no longer be floating
@@ -1516,7 +1533,7 @@ void tst_QDockWidget::closeAndDelete()
// Fallback timer to report event loop still running
QTimer::singleShot(100, this, [&eventLoopStopped] {
- qCDebug(lcQpaDockWidgets) << "Last dock widget hasn't shout down event loop!";
+ qCDebug(lcTestDockWidget) << "Last dock widget hasn't shout down event loop!";
eventLoopStopped = false;
QApplication::quit();
});
@@ -1526,7 +1543,7 @@ void tst_QDockWidget::closeAndDelete()
QTRY_VERIFY(eventLoopStopped);
// Check heap cleanup
- qCDebug(lcQpaDockWidgets) << "Deleting mainWindow";
+ qCDebug(lcTestDockWidget) << "Deleting mainWindow";
up_mainWindow.reset();
QTRY_VERIFY(d1.isNull());
QTRY_VERIFY(d2.isNull());
@@ -1567,7 +1584,7 @@ void tst_QDockWidget::dockPermissions()
// both dock widgets must be direct children of the main window
{
const QList<QDockWidget*> children = mainWindow->findChildren<QDockWidget*>(QString(), Qt::FindDirectChildrenOnly);
- QTRY_VERIFY(children.count() == 2);
+ QTRY_VERIFY(children.size() == 2);
for (const QDockWidget* child : children)
QTRY_VERIFY(child == d1 || child == d2);
}
@@ -1576,28 +1593,187 @@ void tst_QDockWidget::dockPermissions()
QTRY_VERIFY(mainWindow->findChild<QDockWidgetGroupWindow*>() == nullptr);
// Test unpermitted dock areas with d2
- qCDebug(lcQpaDockWidgets) << "*** move d2 to forbidden docks ***";
+ qCDebug(lcTestDockWidget) << "*** move d2 to forbidden docks ***";
// Move d2 to non allowed dock areas and verify it remains floating
- qCDebug(lcQpaDockWidgets) << "Move d2 to top dock";
+ qCDebug(lcTestDockWidget) << "Move d2 to top dock";
moveDockWidget(d2, dockPoint(mainWindow, Qt::TopDockWidgetArea));
QTRY_VERIFY(d2->isFloating());
- qCDebug(lcQpaDockWidgets) << "Move d2 to left dock";
+ qCDebug(lcTestDockWidget) << "Move d2 to left dock";
//moveDockWidget(d2, d2->mapFrom(MainWindow, dockPoint(MainWindow, Qt::LeftDockWidgetArea)));
moveDockWidget(d2, dockPoint(mainWindow, Qt::LeftDockWidgetArea));
QTRY_VERIFY(d2->isFloating());
- qCDebug(lcQpaDockWidgets) << "Move d2 to bottom dock";
+ qCDebug(lcTestDockWidget) << "Move d2 to bottom dock";
moveDockWidget(d2, dockPoint(mainWindow, Qt::BottomDockWidgetArea));
QTRY_VERIFY(d2->isFloating());
- qCDebug(lcQpaDockWidgets) << "Waiting" << waitBeforeClose << "ms before closing.";
+ qCDebug(lcTestDockWidget) << "Waiting" << waitBeforeClose << "ms before closing.";
QTest::qWait(waitBeforeClose);
#else
QSKIP("test requires -developer-build option");
#endif // QT_BUILD_INTERNAL
}
+/*!
+ \internal
+
+ This test checks consistency of QMainWindow::saveState() / QMainWindow::restoreState().
+ These methods (de)serialize dock widget properties via a QDataStream into a QByteArray.
+
+ If the logic of (de)serializing Qt datatypes and classes changes, old settings can fail
+ to restore properly without triggering warnings or assertions.
+
+ The test consists of two parts:
+ \list 1
+ \li Read properties from a hard coded byte array and check if it is deserialized correctly.
+ \li Serialize properties into a \a QByteArray and check if it is serialized correctly.
+ \endlist
+*/
+void tst_QDockWidget::saveAndRestore()
+{
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Test skipped on Wayland.");
+#ifdef Q_OS_WIN
+ QSKIP("Test skipped on Windows platforms");
+#endif // Q_OS_WIN
+#ifndef QT_BUILD_INTERNAL
+ QSKIP("test requires -developer-build option");
+#else
+
+ // Hard coded byte array for test initialization
+ const QByteArray testArray = QByteArrayLiteral(
+ "\x00\x00\x00\xFF\x00\x00\x00\x00\xFD\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x13\x00\x00\x05\xE8\xFC\x02\x00\x00\x00\x01\xFB\x00\x00\x00\x04\x00"
+ "D\x00"
+ "1\x03\x00\x00\x01\f\x00\x00\x00\x97\x00\x00\x02\x19\x00\x00\x01z\x00\x00\x00\x01\x00\x00\x00\x13\x00\x00\x05\xE8\xFC\x02\x00\x00\x00\x01\xFB\x00\x00\x00\x04\x00"
+ "D\x00"
+ "2\x03\x00\x00\x06L\x00\x00\x00\xFF\x00\x00\x01\f\x00\x00\x00\xE2\x00\x00\n\x80\x00\x00\x05\xE8\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\b\x00\x00\x00\b\xFC\x00\x00\x00\x00"
+ );
+
+ QByteArray referenceArray; // Copy of testArray, corrected for current screen limits
+ QPoint topLeft1; // Top left point of dock widget d1
+ QPoint topLeft2; // Top left point of dock widget d2
+ QSize widgetSize1; // Size of dock widget d1
+ QSize widgetSize2; // Size of dock widget d2
+ bool isFloating1; // Floating status of dock widget d1
+ bool isFloating2; // Floating status of dock widget d2
+
+ // Create a mainwindow with a central widget and two dock widgets.
+ // Import properties from hard coded byte array.
+ // Use a scope to delete objects from screen after test.
+ {
+ QPointer<QDockWidget> d1;
+ QPointer<QDockWidget> d2;
+ QPointer<QWidget> cent;
+ QMainWindow* mainWindow;
+ createTestWidgets(mainWindow, cent, d1, d2);
+
+ // Failure to restore properties might lead to inconsistencies and crash.
+ // To leave a clean environment when the test inexpectedly goes out of scope,
+ // => store main window pointer in a std::unique_ptr
+ std::unique_ptr<QMainWindow> up_mainWindow(mainWindow);
+
+ // Restore, wait for events to be processed
+ mainWindow->restoreState(testArray);
+ QVERIFY(QTest::qWaitForWindowExposed(d1));
+ QVERIFY(QTest::qWaitForWindowExposed(d2));
+
+ // Serialized dock widget positions and sizes might be overridden due
+ // screen size limitations => do not check them here.
+ // If the test fails between here and scope end, serialization format/sequence have changed
+ QTRY_VERIFY(d1->isFloating());
+ QTRY_VERIFY(d2->isFloating());
+
+ // Hide main window and save their floating status.
+ // Reason:
+ // - KDE window managers do not take control over dock widgets.
+ // => They always close with the main window.
+ // - Some non KDE window managers do take control over dock widgets.
+ // => They prevent them from closing with the main window (QTBUG-103474).
+ // If properties are restored correctly, closing behavior must be consistent
+ // throughout this test.
+ mainWindow->hide();
+ // FIXME: No method exists in 6.5 to wait for a window to be hidden.
+ // => wait and hope the best, replace with qWaitForWindowHidden once implemented.
+ QTest::qWait(200);
+ isFloating1 = d1->isFloating();
+ isFloating2 = d2->isFloating();
+ }
+
+ // Create a mainwindow with a central widget and two dock widgets.
+ // Assign different properties to each dock widgets.
+ // Write properties to a byte array.
+ // Remember position and size properties for comparison.
+ // Use a scope to delete objects from screen after test.
+ {
+ QPointer<QDockWidget> d1;
+ QPointer<QDockWidget> d2;
+ QPointer<QWidget> cent;
+ QMainWindow* mainWindow;
+ createTestWidgets(mainWindow, cent, d1, d2);
+ std::unique_ptr<QMainWindow> up_mainWindow(mainWindow);
+
+ // unplug, position and resize both dock widgets relative to screen size
+ unplugAndResize(mainWindow, d1, home1(mainWindow), size1(mainWindow));
+ unplugAndResize(mainWindow, d2, home2(mainWindow), size2(mainWindow));
+
+ topLeft1 = d1->pos();
+ topLeft2 = d2->pos();
+ widgetSize1 = d1->size();
+ widgetSize2 = d2->size();
+
+ // save properties, potentially corrected for screen limits
+ referenceArray = mainWindow->saveState();
+
+ // Check closing behavior consistency
+ mainWindow->hide();
+ QTRY_VERIFY(d1->isFloating());
+ QTRY_VERIFY(d2->isFloating());
+ QCOMPARE(d1->isFloating(), isFloating1);
+ QCOMPARE(d2->isFloating(), isFloating2);
+ }
+
+ // Create a new main window, central window and two dock widgets.
+ QPointer<QDockWidget> d1;
+ QPointer<QDockWidget> d2;
+ QPointer<QWidget> cent;
+ QMainWindow* mainWindow;
+ createTestWidgets(mainWindow, cent, d1, d2);
+
+ // Failure to restore properties might lead to inconsistencies and crash.
+ // To leave a clean environment when the test inexpectedly goes out of scope,
+ // - store main window pointer in a std::unique_ptr
+ std::unique_ptr<QMainWindow> up_mainWindow(mainWindow);
+
+ // Restore properties and wait for events to be processed
+ mainWindow->restoreState(referenceArray);
+ QVERIFY(QTest::qWaitForWindowExposed(d1));
+ QVERIFY(QTest::qWaitForWindowExposed(d2));
+
+ // Compare positions, sizes and floating status
+ // If the test fails in the following 12 lines,
+ // the de-serialization format/sequence have changed
+ QCOMPARE(topLeft1, d1->pos());
+ QCOMPARE(topLeft2, d2->pos());
+ QCOMPARE(widgetSize1, d1->size());
+ QCOMPARE(widgetSize2, d2->size());
+ QVERIFY(d1->isFloating());
+ QVERIFY(d2->isFloating());
+
+ // Serialize again to compare all remaining properties
+ const QByteArray comparisonArray = mainWindow->saveState();
+ QCOMPARE(comparisonArray, referenceArray);
+
+ // Check closing behavior consistency
+ mainWindow->hide();
+ QTRY_VERIFY(d1->isFloating());
+ QTRY_VERIFY(d2->isFloating());
+ QCOMPARE(d1->isFloating(), isFloating1);
+ QCOMPARE(d2->isFloating(), isFloating2);
+
+#endif // QT_BUILD_INTERNAL
+}
+
QTEST_MAIN(tst_QDockWidget)
#include "tst_qdockwidget.moc"
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
index 3d7eece17a..a380aef127 100644
--- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -865,37 +865,37 @@ void tst_QDoubleSpinBox::editingFinished()
QTest::keyClick(box, Qt::Key_Up);
- QCOMPARE(editingFinishedSpy1.count(), 0);
- QCOMPARE(editingFinishedSpy2.count(), 0);
+ QCOMPARE(editingFinishedSpy1.size(), 0);
+ QCOMPARE(editingFinishedSpy2.size(), 0);
QTest::keyClick(box2, Qt::Key_Up);
QTest::keyClick(box2, Qt::Key_Up);
box2->setFocus();
- QCOMPARE(editingFinishedSpy1.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 1);
box->setFocus();
- QCOMPARE(editingFinishedSpy1.count(), 1);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 1);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box, Qt::Key_Up);
- QCOMPARE(editingFinishedSpy1.count(), 1);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 1);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box, Qt::Key_Enter);
- QCOMPARE(editingFinishedSpy1.count(), 2);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 2);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box, Qt::Key_Return);
- QCOMPARE(editingFinishedSpy1.count(), 3);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 3);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
box2->setFocus();
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box2, Qt::Key_Enter);
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 2);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 2);
QTest::keyClick(box2, Qt::Key_Return);
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 3);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 3);
testFocusWidget.hide();
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 4);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 4);
}
void tst_QDoubleSpinBox::removeAll()
@@ -1751,12 +1751,12 @@ void tst_QDoubleSpinBox::stepModifierPressAndHold()
QStyle::CC_SpinBox, &spinBoxStyleOption, subControl, &spin);
QTest::mousePress(&spin, Qt::LeftButton, modifiers, buttonRect.center());
- QTRY_VERIFY(spy.length() >= 3);
+ QTRY_VERIFY(spy.size() >= 3);
QTest::mouseRelease(&spin, Qt::LeftButton, modifiers, buttonRect.center());
const auto value = spy.last().at(0);
QVERIFY(value.userType() == QMetaType::Double);
- QCOMPARE(value.toDouble(), spy.length() * expectedStepModifier);
+ QCOMPARE(value.toDouble(), spy.size() * expectedStepModifier);
}
QTEST_MAIN(tst_QDoubleSpinBox)
diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
index 6a0749d7e3..149b6586ae 100644
--- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
+++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
@@ -77,7 +77,7 @@ void tst_QFontComboBox::currentFont_data()
if (!QFontDatabase::isPrivateFamily(defaultFont.family()))
QTest::newRow("default2") << defaultFont;
QStringList list = QFontDatabase::families();
- for (int i = 0; i < list.count(); ++i) {
+ for (int i = 0; i < list.size(); ++i) {
QFont f = QFont(QStringList{QFontInfo(QFont(list.at(i))).family()});
if (!QFontDatabase::isPrivateFamily(f.families().first()))
QTest::newRow(qPrintable(list.at(i))) << f;
@@ -105,7 +105,7 @@ void tst_QFontComboBox::currentFont()
if (oldCurrentFont != box.currentFont()) {
//the signal may be emit twice if there is a foundry into brackets
- QCOMPARE(spy0.count(),1);
+ QCOMPARE(spy0.size(),1);
}
}
@@ -155,7 +155,7 @@ void tst_QFontComboBox::fontFilters()
if((fontFilters & spacingMask) == spacingMask)
fontFilters &= ~spacingMask;
- for (int i = 0; i < list.count(); ++i) {
+ for (int i = 0; i < list.size(); ++i) {
if (QFontDatabase::isPrivateFamily(list[i]))
continue;
if (fontFilters & QFontComboBox::ScalableFonts) {
@@ -180,7 +180,7 @@ void tst_QFontComboBox::fontFilters()
if (c == 0)
QCOMPARE(box.currentFont(), QFont());
- QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0);
+ QCOMPARE(spy0.size(), (currentFont != box.currentFont()) ? 1 : 0);
}
// public QSize sizeHint() const
@@ -221,17 +221,17 @@ void tst_QFontComboBox::writingSystem()
QCOMPARE(box.writingSystem(), writingSystem);
QStringList list = QFontDatabase::families(writingSystem);
- int c = list.count();
- for (int i = 0; i < list.count(); ++i) {
+ int c = list.size();
+ for (int i = 0; i < list.size(); ++i) {
if (QFontDatabase::isPrivateFamily(list[i]))
c--;
}
QCOMPARE(box.model()->rowCount(), c);
- if (list.count() == 0)
+ if (list.size() == 0)
QCOMPARE(box.currentFont(), QFont());
- QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0);
+ QCOMPARE(spy0.size(), (currentFont != box.currentFont()) ? 1 : 0);
}
// protected void currentFontChanged(QFont const& f)
@@ -245,11 +245,11 @@ void tst_QFontComboBox::currentFontChanged()
if (box->model()->rowCount() > 2) {
QTest::keyPress(box, Qt::Key_Down);
- QCOMPARE(spy0.count(), 1);
+ QCOMPARE(spy0.size(), 1);
QFont f( "Sans Serif" );
box->setCurrentFont(f);
- QCOMPARE(spy0.count(), 2);
+ QCOMPARE(spy0.size(), 2);
} else
qWarning("Not enough fonts installed on test system. Consider adding some");
}
diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
index 6c42baf147..c5640d2571 100644
--- a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
@@ -371,8 +371,8 @@ void tst_QGroupBox::clicked()
else
QTest::mouseClick(&testWidget, Qt::LeftButton);
- QTEST(int(spy.count()), "clickedCount");
- if (spy.count() > 0)
+ QTEST(int(spy.size()), "clickedCount");
+ if (spy.size() > 0)
QTEST(spy.at(0).at(0).toBool(), "finalCheck");
QTEST(testWidget.isChecked(), "finalCheck");
}
@@ -386,9 +386,9 @@ void tst_QGroupBox::toggledVsClicked()
QSignalSpy clickSpy(&groupBox, SIGNAL(clicked(bool)));
groupBox.setChecked(!groupBox.isChecked());
- QCOMPARE(clickSpy.count(), 0);
- QCOMPARE(toggleSpy.count(), 1);
- if (toggleSpy.count() > 0)
+ QCOMPARE(clickSpy.size(), 0);
+ QCOMPARE(toggleSpy.size(), 1);
+ if (toggleSpy.size() > 0)
QCOMPARE(toggleSpy.at(0).at(0).toBool(), groupBox.isChecked());
connect(&groupBox, SIGNAL(clicked(bool)), this, SLOT(clickTimestampSlot()));
@@ -401,8 +401,8 @@ void tst_QGroupBox::toggledVsClicked()
QStyle::SC_GroupBoxCheckBox, &groupBox);
QTest::mouseClick(&groupBox, Qt::LeftButton, {}, rect.center());
- QCOMPARE(clickSpy.count(), 1);
- QCOMPARE(toggleSpy.count(), 2);
+ QCOMPARE(clickSpy.size(), 1);
+ QCOMPARE(toggleSpy.size(), 2);
QVERIFY(toggleTimeStamp < clickTimeStamp);
}
@@ -598,9 +598,9 @@ void tst_QGroupBox::buttonPressKeys()
const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
->themeHint(QPlatformTheme::ButtonPressKeys)
.value<QList<Qt::Key>>();
- for (int i = 0; i < buttonPressKeys.length(); ++i) {
+ for (int i = 0; i < buttonPressKeys.size(); ++i) {
QTest::keyClick(&groupBox, buttonPressKeys[i]);
- QCOMPARE(clickedSpy.length(), i + 1);
+ QCOMPARE(clickedSpy.size(), i + 1);
}
}
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index 3441e6296d..2346061c5c 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -81,6 +81,8 @@ private Q_SLOTS:
void taskQTBUG_48157_dprMovie();
void resourceProvider();
+ void mouseEventPropagation_data();
+ void mouseEventPropagation();
private:
QLabel *testWidget;
@@ -598,5 +600,94 @@ void tst_QLabel::resourceProvider()
QVERIFY(providerCalled > 0);
}
+// Test if mouse events are correctly propagated to the parent widget,
+// even if a label contains rich text (QTBUG-110055)
+void tst_QLabel::mouseEventPropagation_data()
+{
+ QTest::addColumn<const QString>("text");
+ QTest::addColumn<const Qt::TextInteractionFlag>("interaction");
+ QTest::addColumn<const QList<Qt::MouseButton>>("buttons");
+ QTest::addColumn<const bool>("expectPropagation");
+
+
+ QTest::newRow("RichText")
+ << QString("<b>This is a rich text propagating mouse events</b>")
+ << Qt::LinksAccessibleByMouse
+ << QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
+ << true;
+ QTest::newRow("PlainText")
+ << QString("This is a plain text propagating mouse events")
+ << Qt::LinksAccessibleByMouse
+ << QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
+ << true;
+ QTest::newRow("PlainTextConsume")
+ << QString("This is a plain text consuming mouse events")
+ << Qt::TextSelectableByMouse
+ << QList<Qt::MouseButton>{Qt::LeftButton}
+ << false;
+ QTest::newRow("RichTextConsume")
+ << QString("<b>This is a rich text consuming mouse events</b>")
+ << Qt::TextSelectableByMouse
+ << QList<Qt::MouseButton>{Qt::LeftButton}
+ << false;
+ QTest::newRow("PlainTextNoInteraction")
+ << QString("This is a text not interacting with mouse")
+ << Qt::NoTextInteraction
+ << QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
+ << true;
+ QTest::newRow("RichTextNoInteraction")
+ << QString("<b>This is a rich text not interacting with mouse</b>")
+ << Qt::NoTextInteraction
+ << QList<Qt::MouseButton>{Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}
+ << true;
+}
+
+void tst_QLabel::mouseEventPropagation()
+{
+ class MouseEventWidget : public QWidget
+ {
+ public:
+ uint pressed() const { return m_pressed; }
+ uint released() const { return m_released; }
+
+ private:
+ uint m_pressed = 0;
+ uint m_released = 0;
+ void mousePressEvent(QMouseEvent *event) override
+ {
+ ++m_pressed;
+ return QWidget::mousePressEvent(event);
+ }
+
+ void mouseReleaseEvent(QMouseEvent *event) override
+ {
+ ++m_released;
+ return QWidget::mouseReleaseEvent(event);
+ }
+ };
+
+ QFETCH(const QString, text);
+ QFETCH(const Qt::TextInteractionFlag, interaction);
+ QFETCH(const QList<Qt::MouseButton>, buttons);
+ QFETCH(const bool, expectPropagation);
+
+ MouseEventWidget widget;
+ auto *layout = new QVBoxLayout(&widget);
+ auto *label = new QLabel(text);
+ label->setTextInteractionFlags(interaction);
+
+ layout->addWidget(label);
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ const QPoint labelCenter = label->rect().center();
+ for (Qt::MouseButton mouseButton : buttons)
+ QTest::mouseClick(label, mouseButton, Qt::KeyboardModifiers(), labelCenter);
+
+ const uint count = expectPropagation ? buttons.count() : 0;
+ QTRY_COMPARE(widget.pressed(), count);
+ QTRY_COMPARE(widget.released(), count);
+}
+
QTEST_MAIN(tst_QLabel)
#include "tst_qlabel.moc"
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index b1928e3785..1dc398cefd 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -652,7 +652,7 @@ void tst_QLineEdit::setInputMask()
testWidget->insert(input);
} else {
psKeyClick(testWidget, Qt::Key_Home);
- for (int i=0; i<input.length(); i++)
+ for (int i=0; i<input.size(); i++)
QTest::keyClick(testWidget, input.at(i).toLatin1());
}
@@ -919,8 +919,8 @@ void tst_QLineEdit::hasAcceptableInputValidator()
qApp->sendEvent(testWidget, &lostFocus);
QVERIFY(testWidget->hasAcceptableInput());
- QCOMPARE(spyChanged.count(), 2);
- QCOMPARE(spyEdited.count(), 0);
+ QCOMPARE(spyChanged.size(), 2);
+ QCOMPARE(spyEdited.size(), 0);
}
@@ -1592,7 +1592,7 @@ void tst_QLineEdit::setText()
QSignalSpy editedSpy(testWidget, SIGNAL(textEdited(QString)));
QSignalSpy changedSpy(testWidget, SIGNAL(textChanged(QString)));
testWidget->setText("hello");
- QCOMPARE(editedSpy.count(), 0);
+ QCOMPARE(editedSpy.size(), 0);
QCOMPARE(changedSpy.value(0).value(0).toString(), QString("hello"));
}
@@ -1664,7 +1664,7 @@ void tst_QLineEdit::displayText_data()
QString input;
QString pass;
input = "Hello World";
- pass.resize(input.length());
+ pass.resize(input.size());
pass.fill(passChar);
QTest::newRow(QString(s + " text0").toLatin1()) << input << pass << m << bool(use_setText);
QTest::newRow(QString(s + " text1").toLatin1()) << QString("") <<
@@ -1672,14 +1672,14 @@ void tst_QLineEdit::displayText_data()
m << bool(use_setText);
QTest::newRow(QString(s + " text2").toLatin1()) << QString("A") << QString(passChar) << m << bool(use_setText);
input = QString("ryyryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryry");
- pass.resize(input.length());
+ pass.resize(input.size());
pass.fill(passChar);
QTest::newRow(QString(s + " text3").toLatin1()) << input << pass << m << bool(use_setText);
input = QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890`~!@#$%^&*()_-+={[}]|\\:;'?/>.<,\"");
- pass.fill(passChar, input.length());
+ pass.fill(passChar, input.size());
QTest::newRow(QString(s + " text4").toLatin1()) << input << pass << m << bool(use_setText);
input = QString("Hello") + QChar(0xa0) + "World";
- pass.resize(input.length());
+ pass.resize(input.size());
pass.fill(passChar);
QTest::newRow(QString(s + " text with nbsp").toLatin1()) << input << pass << m << bool(use_setText);
}
@@ -2292,7 +2292,7 @@ void tst_QLineEdit::deleteSelectedText()
#ifndef QT_NO_CONTEXTMENU
QMenu *menu = edit.createStandardContextMenu();
- for (int i = 0; i < menu->actions().count(); ++i) {
+ for (int i = 0; i < menu->actions().size(); ++i) {
QAction *current = menu->actions().at(i);
if (current->text() == QLineEdit::tr("Delete")) {
current->trigger(); //this will delete the whole text selected
@@ -2425,7 +2425,7 @@ class QIntFixValidator : public QIntValidator {
public:
QIntFixValidator(int min, int max, QObject *parent) : QIntValidator(min, max, parent) {}
void fixup (QString &input) const override {
- for (int i=0; i<input.length(); ++i)
+ for (int i=0; i<input.size(); ++i)
if (!input.at(i).isNumber()) {
input[(int)i] = QChar('0');
}
@@ -2991,7 +2991,7 @@ void tst_QLineEdit::setSelection_data()
QTest::newRow(selectionTestName(start, length).constData())
<< text << start << length << pos << QString("Abc ") << true;
- start = -1; length = 0; pos = text.length();
+ start = -1; length = 0; pos = text.size();
QTest::newRow(selectionTestName(start, length).constData())
<< text << start << length << pos << QString() << false;
@@ -3011,7 +3011,7 @@ void tst_QLineEdit::setSelection_data()
QTest::newRow(selectionTestName(start, length).constData())
<< text << start << length << pos << QString("A") << true;
- start = -1; length = -1; pos = text.length();
+ start = -1; length = -1; pos = text.size();
QTest::newRow(selectionTestName(start, length).constData())
<< text << start << length << pos << QString() << false;
}
@@ -3308,7 +3308,7 @@ void tst_QLineEdit::validateOnFocusOut()
QTest::keyPress(testWidget, '0');
QCOMPARE(testWidget->text(), QString("10"));
testWidget->clearFocus();
- QCOMPARE(editingFinishedSpy.count(), 0);
+ QCOMPARE(editingFinishedSpy.size(), 0);
testWidget->setFocus();
centerOnScreen(testWidget);
@@ -3321,7 +3321,7 @@ void tst_QLineEdit::validateOnFocusOut()
QTRY_COMPARE(testWidget->text(), QString("100"));
testWidget->clearFocus();
- QCOMPARE(editingFinishedSpy.count(), 1);
+ QCOMPARE(editingFinishedSpy.size(), 1);
}
void tst_QLineEdit::editInvalidText()
@@ -3499,7 +3499,7 @@ void tst_QLineEdit::noTextEditedOnClear()
testWidget->setText("Test");
QSignalSpy textEditedSpy(testWidget, SIGNAL(textEdited(QString)));
testWidget->clear();
- QCOMPARE(textEditedSpy.count(), 0);
+ QCOMPARE(textEditedSpy.size(), 0);
}
void tst_QLineEdit::textMargin_data()
@@ -3603,7 +3603,7 @@ void tst_QLineEdit::returnKeyClearsEditedFlag()
// Focus drop with no edits shouldn't emit signal, edited flag == false
testWidget.clearFocus(); // Signal not emitted
QVERIFY(!testWidget.hasFocus());
- QCOMPARE(leSpy.count(), 0);
+ QCOMPARE(leSpy.size(), 0);
// Focus drop after edits should emit signal, edited flag == true
testWidget.setFocus();
@@ -3611,7 +3611,7 @@ void tst_QLineEdit::returnKeyClearsEditedFlag()
QTest::keyClicks(&testWidget, "edit1 "); // edited flag set
testWidget.clearFocus(); // edited flag cleared, signal emitted
QVERIFY(!testWidget.hasFocus());
- QCOMPARE(leSpy.count(), 1);
+ QCOMPARE(leSpy.size(), 1);
// Only text related keys should set edited flag
testWidget.setFocus();
@@ -3621,7 +3621,7 @@ void tst_QLineEdit::returnKeyClearsEditedFlag()
QTest::keyClick(&testWidget, Qt::Key_PageUp);
testWidget.clearFocus(); // Signal not emitted
QVERIFY(!testWidget.hasFocus());
- QCOMPARE(leSpy.count(), 1); // No change
+ QCOMPARE(leSpy.size(), 1); // No change
// Return should always emit signal
testWidget.setFocus();
@@ -3629,12 +3629,12 @@ void tst_QLineEdit::returnKeyClearsEditedFlag()
QTest::keyClick(&testWidget, Qt::Key_Return); /* Without edits,
signal emitted,
edited flag cleared */
- QCOMPARE(leSpy.count(), 2);
+ QCOMPARE(leSpy.size(), 2);
QTest::keyClicks(&testWidget, "edit2 "); // edited flag set
QTest::keyClick(&testWidget, Qt::Key_Return); /* With edits,
signal emitted,
edited flag cleared */
- QCOMPARE(leSpy.count(), 3);
+ QCOMPARE(leSpy.size(), 3);
/* After editing the line edit following a Return key press with a
focus drop should not emit signal a second time since Return now
@@ -3642,10 +3642,10 @@ void tst_QLineEdit::returnKeyClearsEditedFlag()
QTest::keyClicks(&testWidget, "edit3 "); // edited flag set
QTest::keyClick(&testWidget, Qt::Key_Return); /* signal emitted,
edited flag cleared */
- QCOMPARE(leSpy.count(), 4);
+ QCOMPARE(leSpy.size(), 4);
testWidget.clearFocus(); // Signal not emitted since edited == false
QVERIFY(!testWidget.hasFocus());
- QCOMPARE(leSpy.count(), 4); // No change
+ QCOMPARE(leSpy.size(), 4); // No change
}
#ifndef QT_NO_CURSOR
@@ -3721,19 +3721,19 @@ void tst_QLineEdit::task174640_editingFinished()
le1->setFocus();
QTRY_VERIFY(le1->hasFocus());
- QCOMPARE(editingFinishedSpy.count(), 0);
+ QCOMPARE(editingFinishedSpy.size(), 0);
le2->setFocus();
QTRY_VERIFY(le2->hasFocus());
// editingFinished will not be emitted anew because no editing happened
- QCOMPARE(editingFinishedSpy.count(), 0);
+ QCOMPARE(editingFinishedSpy.size(), 0);
le1->setFocus();
QTRY_VERIFY(le1->hasFocus());
QTest::keyPress(le1, Qt::Key_Plus);
le2->setFocus();
QTRY_VERIFY(le2->hasFocus());
- QCOMPARE(editingFinishedSpy.count(), 1);
+ QCOMPARE(editingFinishedSpy.size(), 1);
editingFinishedSpy.clear();
le1->setFocus();
@@ -3748,7 +3748,7 @@ void tst_QLineEdit::task174640_editingFinished()
mw.activateWindow();
delete testMenu1;
- QCOMPARE(editingFinishedSpy.count(), 0);
+ QCOMPARE(editingFinishedSpy.size(), 0);
QTRY_VERIFY(le1->hasFocus());
// Ensure le1 has been edited
QTest::keyPress(le1, Qt::Key_Plus);
@@ -3761,7 +3761,7 @@ void tst_QLineEdit::task174640_editingFinished()
QTest::qWait(20);
mw.activateWindow();
delete testMenu2;
- QCOMPARE(editingFinishedSpy.count(), 1);
+ QCOMPARE(editingFinishedSpy.size(), 1);
}
#if QT_CONFIG(completer)
@@ -3846,7 +3846,7 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged()
QTest::keyPress(&lineEdit, 'd');
QTest::keyPress(&lineEdit, 'e');
QTest::keyPress(&lineEdit, 'f');
- QCOMPARE(changedSpy.count(), 5);
+ QCOMPARE(changedSpy.size(), 5);
}
void tst_QLineEdit::task233101_cursorPosAfterInputMethod_data()
@@ -4061,7 +4061,7 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
QTRY_VERIFY(le.hasFocus());
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_P);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
@@ -4348,14 +4348,14 @@ void tst_QLineEdit::inputMethodSelection()
testWidget->setSelection(0,0);
QSignalSpy selectionSpy(testWidget, SIGNAL(selectionChanged()));
- QCOMPARE(selectionSpy.count(), 0);
+ QCOMPARE(selectionSpy.size(), 0);
QCOMPARE(testWidget->selectionStart(), -1);
QCOMPARE(testWidget->selectionEnd(), -1);
QCOMPARE(testWidget->selectionLength(), 0);
testWidget->setSelection(0,5);
- QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(selectionSpy.size(), 1);
QCOMPARE(testWidget->selectionStart(), 0);
QCOMPARE(testWidget->selectionEnd(), 5);
QCOMPARE(testWidget->selectionLength(), 5);
@@ -4369,7 +4369,7 @@ void tst_QLineEdit::inputMethodSelection()
QApplication::sendEvent(testWidget, &event);
}
- QCOMPARE(selectionSpy.count(), 2);
+ QCOMPARE(selectionSpy.size(), 2);
QCOMPARE(testWidget->selectionStart(), 12);
QCOMPARE(testWidget->selectionEnd(), 17);
QCOMPARE(testWidget->selectionLength(), 5);
@@ -4382,7 +4382,7 @@ void tst_QLineEdit::inputMethodSelection()
QApplication::sendEvent(testWidget, &event);
}
- QCOMPARE(selectionSpy.count(), 3);
+ QCOMPARE(selectionSpy.size(), 3);
QCOMPARE(testWidget->selectionStart(), -1);
QCOMPARE(testWidget->selectionEnd(), -1);
QCOMPARE(testWidget->selectionLength(), 0);
@@ -4570,11 +4570,11 @@ void tst_QLineEdit::clearButton()
QSignalSpy spyEdited(filterLineEdit, &QLineEdit::textEdited);
const QPoint clearButtonCenterPos = QRect(QPoint(0, 0), clearButton->size()).center();
QTest::mouseClick(clearButton, Qt::LeftButton, {}, clearButtonCenterPos);
- QCOMPARE(spyEdited.count(), 1);
+ QCOMPARE(spyEdited.size(), 1);
QTRY_COMPARE(clearButton->cursor().shape(), filterLineEdit->cursor().shape());
QTRY_COMPARE(filterModel->rowCount(), 3);
QCoreApplication::processEvents();
- QCOMPARE(spyEdited.count(), 1);
+ QCOMPARE(spyEdited.size(), 1);
filterLineEdit->setReadOnly(true); // QTBUG-34315
QVERIFY(!clearButton->isEnabled());
@@ -4851,7 +4851,7 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited()
QSignalSpy spy(&lineEdit, SIGNAL(textEdited(QString)));
lineEdit.setInputMask("AAAA");
lineEdit.setInputMask(QString());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
#if QT_CONFIG(shortcut)
@@ -4912,7 +4912,7 @@ void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit()
}
const int activationCount = shouldBeHandledByQLineEdit ? 0 : 1;
- QCOMPARE(spy.count(), activationCount);
+ QCOMPARE(spy.size(), activationCount);
}
#endif // QT_CONFIG(shortcut)
@@ -4965,10 +4965,10 @@ void tst_QLineEdit::QTBUG_60319_setInputMaskCheckImSurroundingText()
QLineEdit *testWidget = ensureTestWidget();
QString mask("+000(000)-000-00-00");
testWidget->setInputMask(mask);
- testWidget->setCursorPosition(mask.length());
+ testWidget->setCursorPosition(mask.size());
QString surroundingText = testWidget->inputMethodQuery(Qt::ImSurroundingText).toString();
int cursorPosition = testWidget->inputMethodQuery(Qt::ImCursorPosition).toInt();
- QCOMPARE(surroundingText.length(), cursorPosition);
+ QCOMPARE(surroundingText.size(), cursorPosition);
}
void tst_QLineEdit::testQuickSelectionWithMouse()
@@ -5065,18 +5065,18 @@ void tst_QLineEdit::inputRejected()
QSignalSpy spyInputRejected(testWidget, SIGNAL(inputRejected()));
QTest::keyClicks(testWidget, "abcde");
- QCOMPARE(spyInputRejected.count(), 0);
+ QCOMPARE(spyInputRejected.size(), 0);
testWidget->setText("fghij");
- QCOMPARE(spyInputRejected.count(), 0);
+ QCOMPARE(spyInputRejected.size(), 0);
testWidget->insert("k");
- QCOMPARE(spyInputRejected.count(), 0);
+ QCOMPARE(spyInputRejected.size(), 0);
testWidget->clear();
testWidget->setMaxLength(5);
QTest::keyClicks(testWidget, "abcde");
- QCOMPARE(spyInputRejected.count(), 0);
+ QCOMPARE(spyInputRejected.size(), 0);
QTest::keyClicks(testWidget, "fgh");
- QCOMPARE(spyInputRejected.count(), 3);
+ QCOMPARE(spyInputRejected.size(), 3);
#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
@@ -5084,7 +5084,7 @@ void tst_QLineEdit::inputRejected()
testWidget->paste();
// The first 5 characters are accepted, but
// the last 2 are not.
- QCOMPARE(spyInputRejected.count(), 1);
+ QCOMPARE(spyInputRejected.size(), 1);
#endif
testWidget->setMaxLength(INT_MAX);
@@ -5093,15 +5093,15 @@ void tst_QLineEdit::inputRejected()
QIntValidator intValidator(1, 100);
testWidget->setValidator(&intValidator);
QTest::keyClicks(testWidget, "11");
- QCOMPARE(spyInputRejected.count(), 0);
+ QCOMPARE(spyInputRejected.size(), 0);
QTest::keyClicks(testWidget, "a#");
- QCOMPARE(spyInputRejected.count(), 2);
+ QCOMPARE(spyInputRejected.size(), 2);
#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
QApplication::clipboard()->setText("a#");
testWidget->paste();
- QCOMPARE(spyInputRejected.count(), 1);
+ QCOMPARE(spyInputRejected.size(), 1);
#endif
testWidget->clear();
@@ -5109,9 +5109,9 @@ void tst_QLineEdit::inputRejected()
spyInputRejected.clear();
testWidget->setInputMask("999.999.999.999;_");
QTest::keyClicks(testWidget, "11");
- QCOMPARE(spyInputRejected.count(), 0);
+ QCOMPARE(spyInputRejected.size(), 0);
QTest::keyClicks(testWidget, "a#");
- QCOMPARE(spyInputRejected.count(), 2);
+ QCOMPARE(spyInputRejected.size(), 2);
}
QTEST_MAIN(tst_QLineEdit)
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 6996591946..91aa651bab 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -2124,14 +2124,14 @@ void tst_QMainWindow::resizeDocks()
int totalFromList = 0;
int actualTotal = 0;
- for (int i = 0; i < docks.count(); ++i) {
+ for (int i = 0; i < docks.size(); ++i) {
totalFromList += sizes[i];
QSize s = list[i]->size();
actualTotal += (orientation == Qt::Horizontal) ? s.width() : s.height();
// qDebug() << list[i] << list[i]->size() << sizes[i];
}
- for (int i = 0; i < docks.count(); ++i) {
+ for (int i = 0; i < docks.size(); ++i) {
QSize s = list[i]->size();
int value = (orientation == Qt::Horizontal) ? s.width() : s.height();
QCOMPARE(value, qRound(sizes[i]*actualTotal/double(totalFromList)));
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 1d76bb4d72..9cdbbc5b0f 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -138,7 +138,7 @@ static bool verifyArrangement(QMdiArea *mdiArea, Arrangement arrangement, const
case Tiled:
{
// Calculate the number of rows and columns.
- const int n = subWindows.count();
+ const int n = subWindows.size();
const int numColumns = qMax(qCeil(qSqrt(qreal(n))), 1);
const int numRows = qMax((n % numColumns) ? (n / numColumns + 1) : (n / numColumns), 1);
@@ -317,12 +317,12 @@ void tst_QMdiArea::subWindowActivated()
widget->show();
qApp->processEvents();
QVERIFY( activeWindow == workspace->activeSubWindow() );
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
QList<QMdiSubWindow *> windows = workspace->subWindowList();
- QCOMPARE( (int)windows.count(), count );
+ QCOMPARE( (int)windows.size(), count );
for ( i = 0; i < count; ++i ) {
QMdiSubWindow *window = windows.at(i);
@@ -346,13 +346,13 @@ void tst_QMdiArea::subWindowActivated()
workspace->activeSubWindow()->close();
qApp->processEvents();
QCOMPARE(activeWindow, workspace->activeSubWindow());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
QVERIFY(!activeWindow);
QVERIFY(!workspace->activeSubWindow());
- QCOMPARE(workspace->subWindowList().count(), 0);
+ QCOMPARE(workspace->subWindowList().size(), 0);
{
workspace->hide();
@@ -360,14 +360,14 @@ void tst_QMdiArea::subWindowActivated()
widget->setAttribute(Qt::WA_DeleteOnClose);
QMdiSubWindow *window = workspace->addSubWindow(widget);
widget->show();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
workspace->show();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QVERIFY( activeWindow == window );
window->close();
qApp->processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QVERIFY( activeWindow == 0 );
}
@@ -379,15 +379,15 @@ void tst_QMdiArea::subWindowActivated()
QMdiSubWindow *window = workspace->addSubWindow(widget);
widget->showMaximized();
qApp->sendPostedEvents();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
workspace->show();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QVERIFY( activeWindow == window );
window->close();
qApp->processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QVERIFY( activeWindow == 0 );
}
@@ -397,13 +397,13 @@ void tst_QMdiArea::subWindowActivated()
widget->setAttribute(Qt::WA_DeleteOnClose);
QMdiSubWindow *window = workspace->addSubWindow(widget);
widget->showMinimized();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QVERIFY( activeWindow == window );
QCOMPARE(workspace->activeSubWindow(), window);
window->close();
qApp->processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QVERIFY(!workspace->activeSubWindow());
QVERIFY(!activeWindow);
@@ -431,12 +431,12 @@ void tst_QMdiArea::subWindowActivated2()
QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)));
for (int i = 0; i < 5; ++i)
mdiArea.addSubWindow(new QWidget);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
mdiArea.show();
mdiArea.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
- QTRY_COMPARE(spy.count(), 5);
+ QTRY_COMPARE(spy.size(), 5);
QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back());
spy.clear();
@@ -445,13 +445,13 @@ void tst_QMdiArea::subWindowActivated2()
QMdiSubWindow *staysOnTopWindow = mdiArea.subWindowList().at(3);
staysOnTopWindow->setWindowFlags(Qt::WindowStaysOnTopHint);
mdiArea.setActiveSubWindow(staysOnTopWindow);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(mdiArea.activeSubWindow(), staysOnTopWindow);
spy.clear();
QMdiSubWindow *activeSubWindow = mdiArea.subWindowList().at(2);
mdiArea.setActiveSubWindow(activeSubWindow);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
@@ -459,7 +459,7 @@ void tst_QMdiArea::subWindowActivated2()
// is unchanged after hide/show.
mdiArea.hide();
QTest::qWait(100);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QVERIFY(!mdiArea.activeSubWindow());
QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
spy.clear();
@@ -487,7 +487,7 @@ void tst_QMdiArea::subWindowActivated2()
#endif
if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive))
QSKIP("QTBUG-25298: Unstable on some X11 window managers");
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QVERIFY(!mdiArea.activeSubWindow());
QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
spy.clear();
@@ -497,7 +497,7 @@ void tst_QMdiArea::subWindowActivated2()
mdiArea.showNormal();
mdiArea.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
}
@@ -534,7 +534,7 @@ void tst_QMdiArea::subWindowActivatedWithMinimize()
QVERIFY(!workspace->activeSubWindow());
QVERIFY(!activeWindow);
- QVERIFY( workspace->subWindowList().count() == 0 );
+ QVERIFY( workspace->subWindowList().size() == 0 );
}
void tst_QMdiArea::showWindows()
@@ -813,14 +813,14 @@ void tst_QMdiArea::fixedSize()
}
QList<QMdiSubWindow *> windows = ws->subWindowList();
- for (i = 0; i < (int)windows.count(); ++i) {
+ for (i = 0; i < (int)windows.size(); ++i) {
QMdiSubWindow *child = windows.at(i);
QCOMPARE(child->size(), fixed);
}
ws->cascadeSubWindows();
ws->resize(800, 800);
- for (i = 0; i < (int)windows.count(); ++i) {
+ for (i = 0; i < (int)windows.size(); ++i) {
QMdiSubWindow *child = windows.at(i);
QCOMPARE(child->size(), fixed);
}
@@ -828,13 +828,13 @@ void tst_QMdiArea::fixedSize()
ws->tileSubWindows();
ws->resize(800, 800);
- for (i = 0; i < (int)windows.count(); ++i) {
+ for (i = 0; i < (int)windows.size(); ++i) {
QMdiSubWindow *child = windows.at(i);
QCOMPARE(child->size(), fixed);
}
ws->resize(500, 500);
- for (i = 0; i < (int)windows.count(); ++i) {
+ for (i = 0; i < (int)windows.size(); ++i) {
QMdiSubWindow *child = windows.at(i);
delete child;
}
@@ -913,7 +913,7 @@ void tst_QMdiArea::setActiveSubWindow()
QVERIFY(windows[i]->isHidden());
workspace.setActiveSubWindow(windows[i]);
}
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(!activeWindow);
spy.clear();
@@ -923,7 +923,7 @@ void tst_QMdiArea::setActiveSubWindow()
QVERIFY(!windows[i]->isHidden());
workspace.setActiveSubWindow(windows[i]);
qApp->processEvents();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(activeWindow, windows[i]);
spy.clear();
}
@@ -931,7 +931,7 @@ void tst_QMdiArea::setActiveSubWindow()
// Deactivate active window
QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]);
workspace.setActiveSubWindow(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!activeWindow);
QVERIFY(!workspace.activeSubWindow());
@@ -1076,11 +1076,11 @@ void tst_QMdiArea::addAndRemoveWindows()
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
{ // addSubWindow with large widget
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
QWidget *window = workspace.addSubWindow(new LargeWidget);
QVERIFY(window);
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 1);
QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), workspace.viewport()->size());
}
@@ -1091,7 +1091,7 @@ void tst_QMdiArea::addAndRemoveWindows()
workspace.addSubWindow(window);
QVERIFY(window);
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 2);
+ QCOMPARE(workspace.subWindowList().size(), 2);
QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), window->minimumSize());
}
@@ -1103,7 +1103,7 @@ void tst_QMdiArea::addAndRemoveWindows()
workspace.addSubWindow(window);
QVERIFY(window);
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 3);
+ QCOMPARE(workspace.subWindowList().size(), 3);
QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), QSize(1500, 1500));
}
@@ -1112,7 +1112,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: null pointer to widget");
QWidget *window = workspace.addSubWindow(0);
QVERIFY(!window);
- QCOMPARE(workspace.subWindowList().count(), 3);
+ QCOMPARE(workspace.subWindowList().size(), 3);
}
{ // addChildWindow
@@ -1121,7 +1121,7 @@ void tst_QMdiArea::addAndRemoveWindows()
qApp->processEvents();
QCOMPARE(window->windowFlags(), DefaultWindowFlags);
window->setWidget(new QWidget);
- QCOMPARE(workspace.subWindowList().count(), 4);
+ QCOMPARE(workspace.subWindowList().size(), 4);
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
workspace.addSubWindow(window);
}
@@ -1129,7 +1129,7 @@ void tst_QMdiArea::addAndRemoveWindows()
{ // addChildWindow with 0 pointer
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: null pointer to widget");
workspace.addSubWindow(0);
- QCOMPARE(workspace.subWindowList().count(), 4);
+ QCOMPARE(workspace.subWindowList().size(), 4);
}
// removeSubWindow
@@ -1137,7 +1137,7 @@ void tst_QMdiArea::addAndRemoveWindows()
workspace.removeSubWindow(window);
delete window;
}
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
// removeSubWindow with 0 pointer
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::removeSubWindow: null pointer to widget");
@@ -1145,7 +1145,7 @@ void tst_QMdiArea::addAndRemoveWindows()
workspace.addSubWindow(new QPushButton(QLatin1String("Dummy to make workspace non-empty")));
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 1);
// removeSubWindow with window not inside workspace
QTest::ignoreMessage(QtWarningMsg,"QMdiArea::removeSubWindow: window is not inside workspace");
@@ -1187,20 +1187,20 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting()
// 0 because the window list contains widgets and not actual
// windows. Silly, but that's the behavior.
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
window.setWidget(new QWidget);
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 1);
window.setParent(0); // Will also reset window flags
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
window.setParent(&workspace);
- QCOMPARE(workspace.subWindowList().count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 1);
QCOMPARE(window.windowFlags(), DefaultWindowFlags);
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
workspace.addSubWindow(&window);
- QCOMPARE(workspace.subWindowList().count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 1);
}
class MySubWindow : public QMdiSubWindow
@@ -1257,17 +1257,17 @@ void tst_QMdiArea::closeWindows()
QWidget *widget = new QWidget;
QMdiSubWindow *subWindow = workspace.addSubWindow(widget);
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 1);
subWindow->close();
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
// Close window
QWidget *window = workspace.addSubWindow(new QWidget);
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 1);
window->close();
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
const int windowCount = 10;
@@ -1275,7 +1275,7 @@ void tst_QMdiArea::closeWindows()
for (int i = 0; i < windowCount; ++i)
workspace.addSubWindow(new QWidget)->show();
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), windowCount);
+ QCOMPARE(workspace.subWindowList().size(), windowCount);
int activeSubWindowCount = 0;
while (workspace.activeSubWindow()) {
workspace.activeSubWindow()->close();
@@ -1283,19 +1283,19 @@ void tst_QMdiArea::closeWindows()
++activeSubWindowCount;
}
QCOMPARE(activeSubWindowCount, windowCount);
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
// Close all windows
for (int i = 0; i < windowCount; ++i)
workspace.addSubWindow(new QWidget)->show();
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), windowCount);
+ QCOMPARE(workspace.subWindowList().size(), windowCount);
QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)));
connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(activeChanged(QMdiSubWindow*)));
workspace.closeAllSubWindows();
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(workspace.subWindowList().size(), 0);
+ QCOMPARE(spy.size(), 1);
QVERIFY(!activeWindow);
}
@@ -1321,7 +1321,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow()
workspace.activateNextSubWindow();
qApp->processEvents();
QCOMPARE(workspace.activeSubWindow(), windows[i]);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
QVERIFY(activeWindow);
@@ -1333,7 +1333,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow()
workspace.activatePreviousSubWindow();
qApp->processEvents();
QCOMPARE(workspace.activeSubWindow(), windows[i]);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
if (i % 2 == 0)
windows[i]->hide(); // 10, 8, 6, 4, 2, 0
@@ -1345,7 +1345,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow()
// activateNextSubWindow with every 2nd window hidden
for (int i = 0; i < windowCount / 2; ++i) {
workspace.activateNextSubWindow(); // 1, 3, 5, 7, 9
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]);
@@ -1353,7 +1353,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow()
// activatePreviousSubWindow with every 2nd window hidden
for (int i = 0; i < windowCount / 2; ++i) {
workspace.activatePreviousSubWindow(); // 7, 5, 3, 1, 9
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]);
@@ -1400,8 +1400,8 @@ void tst_QMdiArea::subWindowList()
{
QList<QMdiSubWindow *> widgets = workspace.subWindowList(windowOrder);
- QCOMPARE(widgets.count(), windowCount);
- for (int i = 0; i < widgets.count(); ++i)
+ QCOMPARE(widgets.size(), windowCount);
+ for (int i = 0; i < widgets.size(); ++i)
QCOMPARE(widgets.at(i), windows[i]);
}
@@ -1420,9 +1420,9 @@ void tst_QMdiArea::subWindowList()
}
if (windowOrder == QMdiArea::StackingOrder) {
- QCOMPARE(subWindows.at(subWindows.count() - 1), windows[staysOnTop1]);
- QCOMPARE(subWindows.at(subWindows.count() - 2), windows[activeSubWindow]);
- QCOMPARE(subWindows.count(), windowCount);
+ QCOMPARE(subWindows.at(subWindows.size() - 1), windows[staysOnTop1]);
+ QCOMPARE(subWindows.at(subWindows.size() - 2), windows[activeSubWindow]);
+ QCOMPARE(subWindows.size(), windowCount);
} else { // ActivationHistoryOrder
QCOMPARE(subWindows, activationOrder);
}
@@ -1437,11 +1437,11 @@ void tst_QMdiArea::subWindowList()
activationOrder.move(activationOrder.indexOf(windows[activeSubWindow]), windowCount - 1);
QList<QMdiSubWindow *> widgets = workspace.subWindowList(windowOrder);
- QCOMPARE(widgets.count(), windowCount);
+ QCOMPARE(widgets.size(), windowCount);
if (windowOrder == QMdiArea::StackingOrder) {
- QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop2]);
- QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]);
- QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]);
+ QCOMPARE(widgets.at(widgets.size() - 1), windows[staysOnTop2]);
+ QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(widgets.size() - 3), windows[activeSubWindow]);
} else { // ActivationHistory
QCOMPARE(widgets, activationOrder);
}
@@ -1451,8 +1451,8 @@ void tst_QMdiArea::subWindowList()
widgets = workspace.subWindowList(windowOrder);
if (windowOrder == QMdiArea::StackingOrder) {
- QCOMPARE(widgets.at(widgets.count() - 1), windows[activeSubWindow]);
- QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(widgets.size() - 1), windows[activeSubWindow]);
+ QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop1]);
QCOMPARE(widgets.at(0), windows[staysOnTop2]);
} else { // ActivationHistoryOrder
QCOMPARE(widgets, activationOrder);
@@ -1463,9 +1463,9 @@ void tst_QMdiArea::subWindowList()
widgets = workspace.subWindowList(windowOrder);
if (windowOrder == QMdiArea::StackingOrder) {
- QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop2]);
- QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]);
- QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]);
+ QCOMPARE(widgets.at(widgets.size() - 1), windows[staysOnTop2]);
+ QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(widgets.size() - 3), windows[activeSubWindow]);
} else { // ActivationHistoryOrder
QCOMPARE(widgets, activationOrder);
}
@@ -1475,9 +1475,9 @@ void tst_QMdiArea::subWindowList()
widgets = workspace.subWindowList(windowOrder);
if (windowOrder == QMdiArea::StackingOrder) {
- QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop1]);
- QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop2]);
- QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]);
+ QCOMPARE(widgets.at(widgets.size() - 1), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop2]);
+ QCOMPARE(widgets.at(widgets.size() - 3), windows[activeSubWindow]);
} else { // ActivationHistoryOrder
QCOMPARE(widgets, activationOrder);
}
@@ -1518,14 +1518,14 @@ void tst_QMdiArea::setViewport()
qApp->processEvents();
QList<QMdiSubWindow *> windowsBeforeViewportChange = workspace.subWindowList();
- QCOMPARE(windowsBeforeViewportChange.count(), windowCount);
+ QCOMPARE(windowsBeforeViewportChange.size(), windowCount);
workspace.setViewport(new QWidget);
qApp->processEvents();
QVERIFY(workspace.viewport() != firstViewport);
QList<QMdiSubWindow *> windowsAfterViewportChange = workspace.subWindowList();
- QCOMPARE(windowsAfterViewportChange.count(), windowCount);
+ QCOMPARE(windowsAfterViewportChange.size(), windowCount);
QCOMPARE(windowsAfterViewportChange, windowsBeforeViewportChange);
// for (int i = 0; i < windowCount; ++i) {
@@ -1541,7 +1541,7 @@ void tst_QMdiArea::setViewport()
delete workspace.viewport();
qApp->processEvents();
- QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(workspace.subWindowList().size(), 0);
QVERIFY(!workspace.activeSubWindow());
}
@@ -1781,7 +1781,7 @@ void tst_QMdiArea::cascadeAndTileSubWindows()
#endif
QCOMPARE(windows.at(2)->geometry().top() - windows.at(1)->geometry().top(), dy);
- for (int i = 0; i < windows.count(); ++i) {
+ for (int i = 0; i < windows.size(); ++i) {
QMdiSubWindow *window = windows.at(i);
if (i % 3 == 0) {
QVERIFY(window->isMinimized());
@@ -1892,7 +1892,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation()
// Verify that activated windows still are maximized on activation.
QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
- for (int i = 0; i < subWindows.count(); ++i) {
+ for (int i = 0; i < subWindows.size(); ++i) {
mdiArea.activateNextSubWindow();
QMdiSubWindow *window = subWindows.at(i);
QCOMPARE(mdiArea.activeSubWindow(), window);
@@ -1903,7 +1903,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation()
// Restore active window and verify that other windows aren't
// maximized on activation.
mdiArea.activeSubWindow()->showNormal();
- for (int i = 0; i < subWindows.count(); ++i) {
+ for (int i = 0; i < subWindows.size(); ++i) {
mdiArea.activateNextSubWindow();
QMdiSubWindow *window = subWindows.at(i);
QCOMPARE(mdiArea.activeSubWindow(), window);
@@ -1917,7 +1917,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation()
int indexOfMaximized = subWindows.indexOf(mdiArea.activeSubWindow());
// Verify that windows are not maximized on activation.
- for (int i = 0; i < subWindows.count(); ++i) {
+ for (int i = 0; i < subWindows.size(); ++i) {
mdiArea.activateNextSubWindow();
QMdiSubWindow *window = subWindows.at(i);
QCOMPARE(mdiArea.activeSubWindow(), window);
@@ -1939,7 +1939,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation()
mdiArea.activeSubWindow()->showMaximized();
// Verify that minimized windows are maximized on activation.
- for (int i = 0; i < subWindows.count(); ++i) {
+ for (int i = 0; i < subWindows.size(); ++i) {
mdiArea.activateNextSubWindow();
QMdiSubWindow *window = subWindows.at(i);
QCOMPARE(mdiArea.activeSubWindow(), window);
@@ -1949,7 +1949,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation()
// Verify that activated windows are maximized after closing
// the active window
- for (int i = 0; i < subWindows.count(); ++i) {
+ for (int i = 0; i < subWindows.size(); ++i) {
QVERIFY(mdiArea.activeSubWindow());
QVERIFY(mdiArea.activeSubWindow()->isMaximized());
mdiArea.activeSubWindow()->close();
@@ -2201,7 +2201,7 @@ void tst_QMdiArea::setActivationOrder()
mdiArea.show();
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
- for (int i = 0; i < subWindows.count(); ++i) {
+ for (int i = 0; i < subWindows.size(); ++i) {
mdiArea.activateNextSubWindow();
QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(i));
qApp->processEvents();
@@ -2265,7 +2265,7 @@ void tst_QMdiArea::tabBetweenSubWindows()
QCOMPARE(qApp->focusWidget(), focusWidget);
QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// Walk through the entire list of sub windows.
#ifdef Q_OS_MAC
@@ -2273,7 +2273,7 @@ void tst_QMdiArea::tabBetweenSubWindows()
#endif
QVERIFY(tabBetweenSubWindowsIn(&mdiArea));
QCOMPARE(mdiArea.activeSubWindow(), subWindows.back());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
mdiArea.setActiveSubWindow(subWindows.front());
QCOMPARE(mdiArea.activeSubWindow(), subWindows.front());
@@ -2282,12 +2282,12 @@ void tst_QMdiArea::tabBetweenSubWindows()
// Walk through the entire list of sub windows in the opposite direction (Ctrl-Shift-Tab).
QVERIFY(tabBetweenSubWindowsIn(&mdiArea, -1, true));
QCOMPARE(mdiArea.activeSubWindow(), subWindows.front());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// Ctrl-Tab-Tab-Tab
QVERIFY(tabBetweenSubWindowsIn(&mdiArea, 3));
QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(3));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
mdiArea.setActiveSubWindow(subWindows.at(1));
QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(1));
@@ -2296,7 +2296,7 @@ void tst_QMdiArea::tabBetweenSubWindows()
// Quick switch (Ctrl-Tab once) -> switch back to the previously active sub-window.
QVERIFY(tabBetweenSubWindowsIn(&mdiArea, 1));
QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(3));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QMdiArea::setViewMode()
@@ -2330,7 +2330,7 @@ void tst_QMdiArea::setViewMode()
QVERIFY(tabBar);
QVERIFY(tabBar->isVisible());
- QCOMPARE(tabBar->count(), subWindows.count());
+ QCOMPARE(tabBar->count(), subWindows.size());
QVERIFY(activeSubWindow->isMaximized());
QCOMPARE(tabBar->currentIndex(), subWindows.indexOf(activeSubWindow));
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index 1bdb1e8201..9fcecd19bf 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -471,7 +471,7 @@ void tst_QMdiSubWindow::mainWindowSupport()
workspace->activateNextSubWindow();
QCoreApplication::processEvents();
- for (QMdiSubWindow *window : qAsConst(windows)) {
+ for (QMdiSubWindow *window : std::as_const(windows)) {
QCOMPARE(workspace->activeSubWindow(), window);
QVERIFY(window->isMaximized());
QVERIFY(window->maximizedButtonsWidget());
@@ -528,9 +528,9 @@ void tst_QMdiSubWindow::emittingOfSignals()
int count = 0;
if (signal == SIGNAL(aboutToActivate())) {
- count += spy.count();
+ count += spy.size();
} else {
- for (int i = 0; i < spy.count(); ++i) {
+ for (int i = 0; i < spy.size(); ++i) {
Qt::WindowStates oldState = qvariant_cast<Qt::WindowStates>(spy.at(i).at(0));
Qt::WindowStates newState = qvariant_cast<Qt::WindowStates>(spy.at(i).at(1));
if (watchedState != Qt::WindowNoState) {
@@ -553,7 +553,7 @@ void tst_QMdiSubWindow::emittingOfSignals()
spy.clear();
triggerSignal(window, &workspace, signal);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
delete window;
window = nullptr;
@@ -1030,7 +1030,7 @@ void tst_QMdiSubWindow::setSystemMenu()
subWindow->setSystemMenu(systemMenu);
QCOMPARE(subWindow->systemMenu(), qobject_cast<QMenu *>(systemMenu));
QCOMPARE(subWindow->systemMenu()->parentWidget(), static_cast<QWidget *>(subWindow));
- QCOMPARE(subWindow->systemMenu()->actions().count(), 1);
+ QCOMPARE(subWindow->systemMenu()->actions().size(), 1);
// Show the new system menu
QVERIFY(!QApplication::activePopupWidget());
@@ -1254,7 +1254,7 @@ void tst_QMdiSubWindow::changeFocusWithTab()
mdiArea.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
mdiArea.addSubWindow(widget);
mdiArea.show();
- QCOMPARE(mdiArea.subWindowList().count(), 1);
+ QCOMPARE(mdiArea.subWindowList().size(), 1);
QApplication::setActiveWindow(&mdiArea);
QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(firstLineEdit));
@@ -1336,7 +1336,7 @@ void tst_QMdiSubWindow::closeEvent()
QVERIFY(window->close());
QCOMPARE(closeSpy.count(), 3);
- QCOMPARE(mdiArea.subWindowList().count(), 0);
+ QCOMPARE(mdiArea.subWindowList().size(), 0);
}
// There exists more tests in QMdiArea which covers window title support
@@ -2101,7 +2101,7 @@ void tst_QMdiSubWindow::styleChange()
// subWindowActivated should NOT be activated by a style change,
// even if internally QMdiSubWindow un-minimizes subwindows temporarily.
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QMdiSubWindow::testFullScreenState()
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 602795debb..a7563bfa26 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -110,6 +110,7 @@ private slots:
void tearOffMenuNotDisplayed();
void QTBUG_61039_menu_shortcuts();
void screenOrientationChangedCloseMenu();
+ void deleteWhenTriggered();
protected slots:
void onActivated(QAction*);
@@ -257,11 +258,11 @@ void tst_QMenu::onStatusMessageChanged(const QString &s)
void tst_QMenu::addActionsAndClear()
{
- QCOMPARE(menus[0]->actions().count(), 0);
+ QCOMPARE(menus[0]->actions().size(), 0);
createActions();
- QCOMPARE(menus[0]->actions().count(), 8);
+ QCOMPARE(menus[0]->actions().size(), 8);
menus[0]->clear();
- QCOMPARE(menus[0]->actions().count(), 0);
+ QCOMPARE(menus[0]->actions().size(), 0);
}
static void testFunction0() {}
@@ -1262,7 +1263,7 @@ void tst_QMenu::click_while_dismissing_submenu()
//the submenu must have been hidden for the bug to be triggered
QVERIFY(!sub.isVisible());
QTest::mouseRelease(menuWindow, Qt::LeftButton, {}, menu.rect().center() - QPoint(0, 2), 300);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
#endif
@@ -1838,12 +1839,12 @@ void tst_QMenu::menuSize_Scrolling()
private:
void showEvent(QShowEvent *e) override
{
- QVERIFY(actions().length() == m_numItems);
+ QVERIFY(actions().size() == m_numItems);
int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, this);
int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, this);
const QMargins cm = contentsMargins();
- QRect lastItem = actionGeometry(actions().at(actions().length() - 1));
+ QRect lastItem = actionGeometry(actions().at(actions().size() - 1));
QSize s = size();
if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)
|| !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) {
@@ -1909,7 +1910,7 @@ void tst_QMenu::menuSize_Scrolling()
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QList<QAction *> actions = menu.actions();
- QCOMPARE(actions.length(), numItems);
+ QCOMPARE(actions.size(), numItems);
MenuMetrics mm(&menu);
QTest::keyClick(&menu, Qt::Key_Home);
@@ -1989,11 +1990,11 @@ void tst_QMenu::QTBUG_61039_menu_shortcuts()
QSignalSpy actionKamenSpy(actionKamen, &QAction::triggered);
QTest::keyClick(&widget, Qt::Key_K);
- QTRY_COMPARE(actionKamenSpy.count(), 1);
+ QTRY_COMPARE(actionKamenSpy.size(), 1);
QSignalSpy actionJoeSpy(actionJoe, &QAction::triggered);
QTest::keyClick(&widget, Qt::Key_J, Qt::ControlModifier);
- QTRY_COMPARE(actionJoeSpy.count(), 1);
+ QTRY_COMPARE(actionJoeSpy.size(), 1);
}
void tst_QMenu::screenOrientationChangedCloseMenu()
@@ -2011,5 +2012,22 @@ void tst_QMenu::screenOrientationChangedCloseMenu()
QTRY_COMPARE(menu.isVisible(),false);
}
+/*
+ Verify that deleting the menu in a slot connected to an
+ action's triggered signal doesn't crash.
+ QTBUG-106718
+*/
+void tst_QMenu::deleteWhenTriggered()
+{
+ QPointer<QMenu> menu = new QMenu;
+ QAction *action = menu->addAction("Action", [&menu]{
+ delete menu;
+ });
+ menu->popup(QGuiApplication::primaryScreen()->availableGeometry().center());
+ menu->setActiveAction(action);
+ QTest::keyClick(menu, Qt::Key_Return);
+ QTRY_VERIFY(!menu);
+}
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 18aacc52c3..d6089cb1e4 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -1268,9 +1268,9 @@ void tst_QMenuBar::task223138_triggered()
//let's trigger the first action
top->trigger();
- QCOMPARE(menubarSpy.count(), 1);
- QCOMPARE(menuSpy.count(), 1);
- QCOMPARE(submenuSpy.count(), 0);
+ QCOMPARE(menubarSpy.size(), 1);
+ QCOMPARE(menuSpy.size(), 1);
+ QCOMPARE(submenuSpy.size(), 0);
menubarSpy.clear();
menuSpy.clear();
@@ -1278,9 +1278,9 @@ void tst_QMenuBar::task223138_triggered()
//let's trigger the sub action
action->trigger();
- QCOMPARE(menubarSpy.count(), 1);
- QCOMPARE(menuSpy.count(), 1);
- QCOMPARE(submenuSpy.count(), 1);
+ QCOMPARE(menubarSpy.size(), 1);
+ QCOMPARE(menuSpy.size(), 1);
+ QCOMPARE(submenuSpy.size(), 1);
}
void tst_QMenuBar::task256322_highlight()
@@ -1623,7 +1623,7 @@ void tst_QMenuBar::QTBUG_65488_hiddenActionTriggered()
// click center of the blank area on the menubar where Action1 resided
QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, win.menuBar()->geometry().center());
QCoreApplication::sendPostedEvents(); // make sure all queued events also dispatched
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
// QTBUG-56526
@@ -1697,13 +1697,13 @@ void tst_QMenuBar::QTBUG_25669_menubarActionDoubleTriggered()
QPoint posAct2 = menuBarActionWindowPos(win.menuBar(), act2);
QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct1);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct2);
- QTRY_COMPARE(spy.count(), 2);
+ QTRY_COMPARE(spy.size(), 2);
QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct2);
- QTRY_COMPARE(spy.count(), 3);
+ QTRY_COMPARE(spy.size(), 3);
}
void tst_QMenuBar::slotForTaskQTBUG53205()
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
index f90879ab12..c44dab255d 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -47,6 +47,8 @@ private slots:
void offscreen();
void offscreenThenOnscreen();
void paintWhileHidden();
+ void widgetWindowColorFormat_data();
+ void widgetWindowColorFormat();
#ifdef QT_BUILD_INTERNAL
void staticTextDanglingPointer();
@@ -68,7 +70,7 @@ void tst_QOpenGLWidget::create()
QSignalSpy frameSwappedSpy(w.data(), SIGNAL(frameSwapped()));
w->show();
QVERIFY(QTest::qWaitForWindowExposed(w.data()));
- QVERIFY(frameSwappedSpy.count() > 0);
+ QVERIFY(frameSwappedSpy.size() > 0);
QVERIFY(w->isValid());
QVERIFY(w->context());
@@ -163,7 +165,7 @@ void tst_QOpenGLWidget::createNonTopLevel()
w.resize(400, 400);
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
- QVERIFY(frameSwappedSpy.count() > 0);
+ QVERIFY(frameSwappedSpy.size() > 0);
QVERIFY(glw->m_resizeCalled);
glw->m_resizeCalled = false;
@@ -324,7 +326,7 @@ void tst_QOpenGLWidget::reparentTopLevel()
{
QSignalSpy frameSwappedSpy(glw1, &QOpenGLWidget::frameSwapped);
tabWidget.setCurrentIndex(tabWidget.addTab(glw1, "OpenGL widget 1"));
- QTRY_VERIFY(frameSwappedSpy.count() > 0);
+ QTRY_VERIFY(frameSwappedSpy.size() > 0);
}
PainterWidget *glw2 = new PainterWidget;
@@ -332,7 +334,7 @@ void tst_QOpenGLWidget::reparentTopLevel()
{
QSignalSpy frameSwappedSpy(glw2, &QOpenGLWidget::frameSwapped);
tabWidget.setCurrentIndex(tabWidget.addTab(glw2, "OpenGL widget 2"));
- QTRY_VERIFY(frameSwappedSpy.count() > 0);
+ QTRY_VERIFY(frameSwappedSpy.size() > 0);
}
QImage image = glw2->grabFramebuffer();
@@ -342,7 +344,7 @@ void tst_QOpenGLWidget::reparentTopLevel()
{
QSignalSpy frameSwappedSpy(glw1, &QOpenGLWidget::frameSwapped);
delete glw2;
- QTRY_VERIFY(frameSwappedSpy.count() > 0);
+ QTRY_VERIFY(frameSwappedSpy.size() > 0);
}
image = glw1->grabFramebuffer();
@@ -354,7 +356,7 @@ void tst_QOpenGLWidget::reparentTopLevel()
glw1->setParent(nullptr);
glw1->show();
QVERIFY(QTest::qWaitForWindowExposed(glw1));
- QTRY_VERIFY(frameSwappedSpy.count() > 0);
+ QTRY_VERIFY(frameSwappedSpy.size() > 0);
}
image = glw1->grabFramebuffer();
@@ -364,7 +366,7 @@ void tst_QOpenGLWidget::reparentTopLevel()
{
QSignalSpy frameSwappedSpy(glw1, &QOpenGLWidget::frameSwapped);
tabWidget.setCurrentIndex(tabWidget.addTab(glw1, "Re-added OpenGL widget 1"));
- QTRY_VERIFY(frameSwappedSpy.count() > 0);
+ QTRY_VERIFY(frameSwappedSpy.size() > 0);
}
image = glw1->grabFramebuffer();
@@ -528,39 +530,132 @@ void tst_QOpenGLWidget::nativeWindow()
#ifdef Q_OS_ANDROID
QSKIP("Crashes on Android, figure out why (QTBUG-102043)");
#endif
- QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
- w->resize(800, 600);
- w->show();
- w->winId();
- QVERIFY(QTest::qWaitForWindowExposed(w.data()));
- QImage image = w->grabFramebuffer();
- QVERIFY(!image.isNull());
- QCOMPARE(image.width(), w->width());
- QCOMPARE(image.height(), w->height());
- QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0));
- QVERIFY(w->internalWinId());
-
- // Now as a native child.
- QWidget nativeParent;
- nativeParent.resize(800, 600);
- nativeParent.setAttribute(Qt::WA_NativeWindow);
- ClearWidget *child = new ClearWidget(0, 800, 600);
- child->setClearColor(0, 1, 0);
- child->setParent(&nativeParent);
- child->resize(400, 400);
- child->move(23, 34);
- nativeParent.show();
- QVERIFY(QTest::qWaitForWindowExposed(&nativeParent));
-
- QVERIFY(nativeParent.internalWinId());
- QVERIFY(!child->internalWinId());
-
- image = child->grabFramebuffer();
- QVERIFY(!image.isNull());
- QCOMPARE(image.width(), child->width());
- QCOMPARE(image.height(), child->height());
- QVERIFY(image.pixel(30, 40) == qRgb(0, 255, 0));
+ // NB these tests do not fully verify that native child widgets are fully
+ // functional since there is no guarantee that the content is composed and
+ // presented correctly as we can only do verification with
+ // grabFramebuffer() here which only exercises a part of the pipeline.
+
+ {
+ QScopedPointer<ClearWidget> w(new ClearWidget(nullptr, 800, 600));
+ w->resize(800, 600);
+ w->show();
+ w->winId();
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
+
+ QImage image = w->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0));
+ QVERIFY(w->internalWinId());
+ }
+
+ // Now as a native child
+ {
+ QWidget topLevel;
+ topLevel.resize(800, 600);
+
+ ClearWidget *child = new ClearWidget(nullptr, 800, 600);
+ child->setParent(&topLevel);
+
+ // make it a native child (native window, but not top-level -> no backingstore)
+ child->winId();
+
+ child->setClearColor(0, 1, 0);
+ child->resize(400, 400);
+ child->move(23, 34);
+
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ QVERIFY(topLevel.internalWinId());
+ QVERIFY(child->internalWinId());
+
+ QImage image = child->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), child->width());
+ QCOMPARE(image.height(), child->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 255, 0));
+ }
+
+ // Now the same with WA_NativeWindow instead
+ {
+ QWidget topLevel;
+ topLevel.resize(800, 600);
+
+ ClearWidget *child = new ClearWidget(nullptr, 800, 600);
+ child->setParent(&topLevel);
+
+ // make it a native child (native window, but not top-level -> no backingstore)
+ child->setAttribute(Qt::WA_NativeWindow);
+
+ child->setClearColor(0, 1, 0);
+ child->resize(400, 400);
+ child->move(23, 34);
+
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ QVERIFY(child->internalWinId());
+
+ QImage image = child->grabFramebuffer();
+ QCOMPARE(image.width(), child->width());
+ QCOMPARE(image.height(), child->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 255, 0));
+ }
+
+ // Now as a child of a native child
+ {
+ QWidget topLevel;
+ topLevel.resize(800, 600);
+
+ QWidget *container = new QWidget(&topLevel);
+ // make it a native child (native window, but not top-level -> no backingstore)
+ container->winId();
+
+ ClearWidget *child = new ClearWidget(nullptr, 800, 600);
+ // set the parent separately, this is important, see next test case
+ child->setParent(container);
+ child->setClearColor(0, 1, 0);
+ child->resize(400, 400);
+ child->move(23, 34);
+
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ QVERIFY(topLevel.internalWinId());
+ QVERIFY(container->internalWinId());
+ QVERIFY(!child->internalWinId());
+
+ QImage image = child->grabFramebuffer();
+ QCOMPARE(image.width(), child->width());
+ QCOMPARE(image.height(), child->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 255, 0));
+ }
+
+ // Again as a child of a native child, but this time specifying the parent
+ // upon construction, not with an explicit setParent() call afterwards.
+ {
+ QWidget topLevel;
+ topLevel.resize(800, 600);
+ QWidget *container = new QWidget(&topLevel);
+ container->winId();
+ // parent it right away
+ ClearWidget *child = new ClearWidget(container, 800, 600);
+ child->setClearColor(0, 1, 0);
+ child->resize(400, 400);
+ child->move(23, 34);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QVERIFY(topLevel.internalWinId());
+ QVERIFY(container->internalWinId());
+ QVERIFY(!child->internalWinId());
+ QImage image = child->grabFramebuffer();
+ QCOMPARE(image.width(), child->width());
+ QCOMPARE(image.height(), child->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 255, 0));
+ }
}
static inline QString msgRgbMismatch(unsigned actual, unsigned expected)
@@ -679,7 +774,7 @@ void tst_QOpenGLWidget::stackWidgetOpaqueChildIsVisible()
// Switch to the QOpenGLWidget.
stack.setCurrentIndex(1);
- QTRY_COMPARE(clearWidget->m_paintCalled, true);
+ QTRY_VERIFY(clearWidget->m_paintCalled);
// Resize the tested region to be half size in the middle, because some OSes make the widget
// have rounded corners (e.g. OSX), and the grabbed window pixmap will not coincide perfectly
@@ -787,10 +882,34 @@ void tst_QOpenGLWidget::paintWhileHidden()
// on-screen at the point when update() is called.
w->setVisible(false);
- w->m_paintCalled = 0;
+ w->m_paintCalled = false;
w->update();
w->setVisible(true);
- QTRY_VERIFY(w->m_paintCalled > 0);
+ QTRY_VERIFY(w->m_paintCalled);
+}
+
+void tst_QOpenGLWidget::widgetWindowColorFormat_data()
+{
+ QTest::addColumn<bool>("translucent");
+ QTest::newRow("Translucent background disabled") << false;
+ QTest::newRow("Translucent background enabled") << true;
+}
+
+void tst_QOpenGLWidget::widgetWindowColorFormat()
+{
+ QFETCH(bool, translucent);
+
+ QOpenGLWidget w;
+ w.setAttribute(Qt::WA_TranslucentBackground, translucent);
+ w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+ w.setFixedSize(16, 16);
+ w.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
+
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ QCOMPARE(w.format().redBufferSize(), ctx->format().redBufferSize());
+ QCOMPARE(w.format().greenBufferSize(), ctx->format().greenBufferSize());
+ QCOMPARE(w.format().blueBufferSize(), ctx->format().blueBufferSize());
}
class StaticTextPainterWidget : public QOpenGLWidget
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index e0c213f8e0..ed68c735d4 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -132,6 +132,7 @@ private slots:
void appendTextWhenInvisible();
void placeholderVisibility_data();
void placeholderVisibility();
+ void scrollBarSignals();
private:
void createSelection();
@@ -393,7 +394,7 @@ void tst_QPlainTextEdit::cursorPositionChanged()
spy.clear();
QTest::keyClick(ed, Qt::Key_A);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTextCursor cursor = ed->textCursor();
cursor.movePosition(QTextCursor::Start);
@@ -401,23 +402,23 @@ void tst_QPlainTextEdit::cursorPositionChanged()
cursor.movePosition(QTextCursor::End);
spy.clear();
cursor.insertText("Test");
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
cursor.movePosition(QTextCursor::End);
ed->setTextCursor(cursor);
cursor.movePosition(QTextCursor::Start);
spy.clear();
cursor.insertText("Test");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QTest::keyClick(ed, Qt::Key_Left);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
CursorPositionChangedRecorder spy2(ed);
QVERIFY(ed->textCursor().position() > 0);
ed->setPlainText("Hello World");
- QCOMPARE(spy2.cursorPositions.count(), 1);
+ QCOMPARE(spy2.cursorPositions.size(), 1);
QCOMPARE(spy2.cursorPositions.at(0), 0);
QCOMPARE(ed->textCursor().position(), 0);
}
@@ -434,7 +435,7 @@ void tst_QPlainTextEdit::setTextCursor()
spy.clear();
ed->setTextCursor(cursor);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
#ifndef QT_NO_CLIPBOARD
@@ -451,7 +452,7 @@ void tst_QPlainTextEdit::undoAvailableAfterPaste()
const QString txt("Test");
QApplication::clipboard()->setText(txt);
ed->paste();
- QVERIFY(spy.count() >= 1);
+ QVERIFY(spy.size() >= 1);
QCOMPARE(ed->toPlainText(), txt);
}
#endif
@@ -705,16 +706,16 @@ void tst_QPlainTextEdit::noPropertiesOnDefaultTextEditCharFormat()
// on a text edit. Font properties instead should be taken from the
// widget's font (in sync with defaultFont property in document) and the
// foreground color should be taken from the palette.
- QCOMPARE(ed->textCursor().charFormat().properties().count(), 0);
+ QCOMPARE(ed->textCursor().charFormat().properties().size(), 0);
}
void tst_QPlainTextEdit::setPlainTextShouldEmitTextChangedOnce()
{
QSignalSpy spy(ed, SIGNAL(textChanged()));
ed->setPlainText("Yankee Doodle");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
ed->setPlainText("");
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QPlainTextEdit::overwriteMode()
@@ -1026,8 +1027,8 @@ void tst_QPlainTextEdit::copyAvailable()
//Compare spied signals
QEXPECT_FAIL("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true",
"Wrong undo selection behaviour. Should be fixed in some future release. (See task: 132482)", Abort);
- QCOMPARE(spyCopyAvailabe.count(), copyAvailable.count());
- for (int i=0;i<spyCopyAvailabe.count(); i++) {
+ QCOMPARE(spyCopyAvailabe.size(), copyAvailable.size());
+ for (int i=0;i<spyCopyAvailabe.size(); i++) {
QVariant variantSpyCopyAvailable = spyCopyAvailabe.at(i).at(0);
QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1());
}
@@ -1063,10 +1064,10 @@ void tst_QPlainTextEdit::moveCursor()
QCOMPARE(ed->textCursor().position(), 0);
ed->moveCursor(QTextCursor::NextCharacter);
QCOMPARE(ed->textCursor().position(), 1);
- QCOMPARE(cursorMovedSpy.count(), 1);
+ QCOMPARE(cursorMovedSpy.size(), 1);
ed->moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
QCOMPARE(ed->textCursor().position(), 2);
- QCOMPARE(cursorMovedSpy.count(), 2);
+ QCOMPARE(cursorMovedSpy.size(), 2);
QCOMPARE(ed->textCursor().selectedText(), QString("e"));
}
@@ -1278,7 +1279,7 @@ void tst_QPlainTextEdit::ensureVisibleWithRtl()
ed->setLayoutDirection(Qt::RightToLeft);
ed->setLineWrapMode(QPlainTextEdit::NoWrap);
QString txt(500, QChar(QLatin1Char('a')));
- QCOMPARE(txt.length(), 500);
+ QCOMPARE(txt.size(), 500);
ed->setPlainText(txt);
ed->resize(100, 100);
ed->show();
@@ -1331,7 +1332,7 @@ void tst_QPlainTextEdit::extraSelections()
ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
QList<QTextEdit::ExtraSelection> selections = ed->extraSelections();
- QCOMPARE(selections.count(), 1);
+ QCOMPARE(selections.size(), 1);
QCOMPARE(selections.at(0).cursor.position(), endPos);
QCOMPARE(selections.at(0).cursor.anchor(), wordPos);
}
@@ -1461,44 +1462,44 @@ void tst_QPlainTextEdit::selectionChanged()
QTest::keyClick(ed, Qt::Key_Right);
QCOMPARE(ed->textCursor().position(), 1);
- QCOMPARE(selectionChangedSpy.count(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
QCOMPARE(ed->textCursor().position(), 2);
- QCOMPARE(selectionChangedSpy.count(), 1);
+ QCOMPARE(selectionChangedSpy.size(), 1);
QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
QCOMPARE(ed->textCursor().position(), 3);
- QCOMPARE(selectionChangedSpy.count(), 2);
+ QCOMPARE(selectionChangedSpy.size(), 2);
QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
QCOMPARE(ed->textCursor().position(), 4);
- QCOMPARE(selectionChangedSpy.count(), 3);
+ QCOMPARE(selectionChangedSpy.size(), 3);
QTest::keyClick(ed, Qt::Key_Right);
QCOMPARE(ed->textCursor().position(), 4);
- QCOMPARE(selectionChangedSpy.count(), 4);
+ QCOMPARE(selectionChangedSpy.size(), 4);
QTest::keyClick(ed, Qt::Key_Right);
QCOMPARE(ed->textCursor().position(), 5);
- QCOMPARE(selectionChangedSpy.count(), 4);
+ QCOMPARE(selectionChangedSpy.size(), 4);
}
void tst_QPlainTextEdit::blockCountChanged()
{
QSignalSpy blockCountCpangedSpy(ed, SIGNAL(blockCountChanged(int)));
ed->setPlainText("Hello");
- QCOMPARE(blockCountCpangedSpy.count(), 0);
+ QCOMPARE(blockCountCpangedSpy.size(), 0);
ed->setPlainText("Hello World");
- QCOMPARE(blockCountCpangedSpy.count(), 0);
+ QCOMPARE(blockCountCpangedSpy.size(), 0);
ed->setPlainText("Hello \n World \n this \n has \n more \n blocks \n than \n just \n one");
- QCOMPARE(blockCountCpangedSpy.count(), 1);
+ QCOMPARE(blockCountCpangedSpy.size(), 1);
ed->setPlainText("One");
- QCOMPARE(blockCountCpangedSpy.count(), 2);
+ QCOMPARE(blockCountCpangedSpy.size(), 2);
ed->setPlainText("One \n Two");
- QCOMPARE(blockCountCpangedSpy.count(), 3);
+ QCOMPARE(blockCountCpangedSpy.size(), 3);
ed->setPlainText("Three \n Four");
- QCOMPARE(blockCountCpangedSpy.count(), 3);
+ QCOMPARE(blockCountCpangedSpy.size(), 3);
}
@@ -1699,7 +1700,7 @@ void tst_QPlainTextEdit::contextMenu()
QVERIFY(!ed->findChild<QAction *>(QStringLiteral("link-copy")));
QTextCursor cursor = ed->textCursor();
- cursor.setPosition(ed->toPlainText().length() - 2);
+ cursor.setPosition(ed->toPlainText().size() - 2);
ed->setTextCursor(cursor);
menu = ed->createStandardContextMenu(ed->cursorRect().center());
@@ -1782,7 +1783,7 @@ void tst_QPlainTextEdit::updateCursorPositionAfterEdit()
QTest::keyClick(&plaintextEdit, Qt::Key_Up);
// The curser should move back to the end of the copied text
- QCOMPARE(plaintextEdit.textCursor().position(), initialPosition + txt.length());
+ QCOMPARE(plaintextEdit.textCursor().position(), initialPosition + txt.size());
}
#endif
@@ -1919,5 +1920,30 @@ void tst_QPlainTextEdit::placeholderVisibility()
QTRY_VERIFY(plainTextEdit_d->placeholderVisible == placeholderVisible);
}
+
+void tst_QPlainTextEdit::scrollBarSignals()
+{
+ QPlainTextEdit plainTextEdit;
+ QString longText;
+ for (uint i = 0; i < 500; ++i)
+ longText += "This is going to be a very long text for scroll signal testing.\n";
+ plainTextEdit.setPlainText(longText);
+ QScrollBar *vbar = plainTextEdit.verticalScrollBar();
+ plainTextEdit.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&plainTextEdit));
+ QSignalSpy spy(vbar, &QScrollBar::valueChanged);
+
+ QTest::keyClick(vbar, Qt::Key_Down);
+ QTRY_COMPARE(spy.count(), 1);
+ QTest::keyClick(vbar, Qt::Key_PageDown);
+ QTRY_COMPARE(spy.count(), 2);
+ QTest::keyClick(vbar, Qt::Key_PageDown);
+ QTRY_COMPARE(spy.count(), 3);
+ QTest::keyClick(vbar, Qt::Key_Up);
+ QTRY_COMPARE(spy.count(), 4);
+ QTest::keyClick(vbar, Qt::Key_PageUp);
+ QTRY_COMPARE(spy.count(), 5);
+}
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 172c5878cb..cf74a9ae1f 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -611,7 +611,7 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QTest::qWait(300);
QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
QTest::qWait(300);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.size(), 2);
// add shortcut 'keypad 5' to button2
spy1.clear();
@@ -621,8 +621,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QTest::qWait(300);
QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
QTest::qWait(300);
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 1);
+ QCOMPARE(spy2.size(), 1);
// remove shortcut from button1
spy1.clear();
@@ -632,8 +632,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QTest::qWait(300);
QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
QTest::qWait(300);
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 0);
+ QCOMPARE(spy2.size(), 1);
}
#endif // QT_CONFIG(shortcut)
@@ -657,16 +657,16 @@ void tst_QPushButton::emitReleasedAfterChange()
QVERIFY(button1->isDown());
QTest::keyClick(&dialog, Qt::Key_Tab);
QVERIFY(!button1->isDown());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
button1->setFocus();
QTest::mousePress(button1, Qt::LeftButton);
QVERIFY(button1->isDown());
button1->setEnabled(false);
QVERIFY(!button1->isDown());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
/*
@@ -744,22 +744,22 @@ void tst_QPushButton::mousePressAndMove()
QSignalSpy releaseSpy(&button, &QAbstractButton::released);
QTest::mousePress(&button, Qt::LeftButton);
- QCOMPARE(pressSpy.count(), 1);
- QCOMPARE(releaseSpy.count(), 0);
+ QCOMPARE(pressSpy.size(), 1);
+ QCOMPARE(releaseSpy.size(), 0);
// mouse pressed and moving out
QTest::mouseMove(&button, QPoint(100, 100));
// should emit released signal when the mouse is dragged out of boundary
- QCOMPARE(pressSpy.count(), 1);
- QCOMPARE(releaseSpy.count(), 1);
+ QCOMPARE(pressSpy.size(), 1);
+ QCOMPARE(releaseSpy.size(), 1);
// mouse pressed and moving into
QTest::mouseMove(&button, QPoint(10, 10));
// should emit pressed signal when the mouse is dragged into of boundary
- QCOMPARE(pressSpy.count(), 2);
- QCOMPARE(releaseSpy.count(), 1);
+ QCOMPARE(pressSpy.size(), 2);
+ QCOMPARE(releaseSpy.size(), 1);
}
QTEST_MAIN(tst_QPushButton)
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
index a6e39bf273..8b53c73361 100644
--- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
+++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
@@ -90,7 +90,7 @@ void tst_QScrollBar::task_209492()
QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int)));
QCOMPARE(scrollArea.scrollCount, 0);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// Simulate a mouse click on the "scroll down button".
const QPoint pressPoint(verticalScrollBar->width() / 2, verticalScrollBar->height() - 10);
@@ -109,7 +109,7 @@ void tst_QScrollBar::task_209492()
QSKIP("The result depends on system setting and is not relevant on Mac");
#endif
QCOMPARE(scrollArea.scrollCount, 1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
#if QT_CONFIG(wheelevent)
@@ -159,7 +159,7 @@ void tst_QScrollBar::QTBUG_42871()
QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int)));
QVERIFY(spy.isValid());
QCOMPARE(myHandler.updatesCount, 0);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// Simulate a mouse click on the "scroll down button".
const QPoint pressPoint(scrollBarWidget.width() / 2, scrollBarWidget.height() - 10);
@@ -180,7 +180,7 @@ void tst_QScrollBar::QTBUG_42871()
}
// Check that the action was triggered once.
QCOMPARE(myHandler.updatesCount, 1);
- QCOMPARE(spy.count(), myHandler.updatesCount);
+ QCOMPARE(spy.size(), myHandler.updatesCount);
}
QTEST_MAIN(tst_QScrollBar)
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 732fdb6515..97df7a6c5f 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -939,38 +939,38 @@ void tst_QSpinBox::editingFinished()
QTest::keyClick(box, Qt::Key_Up);
QTest::keyClick(box, Qt::Key_Up);
- QCOMPARE(editingFinishedSpy1.count(), 0);
- QCOMPARE(editingFinishedSpy2.count(), 0);
+ QCOMPARE(editingFinishedSpy1.size(), 0);
+ QCOMPARE(editingFinishedSpy2.size(), 0);
QTest::keyClick(box2, Qt::Key_Up);
QTest::keyClick(box2, Qt::Key_Up);
box2->setFocus();
- QCOMPARE(editingFinishedSpy1.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 1);
box->setFocus();
- QCOMPARE(editingFinishedSpy1.count(), 1);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 1);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box, Qt::Key_Up);
- QCOMPARE(editingFinishedSpy1.count(), 1);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 1);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box, Qt::Key_Enter);
- QCOMPARE(editingFinishedSpy1.count(), 2);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 2);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box, Qt::Key_Return);
- QCOMPARE(editingFinishedSpy1.count(), 3);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 3);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
box2->setFocus();
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 1);
QTest::keyClick(box2, Qt::Key_Enter);
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 2);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 2);
QTest::keyClick(box2, Qt::Key_Return);
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 3);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 3);
testFocusWidget.hide();
- QCOMPARE(editingFinishedSpy1.count(), 4);
- QCOMPARE(editingFinishedSpy2.count(), 4);
+ QCOMPARE(editingFinishedSpy1.size(), 4);
+ QCOMPARE(editingFinishedSpy2.size(), 4);
//task203285
editingFinishedSpy1.clear();
@@ -987,7 +987,7 @@ void tst_QSpinBox::editingFinished()
box2->setFocus();
QTRY_VERIFY(qApp->focusWidget() != box);
QCOMPARE(box->text(), QLatin1String("20"));
- QCOMPARE(editingFinishedSpy1.count(), 1);
+ QCOMPARE(editingFinishedSpy1.size(), 1);
}
void tst_QSpinBox::removeAll()
@@ -1150,33 +1150,32 @@ public:
void tst_QSpinBox::sizeHint()
{
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout(widget);
+ QWidget widget;
+ QHBoxLayout *layout = new QHBoxLayout(&widget);
+
sizeHint_SpinBox *spinBox = new sizeHint_SpinBox;
layout->addWidget(spinBox);
- widget->show();
- QVERIFY(QTest::qWaitForWindowExposed(widget));
+ // Make sure all layout requests posted by the QHBoxLayout constructor and addWidget
+ // are processed before the widget is shown
+ QCoreApplication::sendPostedEvents(&widget, QEvent::LayoutRequest);
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
// Prefix
spinBox->sizeHintRequests = 0;
spinBox->setPrefix(QLatin1String("abcdefghij"));
- qApp->processEvents();
QTRY_VERIFY(spinBox->sizeHintRequests > 0);
// Suffix
spinBox->sizeHintRequests = 0;
spinBox->setSuffix(QLatin1String("abcdefghij"));
- qApp->processEvents();
QTRY_VERIFY(spinBox->sizeHintRequests > 0);
// Range
spinBox->sizeHintRequests = 0;
spinBox->setRange(0, 1234567890);
spinBox->setValue(spinBox->maximum());
- qApp->processEvents();
QTRY_VERIFY(spinBox->sizeHintRequests > 0);
-
- delete widget;
}
void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate()
@@ -1257,7 +1256,7 @@ void tst_QSpinBox::lineEditReturnPressed()
QSignalSpy spyCurrentChanged(spinBox.lineEdit(), SIGNAL(returnPressed()));
spinBox.show();
QTest::keyClick(&spinBox, Qt::Key_Return);
- QCOMPARE(spyCurrentChanged.count(), 1);
+ QCOMPARE(spyCurrentChanged.size(), 1);
}
void tst_QSpinBox::positiveSign()
@@ -1847,13 +1846,13 @@ void tst_QSpinBox::stepModifierPressAndHold()
qDebug() << "QGuiApplication::focusWindow():" << QGuiApplication::focusWindow();
qDebug() << "QGuiApplication::topLevelWindows():" << QGuiApplication::topLevelWindows();
QTest::mousePress(&spin, Qt::LeftButton, modifiers, buttonRect.center());
- QTRY_VERIFY2(spy.length() >= 3, qPrintable(QString::fromLatin1(
- "Expected valueChanged() to be emitted 3 or more times, but it was only emitted %1 times").arg(spy.length())));
+ QTRY_VERIFY2(spy.size() >= 3, qPrintable(QString::fromLatin1(
+ "Expected valueChanged() to be emitted 3 or more times, but it was only emitted %1 times").arg(spy.size())));
QTest::mouseRelease(&spin, Qt::LeftButton, modifiers, buttonRect.center());
const auto value = spy.last().at(0);
QVERIFY(value.metaType().id() == QMetaType::Int);
- QCOMPARE(value.toInt(), spy.length() * expectedStepModifier);
+ QCOMPARE(value.toInt(), spy.size() * expectedStepModifier);
}
void tst_QSpinBox::stepSelectAll_data()
diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
index 667c6868b7..ec3df1f03d 100644
--- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
@@ -908,55 +908,56 @@ void tst_QSplitter::rubberBandNotInSplitter()
void tst_QSplitter::task187373_addAbstractScrollAreas_data()
{
- QTest::addColumn<QString>("className");
+ QTest::addColumn<QByteArray>("className");
QTest::addColumn<bool>("addInConstructor");
QTest::addColumn<bool>("addOutsideConstructor");
- QStringList classNames;
- classNames << QLatin1String("QGraphicsView");
- classNames << QLatin1String("QMdiArea");
- classNames << QLatin1String("QScrollArea");
- classNames << QLatin1String("QTextEdit");
- classNames << QLatin1String("QTreeView");
-
- foreach (QString className, classNames) {
- QTest::newRow(qPrintable(className + QLatin1String(" 1"))) << className << false << true;
- QTest::newRow(qPrintable(className + QLatin1String(" 2"))) << className << true << false;
- QTest::newRow(qPrintable(className + QLatin1String(" 3"))) << className << true << true;
+ QList<QByteArray> classNames{
+ "QGraphicsView",
+ "QMdiArea",
+ "QScrollArea",
+ "QTextEdit",
+ "QTreeView"
+ };
+
+ for (const auto &className : std::as_const(classNames)) {
+ QTest::newRow(qPrintable(className + " 1")) << className << false << true;
+ QTest::newRow(qPrintable(className + " 2")) << className << true << false;
+ QTest::newRow(qPrintable(className + " 3")) << className << true << true;
}
}
static QAbstractScrollArea *task187373_createScrollArea(
- QSplitter *splitter, const QString &className, bool addInConstructor)
+ QSplitter *splitter, const QByteArray &className, bool addInConstructor)
{
- if (className == QLatin1String("QGraphicsView"))
+ if (className == "QGraphicsView")
return new QGraphicsView(addInConstructor ? splitter : 0);
- if (className == QLatin1String("QMdiArea"))
+ if (className == "QMdiArea")
return new QMdiArea(addInConstructor ? splitter : 0);
- if (className == QLatin1String("QScrollArea"))
+ if (className == "QScrollArea")
return new QScrollArea(addInConstructor ? splitter : 0);
- if (className == QLatin1String("QTextEdit"))
+ if (className == "QTextEdit")
return new QTextEdit(addInConstructor ? splitter : 0);
- if (className == QLatin1String("QTreeView"))
+ if (className == "QTreeView")
return new QTreeView(addInConstructor ? splitter : 0);
return 0;
}
void tst_QSplitter::task187373_addAbstractScrollAreas()
{
- QFETCH(QString, className);
+ QFETCH(QByteArray, className);
QFETCH(bool, addInConstructor);
QFETCH(bool, addOutsideConstructor);
QVERIFY(addInConstructor || addOutsideConstructor);
- QSplitter *splitter = new QSplitter;
- splitter->show();
- QVERIFY(splitter->isVisible());
+ QSplitter splitter;
+ splitter.show();
+ QVERIFY(splitter.isVisible());
- QAbstractScrollArea *w = task187373_createScrollArea(splitter, className, addInConstructor);
+ QAbstractScrollArea *w = task187373_createScrollArea(&splitter, className, addInConstructor);
QVERIFY(w);
if (addOutsideConstructor)
- splitter->addWidget(w);
+ splitter.addWidget(w);
QTRY_VERIFY(w->isVisible());
QVERIFY(!w->isHidden());
@@ -1062,7 +1063,7 @@ void tst_QSplitter::taskQTBUG_102249_moveNonPressed()
Qt::NoButton, Qt::MouseButtons(Qt::LeftButton),
Qt::NoModifier);
qApp->sendEvent(s.handle(0), &me);
- QCOMPARE(spyMove.count(), 0);
+ QCOMPARE(spyMove.size(), 0);
}
void tst_QSplitter::setLayout()
diff --git a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
index 353c44d6b3..15007e8a90 100644
--- a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
+++ b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
@@ -23,6 +23,7 @@ private slots:
void tempMessage();
void insertWidget();
void insertPermanentWidget();
+ void removeWidget();
void setSizeGripEnabled();
void task194017_hiddenWidget();
void QTBUG4334_hiddenOnMaximizedWindow();
@@ -104,6 +105,49 @@ void tst_QStatusBar::insertPermanentWidget()
QCOMPARE(sb.insertPermanentWidget(1, new QLabel("foo")), 6);
}
+void tst_QStatusBar::removeWidget()
+{
+ QStatusBar sb;
+ std::vector<std::unique_ptr<QLabel>> widgets;
+ std::vector<bool> states;
+ for (int i = 0; i < 10; ++i) {
+ const QString text = i > 5 ? QString("p_%1").arg(i) : QString::number(i);
+ widgets.push_back(std::make_unique<QLabel>(text));
+ states.push_back(true);
+ }
+
+ for (auto &&widget : widgets) {
+ if (widget->text().startsWith("p_"))
+ sb.addPermanentWidget(widget.get());
+ else
+ sb.addWidget(widget.get());
+ }
+ sb.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&sb));
+
+ auto checkStates = [&]{
+ for (size_t index = 0; index < std::size(widgets); ++index) {
+ if (widgets.at(index)->isVisible() != states.at(index)) {
+ qCritical("Mismatch for widget at index %zu\n"
+ "\tActual : %s\n"
+ "\tExpected: %s",
+ index, widgets.at(index)->isVisible() ? "true" : "false",
+ states.at(index) ? "true" : "false");
+ return false;
+ }
+ }
+ return true;
+ };
+
+ QVERIFY(checkStates());
+ // remove every widget except the first to trigger unstable reference
+ for (size_t i = 2; i < std::size(widgets); ++i) {
+ sb.removeWidget(widgets[i].get());
+ states[i] = false;
+ QVERIFY2(checkStates(), qPrintable(QString("Failure at index %1").arg(i)));
+ }
+}
+
void tst_QStatusBar::setSizeGripEnabled()
{
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
@@ -272,18 +316,18 @@ void tst_QStatusBar::messageChangedSignal()
testWidget->showMessage("Ready", 0);
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
testWidget->clearMessage();
QCOMPARE(testWidget->currentMessage(), QString());
QCOMPARE(testWidget->currentMessage(), currentMessage);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
testWidget->showMessage("Ready", 0);
testWidget->showMessage("Ready", 0);
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
}
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
index 1e19617be9..1d7e999b10 100644
--- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
+++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
@@ -209,7 +209,7 @@ void tst_QTabBar::testCurrentChanged()
QCOMPARE(tabBar.currentIndex(), 0);
tabBar.setCurrentIndex(tabToSet);
QCOMPARE(tabBar.currentIndex(), tabToSet);
- QCOMPARE(spy.count(), expectedCount);
+ QCOMPARE(spy.size(), expectedCount);
}
class TabBar : public QTabBar
@@ -283,7 +283,7 @@ void tst_QTabBar::removeTab()
tabbar.setCurrentIndex(currentIndex);
QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
tabbar.removeTab(deleteIndex);
- QTEST(int(spy.count()), "spyCount");
+ QTEST(int(spy.size()), "spyCount");
QTEST(tabbar.currentIndex(), "finalIndex");
}
@@ -314,7 +314,7 @@ void tst_QTabBar::hideTab()
tabbar.setCurrentIndex(currentIndex);
QSignalSpy spy(&tabbar, &QTabBar::currentChanged);
tabbar.setTabVisible(hideIndex, false);
- QTEST(int(spy.count()), "spyCount");
+ QTEST(int(spy.size()), "spyCount");
QTEST(tabbar.currentIndex(), "finalIndex");
}
@@ -458,12 +458,12 @@ void tst_QTabBar::removeLastTab()
QTabBar tabbar;
QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
int index = tabbar.addTab("foo");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), index);
spy.clear();
tabbar.removeTab(index);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), -1);
spy.clear();
}
@@ -482,7 +482,7 @@ void tst_QTabBar::removeLastVisibleTab()
{
QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
tabbar.removeTab(visible);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), -1);
QCOMPARE(tabbar.currentIndex(), -1);
}
@@ -495,7 +495,7 @@ void tst_QTabBar::removeLastVisibleTab()
{
QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
tabbar.removeTab(visible);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toInt(), -1);
QCOMPARE(tabbar.currentIndex(), -1);
}
@@ -519,7 +519,7 @@ void tst_QTabBar::closeButton()
QSignalSpy spy(&tabbar, SIGNAL(tabCloseRequested(int)));
button->click();
QCOMPARE(tabbar.count(), 1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
Q_DECLARE_METATYPE(QTabBar::ButtonPosition)
@@ -791,36 +791,36 @@ void tst_QTabBar::tabBarClicked()
QSignalSpy clickSpy(&tabBar, SIGNAL(tabBarClicked(int)));
QSignalSpy doubleClickSpy(&tabBar, SIGNAL(tabBarDoubleClicked(int)));
- QCOMPARE(clickSpy.count(), 0);
- QCOMPARE(doubleClickSpy.count(), 0);
+ QCOMPARE(clickSpy.size(), 0);
+ QCOMPARE(doubleClickSpy.size(), 0);
Qt::MouseButton button = Qt::LeftButton;
while (button <= Qt::MaxMouseButton) {
const QPoint tabPos = tabBar.tabRect(0).center();
QTest::mouseClick(&tabBar, button, {}, tabPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0);
- QCOMPARE(doubleClickSpy.count(), 0);
+ QCOMPARE(doubleClickSpy.size(), 0);
QTest::mouseDClick(&tabBar, button, {}, tabPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0);
- QCOMPARE(doubleClickSpy.count(), 1);
+ QCOMPARE(doubleClickSpy.size(), 1);
QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), 0);
QTest::mouseRelease(&tabBar, button, {}, tabPos);
const QPoint barPos(tabBar.tabRect(0).right() + 5, tabBar.tabRect(0).center().y());
QTest::mouseClick(&tabBar, button, {}, barPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1);
- QCOMPARE(doubleClickSpy.count(), 0);
+ QCOMPARE(doubleClickSpy.size(), 0);
QTest::mouseDClick(&tabBar, button, {}, barPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1);
- QCOMPARE(doubleClickSpy.count(), 1);
+ QCOMPARE(doubleClickSpy.size(), 1);
QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), -1);
QTest::mouseRelease(&tabBar, button, {}, barPos);
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
index 0cf37ad9d0..00cb26c2d3 100644
--- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -358,12 +358,12 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(tw->currentIndex(), -1);
tw->setCurrentIndex(-1);
QCOMPARE(tw->currentIndex(), -1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
int firstIndex = addPage();
tw->setCurrentIndex(firstIndex);
QCOMPARE(tw->currentIndex(), firstIndex);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), firstIndex);
@@ -371,19 +371,19 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(tw->currentIndex(), firstIndex);
tw->setCurrentIndex(index);
QCOMPARE(tw->currentIndex(), index);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), index);
removePage(index);
QCOMPARE(tw->currentIndex(), firstIndex);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), firstIndex);
removePage(firstIndex);
QCOMPARE(tw->currentIndex(), -1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), -1);
}
@@ -664,8 +664,8 @@ void tst_QTabWidget::tabBarClicked()
QSignalSpy clickSpy(&tabWidget, SIGNAL(tabBarClicked(int)));
QSignalSpy doubleClickSpy(&tabWidget, SIGNAL(tabBarDoubleClicked(int)));
- QCOMPARE(clickSpy.count(), 0);
- QCOMPARE(doubleClickSpy.count(), 0);
+ QCOMPARE(clickSpy.size(), 0);
+ QCOMPARE(doubleClickSpy.size(), 0);
QTabBar &tabBar = *tabWidget.tabBar();
Qt::MouseButton button = Qt::LeftButton;
@@ -673,27 +673,27 @@ void tst_QTabWidget::tabBarClicked()
const QPoint tabPos = tabBar.tabRect(0).center();
QTest::mouseClick(&tabBar, button, {}, tabPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0);
- QCOMPARE(doubleClickSpy.count(), 0);
+ QCOMPARE(doubleClickSpy.size(), 0);
QTest::mouseDClick(&tabBar, button, {}, tabPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0);
- QCOMPARE(doubleClickSpy.count(), 1);
+ QCOMPARE(doubleClickSpy.size(), 1);
QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), 0);
const QPoint barPos(tabBar.tabRect(0).right() + 5, tabBar.tabRect(0).center().y());
QTest::mouseClick(&tabBar, button, {}, barPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1);
- QCOMPARE(doubleClickSpy.count(), 0);
+ QCOMPARE(doubleClickSpy.size(), 0);
QTest::mouseDClick(&tabBar, button, {}, barPos);
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1);
- QCOMPARE(doubleClickSpy.count(), 1);
+ QCOMPARE(doubleClickSpy.size(), 1);
QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), -1);
button = Qt::MouseButton(button << 1);
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
index ee950fa670..7107ed43e0 100644
--- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -220,29 +220,29 @@ void tst_QTextBrowser::relativeLinks()
QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(QUrl)));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
- QCOMPARE(sourceChangedSpy.count(), 1);
+ QCOMPARE(sourceChangedSpy.size(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
- QCOMPARE(sourceChangedSpy.count(), 1);
+ QCOMPARE(sourceChangedSpy.size(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
browser->setSource(QUrl("anchor.html"));
QVERIFY(!browser->document()->isEmpty());
- QCOMPARE(sourceChangedSpy.count(), 1);
+ QCOMPARE(sourceChangedSpy.size(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("anchor.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
- QCOMPARE(sourceChangedSpy.count(), 1);
+ QCOMPARE(sourceChangedSpy.size(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
// using QUrl::fromLocalFile()
browser->setSource(QUrl::fromLocalFile("anchor.html"));
QVERIFY(!browser->document()->isEmpty());
- QCOMPARE(sourceChangedSpy.count(), 1);
+ QCOMPARE(sourceChangedSpy.size(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("file:anchor.html"));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
- QCOMPARE(sourceChangedSpy.count(), 1);
+ QCOMPARE(sourceChangedSpy.size(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
}
@@ -274,9 +274,9 @@ void tst_QTextBrowser::forwardBackwardAvailable()
browser->setSource(QUrl::fromLocalFile("anchor.html"));
QVERIFY(!browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(!backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -285,9 +285,9 @@ void tst_QTextBrowser::forwardBackwardAvailable()
browser->setSource(QUrl::fromLocalFile("bigpage.html"));
QVERIFY(browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -296,9 +296,9 @@ void tst_QTextBrowser::forwardBackwardAvailable()
browser->setSource(QUrl::fromLocalFile("pagewithbg.html"));
QVERIFY(browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -307,9 +307,9 @@ void tst_QTextBrowser::forwardBackwardAvailable()
browser->backward();
QVERIFY(browser->isBackwardAvailable());
QVERIFY(browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -318,9 +318,9 @@ void tst_QTextBrowser::forwardBackwardAvailable()
browser->backward();
QVERIFY(!browser->isBackwardAvailable());
QVERIFY(browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(!backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -329,9 +329,9 @@ void tst_QTextBrowser::forwardBackwardAvailable()
browser->forward();
QVERIFY(browser->isBackwardAvailable());
QVERIFY(browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -340,9 +340,9 @@ void tst_QTextBrowser::forwardBackwardAvailable()
browser->forward();
QVERIFY(browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -360,9 +360,9 @@ void tst_QTextBrowser::clearHistory()
browser->clearHistory();
QVERIFY(!browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(!backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
QVERIFY(browser->historyTitle(0).isEmpty());
@@ -374,9 +374,9 @@ void tst_QTextBrowser::clearHistory()
browser->setSource(QUrl::fromLocalFile("anchor.html"));
QVERIFY(!browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(!backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -385,9 +385,9 @@ void tst_QTextBrowser::clearHistory()
browser->setSource(QUrl::fromLocalFile("bigpage.html"));
QVERIFY(browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
backwardSpy.clear();
@@ -396,9 +396,9 @@ void tst_QTextBrowser::clearHistory()
browser->clearHistory();
QVERIFY(!browser->isBackwardAvailable());
QVERIFY(!browser->isForwardAvailable());
- QCOMPARE(backwardSpy.count(), 1);
+ QCOMPARE(backwardSpy.size(), 1);
QVERIFY(!backwardSpy.at(0).at(0).toBool());
- QCOMPARE(forwardSpy.count(), 1);
+ QCOMPARE(forwardSpy.size(), 1);
QVERIFY(!forwardSpy.at(0).at(0).toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
QVERIFY(browser->historyTitle(1).isEmpty());
@@ -671,7 +671,7 @@ void tst_QTextBrowser::urlEncoding()
browser->setEditFocus(true);
#endif
QTest::keyClick(browser, Qt::Key_Enter);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QUrl url = spy.at(0).at(0).toUrl();
QCOMPARE(url.toEncoded(), QByteArray("http://www.google.com/q=%22"));
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 233090e8e6..8fd5cd0d52 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -517,9 +517,9 @@ void tst_QTextEdit::clearShouldClearExtraSelections()
sel.cursor = ed->textCursor();
sel.format.setProperty(QTextFormat::FullWidthSelection, true);
ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
- QCOMPARE(ed->extraSelections().count(), 1);
+ QCOMPARE(ed->extraSelections().size(), 1);
ed->clear();
- QCOMPARE(ed->extraSelections().count(), 0);
+ QCOMPARE(ed->extraSelections().size(), 0);
}
void tst_QTextEdit::paragSeparatorOnPlaintextAppend()
@@ -719,7 +719,7 @@ void tst_QTextEdit::cursorPositionChanged()
spy.clear();
QTest::keyClick(ed, Qt::Key_A);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTextCursor cursor = ed->textCursor();
cursor.movePosition(QTextCursor::Start);
@@ -727,18 +727,18 @@ void tst_QTextEdit::cursorPositionChanged()
cursor.movePosition(QTextCursor::End);
spy.clear();
cursor.insertText("Test");
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
cursor.movePosition(QTextCursor::End);
ed->setTextCursor(cursor);
cursor.movePosition(QTextCursor::Start);
spy.clear();
cursor.insertText("Test");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QTest::keyClick(ed, Qt::Key_Left);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
cursor.movePosition(QTextCursor::Start);
ed->setTextCursor(cursor);
@@ -747,12 +747,12 @@ void tst_QTextEdit::cursorPositionChanged()
QTest::mouseDClick(ed->viewport(), Qt::LeftButton, {}, ed->cursorRect().center());
QVERIFY(ed->textCursor().hasSelection());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
CursorPositionChangedRecorder spy2(ed);
QVERIFY(ed->textCursor().position() > 0);
ed->setPlainText("Hello World");
- QCOMPARE(spy2.cursorPositions.count(), 1);
+ QCOMPARE(spy2.cursorPositions.size(), 1);
QCOMPARE(spy2.cursorPositions.at(0), 0);
QCOMPARE(ed->textCursor().position(), 0);
}
@@ -769,7 +769,7 @@ void tst_QTextEdit::setTextCursor()
spy.clear();
ed->setTextCursor(cursor);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
#ifndef QT_NO_CLIPBOARD
@@ -786,7 +786,7 @@ void tst_QTextEdit::undoAvailableAfterPaste()
const QString txt("Test");
QApplication::clipboard()->setText(txt);
ed->paste();
- QVERIFY(spy.count() >= 1);
+ QVERIFY(spy.size() >= 1);
QCOMPARE(ed->toPlainText(), txt);
}
#endif
@@ -1039,7 +1039,7 @@ void tst_QTextEdit::noPropertiesOnDefaultTextEditCharFormat()
// on a text edit. Font properties instead should be taken from the
// widget's font (in sync with defaultFont property in document) and the
// foreground color should be taken from the palette.
- QCOMPARE(ed->currentCharFormat().properties().count(), 0);
+ QCOMPARE(ed->currentCharFormat().properties().size(), 0);
}
void tst_QTextEdit::setPlainTextShouldUseCurrentCharFormat()
@@ -1061,9 +1061,9 @@ void tst_QTextEdit::setPlainTextShouldEmitTextChangedOnce()
{
QSignalSpy spy(ed, SIGNAL(textChanged()));
ed->setPlainText("Yankee Doodle");
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
ed->setPlainText("");
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QTextEdit::overwriteMode()
@@ -1377,8 +1377,8 @@ void tst_QTextEdit::copyAvailable()
//Compare spied signals
QEXPECT_FAIL("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true",
"Wrong undo selection behaviour. Should be fixed in some future release. (See task: 132482)", Abort);
- QCOMPARE(spyCopyAvailabe.count(), copyAvailable.count());
- for (int i=0;i<spyCopyAvailabe.count(); i++) {
+ QCOMPARE(spyCopyAvailabe.size(), copyAvailable.size());
+ for (int i=0;i<spyCopyAvailabe.size(); i++) {
QVariant variantSpyCopyAvailable = spyCopyAvailabe.at(i).at(0);
QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1());
}
@@ -1414,10 +1414,10 @@ void tst_QTextEdit::moveCursor()
QCOMPARE(ed->textCursor().position(), 0);
ed->moveCursor(QTextCursor::NextCharacter);
QCOMPARE(ed->textCursor().position(), 1);
- QCOMPARE(cursorMovedSpy.count(), 1);
+ QCOMPARE(cursorMovedSpy.size(), 1);
ed->moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
QCOMPARE(ed->textCursor().position(), 2);
- QCOMPARE(cursorMovedSpy.count(), 2);
+ QCOMPARE(cursorMovedSpy.size(), 2);
QCOMPARE(ed->textCursor().selectedText(), QString("e"));
}
@@ -1692,7 +1692,7 @@ void tst_QTextEdit::ensureVisibleWithRtl()
ed->setLayoutDirection(Qt::RightToLeft);
ed->setLineWrapMode(QTextEdit::NoWrap);
QString txt(500, QChar(QLatin1Char('a')));
- QCOMPARE(txt.length(), 500);
+ QCOMPARE(txt.size(), 500);
ed->setPlainText(txt);
ed->resize(100, 100);
ed->show();
@@ -1743,7 +1743,7 @@ void tst_QTextEdit::extraSelections()
ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
QList<QTextEdit::ExtraSelection> selections = ed->extraSelections();
- QCOMPARE(selections.count(), 1);
+ QCOMPARE(selections.size(), 1);
QCOMPARE(selections.at(0).cursor.position(), endPos);
QCOMPARE(selections.at(0).cursor.anchor(), wordPos);
}
@@ -1885,27 +1885,27 @@ void tst_QTextEdit::selectionChanged()
QTest::keyClick(ed, Qt::Key_Right);
QCOMPARE(ed->textCursor().position(), 1);
- QCOMPARE(selectionChangedSpy.count(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
QCOMPARE(ed->textCursor().position(), 2);
- QCOMPARE(selectionChangedSpy.count(), 1);
+ QCOMPARE(selectionChangedSpy.size(), 1);
QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
QCOMPARE(ed->textCursor().position(), 3);
- QCOMPARE(selectionChangedSpy.count(), 2);
+ QCOMPARE(selectionChangedSpy.size(), 2);
QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
QCOMPARE(ed->textCursor().position(), 4);
- QCOMPARE(selectionChangedSpy.count(), 3);
+ QCOMPARE(selectionChangedSpy.size(), 3);
QTest::keyClick(ed, Qt::Key_Right);
QCOMPARE(ed->textCursor().position(), 4);
- QCOMPARE(selectionChangedSpy.count(), 4);
+ QCOMPARE(selectionChangedSpy.size(), 4);
QTest::keyClick(ed, Qt::Key_Right);
QCOMPARE(ed->textCursor().position(), 5);
- QCOMPARE(selectionChangedSpy.count(), 4);
+ QCOMPARE(selectionChangedSpy.size(), 4);
}
#ifndef QT_NO_CLIPBOARD
@@ -2533,7 +2533,7 @@ void tst_QTextEdit::inputMethodEvent()
QInputMethodEvent event;
event.setCommitString("text");
QApplication::sendEvent(ed, &event);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(ed->toPlainText(), QString("text"));
// test that input method gets chance to commit preedit when removing focus
@@ -2563,7 +2563,7 @@ void tst_QTextEdit::inputMethodSelection()
cursor.setPosition(5, QTextCursor::KeepAnchor);
ed->setTextCursor(cursor);
- QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(selectionSpy.size(), 1);
QCOMPARE(ed->textCursor().selectionStart(), 0);
QCOMPARE(ed->textCursor().selectionEnd(), 5);
@@ -2572,7 +2572,7 @@ void tst_QTextEdit::inputMethodSelection()
QInputMethodEvent event("", attributes);
QApplication::sendEvent(ed, &event);
- QCOMPARE(selectionSpy.count(), 2);
+ QCOMPARE(selectionSpy.size(), 2);
QCOMPARE(ed->textCursor().selectionStart(), 12);
QCOMPARE(ed->textCursor().selectionEnd(), 17);
}
@@ -2587,7 +2587,7 @@ void tst_QTextEdit::inputMethodQuery()
QGuiApplication::sendEvent(ed, &event);
int anchor = event.value(Qt::ImAnchorPosition).toInt();
int position = event.value(Qt::ImCursorPosition).toInt();
- QCOMPARE(qAbs(position - anchor), text.length());
+ QCOMPARE(qAbs(position - anchor), text.size());
QCOMPARE(event.value(Qt::ImEnabled).toBool(), true);
ed->setEnabled(false);
@@ -2672,7 +2672,7 @@ void tst_QTextEdit::countTextChangedOnRemove()
QKeyEvent event(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier);
QCoreApplication::instance()->notify(&edit, &event);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
#if QT_CONFIG(regularexpression)
diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
index c1d08316f8..e2c9f22ec2 100644
--- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
+++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
@@ -137,12 +137,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setAllowedAreas(Qt::RightToolBarArea);
QCOMPARE((int)tb.allowedAreas(), (int)Qt::RightToolBarArea);
@@ -150,12 +150,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setAllowedAreas(Qt::TopToolBarArea);
QCOMPARE((int)tb.allowedAreas(), (int)Qt::TopToolBarArea);
@@ -163,12 +163,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setAllowedAreas(Qt::BottomToolBarArea);
QCOMPARE((int)tb.allowedAreas(), (int)Qt::BottomToolBarArea);
@@ -176,12 +176,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// multiple dock window areas
tb.setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
@@ -190,12 +190,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
QCOMPARE(tb.allowedAreas(), Qt::LeftToolBarArea | Qt::RightToolBarArea);
@@ -203,12 +203,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea);
QCOMPARE(tb.allowedAreas(), Qt::TopToolBarArea | Qt::LeftToolBarArea);
@@ -216,12 +216,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setAllowedAreas(Qt::BottomToolBarArea | Qt::RightToolBarArea);
QCOMPARE(tb.allowedAreas(), Qt::BottomToolBarArea | Qt::RightToolBarArea);
@@ -229,12 +229,12 @@ void tst_QToolBar::allowedAreas()
QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
tb.allowedAreas());
spy.clear();
tb.setAllowedAreas(tb.allowedAreas());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QToolBar::orientation()
@@ -246,48 +246,48 @@ void tst_QToolBar::orientation()
tb.setOrientation(Qt::Vertical);
QCOMPARE(tb.orientation(), Qt::Vertical);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
tb.orientation());
spy.clear();
tb.setOrientation(tb.orientation());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setOrientation(Qt::Horizontal);
QCOMPARE(tb.orientation(), Qt::Horizontal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
tb.orientation());
spy.clear();
tb.setOrientation(tb.orientation());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setOrientation(Qt::Vertical);
QCOMPARE(tb.orientation(), Qt::Vertical);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
tb.orientation());
spy.clear();
tb.setOrientation(tb.orientation());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setOrientation(Qt::Horizontal);
QCOMPARE(tb.orientation(), Qt::Horizontal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
tb.orientation());
spy.clear();
tb.setOrientation(tb.orientation());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setOrientation(Qt::Vertical);
QCOMPARE(tb.orientation(), Qt::Vertical);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
tb.orientation());
spy.clear();
tb.setOrientation(tb.orientation());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QToolBar::addAction()
@@ -297,13 +297,13 @@ void tst_QToolBar::addAction()
{
QAction action(0);
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
tb.addAction(&action);
- QCOMPARE(tb.actions().count(), 1);
+ QCOMPARE(tb.actions().size(), 1);
QCOMPARE(tb.actions()[0], &action);
tb.clear();
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
}
{
@@ -326,14 +326,14 @@ void tst_QToolBar::addAction()
QCOMPARE(icon, action4->icon());
QCOMPARE(text, action4->text());
- QCOMPARE(tb.actions().count(), 4);
+ QCOMPARE(tb.actions().size(), 4);
QCOMPARE(tb.actions()[0], action1);
QCOMPARE(tb.actions()[1], action2);
QCOMPARE(tb.actions()[2], action3);
QCOMPARE(tb.actions()[3], action4);
tb.clear();
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
}
}
@@ -362,19 +362,19 @@ void tst_QToolBar::insertAction()
QAction action3(0);
QAction action4(0);
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
tb.insertAction(0, &action1);
tb.insertAction(&action1, &action2);
tb.insertAction(&action2, &action3);
tb.insertAction(&action3, &action4);
- QCOMPARE(tb.actions().count(), 4);
+ QCOMPARE(tb.actions().size(), 4);
QCOMPARE(tb.actions()[0], &action4);
QCOMPARE(tb.actions()[1], &action3);
QCOMPARE(tb.actions()[2], &action2);
QCOMPARE(tb.actions()[3], &action1);
tb.clear();
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
}
void tst_QToolBar::addSeparator()
@@ -388,13 +388,13 @@ void tst_QToolBar::addSeparator()
QAction *sep = tb.addSeparator();
tb.addAction(&action2);
- QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions().size(), 3);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], sep);
QCOMPARE(tb.actions()[2], &action2);
tb.clear();
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
}
void tst_QToolBar::insertSeparator()
@@ -408,13 +408,13 @@ void tst_QToolBar::insertSeparator()
tb.addAction(&action2);
QAction *sep = tb.insertSeparator(&action2);
- QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions().size(), 3);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], sep);
QCOMPARE(tb.actions()[2], &action2);
tb.clear();
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
}
void tst_QToolBar::addWidget()
@@ -429,7 +429,7 @@ void tst_QToolBar::addWidget()
QAction *widget = tb.addWidget(&w);
tb.addAction(&action2);
- QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions().size(), 3);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], widget);
QCOMPARE(tb.actions()[2], &action2);
@@ -437,18 +437,18 @@ void tst_QToolBar::addWidget()
// it should be possible to reuse the action returned by
// addWidget() to place the widget somewhere else in the toolbar
tb.removeAction(widget);
- QCOMPARE(tb.actions().count(), 2);
+ QCOMPARE(tb.actions().size(), 2);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], &action2);
tb.addAction(widget);
- QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions().size(), 3);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], &action2);
QCOMPARE(tb.actions()[2], widget);
tb.clear();
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
}
void tst_QToolBar::insertWidget()
@@ -463,7 +463,7 @@ void tst_QToolBar::insertWidget()
tb.addAction(&action2);
QAction *widget = tb.insertWidget(&action2, &w);
- QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions().size(), 3);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], widget);
QCOMPARE(tb.actions()[2], &action2);
@@ -471,18 +471,18 @@ void tst_QToolBar::insertWidget()
// it should be possible to reuse the action returned by
// addWidget() to place the widget somewhere else in the toolbar
tb.removeAction(widget);
- QCOMPARE(tb.actions().count(), 2);
+ QCOMPARE(tb.actions().size(), 2);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], &action2);
tb.insertAction(&action1, widget);
- QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions().size(), 3);
QCOMPARE(tb.actions()[0], widget);
QCOMPARE(tb.actions()[1], &action1);
QCOMPARE(tb.actions()[2], &action2);
tb.clear();
- QCOMPARE(tb.actions().count(), 0);
+ QCOMPARE(tb.actions().size(), 0);
{
QToolBar tb;
@@ -624,43 +624,43 @@ void tst_QToolBar::iconSize()
QCOMPARE(tb.iconSize(), defaultIconSize);
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
tb.setIconSize(largeIconSize);
QCOMPARE(tb.iconSize(), largeIconSize);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.first().first().toSize(), largeIconSize);
// no-op
spy.clear();
tb.setIconSize(largeIconSize);
QCOMPARE(tb.iconSize(), largeIconSize);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.first().first().toSize(), defaultIconSize);
// no-op
spy.clear();
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
spy.clear();
tb.setIconSize(smallIconSize);
QCOMPARE(tb.iconSize(), smallIconSize);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.first().first().toSize(), smallIconSize);
// no-op
spy.clear();
tb.setIconSize(smallIconSize);
QCOMPARE(tb.iconSize(), smallIconSize);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// setting the icon size to an invalid QSize will reset the
// iconSize property to the default
@@ -688,28 +688,28 @@ void tst_QToolBar::iconSize()
// explicitly set it to the default
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.addToolBar(&tb);
// tb icon size should not change since it has been explicitly set
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.setIconSize(largeIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.setIconSize(smallIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
// resetting to the default should cause the toolbar to take
// on the mainwindow's icon size
@@ -732,51 +732,51 @@ void tst_QToolBar::toolButtonStyle()
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setToolButtonStyle(Qt::ToolButtonTextOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
// no-op
tb.setToolButtonStyle(Qt::ToolButtonTextOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
// no-op
tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
// no-op
tb.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
// no-op
tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.setToolButtonStyle(Qt::ToolButtonFollowStyle);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonFollowStyle);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
{
@@ -790,28 +790,28 @@ void tst_QToolBar::toolButtonStyle()
// explicitly set the tb to the default
tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.addToolBar(&tb);
// tb icon size should not change since it has been explicitly set
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.setToolButtonStyle(Qt::ToolButtonTextOnly);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
- QCOMPARE(tbSpy.count(), 0);
+ QCOMPARE(tbSpy.size(), 0);
// note: there is no way to clear the explicitly set tool
// button style... once you explicitly set it, the toolbar
@@ -925,25 +925,25 @@ void tst_QToolBar::visibilityChanged()
mw.addToolBar(&tb);
mw.show();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
spy.clear();
tb.hide();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), false);
spy.clear();
tb.hide();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
tb.show();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
spy.clear();
tb.show();
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QToolBar::actionOwnership()
@@ -1025,7 +1025,7 @@ void tst_QToolBar::accel()
QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
#ifdef Q_OS_MAC
qt_set_sequence_auto_mnemonic(false);
#endif
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
index abccd7bec8..ffe1a3b687 100644
--- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -122,7 +122,7 @@ void tst_QToolButton::triggered()
QVERIFY(QTest::qWaitForWindowActive(&mainWidget));
defaultAction->trigger();
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
QCOMPARE(qvariant_cast<QAction *>(spy.at(0).at(0)), defaultAction);
m_menu = menu.data();
@@ -133,7 +133,7 @@ void tst_QToolButton::triggered()
timer->start();
QTimer::singleShot(10000, &mainWidget, SLOT(close())); // Emergency bail-out
toolButton->showMenu();
- QTRY_COMPARE(spy.count(),2);
+ QTRY_COMPARE(spy.size(),2);
QCOMPARE(qvariant_cast<QAction *>(spy.at(1).at(0)), one);
}
@@ -186,7 +186,7 @@ void tst_QToolButton::task176137_autoRepeatOfAction()
QTest::mousePress (toolButton, Qt::LeftButton);
QTest::qWait(2000);
QTest::mouseRelease (toolButton, Qt::LeftButton, {}, {});
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
// try again with auto repeat
toolButton->setAutoRepeat (true);
@@ -196,11 +196,11 @@ void tst_QToolButton::task176137_autoRepeatOfAction()
QTest::mouseRelease (toolButton, Qt::LeftButton, {}, {});
const qreal expected = (3000 - toolButton->autoRepeatDelay()) / toolButton->autoRepeatInterval() + 1;
//we check that the difference is small (on some systems timers are not super accurate)
- qreal diff = (expected - repeatSpy.count()) / expected;
+ qreal diff = (expected - repeatSpy.size()) / expected;
QVERIFY2(qAbs(diff) < 0.2, qPrintable(
QString("expected: %1, actual: %2, diff (fraction): %3")
.arg(expected)
- .arg(repeatSpy.count())
+ .arg(repeatSpy.size())
.arg(diff)));
}
@@ -273,21 +273,21 @@ void tst_QToolButton::defaultActionSynced()
tb.setChecked(true);
QVERIFY(a.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
tb.setChecked(false);
QVERIFY(!a.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
a.setChecked(true);
QVERIFY(tb.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
a.setChecked(false);
QVERIFY(!tb.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), ++aToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), ++aToggledCount);
QAction b;
QSignalSpy bSpy(&b, SIGNAL(toggled(bool)));
@@ -301,17 +301,17 @@ void tst_QToolButton::defaultActionSynced()
QVERIFY(!a.isChecked());
QVERIFY(b.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), aToggledCount);
- QCOMPARE(bSpy.count(), ++bToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), aToggledCount);
+ QCOMPARE(bSpy.size(), ++bToggledCount);
tb.click();
QVERIFY(!a.isChecked());
QVERIFY(!tb.isChecked());
QVERIFY(!b.isChecked());
- QCOMPARE(tbSpy.count(), ++tbToggledCount);
- QCOMPARE(aSpy.count(), aToggledCount);
- QCOMPARE(bSpy.count(), ++bToggledCount);
+ QCOMPARE(tbSpy.size(), ++tbToggledCount);
+ QCOMPARE(aSpy.size(), aToggledCount);
+ QCOMPARE(bSpy.size(), ++bToggledCount);
}
QTEST_MAIN(tst_QToolButton)