summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro7
-rw-r--r--tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp28
-rw-r--r--tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp24
-rw-r--r--tests/auto/corelib/animation/qpauseanimation/BLACKLIST4
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/BLACKLIST4
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST4
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp2
-rw-r--r--tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp21
-rw-r--r--tests/auto/corelib/global/qnumeric/qnumeric.pro2
-rw-r--r--tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp160
-rw-r--r--tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp4
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp34
-rw-r--r--tests/auto/corelib/io/qdir/qdir.pro2
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp69
-rw-r--r--tests/auto/corelib/io/qdiriterator/qdiriterator.pro2
-rw-r--r--tests/auto/corelib/io/qfile/BLACKLIST5
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp286
-rw-r--r--tests/auto/corelib/io/qfileinfo/qfileinfo.pro2
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp101
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+haiku/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+haiku/test20
-rw-r--r--tests/auto/corelib/io/qfileselector/platforms/+unix/+haiku/test0
-rw-r--r--tests/auto/corelib/io/qfileselector/qfileselector.qrc3
-rw-r--r--tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp2
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST1
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp15
-rw-r--r--tests/auto/corelib/io/qiodevice/BLACKLIST2
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp1
-rw-r--r--tests/auto/corelib/io/qprocess/BLACKLIST5
-rw-r--r--tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp14
-rw-r--r--tests/auto/corelib/io/qprocess/testDetached/main.cpp3
-rw-r--r--tests/auto/corelib/io/qprocess/testExitCodes/main.cpp4
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp597
-rw-r--r--tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp19
-rw-r--r--tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp22
-rw-r--r--tests/auto/corelib/io/qsettings/BLACKLIST2
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp6
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp9
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp4
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp8
-rw-r--r--tests/auto/corelib/io/qtextstream/BLACKLIST2
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp1
-rw-r--r--tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp3
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp96
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp27
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro1
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp77
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h3
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST4
-rw-r--r--tests/auto/corelib/kernel/qeventloop/BLACKLIST2
-rw-r--r--tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp15
-rw-r--r--tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp69
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp6
-rw-r--r--tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp40
-rw-r--r--tests/auto/corelib/kernel/qobject/BLACKLIST2
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp4
-rw-r--r--tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp17
-rw-r--r--tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST3
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp27
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp3
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp13
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp19
-rw-r--r--tests/auto/corelib/statemachine/qstate/tst_qstate.cpp31
-rw-r--r--tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp61
-rw-r--r--tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp58
-rw-r--r--tests/auto/corelib/thread/qfuture/tst_qfuture.cpp34
-rw-r--r--tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp21
-rw-r--r--tests/auto/corelib/thread/qsemaphore/BLACKLIST3
-rw-r--r--tests/auto/corelib/thread/qthread/BLACKLIST2
-rw-r--r--tests/auto/corelib/thread/qthreadpool/BLACKLIST5
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp2
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp2
-rw-r--r--tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp107
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp15
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm12
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp6
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp39
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm6
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp29
-rw-r--r--tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp18
-rw-r--r--tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp20
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp228
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp2
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp63
-rw-r--r--tests/auto/corelib/tools/qregexp/tst_qregexp.cpp3
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp5
-rw-r--r--tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp129
-rw-r--r--tests/auto/corelib/tools/qset/tst_qset.cpp65
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/externaltests.cpp1
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp544
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring_mac.mm8
-rw-r--r--tests/auto/corelib/tools/qstringref/tst_qstringref.cpp25
-rw-r--r--tests/auto/corelib/tools/qtimeline/BLACKLIST4
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp2
-rw-r--r--tests/auto/corelib/tools/qtimezone/BLACKLIST2
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp60
-rw-r--r--tests/auto/corelib/tools/qvector/qvector.pro1
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp261
-rw-r--r--tests/auto/corelib/tools/qversionnumber/qversionnumber.pro3
-rw-r--r--tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp2
-rw-r--r--tests/auto/dbus/dbus.pro3
-rw-r--r--tests/auto/dbus/qdbusabstractadaptor/BLACKLIST2
-rw-r--r--tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp2
-rw-r--r--tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp10
-rw-r--r--tests/auto/dbus/qdbusconnection/qdbusconnection.pro1
-rw-r--r--tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp348
-rw-r--r--tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h287
-rw-r--r--tests/auto/dbus/qdbusconnection_no_app/qdbusconnection_no_app.pro6
-rw-r--r--tests/auto/dbus/qdbusconnection_no_app/tst_qdbusconnection_no_app.cpp37
-rw-r--r--tests/auto/dbus/qdbusmarshall/BLACKLIST3
-rw-r--r--tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp16
-rw-r--r--tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp33
-rw-r--r--tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp104
-rw-r--r--tests/auto/dbus/qdbustype/tst_qdbustype.cpp4
-rw-r--r--tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp7
-rw-r--r--tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp5
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.cpp16
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp10
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp10
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp10
-rw-r--r--tests/auto/gui/image/qmovie/tst_qmovie.cpp6
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp24
-rw-r--r--tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp10
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp26
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp12
-rw-r--r--tests/auto/gui/kernel/qguivariant/no_application/main.cpp2
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp12
-rw-r--r--tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp7
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp4
-rw-r--r--tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp2
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp136
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp127
-rw-r--r--tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp48
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp20
-rw-r--r--tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp74
-rw-r--r--tests/auto/gui/painting/qbrush/tst_qbrush.cpp4
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp114
-rw-r--r--tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp2
-rw-r--r--tests/auto/gui/painting/qpainter/qpainter.pro2
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp278
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp34
-rw-r--r--tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp6
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp2
-rw-r--r--tests/auto/gui/painting/qtransform/tst_qtransform.cpp37
-rw-r--r--tests/auto/gui/qopengl/BLACKLIST8
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp201
-rw-r--r--tests/auto/gui/qopenglconfig/buglist.json22
-rw-r--r--tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp42
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp38
-rw-r--r--tests/auto/gui/text/qfont/BLACKLIST2
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp77
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp12
-rw-r--r--tests/auto/gui/text/qrawfont/BLACKLIST4
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp31
-rw-r--r--tests/auto/gui/text/qtextblock/tst_qtextblock.cpp4
-rw-r--r--tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp186
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp37
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp224
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/BLACKLIST2
-rw-r--r--tests/auto/gui/text/qtextformat/tst_qtextformat.cpp4
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp36
-rw-r--r--tests/auto/gui/text/qtextlist/tst_qtextlist.cpp46
-rw-r--r--tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp336
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp188
-rw-r--r--tests/auto/gui/text/qzip/tst_qzip.cpp19
-rw-r--r--tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp5
-rw-r--r--tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp32
-rw-r--r--tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp16
-rw-r--r--tests/auto/network/access/qabstractnetworkcache/BLACKLIST9
-rw-r--r--tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp3
-rw-r--r--tests/auto/network/access/qftp/BLACKLIST11
-rw-r--r--tests/auto/network/access/qftp/qftp.pro1
-rw-r--r--tests/auto/network/access/qftp/tst_qftp.cpp3
-rw-r--r--tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp54
-rw-r--r--tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp4
-rw-r--r--tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp2
-rw-r--r--tests/auto/network/access/qnetworkreply/element.xml1
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp258
-rw-r--r--tests/auto/network/access/spdy/BLACKLIST4
-rw-r--r--tests/auto/network/access/spdy/spdy.pro2
-rw-r--r--tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp38
-rw-r--r--tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp4
-rw-r--r--tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp99
-rw-r--r--tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp6
-rw-r--r--tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp74
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp6
-rw-r--r--tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp2
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/BLACKLIST2
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp48
-rw-r--r--tests/auto/network/socket/platformsocketengine/BLACKLIST1
-rw-r--r--tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp138
-rw-r--r--tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp53
-rw-r--r--tests/auto/network/socket/qhttpsocketengine/BLACKLIST1
-rw-r--r--tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp62
-rw-r--r--tests/auto/network/socket/qlocalsocket/BLACKLIST2
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp25
-rw-r--r--tests/auto/network/socket/qsocks5socketengine/BLACKLIST2
-rw-r--r--tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp116
-rw-r--r--tests/auto/network/socket/qtcpserver/BLACKLIST13
-rw-r--r--tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp10
-rw-r--r--tests/auto/network/socket/qtcpsocket/test/test.pro2
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp112
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp5
-rw-r--r--tests/auto/network/ssl/qsslcertificate/BLACKLIST3
-rw-r--r--tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp81
-rw-r--r--tests/auto/network/ssl/qsslkey/BLACKLIST1
-rw-r--r--tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp2
-rw-r--r--tests/auto/network/ssl/qsslsocket/BLACKLIST1
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp124
-rw-r--r--tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/BLACKLIST2
-rw-r--r--tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/BLACKLIST2
-rw-r--r--tests/auto/opengl/qgl/BLACKLIST16
-rw-r--r--tests/auto/opengl/qgl/tst_qgl.cpp128
-rw-r--r--tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp10
-rw-r--r--tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp4
-rw-r--r--tests/auto/other/compiler/tst_compiler.cpp16
-rw-r--r--tests/auto/other/gestures/BLACKLIST2
-rw-r--r--tests/auto/other/gestures/tst_gestures.cpp2
-rw-r--r--tests/auto/other/lancelot/tst_lancelot.cpp6
-rw-r--r--tests/auto/other/languagechange/tst_languagechange.cpp2
-rw-r--r--tests/auto/other/macgui/tst_macgui.cpp4
-rw-r--r--tests/auto/other/macnativeevents/BLACKLIST13
-rw-r--r--tests/auto/other/macnativeevents/tst_macnativeevents.cpp8
-rw-r--r--tests/auto/other/modeltest/modeltest.cpp2
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp56
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp57
-rw-r--r--tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro3
-rw-r--r--tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp34
-rw-r--r--tests/auto/other/qcomplextext/tst_qcomplextext.cpp2
-rw-r--r--tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp2
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp5
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp6
-rw-r--r--[-rwxr-xr-x]tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdbbin65536 -> 65536 bytes
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_databases.h4
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp30
-rw-r--r--tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp2
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp64
-rw-r--r--tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp30
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp18
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp51
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.lightxml98
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.txt58
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xml98
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xunitxml22
-rw-r--r--tests/auto/testlib/selftests/expected_crashes_3.txt1
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp31
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp64
-rw-r--r--tests/auto/tools/qmake/qmake.pro6
-rw-r--r--tests/auto/tools/qmake/testdata/resources/main.cpp (renamed from tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp)18
-rw-r--r--tests/auto/tools/qmake/testdata/resources/resources.pro10
-rw-r--r--tests/auto/tools/qmake/testdata/resources/subdir/file.txt0
-rw-r--r--tests/auto/tools/qmake/testdata/resources/test.qrc5
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp42
-rw-r--r--tests/auto/tools/uic/tst_uic.cpp1
-rw-r--r--tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro3
-rw-r--r--tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qdialog/BLACKLIST2
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp16
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp44
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp28
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/BLACKLIST4
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm2
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp30
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST2
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp96
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp4
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp32
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp38
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp113
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp47
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST18
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp13
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp18
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp40
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp16
-rw-r--r--tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp17
-rw-r--r--tests/auto/widgets/itemviews/qlistview/qlistview.pro1
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp51
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qtableview/BLACKLIST2
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp12
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp25
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/qtreeview.pro2
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp34
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp53
-rw-r--r--tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp4
-rw-r--r--tests/auto/widgets/kernel/qaction/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp2
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp3
-rw-r--r--tests/auto/widgets/kernel/qapplication/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qapplication/qapplication.pro1
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp159
-rw-r--r--tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro5
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp103
-rw-r--r--tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp1
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp429
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp160
-rw-r--r--tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp7
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp1
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp21
-rw-r--r--tests/auto/widgets/kernel/qtooltip/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST78
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp114
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp91
-rw-r--r--tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp33
-rw-r--r--tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp4
-rw-r--r--tests/auto/widgets/styles/qstyle/tst_qstyle.cpp10
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST2
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp188
-rw-r--r--tests/auto/widgets/util/qcompleter/BLACKLIST2
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp22
-rw-r--r--tests/auto/widgets/util/qscroller/tst_qscroller.cpp2
-rw-r--r--tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp2
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp6
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp36
-rw-r--r--tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp4
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp45
-rw-r--r--tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp8
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp14
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp6
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp32
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp5
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp62
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp159
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/BLACKLIST3
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp30
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp37
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp120
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp4
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp30
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp4
-rw-r--r--tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp4
-rw-r--r--tests/auto/widgets/widgets/qsizegrip/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qspinbox/BLACKLIST3
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp2
-rw-r--r--tests/auto/widgets/widgets/qtabbar/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp42
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp60
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp48
-rw-r--r--tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp32
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp4
-rw-r--r--tests/auto/xml/dom/qdom/tst_qdom.cpp10
-rw-r--r--tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp2
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.entbin4 -> 4 bytes
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.entbin54 -> 54 bytes
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.entbin12 -> 12 bytes
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent0
-rw-r--r--[-rwxr-xr-x]tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent0
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp4
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp4
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h3
-rw-r--r--tests/benchmarks/corelib/tools/qringbuffer/main.cpp4
-rw-r--r--tests/benchmarks/gui/text/qtext/main.cpp14
-rw-r--r--tests/benchmarks/sql/kernel/qsqlquery/main.cpp40
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/main.mm168
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/qt_on_cocoa.pro10
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp (renamed from tests/manual/cocoa/qt_on_cocoa/window.cpp)37
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/rasterwindow.h (renamed from tests/manual/cocoa/qt_on_cocoa/window.h)7
-rw-r--r--tests/manual/diaglib/eventfilter.cpp9
-rw-r--r--tests/manual/highdpi/dragwidget.cpp223
-rw-r--r--tests/manual/highdpi/dragwidget.h68
-rw-r--r--tests/manual/highdpi/highdpi.pro13
-rw-r--r--tests/manual/highdpi/main.cpp725
-rw-r--r--tests/manual/qscreen/main.cpp148
-rw-r--r--tests/manual/qscreen/propertywatcher.cpp81
-rw-r--r--tests/manual/qscreen/propertywatcher.h14
-rw-r--r--tests/manual/qscreen/qscreen.pro1
-rw-r--r--tests/manual/qsysinfo/main.cpp1
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.cpp3
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.h1
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp34
-rw-r--r--tests/manual/touch/main.cpp433
445 files changed, 10217 insertions, 4614 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 6f06ba591f..9cab3c9e42 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -32,8 +32,11 @@ cross_compile: SUBDIRS -= tools
# Disable the QtDBus tests if we can't connect to the session bus
qtHaveModule(dbus) {
- !system("dbus-send --session --type=signal / local.AutotestCheck.Hello"): {
- warning("QtDBus is enabled but session bus is not available. Please check the installation.")
+ !system("dbus-send --session --type=signal / local.AutotestCheck.Hello >/dev/null 2>&1") {
+ contains(QT_CONFIG, dbus-linked): \
+ error("QtDBus is enabled but session bus is not available. Please check the installation.")
+ else: \
+ warning("QtDBus is enabled with runtime support, but session bus is not available. Skipping QtDBus tests.")
SUBDIRS -= dbus
}
} else {
diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
index b5e3dee9a6..cadd4e82cd 100644
--- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
+++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp
@@ -1443,45 +1443,45 @@ void tst_QtConcurrentFilter::noDetach()
QVERIFY(l.isDetached());
QList<int> ll = l;
- QVERIFY(l.isDetached() == false);
+ QVERIFY(!l.isDetached());
QtConcurrent::filtered(l, waitFilterfn).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
QtConcurrent::blockingFiltered(l, waitFilterfn);
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
QtConcurrent::filteredReduced(l, waitFilterfn, intSumReduce).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
QtConcurrent::filter(l, waitFilterfn).waitForFinished();
if (!l.isDetached())
QEXPECT_FAIL("", "QTBUG-20688: Known unstable failure", Abort);
- QVERIFY(l.isDetached() == true);
- QVERIFY(ll.isDetached() == true);
+ QVERIFY(l.isDetached());
+ QVERIFY(ll.isDetached());
}
{
const QList<int> l = QList<int>() << 1;
QVERIFY(l.isDetached());
const QList<int> ll = l;
- QVERIFY(l.isDetached() == false);
+ QVERIFY(!l.isDetached());
QtConcurrent::filtered(l, waitFilterfn).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
QtConcurrent::filteredReduced(l, waitFilterfn, intSumReduce).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
}
}
diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
index 4e19124ca8..33941d8e90 100644
--- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp
@@ -2250,38 +2250,38 @@ void tst_QtConcurrentMap::noDetach()
QVERIFY(l.isDetached());
QList<int> ll = l;
- QVERIFY(l.isDetached() == false);
+ QVERIFY(!l.isDetached());
QtConcurrent::mapped(l, mapper).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
QtConcurrent::mappedReduced(l, mapper, intSumReduce).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
QtConcurrent::map(l, multiplyBy2Immutable).waitForFinished();
- QVERIFY(l.isDetached() == true);
- QVERIFY(ll.isDetached() == true);
+ QVERIFY(l.isDetached());
+ QVERIFY(ll.isDetached());
}
{
const QList<int> l = QList<int>() << 1;
QVERIFY(l.isDetached());
const QList<int> ll = l;
- QVERIFY(l.isDetached() == false);
+ QVERIFY(!l.isDetached());
QtConcurrent::mapped(l, mapper).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
QtConcurrent::mappedReduced(l, mapper, intSumReduce).waitForFinished();
- QVERIFY(l.isDetached() == false);
- QVERIFY(ll.isDetached() == false);
+ QVERIFY(!l.isDetached());
+ QVERIFY(!ll.isDetached());
}
}
diff --git a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
new file mode 100644
index 0000000000..3b2cd84749
--- /dev/null
+++ b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST
@@ -0,0 +1,4 @@
+[multiplePauseAnimations]
+osx-10.9
+[pauseAndPropertyAnimations]
+*
diff --git a/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST b/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST
new file mode 100644
index 0000000000..a7e95b1e97
--- /dev/null
+++ b/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST
@@ -0,0 +1,4 @@
+[statesAndSignals:normal animation]
+windows
+[startBackwardWithoutEndValue]
+windows
diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST
new file mode 100644
index 0000000000..e11e4ae6fb
--- /dev/null
+++ b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST
@@ -0,0 +1,4 @@
+[startGroupWithRunningChild]
+windows
+[finishWithUncontrolledAnimation]
+windows
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 69bf7598fc..00f70f5380 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -457,7 +457,7 @@ void tst_QGlobal::isEnum()
// fallback type traits implementation. Any compiler
// supported by Qt that supports C++0x class enums
// should also support the __is_enum intrinsic.
- QVERIFY(Q_IS_ENUM(isEnum_G) == true);
+ QVERIFY(Q_IS_ENUM(isEnum_G));
#endif
#undef IS_ENUM_TRUE
diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp
index a1cfff7e85..e9fd999e9f 100644
--- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp
+++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp
@@ -41,10 +41,17 @@
#include <QtCore/QThread>
#include <QtTest/QtTest>
+#if defined(Q_OS_UNIX)
+#include <sys/resource.h>
+#endif
+
class tst_QGlobalStatic : public QObject
{
Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
private Q_SLOTS:
void beforeInitialization();
void api();
@@ -55,6 +62,20 @@ private Q_SLOTS:
void afterDestruction();
};
+void tst_QGlobalStatic::initTestCase()
+{
+#if defined(Q_OS_UNIX)
+ // The tests create a lot of threads, which require file descriptors. On systems like
+ // OS X low defaults such as 256 as the limit for the number of simultaneously
+ // open files is not sufficient.
+ struct rlimit numFiles;
+ if (getrlimit(RLIMIT_NOFILE, &numFiles) == 0 && numFiles.rlim_cur < 1024) {
+ numFiles.rlim_cur = qMin(rlim_t(1024), numFiles.rlim_max);
+ setrlimit(RLIMIT_NOFILE, &numFiles);
+ }
+#endif
+}
+
Q_GLOBAL_STATIC_WITH_ARGS(const int, constInt, (42))
Q_GLOBAL_STATIC_WITH_ARGS(volatile int, volatileInt, (-47))
diff --git a/tests/auto/corelib/global/qnumeric/qnumeric.pro b/tests/auto/corelib/global/qnumeric/qnumeric.pro
index 00f3635be9..0772ce6aab 100644
--- a/tests/auto/corelib/global/qnumeric/qnumeric.pro
+++ b/tests/auto/corelib/global/qnumeric/qnumeric.pro
@@ -1,6 +1,6 @@
CONFIG += testcase parallel_test
TARGET = tst_qnumeric
-QT = core testlib
+QT = core-private testlib
SOURCES = tst_qnumeric.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
intel_icc: QMAKE_CXXFLAGS += -fp-model strict
diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
index fdc8bc6aab..6be8ff81cf 100644
--- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
+++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
@@ -34,6 +34,7 @@
#include <QtTest/QtTest>
#include <QtGlobal>
+#include "private/qnumeric_p.h"
#include <math.h>
#include <float.h>
@@ -50,6 +51,10 @@ private slots:
void floatDistance();
void floatDistance_double_data();
void floatDistance_double();
+ void addOverflow_data();
+ void addOverflow();
+ void mulOverflow_data();
+ void mulOverflow();
};
void tst_QNumeric::fuzzyCompare_data()
@@ -206,5 +211,160 @@ void tst_QNumeric::floatDistance_double()
QCOMPARE(qFloatDistance(val1, val2), expectedDistance);
}
+void tst_QNumeric::addOverflow_data()
+{
+ QTest::addColumn<int>("size");
+ QTest::newRow("quint8") << 8;
+ QTest::newRow("quint16") << 16;
+ QTest::newRow("quint32") << 32;
+ QTest::newRow("quint64") << 64;
+ QTest::newRow("ulong") << 48; // it's either 32- or 64-bit, so on average it's 48 :-)
+}
+
+// Note: in release mode, all the tests may be statically determined and only the calls
+// to QTest::toString and QTest::qCompare will remain.
+template <typename Int> static void addOverflow_template()
+{
+#if defined(Q_CC_MSVC) && Q_CC_MSVC < 2000
+ QSKIP("Test disabled, this test generates an Internal Compiler Error compiling in release mode");
+#else
+ const Int max = std::numeric_limits<Int>::max();
+ Int r;
+
+ // basic values
+ QCOMPARE(add_overflow(Int(0), Int(0), &r), false);
+ QCOMPARE(r, Int(0));
+ QCOMPARE(add_overflow(Int(1), Int(0), &r), false);
+ QCOMPARE(r, Int(1));
+ QCOMPARE(add_overflow(Int(0), Int(1), &r), false);
+ QCOMPARE(r, Int(1));
+
+ // half-way through max
+ QCOMPARE(add_overflow(Int(max/2), Int(max/2), &r), false);
+ QCOMPARE(r, Int(max / 2 * 2));
+ QCOMPARE(add_overflow(Int(max/2 - 1), Int(max/2 + 1), &r), false);
+ QCOMPARE(r, Int(max / 2 * 2));
+ QCOMPARE(add_overflow(Int(max/2 + 1), Int(max/2), &r), false);
+ QCOMPARE(r, max);
+ QCOMPARE(add_overflow(Int(max/2), Int(max/2 + 1), &r), false);
+ QCOMPARE(r, max);
+
+ // more than half
+ QCOMPARE(add_overflow(Int(max/4 * 3), Int(max/4), &r), false);
+ QCOMPARE(r, Int(max / 4 * 4));
+
+ // max
+ QCOMPARE(add_overflow(max, Int(0), &r), false);
+ QCOMPARE(r, max);
+ QCOMPARE(add_overflow(Int(0), max, &r), false);
+ QCOMPARE(r, max);
+
+ // 64-bit issues
+ if (max > std::numeric_limits<uint>::max()) {
+ QCOMPARE(add_overflow(Int(std::numeric_limits<uint>::max()), Int(std::numeric_limits<uint>::max()), &r), false);
+ QCOMPARE(r, Int(2 * Int(std::numeric_limits<uint>::max())));
+ }
+
+ // overflows
+ QCOMPARE(add_overflow(max, Int(1), &r), true);
+ QCOMPARE(add_overflow(Int(1), max, &r), true);
+ QCOMPARE(add_overflow(Int(max/2 + 1), Int(max/2 + 1), &r), true);
+#endif
+}
+
+void tst_QNumeric::addOverflow()
+{
+ QFETCH(int, size);
+ if (size == 8)
+ addOverflow_template<quint8>();
+ if (size == 16)
+ addOverflow_template<quint16>();
+ if (size == 32)
+ addOverflow_template<quint32>();
+ if (size == 48)
+ addOverflow_template<ulong>(); // not really 48-bit
+ if (size == 64)
+ addOverflow_template<quint64>();
+}
+
+void tst_QNumeric::mulOverflow_data()
+{
+ addOverflow_data();
+}
+
+// Note: in release mode, all the tests may be statically determined and only the calls
+// to QTest::toString and QTest::qCompare will remain.
+template <typename Int> static void mulOverflow_template()
+{
+#if defined(Q_CC_MSVC) && Q_CC_MSVC < 1900
+ QSKIP("Test disabled, this test generates an Internal Compiler Error compiling");
+#else
+ const Int max = std::numeric_limits<Int>::max();
+ const Int middle = Int(max >> (sizeof(Int) * CHAR_BIT / 2));
+ Int r;
+
+ // basic multiplications
+ QCOMPARE(mul_overflow(Int(0), Int(0), &r), false);
+ QCOMPARE(r, Int(0));
+ QCOMPARE(mul_overflow(Int(1), Int(0), &r), false);
+ QCOMPARE(r, Int(0));
+ QCOMPARE(mul_overflow(Int(0), Int(1), &r), false);
+ QCOMPARE(r, Int(0));
+ QCOMPARE(mul_overflow(max, Int(0), &r), false);
+ QCOMPARE(r, Int(0));
+ QCOMPARE(mul_overflow(Int(0), max, &r), false);
+ QCOMPARE(r, Int(0));
+
+ QCOMPARE(mul_overflow(Int(1), Int(1), &r), false);
+ QCOMPARE(r, Int(1));
+ QCOMPARE(mul_overflow(Int(1), max, &r), false);
+ QCOMPARE(r, max);
+ QCOMPARE(mul_overflow(max, Int(1), &r), false);
+ QCOMPARE(r, max);
+
+ // almost max
+ QCOMPARE(mul_overflow(middle, middle, &r), false);
+ QCOMPARE(r, Int(max - 2 * middle));
+ QCOMPARE(mul_overflow(Int(middle + 1), middle, &r), false);
+ QCOMPARE(r, Int(middle << (sizeof(Int) * CHAR_BIT / 2)));
+ QCOMPARE(mul_overflow(middle, Int(middle + 1), &r), false);
+ QCOMPARE(r, Int(middle << (sizeof(Int) * CHAR_BIT / 2)));
+ QCOMPARE(mul_overflow(Int(max / 2), Int(2), &r), false);
+ QCOMPARE(r, Int(max & ~Int(1)));
+ QCOMPARE(mul_overflow(Int(max / 4), Int(4), &r), false);
+ QCOMPARE(r, Int(max & ~Int(3)));
+
+ // overflows
+ QCOMPARE(mul_overflow(max, Int(2), &r), true);
+ QCOMPARE(mul_overflow(Int(max / 2), Int(3), &r), true);
+ QCOMPARE(mul_overflow(Int(middle + 1), Int(middle + 1), &r), true);
+#endif
+}
+
+template <typename Int, bool enabled = sizeof(Int) <= sizeof(void*)> struct MulOverflowDispatch;
+template <typename Int> struct MulOverflowDispatch<Int, true>
+{
+ void operator()() { mulOverflow_template<Int>(); }
+};
+template <typename Int> struct MulOverflowDispatch<Int, false>
+{
+ void operator()() { QSKIP("This type is too big for this architecture"); }
+};
+
+void tst_QNumeric::mulOverflow()
+{
+ QFETCH(int, size);
+ if (size == 8)
+ MulOverflowDispatch<quint8>()();
+ if (size == 16)
+ MulOverflowDispatch<quint16>()();
+ if (size == 32)
+ MulOverflowDispatch<quint32>()();
+ if (size == 48)
+ MulOverflowDispatch<ulong>()(); // not really 48-bit
+ if (size == 64)
+ MulOverflowDispatch<quint64>()();
+}
+
QTEST_APPLESS_MAIN(tst_QNumeric)
#include "tst_qnumeric.moc"
diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
index 2cf93e1c45..d9d3f55d4a 100644
--- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
@@ -264,7 +264,9 @@ static int NColorRoles[] = {
QPalette::ToolTipText + 1, // Qt_5_2
QPalette::ToolTipText + 1, // Qt_5_3
QPalette::ToolTipText + 1, // Qt_5_4
- 0 // add the correct value for Qt_5_5 here later
+ QPalette::ToolTipText + 1, // Qt_5_5
+ QPalette::ToolTipText + 1, // Qt_5_6
+ 0 // add the correct value for Qt_5_7 here later
};
// Testing get/set functions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 3e19e816c9..db2805ebf0 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -49,6 +49,7 @@ private slots:
void debugWithBool() const;
void debugSpaceHandling() const;
void debugNoQuotes() const;
+ void verbosity() const;
void stateSaver() const;
void veryLongWarningMessage() const;
void qDebugQChar() const;
@@ -192,7 +193,11 @@ public:
QDebug operator<< (QDebug s, const MyLine& line)
{
const QDebugStateSaver saver(s);
- s.nospace() << "MyLine(" << line.p1 << ", " << line.p2 << ")";
+ s.nospace();
+ s << "MyLine(" << line.p1 << ", "<< line.p2;
+ if (s.verbosity() > 2)
+ s << ", Manhattan length=" << (qAbs(line.p2.v1 - line.p1.v1) + qAbs(line.p2.v2 - line.p1.v2));
+ s << ')';
return s;
}
@@ -255,6 +260,33 @@ void tst_QDebug::debugNoQuotes() const
QCOMPARE(s_msg, QString::fromLatin1("'H' \"Hello\" \"Hello\" H Hello Hello"));
}
+void tst_QDebug::verbosity() const
+{
+ MyLine line(MyPoint(10, 11), MyPoint (12, 13));
+ QString output;
+ QDebug d(&output);
+ d.nospace();
+ d << line << '\n';
+ const int oldVerbosity = d.verbosity();
+ d.setVerbosity(0);
+ QCOMPARE(d.verbosity(), 0);
+ d.setVerbosity(7);
+ QCOMPARE(d.verbosity(), 7);
+ const int newVerbosity = oldVerbosity + 2;
+ d.setVerbosity(newVerbosity);
+ QCOMPARE(d.verbosity(), newVerbosity);
+ d << line << '\n';
+ d.setVerbosity(oldVerbosity );
+ QCOMPARE(d.verbosity(), oldVerbosity );
+ d << line;
+ const QStringList lines = output.split(QLatin1Char('\n'));
+ QCOMPARE(lines.size(), 3);
+ // Verbose should be longer
+ QVERIFY2(lines.at(1).size() > lines.at(0).size(), qPrintable(lines.join(QLatin1Char(','))));
+ // Switching back to brief produces same output
+ QCOMPARE(lines.at(0).size(), lines.at(2).size());
+}
+
void tst_QDebug::stateSaver() const
{
MessageHandlerSetter mhs(myMessageHandler);
diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro
index d3e954bd32..0adc7e0450 100644
--- a/tests/auto/corelib/io/qdir/qdir.pro
+++ b/tests/auto/corelib/io/qdir/qdir.pro
@@ -10,3 +10,5 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
android:!android-no-sdk {
RESOURCES += android_testdata.qrc
}
+
+win32: CONFIG += insignificant_test # Crashes on Windows in release builds
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 72d036c2ae..ae6fe7eaef 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -68,6 +68,12 @@ QT_END_NAMESPACE
#endif
+static QByteArray msgDoesNotExist(const QString &name)
+{
+ return (QLatin1Char('"') + QDir::toNativeSeparators(name)
+ + QLatin1String("\" does not exist.")).toLocal8Bit();
+}
+
class tst_QDir : public QObject
{
Q_OBJECT
@@ -354,7 +360,7 @@ void tst_QDir::mkdir()
//make sure it really exists (ie that mkdir returns the right value)
QFileInfo fi(path);
- QVERIFY(fi.exists() && fi.isDir());
+ QVERIFY2(fi.exists() && fi.isDir(), msgDoesNotExist(path).constData());
}
void tst_QDir::makedirReturnCode()
@@ -378,7 +384,7 @@ void tst_QDir::makedirReturnCode()
f.open(QIODevice::WriteOnly);
f.write("test");
f.close();
- QVERIFY(f.exists());
+ QVERIFY2(f.exists(), msgDoesNotExist(f.fileName()).constData());
QVERIFY(!QDir::current().mkdir(dirName)); // calling mkdir on an existing file will fail.
QVERIFY(!QDir::current().mkpath(dirName)); // calling mkpath on an existing file will fail.
f.remove();
@@ -474,7 +480,7 @@ void tst_QDir::removeRecursivelyFailure()
QVERIFY(!QDir().rmdir(path));
QDir dir(path);
QVERIFY(!dir.removeRecursively()); // didn't work
- QVERIFY(dir.exists()); // still exists
+ QVERIFY2(dir.exists(), msgDoesNotExist(dir.absolutePath()).constData()); // still exists
QVERIFY(dirAsFile.setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner)));
QVERIFY(dir.removeRecursively());
@@ -527,14 +533,15 @@ 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) && !defined(Q_OS_WINCE))
- QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
- QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true;
- QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << true;
- QTest::newRow("unc 4") << "//" + QtNetworkSettings::winServerName() + "/testshare/" << true;
- QTest::newRow("unc 5") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp" << true;
- QTest::newRow("unc 6") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp/" << true;
- QTest::newRow("unc 7") << "//" + QtNetworkSettings::winServerName() + "/testshare/adirthatshouldnotexist" << false;
- QTest::newRow("unc 8") << "//" + QtNetworkSettings::winServerName() + "/asharethatshouldnotexist" << false;
+ const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ QTest::newRow("unc 1") << uncRoot << true;
+ QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
+ QTest::newRow("unc 3") << uncRoot + "/testshare" << true;
+ QTest::newRow("unc 4") << uncRoot + "/testshare/" << true;
+ QTest::newRow("unc 5") << uncRoot + "/testshare/tmp" << true;
+ QTest::newRow("unc 6") << uncRoot + "/testshare/tmp/" << true;
+ QTest::newRow("unc 7") << uncRoot + "/testshare/adirthatshouldnotexist" << false;
+ QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << false;
QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false;
#endif
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
@@ -566,7 +573,10 @@ void tst_QDir::exists()
QFETCH(bool, expected);
QDir dir(path);
- QCOMPARE(dir.exists(), expected);
+ if (expected)
+ QVERIFY2(dir.exists(), msgDoesNotExist(path).constData());
+ else
+ QVERIFY(!dir.exists());
}
void tst_QDir::isRelativePath_data()
@@ -802,7 +812,7 @@ void tst_QDir::entryList()
#endif //Q_NO_SYMLINKS
QDir dir(dirName);
- QVERIFY(dir.exists());
+ QVERIFY2(dir.exists(), msgDoesNotExist(dirName).constData());
QStringList actual = dir.entryList(nameFilters, (QDir::Filters)filterspec,
(QDir::SortFlags)sortspec);
@@ -845,8 +855,8 @@ void tst_QDir::entryListTimedSort()
QTemporaryFile aFile(entrylistPath + "A-XXXXXX.qws");
QTemporaryFile bFile(entrylistPath + "B-XXXXXX.qws");
- QVERIFY(aFile.open());
- QVERIFY(bFile.open());
+ QVERIFY2(aFile.open(), qPrintable(aFile.errorString()));
+ QVERIFY2(bFile.open(), qPrintable(bFile.errorString()));
{
QProcess p;
p.start(touchBinary, QStringList() << "-t" << "201306021513" << aFile.fileName());
@@ -888,18 +898,25 @@ void tst_QDir::entryListSimple_data()
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << 2;
- QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << 2;
- QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << 2;
- QTest::newRow("unc 4") << "//" + QtNetworkSettings::winServerName() + "/testshare/" << 2;
- QTest::newRow("unc 5") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp" << 2;
- QTest::newRow("unc 6") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp/" << 2;
- QTest::newRow("unc 7") << "//" + QtNetworkSettings::winServerName() + "/testshare/adirthatshouldnotexist" << 0;
- QTest::newRow("unc 8") << "//" + QtNetworkSettings::winServerName() + "/asharethatshouldnotexist" << 0;
+ const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ QTest::newRow("unc 1") << uncRoot << 2;
+ QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2;
+ QTest::newRow("unc 3") << uncRoot + "/testshare" << 2;
+ QTest::newRow("unc 4") << uncRoot + "/testshare/" << 2;
+ QTest::newRow("unc 5") << uncRoot + "/testshare/tmp" << 2;
+ QTest::newRow("unc 6") << uncRoot + "/testshare/tmp/" << 2;
+ QTest::newRow("unc 7") << uncRoot + "/testshare/adirthatshouldnotexist" << 0;
+ QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << 0;
QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << 0;
#endif
}
+static QByteArray msgEntryListFailed(int actual, int expectedMin, const QString &name)
+{
+ return QByteArray::number(actual) + " < " + QByteArray::number(expectedMin) + " in \""
+ + QFile::encodeName(QDir::toNativeSeparators(name)) + '"';
+}
+
void tst_QDir::entryListSimple()
{
QFETCH(QString, dirName);
@@ -907,7 +924,7 @@ void tst_QDir::entryListSimple()
QDir dir(dirName);
QStringList actual = dir.entryList();
- QVERIFY(actual.count() >= countMin);
+ QVERIFY2(actual.count() >= countMin, msgEntryListFailed(actual.count(), countMin, dirName).constData());
}
void tst_QDir::entryListWithSymLinks()
@@ -1121,7 +1138,7 @@ void tst_QDir::setNameFilters()
QFETCH(QStringList, expected);
QDir dir(dirName);
- QVERIFY(dir.exists());
+ QVERIFY2(dir.exists(), msgDoesNotExist(dirName).constData());
dir.setNameFilters(nameFilters);
QStringList actual = dir.entryList();
@@ -1504,7 +1521,7 @@ void tst_QDir::exists2()
QDir dir;
if (exists)
- QVERIFY(dir.exists(path));
+ QVERIFY2(dir.exists(path), msgDoesNotExist(path).constData());
else
QVERIFY(!dir.exists(path));
diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro
index 3b5d2bd931..a2429bf2f0 100644
--- a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro
+++ b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro
@@ -8,3 +8,5 @@ TESTDATA += entrylist
wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+win32: CONFIG += insignificant_test # Crashes on Windows in release builds
diff --git a/tests/auto/corelib/io/qfile/BLACKLIST b/tests/auto/corelib/io/qfile/BLACKLIST
new file mode 100644
index 0000000000..7aac313b12
--- /dev/null
+++ b/tests/auto/corelib/io/qfile/BLACKLIST
@@ -0,0 +1,5 @@
+# QTBUG-48455
+[readLineStdin]
+msvc-2015
+[readLineStdin_lineByLine]
+msvc-2015
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index b423e857d0..1c695a1113 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -390,9 +390,30 @@ tst_QFile::tst_QFile() : m_oldDir(QDir::currentPath())
{
}
+static QByteArray msgOpenFailed(QIODevice::OpenMode om, const QFile &file)
+{
+ QString result;
+ QDebug(&result).noquote().nospace() << "Could not open \""
+ << QDir::toNativeSeparators(file.fileName()) << "\" using "
+ << om << ": " << file.errorString();
+ return result.toLocal8Bit();
+}
+
+static QByteArray msgOpenFailed(const QFile &file)
+{
+ return (QLatin1String("Could not open \"") + QDir::toNativeSeparators(file.fileName())
+ + QLatin1String("\": ") + file.errorString()).toLocal8Bit();
+}
+
+static QByteArray msgFileDoesNotExist(const QString &name)
+{
+ return (QLatin1Char('"') + QDir::toNativeSeparators(name)
+ + QLatin1String("\" does not exist.")).toLocal8Bit();
+}
+
void tst_QFile::initTestCase()
{
- QVERIFY(m_temporaryDir.isValid());
+ QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
m_stdinProcessDir = QFINDTESTDATA("stdinprocess");
QVERIFY(!m_stdinProcessDir.isEmpty());
m_testSourceFile = QFINDTESTDATA("tst_qfile.cpp");
@@ -418,19 +439,19 @@ void tst_QFile::initTestCase()
// create a file and make it read-only
QFile file(QString::fromLatin1(readOnlyFile));
- QVERIFY2(file.open(QFile::WriteOnly), qPrintable(file.errorString()));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
file.write("a", 1);
file.close();
QVERIFY2(file.setPermissions(QFile::ReadOwner), qPrintable(file.errorString()));
// create another file and make it not readable
file.setFileName(QString::fromLatin1(noReadFile));
- QVERIFY2(file.open(QFile::WriteOnly), qPrintable(file.errorString()));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
file.write("b", 1);
file.close();
#ifndef Q_OS_WIN // Not supported on Windows.
QVERIFY2(file.setPermissions(0), qPrintable(file.errorString()));
#else
- QVERIFY2(file.open(QFile::WriteOnly), qPrintable(file.errorString()));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
#endif
}
@@ -455,19 +476,19 @@ void tst_QFile::cleanupTestCase()
void tst_QFile::exists()
{
QFile f( m_testFile );
- QVERIFY(f.exists());
+ QVERIFY2(f.exists(), msgFileDoesNotExist(m_testFile));
QFile file("nobodyhassuchafile");
file.remove();
QVERIFY(!file.exists());
QFile file2("nobodyhassuchafile");
- QVERIFY(file2.open(QIODevice::WriteOnly));
+ QVERIFY2(file2.open(QIODevice::WriteOnly), msgOpenFailed(file2).constData());
file2.close();
QVERIFY(file.exists());
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgOpenFailed(file).constData());
file.close();
QVERIFY(file.exists());
@@ -475,8 +496,9 @@ void tst_QFile::exists()
QVERIFY(!file.exists());
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
- QFile unc("//" + QtNetworkSettings::winServerName() + "/testshare/readme.txt");
- QVERIFY(unc.exists());
+ const QString uncPath = "//" + QtNetworkSettings::winServerName() + "/testshare/readme.txt";
+ QFile unc(uncPath);
+ QVERIFY2(unc.exists(), msgFileDoesNotExist(uncPath).constData());
#endif
}
@@ -558,7 +580,12 @@ void tst_QFile::open()
if (filename.isEmpty())
QTest::ignoreMessage(QtWarningMsg, "QFSFileEngine::open: No file name specified");
- QCOMPARE(f.open( QIODevice::OpenMode(mode) ), ok);
+ const QIODevice::OpenMode om(mode);
+ const bool succeeded = f.open(om);
+ if (ok)
+ QVERIFY2(succeeded, msgOpenFailed(om, f).constData());
+ else
+ QVERIFY(!succeeded);
QTEST( f.error(), "status" );
}
@@ -566,7 +593,7 @@ void tst_QFile::open()
void tst_QFile::openUnbuffered()
{
QFile file(m_testFile);
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered));
+ QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered), msgOpenFailed(file).constData());
char c = '\0';
QVERIFY(file.seek(1));
QCOMPARE(file.pos(), qint64(1));
@@ -618,7 +645,7 @@ void tst_QFile::size()
QFile f( filename );
QCOMPARE( f.size(), size );
- QVERIFY( f.open(QIODevice::ReadOnly) );
+ QVERIFY2(f.open(QIODevice::ReadOnly), msgOpenFailed(f).constData());
QCOMPARE( f.size(), size );
}
@@ -662,7 +689,7 @@ void tst_QFile::sizeNoExist()
void tst_QFile::seek()
{
QFile file("newfile.txt");
- file.open(QIODevice::WriteOnly);
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgOpenFailed(file).constData());
QCOMPARE(file.size(), qint64(0));
QCOMPARE(file.pos(), qint64(0));
QVERIFY(file.seek(10));
@@ -674,7 +701,7 @@ void tst_QFile::seek()
void tst_QFile::setSize()
{
QFile f("createme.txt");
- QVERIFY(f.open(QIODevice::Truncate | QIODevice::ReadWrite));
+ QVERIFY2(f.open(QIODevice::Truncate | QIODevice::ReadWrite), msgOpenFailed(f).constData());
f.putChar('a');
f.seek(0);
@@ -712,7 +739,7 @@ void tst_QFile::setSize()
void tst_QFile::setSizeSeek()
{
QFile f("setsizeseek.txt");
- QVERIFY(f.open(QFile::WriteOnly));
+ QVERIFY2(f.open(QFile::WriteOnly), msgOpenFailed(f).constData());
f.write("ABCD");
QCOMPARE(f.pos(), qint64(4));
@@ -734,7 +761,7 @@ void tst_QFile::setSizeSeek()
void tst_QFile::atEnd()
{
QFile f( m_testFile );
- QVERIFY(f.open( QIODevice::ReadOnly ));
+ QVERIFY2(f.open(QFile::ReadOnly), msgOpenFailed(f).constData());
int size = f.size();
f.seek( size );
@@ -747,7 +774,7 @@ void tst_QFile::atEnd()
void tst_QFile::readLine()
{
QFile f( m_testFile );
- QVERIFY(f.open( QIODevice::ReadOnly ));
+ QVERIFY2(f.open(QFile::ReadOnly), msgOpenFailed(f).constData());
int i = 0;
char p[128];
@@ -767,7 +794,8 @@ void tst_QFile::readLine()
void tst_QFile::readLine2()
{
QFile f( m_testFile );
- f.open( QIODevice::ReadOnly );
+ QVERIFY2(f.open(QFile::ReadOnly), msgOpenFailed(f).constData());
+
char p[128];
QCOMPARE(f.readLine(p, 60), qlonglong(59));
@@ -785,7 +813,7 @@ void tst_QFile::readLineNullInLine()
{
QFile::remove("nullinline.txt");
QFile file("nullinline.txt");
- QVERIFY(file.open(QIODevice::ReadWrite));
+ QVERIFY2(file.open(QFile::ReadWrite), msgOpenFailed(file).constData());
QVERIFY(file.write("linewith\0null\nanotherline\0withnull\n\0\nnull\0", 42) > 0);
QVERIFY(file.flush());
file.reset();
@@ -816,10 +844,8 @@ void tst_QFile::readAll()
QFETCH( QString, fileName );
QFile file(fileName);
- if (textMode)
- QVERIFY(file.open(QFile::Text | QFile::ReadOnly));
- else
- QVERIFY(file.open(QFile::ReadOnly));
+ const QIODevice::OpenMode om = textMode ? (QFile::Text | QFile::ReadOnly) : QFile::ReadOnly;
+ QVERIFY2(file.open(om), msgOpenFailed(om, file).constData());
QByteArray a = file.readAll();
file.reset();
@@ -848,8 +874,8 @@ void tst_QFile::readAllBuffer()
QByteArray data1("This is arguably a very simple text.");
QByteArray data2("This is surely not as simple a test.");
- QVERIFY( writer.open(QIODevice::ReadWrite | QIODevice::Unbuffered) );
- QVERIFY( reader.open(QIODevice::ReadOnly) );
+ QVERIFY2(writer.open(QIODevice::ReadWrite | QIODevice::Unbuffered), msgOpenFailed(writer).constData());
+ QVERIFY2(reader.open(QIODevice::ReadOnly), msgOpenFailed(reader).constData());
QCOMPARE( writer.write(data1), qint64(data1.size()) );
QVERIFY( writer.seek(0) );
@@ -868,6 +894,32 @@ void tst_QFile::readAllBuffer()
QFile::remove(fileName);
}
+#ifndef QT_NO_PROCESS
+class StdinReaderProcessGuard { // Ensure the stdin reader process is stopped on destruction.
+ Q_DISABLE_COPY(StdinReaderProcessGuard)
+
+public:
+ StdinReaderProcessGuard(QProcess *p) : m_process(p) {}
+ ~StdinReaderProcessGuard() { stop(); }
+
+ bool stop(int msecs = 30000)
+ {
+ if (m_process->state() != QProcess::Running)
+ return true;
+ m_process->closeWriteChannel();
+ if (m_process->waitForFinished(msecs))
+ return m_process->exitStatus() == QProcess::NormalExit && !m_process->exitCode();
+ m_process->terminate();
+ if (!m_process->waitForFinished())
+ m_process->kill();
+ return false;
+ }
+
+private:
+ QProcess *m_process;
+};
+#endif // !QT_NO_PROCESS
+
#if !defined(Q_OS_WINCE)
void tst_QFile::readAllStdin()
{
@@ -877,18 +929,17 @@ void tst_QFile::readAllStdin()
QByteArray lotsOfData(1024, '@'); // 10 megs
QProcess process;
+ StdinReaderProcessGuard processGuard(&process);
process.start(m_stdinProcessDir + QStringLiteral("/stdinprocess"), QStringList(QStringLiteral("all")));
QVERIFY2(process.waitForStarted(), qPrintable(process.errorString()));
for (int i = 0; i < 5; ++i) {
QTest::qWait(1000);
process.write(lotsOfData);
- while (process.bytesToWrite() > 0) {
+ while (process.bytesToWrite() > 0)
QVERIFY(process.waitForBytesWritten());
- }
}
- process.closeWriteChannel();
- process.waitForFinished();
+ QVERIFY(processGuard.stop());
QCOMPARE(process.readAll().size(), lotsOfData.size() * 5);
#endif
}
@@ -908,6 +959,7 @@ void tst_QFile::readLineStdin()
for (int i = 0; i < 2; ++i) {
QProcess process;
+ StdinReaderProcessGuard processGuard(&process);
process.start(m_stdinProcessDir + QStringLiteral("/stdinprocess"),
QStringList() << QStringLiteral("line") << QString::number(i),
QIODevice::Text | QIODevice::ReadWrite);
@@ -915,13 +967,11 @@ void tst_QFile::readLineStdin()
for (int i = 0; i < 5; ++i) {
QTest::qWait(1000);
process.write(lotsOfData);
- while (process.bytesToWrite() > 0) {
+ while (process.bytesToWrite() > 0)
QVERIFY(process.waitForBytesWritten());
- }
}
- process.closeWriteChannel();
- QVERIFY(process.waitForFinished(5000));
+ QVERIFY(processGuard.stop(5000));
QByteArray array = process.readAll();
QCOMPARE(array.size(), lotsOfData.size() * 5);
@@ -942,6 +992,7 @@ void tst_QFile::readLineStdin_lineByLine()
#else
for (int i = 0; i < 2; ++i) {
QProcess process;
+ StdinReaderProcessGuard processGuard(&process);
process.start(m_stdinProcessDir + QStringLiteral("/stdinprocess"),
QStringList() << QStringLiteral("line") << QString::number(i),
QIODevice::Text | QIODevice::ReadWrite);
@@ -956,8 +1007,7 @@ void tst_QFile::readLineStdin_lineByLine()
QCOMPARE(process.readAll(), line);
}
- process.closeWriteChannel();
- QVERIFY(process.waitForFinished(5000));
+ QVERIFY(processGuard.stop(5000));
}
#endif
}
@@ -967,7 +1017,7 @@ void tst_QFile::text()
{
// dosfile.txt is a binary CRLF file
QFile file(m_dosFile);
- QVERIFY(file.open(QFile::Text | QFile::ReadOnly));
+ QVERIFY2(file.open(QFile::Text | QFile::ReadOnly), msgOpenFailed(file).constData());
QCOMPARE(file.readLine(),
QByteArray("/dev/system/root / reiserfs acl,user_xattr 1 1\n"));
QCOMPARE(file.readLine(),
@@ -980,7 +1030,7 @@ void tst_QFile::text()
void tst_QFile::missingEndOfLine()
{
QFile file(m_noEndOfLineFile);
- QVERIFY(file.open(QFile::ReadOnly));
+ QVERIFY2(file.open(QFile::ReadOnly), msgOpenFailed(file).constData());
int nlines = 0;
while (!file.atEnd()) {
@@ -1026,7 +1076,7 @@ void tst_QFile::getch()
void tst_QFile::ungetChar()
{
QFile f(m_testFile);
- QVERIFY(f.open(QIODevice::ReadOnly));
+ QVERIFY2(f.open(QFile::ReadOnly), msgOpenFailed(f).constData());
QByteArray array = f.readLine();
QCOMPARE(array.constData(), "----------------------------------------------------------\n");
@@ -1044,7 +1094,7 @@ void tst_QFile::ungetChar()
QFile::remove("genfile.txt");
QFile out("genfile.txt");
- QVERIFY(out.open(QIODevice::ReadWrite));
+ QVERIFY2(out.open(QIODevice::ReadWrite), msgOpenFailed(out).constData());
out.write("123");
out.seek(0);
QCOMPARE(out.readAll().constData(), "123");
@@ -1127,7 +1177,7 @@ void tst_QFile::createFile()
QVERIFY( !QFile::exists( "createme.txt" ) );
QFile f( "createme.txt" );
- QVERIFY( f.open( QIODevice::WriteOnly ) );
+ QVERIFY2( f.open(QIODevice::WriteOnly), msgOpenFailed(f).constData());
f.close();
QVERIFY( QFile::exists( "createme.txt" ) );
}
@@ -1140,11 +1190,11 @@ void tst_QFile::append()
QVERIFY(!QFile::exists(name));
QFile f(name);
- QVERIFY(f.open(QIODevice::WriteOnly | QIODevice::Truncate));
+ QVERIFY2(f.open(QIODevice::WriteOnly | QIODevice::Truncate), msgOpenFailed(f).constData());
f.putChar('a');
f.close();
- QVERIFY(f.open(QIODevice::Append));
+ QVERIFY2(f.open(QIODevice::Append), msgOpenFailed(f).constData());
QVERIFY(f.pos() == 1);
f.putChar('a');
f.close();
@@ -1181,7 +1231,7 @@ void tst_QFile::permissions()
QFETCH(bool, create);
if (create) {
QFile fc(file);
- QVERIFY(fc.open(QFile::WriteOnly));
+ QVERIFY2(fc.open(QFile::WriteOnly), msgOpenFailed(fc).constData());
QVERIFY(fc.write("hello\n"));
fc.close();
}
@@ -1230,7 +1280,7 @@ void tst_QFile::setPermissions()
QVERIFY( !QFile::exists( "createme.txt" ) );
QFile f("createme.txt");
- QVERIFY(f.open(QIODevice::WriteOnly | QIODevice::Truncate));
+ QVERIFY2(f.open(QIODevice::WriteOnly | QIODevice::Truncate), msgOpenFailed(f).constData());
f.putChar('a');
f.close();
@@ -1247,8 +1297,8 @@ void tst_QFile::copy()
QFile::remove("test2");
QVERIFY(QFile::copy(m_testSourceFile, "tst_qfile_copy.cpp"));
QFile in1(m_testSourceFile), in2("tst_qfile_copy.cpp");
- QVERIFY(in1.open(QFile::ReadOnly));
- QVERIFY(in2.open(QFile::ReadOnly));
+ QVERIFY2(in1.open(QFile::ReadOnly), msgOpenFailed(in1).constData());
+ QVERIFY2(in2.open(QFile::ReadOnly), msgOpenFailed(in2).constData());
QByteArray data1 = in1.readAll(), data2 = in2.readAll();
QCOMPARE(data1, data2);
QFile::remove( "main_copy.cpp" );
@@ -1261,8 +1311,8 @@ void tst_QFile::copyAfterFail()
QFile file1("file-to-be-copied.txt");
QFile file2("existing-file.txt");
- QVERIFY(file1.open(QIODevice::ReadWrite) && "(test-precondition)");
- QVERIFY(file2.open(QIODevice::ReadWrite) && "(test-precondition)");
+ QVERIFY2(file1.open(QIODevice::ReadWrite), msgOpenFailed(file1).constData());
+ QVERIFY2(file2.open(QIODevice::ReadWrite), msgOpenFailed(file1).constData());
file2.close();
QVERIFY(!QFile::exists("copied-file-1.txt") && "(test-precondition)");
QVERIFY(!QFile::exists("copied-file-2.txt") && "(test-precondition)");
@@ -1331,7 +1381,7 @@ void tst_QFile::copyFallback()
QVERIFY(QFile::remove("file-copy-destination.txt"));
// Fallback copy of open file.
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
QVERIFY(file.copy("file-copy-destination.txt"));
QVERIFY(QFile::exists("file-copy-destination.txt"));
QVERIFY(!file.isOpen());
@@ -1401,7 +1451,7 @@ void tst_QFile::link()
QCOMPARE(info2.symLinkTarget(), referenceTarget);
QFile link("myLink.lnk");
- QVERIFY(link.open(QIODevice::ReadOnly));
+ QVERIFY2(link.open(QIODevice::ReadOnly), msgOpenFailed(link).constData());
QCOMPARE(link.symLinkTarget(), referenceTarget);
link.close();
@@ -1483,15 +1533,15 @@ void tst_QFile::readTextFile()
QFETCH(QByteArray, out);
QFile winfile("winfile.txt");
- QVERIFY(winfile.open(QFile::WriteOnly | QFile::Truncate));
+ QVERIFY2(winfile.open(QFile::WriteOnly | QFile::Truncate), msgOpenFailed(winfile).constData());
winfile.write(in);
winfile.close();
- QVERIFY(winfile.open(QFile::ReadOnly));
+ QVERIFY2(winfile.open(QFile::ReadOnly), msgOpenFailed(winfile).constData());
QCOMPARE(winfile.readAll(), in);
winfile.close();
- QVERIFY(winfile.open(QFile::ReadOnly | QFile::Text));
+ QVERIFY2(winfile.open(QFile::ReadOnly | QFile::Text), msgOpenFailed(winfile).constData());
QCOMPARE(winfile.readAll(), out);
}
@@ -1499,13 +1549,13 @@ void tst_QFile::readTextFile2()
{
{
QFile file(m_testLogFile);
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
file.read(4097);
}
{
QFile file(m_testLogFile);
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), msgOpenFailed(file).constData());
file.read(4097);
}
}
@@ -1532,7 +1582,8 @@ void tst_QFile::writeTextFile()
QFETCH(QByteArray, in);
QFile file("textfile.txt");
- QVERIFY(file.open(QFile::WriteOnly | QFile::Truncate | QFile::Text));
+ QVERIFY2(file.open(QFile::WriteOnly | QFile::Truncate | QFile::Text),
+ msgOpenFailed(file).constData());
QByteArray out = in;
#ifdef Q_OS_WIN
out.replace('\n', "\r\n");
@@ -1555,8 +1606,10 @@ void tst_QFile::largeUncFileSupport()
{
// 1) Native file handling.
QFile file(largeFile);
+ QVERIFY2(file.exists(), msgFileDoesNotExist(largeFile));
+
QCOMPARE(file.size(), size);
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
QCOMPARE(file.size(), size);
QVERIFY(file.seek(dataOffset));
QCOMPARE(file.read(knownData.size()), knownData);
@@ -1593,13 +1646,13 @@ void tst_QFile::flush()
{
QFile file(fileName);
- QVERIFY(file.open(QFile::WriteOnly));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
QCOMPARE(file.write("abc", 3),qint64(3));
}
{
QFile file(fileName);
- QVERIFY(file.open(QFile::WriteOnly | QFile::Append));
+ QVERIFY2(file.open(QFile::WriteOnly | QFile::Append), msgOpenFailed(file).constData());
QCOMPARE(file.pos(), qlonglong(3));
QCOMPARE(file.write("def", 3), qlonglong(3));
QCOMPARE(file.pos(), qlonglong(6));
@@ -1607,7 +1660,7 @@ void tst_QFile::flush()
{
QFile file("stdfile.txt");
- QVERIFY(file.open(QFile::ReadOnly));
+ QVERIFY2(file.open(QFile::ReadOnly), msgOpenFailed(file).constData());
QCOMPARE(file.readAll(), QByteArray("abcdef"));
}
}
@@ -1617,7 +1670,7 @@ void tst_QFile::bufferedRead()
QFile::remove("stdfile.txt");
QFile file("stdfile.txt");
- QVERIFY(file.open(QFile::WriteOnly));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
file.write("abcdef");
file.close();
@@ -1634,7 +1687,7 @@ void tst_QFile::bufferedRead()
{
QFile file;
- QVERIFY(file.open(stdFile, QFile::ReadOnly));
+ QVERIFY2(file.open(stdFile, QFile::ReadOnly), msgOpenFailed(file).constData());
QCOMPARE(file.pos(), qlonglong(1));
QCOMPARE(file.read(&c, 1), qlonglong(1));
QCOMPARE(c, 'b');
@@ -1648,7 +1701,7 @@ void tst_QFile::bufferedRead()
void tst_QFile::isSequential()
{
QFile zero("/dev/null");
- QVERIFY(zero.open(QFile::ReadOnly));
+ QVERIFY2(zero.open(QFile::ReadOnly), msgOpenFailed(zero).constData());
QVERIFY(zero.isSequential());
}
#endif
@@ -1662,15 +1715,15 @@ void tst_QFile::truncate()
{
for (int i = 0; i < 2; ++i) {
QFile file("truncate.txt");
- QVERIFY(file.open(QFile::WriteOnly));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
file.write(QByteArray(200, '@'));
file.close();
- QVERIFY(file.open((i ? QFile::WriteOnly : QFile::ReadWrite) | QFile::Truncate));
+ QVERIFY2(file.open((i ? QFile::WriteOnly : QFile::ReadWrite) | QFile::Truncate), msgOpenFailed(file).constData());
file.write(QByteArray(100, '$'));
file.close();
- QVERIFY(file.open(QFile::ReadOnly));
+ QVERIFY2(file.open(QFile::ReadOnly), msgOpenFailed(file).constData());
QCOMPARE(file.readAll(), QByteArray(100, '$'));
}
}
@@ -1679,13 +1732,13 @@ void tst_QFile::seekToPos()
{
{
QFile file("seekToPos.txt");
- QVERIFY(file.open(QFile::WriteOnly));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
file.write("a\r\nb\r\nc\r\n");
file.flush();
}
QFile file("seekToPos.txt");
- QVERIFY(file.open(QFile::ReadOnly | QFile::Text));
+ QVERIFY2(file.open(QFile::ReadOnly | QFile::Text), msgOpenFailed(file).constData());
file.seek(1);
char c;
QVERIFY(file.getChar(&c));
@@ -1707,7 +1760,7 @@ void tst_QFile::seekAfterEndOfFile()
QFile::remove(filename);
{
QFile file(filename);
- QVERIFY(file.open(QFile::WriteOnly));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
file.write("abcd");
QCOMPARE(file.size(), qint64(4));
file.seek(8);
@@ -1723,7 +1776,7 @@ void tst_QFile::seekAfterEndOfFile()
}
QFile file(filename);
- QVERIFY(file.open(QFile::ReadOnly));
+ QVERIFY2(file.open(QFile::ReadOnly), msgOpenFailed(file).constData());
QByteArray contents = file.readAll();
QCOMPARE(contents.left(12), QByteArray("abcdefghijkl", 12));
//bytes 12-15 are uninitialised so we don't care what they read as.
@@ -1741,7 +1794,7 @@ void tst_QFile::FILEReadWrite()
// create test file
{
QFile f("FILEReadWrite.txt");
- QVERIFY(f.open(QFile::WriteOnly));
+ QVERIFY2(f.open(QFile::WriteOnly), msgOpenFailed(f).constData());
QDataStream ds(&f);
qint8 c = 0;
ds << c;
@@ -1777,7 +1830,7 @@ void tst_QFile::FILEReadWrite()
#endif
QVERIFY(fp);
QFile file;
- QVERIFY(file.open(fp, QFile::ReadWrite));
+ QVERIFY2(file.open(fp, QFile::ReadWrite), msgOpenFailed(file).constData());
QDataStream sfile(&file) ;
qint8 var1,var2,var3,var4;
@@ -1814,7 +1867,7 @@ void tst_QFile::FILEReadWrite()
// check modified file
{
QFile f("FILEReadWrite.txt");
- QVERIFY(f.open(QFile::ReadOnly));
+ QVERIFY2(f.open(QFile::ReadOnly), msgOpenFailed(file).constData());
QDataStream ds(&f);
qint8 c = 0;
ds >> c;
@@ -1928,14 +1981,14 @@ void tst_QFile::i18nFileName()
}
{
QFile file(fileName);
- QVERIFY(file.open(QFile::WriteOnly | QFile::Text));
+ QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
ts.setCodec("UTF-8");
ts << fileName << endl;
}
{
QFile file(fileName);
- QVERIFY(file.open(QFile::ReadOnly | QFile::Text));
+ QVERIFY2(file.open(QFile::ReadOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
ts.setCodec("UTF-8");
QString line = ts.readLine();
@@ -1983,13 +2036,13 @@ void tst_QFile::longFileName()
QEXPECT_FAIL("244 chars", "Full pathname must be less than 260 chars", Abort);
QEXPECT_FAIL("244 chars to absolutepath", "Full pathname must be less than 260 chars", Abort);
#endif
- QVERIFY(file.open(QFile::WriteOnly | QFile::Text));
+ QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
ts << fileName << endl;
}
{
QFile file(fileName);
- QVERIFY(file.open(QFile::ReadOnly | QFile::Text));
+ QVERIFY2(file.open(QFile::ReadOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
QString line = ts.readLine();
QCOMPARE(line, fileName);
@@ -1998,7 +2051,7 @@ void tst_QFile::longFileName()
{
QVERIFY(QFile::copy(fileName, newName));
QFile file(newName);
- QVERIFY(file.open(QFile::ReadOnly | QFile::Text));
+ QVERIFY2(file.open(QFile::ReadOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
QString line = ts.readLine();
QCOMPARE(line, fileName);
@@ -2008,12 +2061,12 @@ void tst_QFile::longFileName()
{
QVERIFY(QFile::rename(fileName, newName));
QFile file(newName);
- QVERIFY(file.open(QFile::ReadOnly | QFile::Text));
+ QVERIFY2(file.open(QFile::ReadOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
QString line = ts.readLine();
QCOMPARE(line, fileName);
}
- QVERIFY(QFile::exists(newName));
+ QVERIFY2(QFile::exists(newName), msgFileDoesNotExist(newName).constData());
}
#ifdef QT_BUILD_INTERNAL
@@ -2146,7 +2199,7 @@ void tst_QFile::remove_and_exists()
bool opened = f.open(QIODevice::WriteOnly);
QVERIFY(opened);
- f.write(QString("testing that remove/exists work...").toLatin1());
+ f.write("testing that remove/exists work...");
f.close();
QVERIFY(f.exists());
@@ -2165,7 +2218,7 @@ void tst_QFile::removeOpenFile()
QVERIFY(!f.exists());
bool opened = f.open(QIODevice::WriteOnly);
QVERIFY(opened);
- f.write(QString("testing that remove closes the file first...").toLatin1());
+ f.write("testing that remove closes the file first...");
bool removed = f.remove(); // remove should both close and remove the file
QVERIFY(removed);
@@ -2184,7 +2237,7 @@ void tst_QFile::removeOpenFile()
QVERIFY(!f.exists());
bool opened = f.open(QIODevice::WriteOnly);
QVERIFY(opened);
- f.write(QString("testing that remove closes the file first...").toLatin1());
+ f.write("testing that remove closes the file first...");
f.close();
}
@@ -2208,7 +2261,7 @@ void tst_QFile::fullDisk()
if (!file.exists())
QSKIP("/dev/full doesn't exist on this system");
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgOpenFailed(file).constData());
file.write("foobar", 6);
QVERIFY(!file.flush());
@@ -2235,7 +2288,7 @@ void tst_QFile::fullDisk()
QCOMPARE(file.error(), QFile::NoError);
// try again without flush:
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgOpenFailed(file).constData());
file.write("foobar", 6);
file.close();
QVERIFY(file.error() != QFile::NoError);
@@ -2288,8 +2341,7 @@ void tst_QFile::writeLargeDataBlock()
{
QFile file(fileName);
- QVERIFY2( openFile(file, QIODevice::WriteOnly, (FileType)type),
- qPrintable(QString("Couldn't open file for writing: [%1]").arg(fileName)) );
+ QVERIFY2(openFile(file, QIODevice::WriteOnly, (FileType)type), msgOpenFailed(file));
qint64 fileWriteOriginalData = file.write(originalData);
qint64 originalDataSize = (qint64)originalData.size();
#if defined(Q_OS_WIN)
@@ -2332,7 +2384,7 @@ void tst_QFile::writeLargeDataBlock()
void tst_QFile::readFromWriteOnlyFile()
{
QFile file("writeonlyfile");
- QVERIFY(file.open(QFile::WriteOnly));
+ QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData());
char c;
QTest::ignoreMessage(QtWarningMsg, "QIODevice::read (QFile, \"writeonlyfile\"): WriteOnly device");
QCOMPARE(file.read(&c, 1), qint64(-1));
@@ -2341,7 +2393,7 @@ void tst_QFile::readFromWriteOnlyFile()
void tst_QFile::writeToReadOnlyFile()
{
QFile file("readonlyfile");
- QVERIFY(file.open(QFile::ReadOnly));
+ QVERIFY2(file.open(QFile::ReadOnly), msgOpenFailed(file).constData());
char c = 0;
QTest::ignoreMessage(QtWarningMsg, "QIODevice::write (QFile, \"readonlyfile\"): ReadOnly device");
QCOMPARE(file.write(&c, 1), qint64(-1));
@@ -2363,13 +2415,13 @@ void tst_QFile::virtualFile()
// consistency check
QFileInfo fi(fname);
- QVERIFY(fi.exists());
+ QVERIFY2(fi.exists(), msgFileDoesNotExist(fname).constData());
QVERIFY(fi.isFile());
QCOMPARE(fi.size(), Q_INT64_C(0));
// open the file
QFile f(fname);
- QVERIFY(f.open(QIODevice::ReadOnly));
+ QVERIFY2(f.open(QIODevice::ReadOnly), msgOpenFailed(f).constData());
QCOMPARE(f.size(), Q_INT64_C(0));
QVERIFY(f.atEnd());
@@ -2413,7 +2465,7 @@ void tst_QFile::textFile()
::fclose(fs);
QFile file("writeabletextfile");
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
QByteArray data = file.readAll();
@@ -2543,8 +2595,8 @@ void tst_QFile::renameMultiple()
// create the file if it doesn't exist
QFile file("file-to-be-renamed.txt");
QFile file2("existing-file.txt");
- QVERIFY(file.open(QIODevice::ReadWrite) && "(test-precondition)");
- QVERIFY(file2.open(QIODevice::ReadWrite) && "(test-precondition)");
+ QVERIFY2(file.open(QIODevice::ReadWrite), msgOpenFailed(file).constData());
+ QVERIFY2(file2.open(QIODevice::ReadWrite), msgOpenFailed(file2).constData());
// any stale files from previous test failures?
QFile::remove("file-renamed-once.txt");
@@ -2583,10 +2635,10 @@ void tst_QFile::renameMultiple()
void tst_QFile::appendAndRead()
{
QFile writeFile(QLatin1String("appendfile.txt"));
- QVERIFY(writeFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
+ QVERIFY2(writeFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgOpenFailed(writeFile).constData());
QFile readFile(QLatin1String("appendfile.txt"));
- QVERIFY(readFile.open(QIODevice::ReadOnly));
+ QVERIFY2(readFile.open(QIODevice::ReadOnly), msgOpenFailed(readFile).constData());
// Write to the end of the file, then read that character back, and so on.
for (int i = 0; i < 100; ++i) {
@@ -2612,11 +2664,13 @@ void tst_QFile::miscWithUncPathAsCurrentDir()
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QString current = QDir::currentPath();
- QVERIFY(QDir::setCurrent("//" + QtNetworkSettings::winServerName() + "/testshare"));
+ const QString path = QLatin1String("//") + QtNetworkSettings::winServerName()
+ + QLatin1String("/testshare");
+ QVERIFY2(QDir::setCurrent(path), qPrintable(QDir::toNativeSeparators(path)));
QFile file("test.pri");
- QVERIFY(file.exists());
+ QVERIFY2(file.exists(), msgFileDoesNotExist(file.fileName()).constData());
QCOMPARE(int(file.size()), 34);
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
QVERIFY(QDir::setCurrent(current));
#endif
}
@@ -2634,7 +2688,7 @@ void tst_QFile::handle()
int fd;
#if !defined(Q_OS_WINCE)
QFile file(m_testSourceFile);
- QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
fd = int(file.handle());
QVERIFY(fd > 2);
QCOMPARE(int(file.handle()), fd);
@@ -2648,7 +2702,7 @@ void tst_QFile::handle()
// same, but read from QFile first now
file.close();
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered));
+ QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered), msgOpenFailed(file).constData());
fd = int(file.handle());
QVERIFY(fd > 2);
QVERIFY(file.getChar(&c));
@@ -2690,7 +2744,7 @@ void tst_QFile::nativeHandleLeaks()
{
QFile file("qt_file.tmp");
- QVERIFY( file.open(QIODevice::ReadWrite) );
+ QVERIFY2(file.open(QIODevice::ReadWrite), msgOpenFailed(file).constData());
fd1 = file.handle();
QVERIFY( -1 != fd1 );
@@ -2709,7 +2763,7 @@ void tst_QFile::nativeHandleLeaks()
{
QFile file("qt_file.tmp");
- QVERIFY( file.open(QIODevice::ReadOnly) );
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
fd2 = file.handle();
QVERIFY( -1 != fd2 );
@@ -2755,7 +2809,7 @@ void tst_QFile::readEof()
{
QFile file(filename);
- QVERIFY(file.open(QIODevice::ReadOnly | mode));
+ QVERIFY2(file.open(QIODevice::ReadOnly | mode), msgOpenFailed(file).constData());
bool isSequential = file.isSequential();
if (!isSequential) {
QVERIFY(file.seek(245));
@@ -2777,7 +2831,7 @@ void tst_QFile::readEof()
{
QFile file(filename);
- QVERIFY(file.open(QIODevice::ReadOnly | mode));
+ QVERIFY2(file.open(QIODevice::ReadOnly | mode), msgOpenFailed(file).constData());
bool isSequential = file.isSequential();
if (!isSequential) {
QVERIFY(file.seek(245));
@@ -2798,7 +2852,7 @@ void tst_QFile::readEof()
{
QFile file(filename);
- QVERIFY(file.open(QIODevice::ReadOnly | mode));
+ QVERIFY2(file.open(QIODevice::ReadOnly | mode), msgOpenFailed(file).constData());
bool isSequential = file.isSequential();
if (!isSequential) {
QVERIFY(file.seek(245));
@@ -2820,7 +2874,7 @@ void tst_QFile::readEof()
{
QFile file(filename);
- QVERIFY(file.open(QIODevice::ReadOnly | mode));
+ QVERIFY2(file.open(QIODevice::ReadOnly | mode), msgOpenFailed(file).constData());
bool isSequential = file.isSequential();
if (!isSequential) {
QVERIFY(file.seek(245));
@@ -2841,7 +2895,7 @@ void tst_QFile::readEof()
{
QFile file(filename);
- QVERIFY(file.open(QIODevice::ReadOnly | mode));
+ QVERIFY2(file.open(QIODevice::ReadOnly | mode), msgOpenFailed(file).constData());
bool isSequential = file.isSequential();
if (!isSequential) {
QVERIFY(file.seek(245));
@@ -2867,7 +2921,7 @@ void tst_QFile::posAfterFailedStat()
QFile::remove("tmp.txt");
QFile file("tmp.txt");
QVERIFY(!file.exists());
- QVERIFY(file.open(QIODevice::Append));
+ QVERIFY2(file.open(QIODevice::Append), msgOpenFailed(file).constData());
QVERIFY(file.exists());
file.write("qt430", 5);
QVERIFY(!file.isSequential());
@@ -2922,11 +2976,11 @@ void tst_QFile::map()
QCOMPARE(file.error(), QFile::PermissionsError);
// make a file
- QVERIFY(file.open(QFile::ReadWrite));
+ QVERIFY2(file.open(QFile::ReadWrite), msgOpenFailed(file).constData());
QVERIFY(file.resize(fileSize));
QVERIFY(file.flush());
file.close();
- QVERIFY(file.open(QFile::ReadWrite));
+ QVERIFY2(file.open(QFile::ReadWrite), msgOpenFailed(file).constData());
memory = file.map(offset, size);
if (error != QFile::NoError) {
QVERIFY(file.error() != QFile::NoError);
@@ -3061,13 +3115,14 @@ void tst_QFile::mapOpenMode()
QFile file(fileName);
// make a file
- QVERIFY(file.open(QFile::ReadWrite));
+ QVERIFY2(file.open(QFile::ReadWrite), msgOpenFailed(file).constData());
QVERIFY(file.write(pattern));
QVERIFY(file.flush());
file.close();
// open according to our mode
- QVERIFY(file.open(QIODevice::OpenMode(openMode)));
+ const QIODevice::OpenMode om(openMode);
+ QVERIFY2(file.open(om), msgOpenFailed(om, file).constData());
uchar *memory = file.map(0, fileSize, QFileDevice::MemoryMapFlags(flags));
#if defined(Q_OS_WINCE)
@@ -3116,7 +3171,8 @@ void tst_QFile::mapWrittenFile()
QFile::remove(fileName);
}
QFile file(fileName);
- QVERIFY(file.open(QIODevice::ReadWrite | QFile::OpenMode(mode)));
+ const QIODevice::OpenMode om = QIODevice::ReadWrite | QIODevice::OpenMode(mode);
+ QVERIFY2(file.open(om), msgOpenFailed(om, file).constData());
QCOMPARE(file.write(data, sizeof data), qint64(sizeof data));
if ((mode & QIODevice::Unbuffered) == 0)
file.flush();
@@ -3328,7 +3384,7 @@ void tst_QFile::caseSensitivity()
QString filename("File.txt");
{
QFile f(filename);
- QVERIFY(f.open(QIODevice::WriteOnly));
+ QVERIFY2(f.open(QIODevice::WriteOnly), msgOpenFailed(f));
QVERIFY(f.write(testData));
f.close();
}
diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro
index de99447404..571637be37 100644
--- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro
+++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro
@@ -7,3 +7,5 @@ RESOURCES += qfileinfo.qrc \
win32:!wince:!winrt:LIBS += -ladvapi32 -lnetapi32
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+win32: CONFIG += insignificant_test # Crashes on Windows in release builds
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 96ad78a666..210fdb5a12 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -149,6 +149,25 @@ static QString seedAndTemplate()
qsrand(QDateTime::currentDateTimeUtc().toTime_t());
return QDir::tempPath() + "/tst_qfileinfo-XXXXXX";
}
+
+static QByteArray msgDoesNotExist(const QString &name)
+{
+ return (QLatin1Char('"') + QDir::toNativeSeparators(name)
+ + QLatin1String("\" does not exist.")).toLocal8Bit();
+}
+
+static QByteArray msgIsNoDirectory(const QString &name)
+{
+ return (QLatin1Char('"') + QDir::toNativeSeparators(name)
+ + QLatin1String("\" is not a directory.")).toLocal8Bit();
+}
+
+static QByteArray msgIsNotRoot(const QString &name)
+{
+ return (QLatin1Char('"') + QDir::toNativeSeparators(name)
+ + QLatin1String("\" is no root directory.")).toLocal8Bit();
+}
+
class tst_QFileInfo : public QObject
{
Q_OBJECT
@@ -287,7 +306,8 @@ void tst_QFileInfo::initTestCase()
m_resourcesDir = dataPath + QLatin1String("/resources");
m_proFile = dataPath + QLatin1String("/tst_qfileinfo.pro");
- QVERIFY(m_dir.isValid());
+ QVERIFY2(m_dir.isValid(),
+ ("Failed to create temporary dir: " + m_dir.errorString()).toUtf8());
QVERIFY(QDir::setCurrent(m_dir.path()));
}
@@ -316,7 +336,7 @@ static QFileInfoPrivate* getPrivate(QFileInfo &info)
void tst_QFileInfo::copy()
{
QTemporaryFile t;
- t.open();
+ QVERIFY2(t.open(), qPrintable(t.errorString()));
QFileInfo info(t.fileName());
QVERIFY(info.exists());
@@ -413,13 +433,14 @@ void tst_QFileInfo::isDir_data()
//QTest::newRow("drive 2") << "t:s" << false;
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
- QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true;
- QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << true;
- QTest::newRow("unc 4") << "//" + QtNetworkSettings::winServerName() + "/testshare/" << true;
- QTest::newRow("unc 5") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp" << true;
- QTest::newRow("unc 6") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp/" << true;
- QTest::newRow("unc 7") << "//" + QtNetworkSettings::winServerName() + "/testshare/adirthatshouldnotexist" << false;
+ const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ QTest::newRow("unc 1") << uncRoot << true;
+ QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
+ QTest::newRow("unc 3") << uncRoot + "/testshare" << true;
+ QTest::newRow("unc 4") << uncRoot + "/testshare/" << true;
+ QTest::newRow("unc 5") << uncRoot + "/testshare/tmp" << true;
+ QTest::newRow("unc 6") << uncRoot + "/testshare/tmp/" << true;
+ QTest::newRow("unc 7") << uncRoot + "/testshare/adirthatshouldnotexist" << false;
#endif
}
@@ -428,8 +449,11 @@ void tst_QFileInfo::isDir()
QFETCH(QString, path);
QFETCH(bool, expected);
- QFileInfo fi(path);
- QCOMPARE(fi.isDir(), expected);
+ const bool isDir = QFileInfo(path).isDir();
+ if (expected)
+ QVERIFY2(isDir, msgIsNoDirectory(path).constData());
+ else
+ QVERIFY(!isDir);
}
void tst_QFileInfo::isRoot_data()
@@ -452,10 +476,11 @@ void tst_QFileInfo::isRoot_data()
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
- QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
- QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true;
- QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << false;
- QTest::newRow("unc 4") << "//" + QtNetworkSettings::winServerName() + "/testshare/" << false;
+ const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ QTest::newRow("unc 1") << uncRoot << true;
+ QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
+ QTest::newRow("unc 3") << uncRoot + "/testshare" << false;
+ QTest::newRow("unc 4") << uncRoot + "/testshare/" << false;
QTest::newRow("unc 7") << "//ahostthatshouldnotexist" << false;
#endif
}
@@ -465,8 +490,11 @@ void tst_QFileInfo::isRoot()
QFETCH(QString, path);
QFETCH(bool, expected);
- QFileInfo fi(path);
- QCOMPARE(fi.isRoot(), expected);
+ const bool isRoot = QFileInfo(path).isRoot();
+ if (expected)
+ QVERIFY2(isRoot, msgIsNotRoot(path).constData());
+ else
+ QVERIFY(!isRoot);
}
void tst_QFileInfo::exists_data()
@@ -492,14 +520,15 @@ void tst_QFileInfo::exists_data()
QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << true;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
- QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
- QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true;
- QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << true;
- QTest::newRow("unc 4") << "//" + QtNetworkSettings::winServerName() + "/testshare/" << true;
- QTest::newRow("unc 5") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp" << true;
- QTest::newRow("unc 6") << "//" + QtNetworkSettings::winServerName() + "/testshare/tmp/" << true;
- QTest::newRow("unc 7") << "//" + QtNetworkSettings::winServerName() + "/testshare/adirthatshouldnotexist" << false;
- QTest::newRow("unc 8") << "//" + QtNetworkSettings::winServerName() + "/asharethatshouldnotexist" << false;
+ const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ QTest::newRow("unc 1") << uncRoot << true;
+ QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
+ QTest::newRow("unc 3") << uncRoot + "/testshare" << true;
+ QTest::newRow("unc 4") << uncRoot + "/testshare/" << true;
+ QTest::newRow("unc 5") << uncRoot + "/testshare/tmp" << true;
+ QTest::newRow("unc 6") << uncRoot + "/testshare/tmp/" << true;
+ QTest::newRow("unc 7") << uncRoot + "/testshare/adirthatshouldnotexist" << false;
+ QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << false;
QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false;
#endif
}
@@ -510,8 +539,12 @@ void tst_QFileInfo::exists()
QFETCH(bool, expected);
QFileInfo fi(path);
- QCOMPARE(fi.exists(), expected);
- QCOMPARE(QFileInfo::exists(path), expected);
+ const bool exists = fi.exists();
+ QCOMPARE(exists, QFileInfo::exists(path));
+ if (expected)
+ QVERIFY2(exists, msgDoesNotExist(path).constData());
+ else
+ QVERIFY(!exists);
}
void tst_QFileInfo::absolutePath_data()
@@ -611,7 +644,7 @@ void tst_QFileInfo::canonicalPath()
{
QTemporaryFile tempFile;
tempFile.setAutoRemove(true);
- tempFile.open();
+ QVERIFY2(tempFile.open(), qPrintable(tempFile.errorString()));
QFileInfo fi(tempFile.fileName());
QCOMPARE(fi.canonicalPath(), QFileInfo(QDir::tempPath()).canonicalFilePath());
}
@@ -993,7 +1026,7 @@ void tst_QFileInfo::systemFiles()
QSKIP("This is a Windows only test");
#endif
QFileInfo fi("c:\\pagefile.sys");
- QVERIFY(fi.exists());
+ QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData());
QVERIFY(fi.size() > 0);
QVERIFY(fi.lastModified().isValid());
}
@@ -1478,7 +1511,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
QTest::newRow("dummy") << target.path() << false << "" << target.canonicalPath();
QSKIP("link not supported by FS or insufficient privilege");
}
- QVERIFY(file.exists());
+ QVERIFY2(file.exists(), msgDoesNotExist(file.fileName()).constData());
QTest::newRow("absolute dir symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath();
QTest::newRow("relative dir symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalPath();
@@ -1509,7 +1542,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
QFile file(fileInJunction.absoluteFilePath());
file.open(QIODevice::ReadWrite);
file.close();
- QVERIFY(file.exists());
+ QVERIFY2(file.exists(), msgDoesNotExist(file.fileName()).constData());
QTest::newRow("file in junction") << fileInJunction.absoluteFilePath() << false << "" << fileInJunction.canonicalFilePath();
target = QDir::rootPath();
@@ -1601,7 +1634,7 @@ void tst_QFileInfo::isWritable()
#else
QFileInfo fi("c:\\pagefile.sys");
#endif
- QVERIFY(fi.exists());
+ QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData());
QVERIFY(!fi.isWritable());
#endif
#if defined (Q_OS_QNX) // On QNX /etc is usually on a read-only filesystem
@@ -1859,7 +1892,7 @@ void tst_QFileInfo::owner()
QVERIFY(testFile.write(testData) != -1);
}
QFileInfo fi(fileName);
- QVERIFY(fi.exists());
+ QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData());
QCOMPARE(fi.owner(), userName);
QFile::remove(fileName);
@@ -1894,7 +1927,7 @@ void tst_QFileInfo::group()
QVERIFY(testFile.write(testData) != -1);
testFile.close();
QFileInfo fi(fileName);
- QVERIFY(fi.exists());
+ QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData());
QCOMPARE(fi.group(), expected);
}
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+haiku/test b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+haiku/test2 b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test2
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test2
diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+haiku/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+haiku/test
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+haiku/test
diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc
index 661647f933..6e2699774d 100644
--- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc
+++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc
@@ -19,6 +19,7 @@
<file>platforms/+unix/+darwin/+mac/+osx/test</file>
<file>platforms/+unix/+darwin/+mac/test</file>
<file>platforms/+unix/+darwin/test</file>
+ <file>platforms/+unix/+haiku/test</file>
<file>platforms/+unix/+linux/test</file>
<file>platforms/+unix/test</file>
<file>platforms/+windows/+wince/test</file>
@@ -30,6 +31,7 @@
<file>platforms/+osx/test</file>
<file>platforms/+darwin/test</file>
<file>platforms/+mac/test</file>
+ <file>platforms/+haiku/test</file>
<file>platforms/+linux/test</file>
<file>platforms/+wince/test</file>
@@ -39,6 +41,7 @@
<file>platforms/+blackberry/test2</file>
<file>platforms/+ios/test2</file>
<file>platforms/+osx/test2</file>
+ <file>platforms/+haiku/test2</file>
<file>platforms/+linux/test2</file>
<file>platforms/+wince/test2</file>
<file>platforms/+winnt/test2</file>
diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
index b3767b4887..87381f4c4e 100644
--- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
+++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp
@@ -89,7 +89,7 @@ void tst_QFileSelector::basicTest_data()
QString expectedPlatform2File(""); //Only the last selector
QString expectedPlatform3File; // Only the first selector (the family)
#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && \
- !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX)
+ !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU)
/* We are only aware of specific unixes, and do not have test files for any of the others.
However those unixes can get a selector added from the result of a uname call, so this will
lead to a case where we don't have that file so we can't expect the concatenation of platform
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
index 3ac0b9dff4..10a4ba069e 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
+++ b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST
@@ -6,3 +6,4 @@ windows 64bit msvc
osx
[watchFileAndItsDirectory:native backend-specialchars]
osx
+windows
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index 7e56ecaab3..026743257c 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -126,7 +126,7 @@ void tst_QFileSystemWatcher::basicTest()
// create test file
QTemporaryDir temporaryDirectory(m_tempDirPattern);
- QVERIFY(temporaryDirectory.isValid());
+ QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString()));
QFile testFile(temporaryDirectory.path() + QLatin1Char('/') + testFileName);
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
testFile.write(QByteArray("hello"));
@@ -263,7 +263,7 @@ void tst_QFileSystemWatcher::watchDirectory()
QFETCH(QString, backend);
QTemporaryDir temporaryDirectory(m_tempDirPattern);
- QVERIFY(temporaryDirectory.isValid());
+ QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString()));
QDir temporaryDir(temporaryDirectory.path());
const QString testDirName = QStringLiteral("testDir");
@@ -498,7 +498,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
QFETCH(QString, backend);
QTemporaryDir temporaryDirectory(m_tempDirPattern);
- QVERIFY(temporaryDirectory.isValid());
+ QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString()));
QDir temporaryDir(temporaryDirectory.path());
const QString testDirName = QStringLiteral("testDir");
@@ -553,7 +553,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
timer.start(3000);
eventLoop.exec();
int fileChangedSpyCount = fileChangedSpy.count();
-#ifdef Q_OS_WIN64
+#ifdef Q_OS_WIN
if (fileChangedSpyCount != 0)
QEXPECT_FAIL("", "See QTBUG-30943", Continue);
#endif
@@ -605,7 +605,7 @@ void tst_QFileSystemWatcher::nonExistingFile()
void tst_QFileSystemWatcher::removeFileAndUnWatch()
{
QTemporaryDir temporaryDirectory(m_tempDirPattern);
- QVERIFY(temporaryDirectory.isValid());
+ QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString()));
const QString filename = temporaryDirectory.path() + QStringLiteral("/foo.txt");
@@ -664,7 +664,7 @@ void tst_QFileSystemWatcher::QTBUG2331()
QFETCH(QString, backend);
QTemporaryDir temporaryDirectory(m_tempDirPattern);
- QVERIFY(temporaryDirectory.isValid());
+ QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString()));
QFileSystemWatcher watcher;
watcher.setObjectName(QLatin1String("_qt_autotest_force_engine_") + backend);
QVERIFY(watcher.addPath(temporaryDirectory.path()));
@@ -724,7 +724,8 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved()
{
const int fileCount = 10;
QTemporaryDir temporaryDirectory(m_tempDirPattern);
- QVERIFY(temporaryDirectory.isValid());
+ QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString()));
+
QDir testDir(temporaryDirectory.path());
QVERIFY(testDir.mkdir("movehere"));
QString movePath = testDir.filePath("movehere");
diff --git a/tests/auto/corelib/io/qiodevice/BLACKLIST b/tests/auto/corelib/io/qiodevice/BLACKLIST
new file mode 100644
index 0000000000..b8a61d3ca9
--- /dev/null
+++ b/tests/auto/corelib/io/qiodevice/BLACKLIST
@@ -0,0 +1,2 @@
+[unget]
+redhatenterpriselinuxworkstation-6.6
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index 27614e0eb8..21c5696d1d 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -80,6 +80,7 @@ void tst_QLockFile::initTestCase()
#elif defined(QT_NO_PROCESS)
QSKIP("This test requires QProcess support");
#else
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
// chdir to our testdata path and execute helper apps relative to that.
QString testdata_dir = QFileInfo(QFINDTESTDATA("qlockfiletesthelper")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
diff --git a/tests/auto/corelib/io/qprocess/BLACKLIST b/tests/auto/corelib/io/qprocess/BLACKLIST
new file mode 100644
index 0000000000..216faa7fb4
--- /dev/null
+++ b/tests/auto/corelib/io/qprocess/BLACKLIST
@@ -0,0 +1,5 @@
+[lockupsInStartDetached]
+redhatenterpriselinuxworkstation-6.6
+# QTBUG-48455
+[fileWriterProcess]
+msvc-2015
diff --git a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
index 411c7e334b..25cb66f9d2 100644
--- a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
+++ b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
@@ -33,20 +33,26 @@
#include <QCoreApplication>
#include <QFile>
+#include <stdio.h>
+
int main(int argc, char **argv)
{
QCoreApplication ca(argc, argv);
QFile f;
f.open(stdin, QIODevice::ReadOnly);
- QString input;
+ QByteArray input;
char buf[1024];
qint64 len;
while ((len = f.read(buf, 1024)) > 0)
- input += QByteArray(buf, len);
+ input.append(buf, len);
f.close();
QFile f2("fileWriterProcess.txt");
- f2.open(QIODevice::WriteOnly | QIODevice::Truncate);
- f2.write(input.toLatin1());
+ if (!f2.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+ fprintf(stderr, "Cannot open %s for writing: %s\n",
+ qPrintable(f2.fileName()), qPrintable(f2.errorString()));
+ return 1;
+ }
+ f2.write(input);
f2.close();
return 0;
}
diff --git a/tests/auto/corelib/io/qprocess/testDetached/main.cpp b/tests/auto/corelib/io/qprocess/testDetached/main.cpp
index bbcc7033c7..760306ea17 100644
--- a/tests/auto/corelib/io/qprocess/testDetached/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testDetached/main.cpp
@@ -57,7 +57,8 @@ int main(int argc, char **argv)
QFile f(args.at(1));
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
- fprintf(stderr, "Cannot open %s for writing", qPrintable(f.fileName()));
+ fprintf(stderr, "Cannot open %s for writing: %s\n",
+ qPrintable(f.fileName()), qPrintable(f.errorString()));
return 1;
}
diff --git a/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp b/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp
index c92d7f515f..c3cf9f56c7 100644
--- a/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp
@@ -33,8 +33,8 @@
#include <stdlib.h>
-int main(int /* argc */, char **argv)
+int main(int argc, char **argv)
{
- return atoi(argv[1]);
+ return argc >= 2 ? atoi(argv[1]) : -1;
}
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 0995f764b7..45d6cf3dcd 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -62,6 +62,10 @@ if (ret == false) \
QVERIFY(ret); \
}
+typedef void (QProcess::*QProcessFinishedSignal1)(int);
+typedef void (QProcess::*QProcessFinishedSignal2)(int, QProcess::ExitStatus);
+typedef void (QProcess::*QProcessErrorSignal)(QProcess::ProcessError);
+
class tst_QProcess : public QObject
{
Q_OBJECT
@@ -69,6 +73,7 @@ class tst_QProcess : public QObject
public slots:
void initTestCase();
void cleanupTestCase();
+ void init();
#ifndef QT_NO_PROCESS
private slots:
@@ -124,9 +129,9 @@ private slots:
void removeFileWhileProcessIsRunning();
void fileWriterProcess();
void switchReadChannels();
-#ifdef Q_OS_WIN
+ void discardUnwantedOutput();
void setWorkingDirectory();
-#endif // Q_OS_WIN
+ void setNonExistentWorkingDirectory();
#endif // not Q_OS_WINCE
void exitStatus_data();
@@ -174,7 +179,6 @@ protected slots:
#endif
private:
- QProcess *process;
qint64 bytesAvailable;
#endif //QT_NO_PROCESS
};
@@ -197,6 +201,11 @@ void tst_QProcess::cleanupTestCase()
#endif
}
+void tst_QProcess::init()
+{
+ bytesAvailable = 0;
+}
+
#ifndef QT_NO_PROCESS
// Testing get/set functions
@@ -220,7 +229,6 @@ void tst_QProcess::getSetCheck()
QCOMPARE(QProcess::ProcessChannel(QProcess::StandardError), obj1.readChannel());
}
-//-----------------------------------------------------------------------------
void tst_QProcess::constructing()
{
QProcess process;
@@ -258,10 +266,10 @@ void tst_QProcess::simpleStart()
{
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
- process = new QProcess;
- QSignalSpy spy(process, &QProcess::stateChanged);
+ QScopedPointer<QProcess> process(new QProcess);
+ QSignalSpy spy(process.data(), &QProcess::stateChanged);
QVERIFY(spy.isValid());
- connect(process, SIGNAL(readyRead()), this, SLOT(readFromProcess()));
+ connect(process.data(), &QIODevice::readyRead, this, &tst_QProcess::readFromProcess);
/* valgrind dislike SUID binaries(those that have the `s'-flag set), which
* makes it fail to start the process. For this reason utilities like `ping' won't
@@ -273,8 +281,7 @@ void tst_QProcess::simpleStart()
QCOMPARE(process->state(), QProcess::Running);
QTRY_COMPARE(process->state(), QProcess::NotRunning);
- delete process;
- process = 0;
+ process.reset();
QCOMPARE(spy.count(), 3);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(0).at(0)), QProcess::Starting);
@@ -282,7 +289,6 @@ void tst_QProcess::simpleStart()
QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning);
}
-//-----------------------------------------------------------------------------
void tst_QProcess::startWithOpen()
{
QProcess p;
@@ -300,7 +306,6 @@ void tst_QProcess::startWithOpen()
QVERIFY(p.waitForFinished(5000));
}
-//-----------------------------------------------------------------------------
void tst_QProcess::startWithOldOpen()
{
// similar to the above, but we start with start() actually
@@ -319,7 +324,6 @@ void tst_QProcess::startWithOldOpen()
QVERIFY(p.waitForFinished(5000));
}
-//-----------------------------------------------------------------------------
void tst_QProcess::execute()
{
QCOMPARE(QProcess::execute("testProcessNormal/testProcessNormal",
@@ -327,34 +331,32 @@ void tst_QProcess::execute()
QCOMPARE(QProcess::execute("nonexistingexe"), -2);
}
-//-----------------------------------------------------------------------------
void tst_QProcess::startDetached()
{
- QProcess proc;
- QVERIFY(proc.startDetached("testProcessNormal/testProcessNormal",
- QStringList() << "arg1" << "arg2"));
+ QVERIFY(QProcess::startDetached("testProcessNormal/testProcessNormal",
+ QStringList() << "arg1" << "arg2"));
#ifdef QPROCESS_USE_SPAWN
QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue);
#endif
QCOMPARE(QProcess::startDetached("nonexistingexe"), false);
}
-//-----------------------------------------------------------------------------
void tst_QProcess::readFromProcess()
{
+ QProcess *process = qobject_cast<QProcess *>(sender());
+ QVERIFY(process);
int lines = 0;
while (process->canReadLine()) {
++lines;
- QByteArray line = process->readLine();
+ process->readLine();
}
}
-//-----------------------------------------------------------------------------
void tst_QProcess::crashTest()
{
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
- process = new QProcess;
- QSignalSpy stateSpy(process, &QProcess::stateChanged);
+ QScopedPointer<QProcess> process(new QProcess);
+ QSignalSpy stateSpy(process.data(), &QProcess::stateChanged);
QVERIFY(stateSpy.isValid());
process->start("testProcessCrash/testProcessCrash");
QVERIFY(process->waitForStarted(5000));
@@ -362,11 +364,13 @@ void tst_QProcess::crashTest()
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
- QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
- QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
+ QSignalSpy spy(process.data(), &QProcess::errorOccurred);
+ QSignalSpy spy2(process.data(), static_cast<QProcessErrorSignal>(&QProcess::error));
+ QSignalSpy spy3(process.data(), static_cast<QProcessFinishedSignal2>(&QProcess::finished));
QVERIFY(spy.isValid());
QVERIFY(spy2.isValid());
+ QVERIFY(spy3.isValid());
QVERIFY(process->waitForFinished(30000));
@@ -374,12 +378,15 @@ void tst_QProcess::crashTest()
QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed);
QCOMPARE(spy2.count(), 1);
- QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit);
+ QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed);
+
+ QCOMPARE(spy3.count(), 1);
+ QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy3.at(0).at(1).constData()), QProcess::CrashExit);
QCOMPARE(process->exitStatus(), QProcess::CrashExit);
- delete process;
- process = 0;
+ // delete process;
+ process.reset();
QCOMPARE(stateSpy.count(), 3);
QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(0).at(0)), QProcess::Starting);
@@ -387,23 +394,23 @@ void tst_QProcess::crashTest()
QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning);
}
-//-----------------------------------------------------------------------------
void tst_QProcess::crashTest2()
{
- process = new QProcess;
- process->start("testProcessCrash/testProcessCrash");
- QVERIFY(process->waitForStarted(5000));
+ QProcess process;
+ process.start("testProcessCrash/testProcessCrash");
+ QVERIFY(process.waitForStarted(5000));
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
- QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
- QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
+ QSignalSpy spy(&process, static_cast<QProcessErrorSignal>(&QProcess::errorOccurred));
+ QSignalSpy spy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished));
QVERIFY(spy.isValid());
QVERIFY(spy2.isValid());
- QObject::connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot()));
+ QObject::connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished),
+ this, &tst_QProcess::exitLoopSlot);
QTestEventLoop::instance().enterLoop(30);
if (QTestEventLoop::instance().timeout())
@@ -415,15 +422,11 @@ void tst_QProcess::crashTest2()
QCOMPARE(spy2.count(), 1);
QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit);
- QCOMPARE(process->exitStatus(), QProcess::CrashExit);
-
- delete process;
- process = 0;
+ QCOMPARE(process.exitStatus(), QProcess::CrashExit);
}
#ifndef Q_OS_WINCE
//Reading and writing to a process is not supported on Qt/CE
-//-----------------------------------------------------------------------------
void tst_QProcess::echoTest_data()
{
QTest::addColumn<QByteArray>("input");
@@ -438,30 +441,28 @@ void tst_QProcess::echoTest_data()
QTest::newRow("10000 bytes") << QByteArray(10000, '@');
}
-//-----------------------------------------------------------------------------
-
void tst_QProcess::echoTest()
{
QFETCH(QByteArray, input);
- process = new QProcess;
- connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
+ QProcess process;
+ connect(&process, &QIODevice::readyRead, this, &tst_QProcess::exitLoopSlot);
- process->start("testProcessEcho/testProcessEcho");
- QVERIFY(process->waitForStarted(5000));
+ process.start("testProcessEcho/testProcessEcho");
+ QVERIFY(process.waitForStarted(5000));
- process->write(input);
+ process.write(input);
QTime stopWatch;
stopWatch.start();
do {
- QVERIFY(process->isOpen());
+ QVERIFY(process.isOpen());
QTestEventLoop::instance().enterLoop(2);
- } while (stopWatch.elapsed() < 60000 && process->bytesAvailable() < input.size());
+ } while (stopWatch.elapsed() < 60000 && process.bytesAvailable() < input.size());
if (stopWatch.elapsed() >= 60000)
QFAIL("Timed out");
- QByteArray message = process->readAll();
+ QByteArray message = process.readAll();
QCOMPARE(message.size(), input.size());
char *c1 = message.data();
@@ -474,40 +475,35 @@ void tst_QProcess::echoTest()
}
QCOMPARE(*c1, *c2);
- process->write("", 1);
-
- QVERIFY(process->waitForFinished(5000));
-
+ process.write("", 1);
- delete process;
- process = 0;
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
void tst_QProcess::exitLoopSlot()
{
QTestEventLoop::instance().exitLoop();
}
-//-----------------------------------------------------------------------------
-
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::echoTest2()
{
- process = new QProcess;
- connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
+ QProcess process;
+ connect(&process, &QIODevice::readyRead, this, &tst_QProcess::exitLoopSlot);
- process->start("testProcessEcho2/testProcessEcho2");
- QVERIFY(process->waitForStarted(5000));
- QVERIFY(!process->waitForReadyRead(250));
- QCOMPARE(process->error(), QProcess::Timedout);
+ process.start("testProcessEcho2/testProcessEcho2");
+ QVERIFY(process.waitForStarted(5000));
+ QVERIFY(!process.waitForReadyRead(250));
+ QCOMPARE(process.error(), QProcess::Timedout);
- process->write("Hello");
- QSignalSpy spy1(process, &QProcess::readyReadStandardOutput);
- QSignalSpy spy2(process, &QProcess::readyReadStandardError);
+ process.write("Hello");
+ QSignalSpy spy1(&process, &QProcess::readyReadStandardOutput);
+ QSignalSpy spy2(&process, &QProcess::readyReadStandardError);
QVERIFY(spy1.isValid());
QVERIFY(spy2.isValid());
@@ -518,11 +514,11 @@ void tst_QProcess::echoTest2()
QTestEventLoop::instance().enterLoop(1);
if (stopWatch.elapsed() >= 30000)
QFAIL("Timed out");
- process->setReadChannel(QProcess::StandardOutput);
- qint64 baso = process->bytesAvailable();
+ process.setReadChannel(QProcess::StandardOutput);
+ qint64 baso = process.bytesAvailable();
- process->setReadChannel(QProcess::StandardError);
- qint64 base = process->bytesAvailable();
+ process.setReadChannel(QProcess::StandardError);
+ qint64 base = process.bytesAvailable();
if (baso == 5 && base == 5)
break;
}
@@ -530,20 +526,18 @@ void tst_QProcess::echoTest2()
QVERIFY(spy1.count() > 0);
QVERIFY(spy2.count() > 0);
- QCOMPARE(process->readAllStandardOutput(), QByteArray("Hello"));
- QCOMPARE(process->readAllStandardError(), QByteArray("Hello"));
-
- process->write("", 1);
- QVERIFY(process->waitForFinished(5000));
+ QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello"));
+ QCOMPARE(process.readAllStandardError(), QByteArray("Hello"));
- delete process;
- process = 0;
+ process.write("", 1);
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// Reading and writing to a process is not supported on Qt/CE
-//-----------------------------------------------------------------------------
void tst_QProcess::echoTestGui()
{
QProcess process;
@@ -555,6 +549,8 @@ void tst_QProcess::echoTestGui()
process.write("q");
QVERIFY(process.waitForFinished(50000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello"));
QCOMPARE(process.readAllStandardError(), QByteArray("Hello"));
@@ -572,7 +568,6 @@ void tst_QProcess::testSetNamedPipeHandleState()
}
#endif // !Q_OS_WINCE && Q_OS_WIN
-//-----------------------------------------------------------------------------
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// Batch files are not supported on Windows CE
void tst_QProcess::batFiles_data()
@@ -594,6 +589,8 @@ void tst_QProcess::batFiles()
proc.start(batFile, QStringList());
QVERIFY(proc.waitForFinished(5000));
+ QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(proc.exitCode(), 0);
QVERIFY(proc.bytesAvailable() > 0);
@@ -601,7 +598,6 @@ void tst_QProcess::batFiles()
}
#endif // !Q_OS_WINCE && Q_OS_WIN
-//-----------------------------------------------------------------------------
void tst_QProcess::exitStatus_data()
{
QTest::addColumn<QStringList>("processList");
@@ -628,79 +624,75 @@ void tst_QProcess::exitStatus_data()
void tst_QProcess::exitStatus()
{
- process = new QProcess;
+ QProcess process;
QFETCH(QStringList, processList);
QFETCH(QList<QProcess::ExitStatus>, exitStatus);
QCOMPARE(exitStatus.count(), processList.count());
for (int i = 0; i < processList.count(); ++i) {
- process->start(processList.at(i));
- QVERIFY(process->waitForStarted(5000));
- QVERIFY(process->waitForFinished(30000));
+ process.start(processList.at(i));
+ QVERIFY(process.waitForStarted(5000));
+ QVERIFY(process.waitForFinished(30000));
- QCOMPARE(process->exitStatus(), exitStatus.at(i));
+ QCOMPARE(process.exitStatus(), exitStatus.at(i));
}
-
- process->deleteLater();
- process = 0;
}
-//-----------------------------------------------------------------------------
+
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::loopBackTest()
{
- process = new QProcess;
- process->start("testProcessEcho/testProcessEcho");
- QVERIFY(process->waitForStarted(5000));
+ QProcess process;
+ process.start("testProcessEcho/testProcessEcho");
+ QVERIFY(process.waitForStarted(5000));
for (int i = 0; i < 100; ++i) {
- process->write("Hello");
+ process.write("Hello");
do {
- QVERIFY(process->waitForReadyRead(5000));
- } while (process->bytesAvailable() < 5);
- QCOMPARE(process->readAll(), QByteArray("Hello"));
+ QVERIFY(process.waitForReadyRead(5000));
+ } while (process.bytesAvailable() < 5);
+ QCOMPARE(process.readAll(), QByteArray("Hello"));
}
- process->write("", 1);
- QVERIFY(process->waitForFinished(5000));
-
- delete process;
- process = 0;
+ process.write("", 1);
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::readTimeoutAndThenCrash()
{
- process = new QProcess;
- process->start("testProcessEcho/testProcessEcho");
- if (process->state() != QProcess::Starting)
- QCOMPARE(process->state(), QProcess::Running);
+ QProcess process;
+ process.start("testProcessEcho/testProcessEcho");
+ if (process.state() != QProcess::Starting)
+ QCOMPARE(process.state(), QProcess::Running);
- QVERIFY(process->waitForStarted(5000));
- QCOMPARE(process->state(), QProcess::Running);
+ QVERIFY(process.waitForStarted(5000));
+ QCOMPARE(process.state(), QProcess::Running);
- QVERIFY(!process->waitForReadyRead(5000));
- QCOMPARE(process->error(), QProcess::Timedout);
+ QVERIFY(!process.waitForReadyRead(5000));
+ QCOMPARE(process.error(), QProcess::Timedout);
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
- QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy spy(&process, &QProcess::errorOccurred);
+ QSignalSpy spy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error));
QVERIFY(spy.isValid());
+ QVERIFY(spy2.isValid());
- process->kill();
+ process.kill();
- QVERIFY(process->waitForFinished(5000));
- QCOMPARE(process->state(), QProcess::NotRunning);
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.state(), QProcess::NotRunning);
QCOMPARE(spy.count(), 1);
QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed);
-
- delete process;
- process = 0;
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed);
}
#endif
@@ -747,10 +739,11 @@ void tst_QProcess::deadWhileReading()
QCOMPARE(output.count("\n"), 10*1024);
process.waitForFinished();
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::restartProcessDeadlock()
@@ -759,28 +752,31 @@ void tst_QProcess::restartProcessDeadlock()
// The purpose of this test is to detect whether restarting a
// process in the finished() connected slot causes a deadlock
// because of the way QProcessManager uses its locks.
- QProcess proc;
- process = &proc;
- connect(process, SIGNAL(finished(int)), this, SLOT(restartProcess()));
+ QProcess process;
+ connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished),
+ this, &tst_QProcess::restartProcess);
- process->start("testProcessEcho/testProcessEcho");
+ process.start("testProcessEcho/testProcessEcho");
- QCOMPARE(process->write("", 1), qlonglong(1));
- QVERIFY(process->waitForFinished(5000));
+ QCOMPARE(process.write("", 1), qlonglong(1));
+ QVERIFY(process.waitForFinished(5000));
- process->disconnect(SIGNAL(finished(int)));
+ QObject::disconnect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), Q_NULLPTR, Q_NULLPTR);
- QCOMPARE(process->write("", 1), qlonglong(1));
- QVERIFY(process->waitForFinished(5000));
+ QCOMPARE(process.write("", 1), qlonglong(1));
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
void tst_QProcess::restartProcess()
{
+ QProcess *process = qobject_cast<QProcess *>(sender());
+ QVERIFY(process);
process->start("testProcessEcho/testProcessEcho");
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::closeWriteChannel()
@@ -805,10 +801,11 @@ void tst_QProcess::closeWriteChannel()
if (more.state() == QProcess::Running)
more.write("q");
QVERIFY(more.waitForFinished(5000));
+ QCOMPARE(more.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(more.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE"
void tst_QProcess::closeReadChannel()
@@ -836,11 +833,12 @@ void tst_QProcess::closeReadChannel()
proc.write("", 1);
QVERIFY(proc.waitForFinished(5000));
+ QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(proc.exitCode(), 0);
}
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::openModes()
@@ -885,14 +883,13 @@ void tst_QProcess::openModes()
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
{
QProcess proc;
- connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
+ connect(&proc, &QIODevice::readyRead, this, &tst_QProcess::exitLoopSlot);
QSignalSpy spy(&proc, &QProcess::readyRead);
QVERIFY(spy.isValid());
@@ -912,16 +909,17 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
QVERIFY(QTestEventLoop::instance().timeout());
QVERIFY(!proc.waitForReadyRead(250));
- QObject::disconnect(&proc, SIGNAL(readyRead()), 0, 0);
+ QObject::disconnect(&proc, &QIODevice::readyRead, Q_NULLPTR, Q_NULLPTR);
proc.write("B");
QVERIFY(proc.waitForReadyRead(5000));
proc.write("", 1);
QVERIFY(proc.waitForFinished(5000));
+ QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(proc.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
void tst_QProcess::hardExit()
{
QProcess proc;
@@ -945,7 +943,6 @@ void tst_QProcess::hardExit()
QCOMPARE(int(proc.error()), int(QProcess::Crashed));
}
-//-----------------------------------------------------------------------------
void tst_QProcess::softExit()
{
QProcess proc;
@@ -976,30 +973,30 @@ public:
SoftExitProcess(int n) : waitedForFinished(false), n(n), killing(false)
{
- connect(this, SIGNAL(finished(int,QProcess::ExitStatus)),
- this, SLOT(finishedSlot(int,QProcess::ExitStatus)));
+ connect(this, static_cast<QProcessFinishedSignal2>(&QProcess::finished),
+ this, &SoftExitProcess::finishedSlot);
switch (n) {
case 0:
setReadChannelMode(QProcess::MergedChannels);
- connect(this, SIGNAL(readyRead()), this, SLOT(terminateSlot()));
+ connect(this, &QIODevice::readyRead, this, &SoftExitProcess::terminateSlot);
break;
case 1:
- connect(this, SIGNAL(readyReadStandardOutput()),
- this, SLOT(terminateSlot()));
+ connect(this, &QProcess::readyReadStandardOutput,
+ this, &SoftExitProcess::terminateSlot);
break;
case 2:
- connect(this, SIGNAL(readyReadStandardError()),
- this, SLOT(terminateSlot()));
+ connect(this, &QProcess::readyReadStandardError,
+ this, &SoftExitProcess::terminateSlot);
break;
case 3:
- connect(this, SIGNAL(started()),
- this, SLOT(terminateSlot()));
+ connect(this, &QProcess::started,
+ this, &SoftExitProcess::terminateSlot);
break;
case 4:
default:
- connect(this, SIGNAL(stateChanged(QProcess::ProcessState)),
- this, SLOT(terminateSlot()));
+ connect(this, &QProcess::stateChanged,
+ this, &SoftExitProcess::terminateSlot);
break;
}
}
@@ -1055,7 +1052,6 @@ private:
QByteArray dataToWrite;
};
-//-----------------------------------------------------------------------------
void tst_QProcess::softExitInSlots_data()
{
QTest::addColumn<QString>("appName");
@@ -1065,7 +1061,6 @@ void tst_QProcess::softExitInSlots_data()
#endif
QTest::newRow("console app") << "testProcessEcho2/testProcessEcho2";
}
-//-----------------------------------------------------------------------------
void tst_QProcess::softExitInSlots()
{
@@ -1081,7 +1076,6 @@ void tst_QProcess::softExitInSlots()
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::mergedChannels()
@@ -1103,10 +1097,11 @@ void tst_QProcess::mergedChannels()
process.closeWriteChannel();
QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
@@ -1142,6 +1137,8 @@ void tst_QProcess::forwardedChannels()
QCOMPARE(process.write("input"), 5);
process.closeWriteChannel();
QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
const char *err;
switch (process.exitCode()) {
case 0: err = "ok"; break;
@@ -1161,7 +1158,6 @@ void tst_QProcess::forwardedChannels()
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::atEnd()
@@ -1182,6 +1178,8 @@ void tst_QProcess::atEnd()
process.write("", 1);
QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
@@ -1200,8 +1198,8 @@ protected:
exitCode = 90210;
QProcess process;
- connect(&process, SIGNAL(finished(int)), this, SLOT(catchExitCode(int)),
- Qt::DirectConnection);
+ connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished),
+ this, &TestThread::catchExitCode, Qt::DirectConnection);
process.start("testProcessEcho/testProcessEcho");
@@ -1222,7 +1220,6 @@ private:
int exitCode;
};
-//-----------------------------------------------------------------------------
void tst_QProcess::processInAThread()
{
for (int i = 0; i < 10; ++i) {
@@ -1233,7 +1230,6 @@ void tst_QProcess::processInAThread()
}
}
-//-----------------------------------------------------------------------------
void tst_QProcess::processesInMultipleThreads()
{
for (int i = 0; i < 10; ++i) {
@@ -1258,61 +1254,58 @@ void tst_QProcess::processesInMultipleThreads()
}
}
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForFinishedWithTimeout()
{
- process = new QProcess(this);
-
- process->start("testProcessEcho/testProcessEcho");
+ QProcess process;
- QVERIFY(process->waitForStarted(5000));
- QVERIFY(!process->waitForFinished(1));
+ process.start("testProcessEcho/testProcessEcho");
- process->write("", 1);
+ QVERIFY(process.waitForStarted(5000));
+ QVERIFY(!process.waitForFinished(1));
- QVERIFY(process->waitForFinished());
+ process.write("", 1);
- delete process;
- process = 0;
+ QVERIFY(process.waitForFinished());
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForReadyReadInAReadyReadSlot()
{
- process = new QProcess(this);
- connect(process, SIGNAL(readyRead()), this, SLOT(waitForReadyReadInAReadyReadSlotSlot()));
- connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot()));
+ QProcess process;
+ connect(&process, &QIODevice::readyRead, this, &tst_QProcess::waitForReadyReadInAReadyReadSlotSlot);
+ connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished),
+ this, &tst_QProcess::exitLoopSlot);
bytesAvailable = 0;
- process->start("testProcessEcho/testProcessEcho");
- QVERIFY(process->waitForStarted(5000));
+ process.start("testProcessEcho/testProcessEcho");
+ QVERIFY(process.waitForStarted(5000));
- QSignalSpy spy(process, &QProcess::readyRead);
+ QSignalSpy spy(&process, &QProcess::readyRead);
QVERIFY(spy.isValid());
- process->write("foo");
+ process.write("foo");
QTestEventLoop::instance().enterLoop(30);
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(spy.count(), 1);
- process->disconnect();
- QVERIFY(process->waitForFinished(5000));
- QVERIFY(process->bytesAvailable() > bytesAvailable);
- delete process;
- process = 0;
+ process.disconnect();
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+ QVERIFY(process.bytesAvailable() > bytesAvailable);
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
{
+ QProcess *process = qobject_cast<QProcess *>(sender());
+ QVERIFY(process);
bytesAvailable = process->bytesAvailable();
process->write("bar", 4);
QVERIFY(process->waitForReadyRead(5000));
@@ -1320,44 +1313,44 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
{
- process = new QProcess(this);
- connect(process, SIGNAL(bytesWritten(qint64)), this, SLOT(waitForBytesWrittenInABytesWrittenSlotSlot()));
+ QProcess process;
+ connect(&process, &QIODevice::bytesWritten, this, &tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot);
bytesAvailable = 0;
- process->start("testProcessEcho/testProcessEcho");
- QVERIFY(process->waitForStarted(5000));
+ process.start("testProcessEcho/testProcessEcho");
+ QVERIFY(process.waitForStarted(5000));
- QSignalSpy spy(process, &QProcess::bytesWritten);
+ QSignalSpy spy(&process, &QProcess::bytesWritten);
QVERIFY(spy.isValid());
- process->write("f");
+ process.write("f");
QTestEventLoop::instance().enterLoop(30);
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(spy.count(), 1);
- process->write("", 1);
- process->disconnect();
- QVERIFY(process->waitForFinished());
- delete process;
- process = 0;
+ process.write("", 1);
+ process.disconnect();
+ QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot()
{
+ QProcess *process = qobject_cast<QProcess *>(sender());
+ QVERIFY(process);
process->write("b");
QVERIFY(process->waitForBytesWritten(5000));
QTestEventLoop::instance().exitLoop();
}
#endif
-//-----------------------------------------------------------------------------
+
void tst_QProcess::spaceArgsTest_data()
{
QTest::addColumn<QStringList>("args");
@@ -1410,7 +1403,6 @@ static QByteArray startFailMessage(const QString &program, const QProcess &proce
return result;
}
-//-----------------------------------------------------------------------------
void tst_QProcess::spaceArgsTest()
{
QFETCH(QStringList, args);
@@ -1421,11 +1413,11 @@ void tst_QProcess::spaceArgsTest()
<< QString::fromLatin1("testProcessSpacesArgs/one space")
<< QString::fromLatin1("testProcessSpacesArgs/two space s");
- process = new QProcess(this);
+ QProcess process;
for (int i = 0; i < programs.size(); ++i) {
QString program = programs.at(i);
- process->start(program, args);
+ process.start(program, args);
#if defined(Q_OS_WINCE)
const int timeOutMS = 10000;
@@ -1433,14 +1425,16 @@ void tst_QProcess::spaceArgsTest()
const int timeOutMS = 5000;
#endif
QByteArray errorMessage;
- bool started = process->waitForStarted(timeOutMS);
+ bool started = process.waitForStarted(timeOutMS);
if (!started)
- errorMessage = startFailMessage(program, *process);
+ errorMessage = startFailMessage(program, process);
QVERIFY2(started, errorMessage.constData());
- QVERIFY(process->waitForFinished(timeOutMS));
+ QVERIFY(process.waitForFinished(timeOutMS));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
#if !defined(Q_OS_WINCE)
- QStringList actual = QString::fromLatin1(process->readAll()).split("|");
+ QStringList actual = QString::fromLatin1(process.readAll()).split("|");
#endif
#if !defined(Q_OS_WINCE)
QVERIFY(!actual.isEmpty());
@@ -1457,16 +1451,16 @@ void tst_QProcess::spaceArgsTest()
program += QString::fromLatin1(" ") + stringArgs;
errorMessage.clear();
- process->start(program);
- started = process->waitForStarted(5000);
+ process.start(program);
+ started = process.waitForStarted(5000);
if (!started)
- errorMessage = startFailMessage(program, *process);
+ errorMessage = startFailMessage(program, process);
QVERIFY2(started, errorMessage.constData());
- QVERIFY(process->waitForFinished(5000));
+ QVERIFY(process.waitForFinished(5000));
#if !defined(Q_OS_WINCE)
- actual = QString::fromLatin1(process->readAll()).split("|");
+ actual = QString::fromLatin1(process.readAll()).split("|");
#endif
#if !defined(Q_OS_WINCE)
QVERIFY(!actual.isEmpty());
@@ -1476,14 +1470,10 @@ void tst_QProcess::spaceArgsTest()
QCOMPARE(actual, args);
#endif
}
-
- delete process;
- process = 0;
}
#if defined(Q_OS_WIN)
-//-----------------------------------------------------------------------------
void tst_QProcess::nativeArguments()
{
QProcess proc;
@@ -1501,6 +1491,8 @@ void tst_QProcess::nativeArguments()
QVERIFY(proc.waitForStarted(10000));
QVERIFY(proc.waitForFinished(10000));
#endif
+ QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(proc.exitCode(), 0);
#if defined(Q_OS_WINCE)
// WinCE test outputs to a file, so check that
@@ -1527,7 +1519,6 @@ void tst_QProcess::nativeArguments()
#endif
-//-----------------------------------------------------------------------------
void tst_QProcess::exitCodeTest()
{
for (int i = 0; i < 255; ++i) {
@@ -1544,7 +1535,6 @@ void tst_QProcess::exitCodeTest()
}
}
-//-----------------------------------------------------------------------------
void tst_QProcess::failToStart()
{
#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX)
@@ -1556,12 +1546,14 @@ void tst_QProcess::failToStart()
QProcess process;
QSignalSpy stateSpy(&process, &QProcess::stateChanged);
- QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
- QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
- QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
+ QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
+ QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error));
+ QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished));
QVERIFY(stateSpy.isValid());
QVERIFY(errorSpy.isValid());
+ QVERIFY(errorSpy2.isValid());
QVERIFY(finishedSpy.isValid());
QVERIFY(finishedSpy2.isValid());
@@ -1578,6 +1570,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(errorSpy2.count(), j * attempts + i);
process.start("/blurp");
switch (j) {
@@ -1602,6 +1595,7 @@ void tst_QProcess::failToStart()
QCOMPARE(process.error(), QProcess::FailedToStart);
QCOMPARE(errorSpy.count(), j * attempts + i + 1);
+ QCOMPARE(errorSpy2.count(), j * attempts + i + 1);
QCOMPARE(finishedSpy.count(), 0);
QCOMPARE(finishedSpy2.count(), 0);
@@ -1614,7 +1608,6 @@ void tst_QProcess::failToStart()
}
}
-//-----------------------------------------------------------------------------
void tst_QProcess::failToStartWithWait()
{
#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX)
@@ -1625,11 +1618,13 @@ void tst_QProcess::failToStartWithWait()
QProcess process;
QEventLoop loop;
- QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
- QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
- QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
+ QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
+ QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error));
+ QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished));
QVERIFY(errorSpy.isValid());
+ QVERIFY(errorSpy2.isValid());
QVERIFY(finishedSpy.isValid());
QVERIFY(finishedSpy2.isValid());
@@ -1639,12 +1634,12 @@ void tst_QProcess::failToStartWithWait()
QCOMPARE(process.error(), QProcess::FailedToStart);
QCOMPARE(errorSpy.count(), i + 1);
+ QCOMPARE(errorSpy2.count(), i + 1);
QCOMPARE(finishedSpy.count(), 0);
QCOMPARE(finishedSpy2.count(), 0);
}
}
-//-----------------------------------------------------------------------------
void tst_QProcess::failToStartWithEventLoop()
{
#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX)
@@ -1655,16 +1650,18 @@ void tst_QProcess::failToStartWithEventLoop()
QProcess process;
QEventLoop loop;
- QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
- QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
- QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
+ QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
+ QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error));
+ QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished));
QVERIFY(errorSpy.isValid());
+ QVERIFY(errorSpy2.isValid());
QVERIFY(finishedSpy.isValid());
QVERIFY(finishedSpy2.isValid());
// The error signal may be emitted before start() returns
- connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()), Qt::QueuedConnection);
+ connect(&process, &QProcess::errorOccurred, &loop, &QEventLoop::quit, Qt::QueuedConnection);
for (int i = 0; i < 50; ++i) {
@@ -1674,6 +1671,7 @@ void tst_QProcess::failToStartWithEventLoop()
QCOMPARE(process.error(), QProcess::FailedToStart);
QCOMPARE(errorSpy.count(), i + 1);
+ QCOMPARE(errorSpy2.count(), i + 1);
QCOMPARE(finishedSpy.count(), 0);
QCOMPARE(finishedSpy2.count(), 0);
}
@@ -1693,7 +1691,7 @@ void tst_QProcess::failToStartEmptyArgs()
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
QProcess process;
- QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy errorSpy(&process, static_cast<QProcessErrorSignal>(&QProcess::error));
QVERIFY(errorSpy.isValid());
switch (startOverload) {
@@ -1715,7 +1713,6 @@ void tst_QProcess::failToStartEmptyArgs()
QCOMPARE(process.error(), QProcess::FailedToStart);
}
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::removeFileWhileProcessIsRunning()
@@ -1732,9 +1729,10 @@ void tst_QProcess::removeFileWhileProcessIsRunning()
process.write("", 1);
QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// OS doesn't support environment variables
void tst_QProcess::setEnvironment_data()
@@ -1812,7 +1810,6 @@ void tst_QProcess::setEnvironment()
}
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// OS doesn't support environment variables
void tst_QProcess::setProcessEnvironment_data()
@@ -1853,7 +1850,7 @@ void tst_QProcess::setProcessEnvironment()
}
}
#endif
-//-----------------------------------------------------------------------------
+
void tst_QProcess::systemEnvironment()
{
#if defined (Q_OS_WINCE)
@@ -1869,7 +1866,6 @@ void tst_QProcess::systemEnvironment()
#endif
}
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::spaceInName()
@@ -1879,10 +1875,11 @@ void tst_QProcess::spaceInName()
QVERIFY(process.waitForStarted());
process.write("", 1);
QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
#endif
-//-----------------------------------------------------------------------------
void tst_QProcess::lockupsInStartDetached()
{
// Check that QProcess doesn't cause a lock up at this program's
@@ -1896,7 +1893,6 @@ void tst_QProcess::lockupsInStartDetached()
QProcess::startDetached("yjhbrty");
}
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::atEnd2()
@@ -1915,7 +1911,6 @@ void tst_QProcess::atEnd2()
}
#endif
-//-----------------------------------------------------------------------------
void tst_QProcess::waitForReadyReadForNonexistantProcess()
{
// Start a program that doesn't exist, process events and then try to waitForReadyRead
@@ -1923,11 +1918,13 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
QProcess process;
- QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
- QSignalSpy finishedSpy1(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
- QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
+ QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
+ QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error));
+ QSignalSpy finishedSpy1(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished));
QVERIFY(errorSpy.isValid());
+ QVERIFY(errorSpy2.isValid());
QVERIFY(finishedSpy1.isValid());
QVERIFY(finishedSpy2.isValid());
@@ -1939,11 +1936,12 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
#endif
QCOMPARE(errorSpy.count(), 1);
QCOMPARE(errorSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(errorSpy2.count(), 1);
+ QCOMPARE(errorSpy2.at(0).at(0).toInt(), 0);
QCOMPARE(finishedSpy1.count(), 0);
QCOMPARE(finishedSpy2.count(), 0);
}
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardInputFile()
@@ -1960,6 +1958,8 @@ void tst_QProcess::setStandardInputFile()
process.start("testProcessEcho/testProcessEcho");
QPROCESS_VERIFY(process, waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
QByteArray all = process.readAll();
QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0
QVERIFY(all == data);
@@ -1973,7 +1973,6 @@ void tst_QProcess::setStandardInputFile()
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardOutputFile_data()
@@ -2004,7 +2003,6 @@ void tst_QProcess::setStandardOutputFile_data()
<< true;
}
-//-----------------------------------------------------------------------------
void tst_QProcess::setStandardOutputFile()
{
static const char data[] = "Original data. ";
@@ -2034,6 +2032,8 @@ void tst_QProcess::setStandardOutputFile()
process.start("testProcessEcho2/testProcessEcho2");
process.write(testdata, sizeof testdata);
QPROCESS_VERIFY(process,waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
// open the file again and verify the data
QVERIFY(file.open(QIODevice::ReadOnly));
@@ -2063,6 +2063,8 @@ void tst_QProcess::setStandardOutputFileNullDevice()
process.start("testProcessEcho2/testProcessEcho2");
process.write(testdata, sizeof testdata);
QPROCESS_VERIFY(process,waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
QVERIFY(!QFileInfo(QProcess::nullDevice()).isFile());
@@ -2079,6 +2081,8 @@ void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten()
process.write(testdata, sizeof testdata);
process.waitForBytesWritten();
QPROCESS_VERIFY(process, waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
// open the file again and verify the data
QVERIFY(file.open(QIODevice::ReadOnly));
@@ -2089,7 +2093,6 @@ void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten()
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardOutputProcess_data()
@@ -2120,7 +2123,11 @@ void tst_QProcess::setStandardOutputProcess()
source.waitForBytesWritten();
source.closeWriteChannel();
QPROCESS_VERIFY(source, waitForFinished());
+ QCOMPARE(source.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(source.exitCode(), 0);
QPROCESS_VERIFY(sink, waitForFinished());
+ QCOMPARE(sink.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(sink.exitCode(), 0);
QByteArray all = sink.readAll();
if (!merged)
@@ -2130,35 +2137,42 @@ void tst_QProcess::setStandardOutputProcess()
}
#endif
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::fileWriterProcess()
{
- QString stdinStr;
- for (int i = 0; i < 5000; ++i)
- stdinStr += QString::fromLatin1("%1 -- testing testing 1 2 3\n").arg(i);
+ const QByteArray line = QByteArrayLiteral(" -- testing testing 1 2 3\n");
+ QByteArray stdinStr;
+ stdinStr.reserve(5000 * (4 + line.size()) + 1);
+ for (int i = 0; i < 5000; ++i) {
+ stdinStr += QByteArray::number(i);
+ stdinStr += line;
+ }
QTime stopWatch;
stopWatch.start();
+ const QString fileName = QLatin1String("fileWriterProcess.txt");
+
do {
- QFile::remove("fileWriterProcess.txt");
+ if (QFile::exists(fileName))
+ QVERIFY(QFile::remove(fileName));
QProcess process;
process.start("fileWriterProcess/fileWriterProcess",
QIODevice::ReadWrite | QIODevice::Text);
- process.write(stdinStr.toLatin1());
+ process.write(stdinStr);
process.closeWriteChannel();
while (process.bytesToWrite()) {
QVERIFY(stopWatch.elapsed() < 3500);
QVERIFY(process.waitForBytesWritten(2000));
}
QVERIFY(process.waitForFinished());
- QCOMPARE(QFile("fileWriterProcess.txt").size(), qint64(stdinStr.size()));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+ QCOMPARE(QFile(fileName).size(), qint64(stdinStr.size()));
} while (stopWatch.elapsed() < 3000);
}
#endif
-//-----------------------------------------------------------------------------
void tst_QProcess::detachedWorkingDirectoryAndPid()
{
qint64 pid;
@@ -2202,7 +2216,6 @@ void tst_QProcess::detachedWorkingDirectoryAndPid()
QCOMPARE(actualPid, pid);
}
-//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::switchReadChannels()
@@ -2215,6 +2228,8 @@ void tst_QProcess::switchReadChannels()
process.write(data);
process.closeWriteChannel();
QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
for (int i = 0; i < 4; ++i) {
process.setReadChannel(QProcess::StandardOutput);
@@ -2233,26 +2248,63 @@ void tst_QProcess::switchReadChannels()
}
#endif
-//-----------------------------------------------------------------------------
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#ifndef Q_OS_WINCE
+// Reading and writing to a process is not supported on Qt/CE
+void tst_QProcess::discardUnwantedOutput()
+{
+ QProcess process;
+
+ process.setProgram("testProcessEcho2/testProcessEcho2");
+ process.start(QIODevice::WriteOnly);
+ process.write("Hello, World");
+ process.closeWriteChannel();
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+
+ process.setReadChannel(QProcess::StandardOutput);
+ QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
+ process.setReadChannel(QProcess::StandardError);
+ QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
+}
+#endif
+
+#ifndef Q_OS_WINCE
// Q_OS_WIN - setWorkingDirectory will chdir before starting the process on unices
// Windows CE does not support working directory logic
void tst_QProcess::setWorkingDirectory()
{
- process = new QProcess;
- process->setWorkingDirectory("test");
- process->start("testSetWorkingDirectory/testSetWorkingDirectory");
- QVERIFY(process->waitForFinished());
+ QProcess process;
+ process.setWorkingDirectory("test");
+
+ // use absolute path because on Windows, the executable is relative to the parent's CWD
+ // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either).
+ process.start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath());
+
+ QVERIFY2(process.waitForFinished(), process.errorString().toLocal8Bit());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
- QByteArray workingDir = process->readAllStandardOutput();
+ QByteArray workingDir = process.readAllStandardOutput();
QCOMPARE(QDir("test").canonicalPath(), QDir(workingDir.constData()).canonicalPath());
+}
- delete process;
- process = 0;
+void tst_QProcess::setNonExistentWorkingDirectory()
+{
+ QProcess process;
+ process.setWorkingDirectory("this/directory/should/not/exist/for/sure");
+
+ // use absolute path because on Windows, the executable is relative to the parent's CWD
+ // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either).
+ process.start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath());
+ QVERIFY(!process.waitForFinished());
+#ifdef QPROCESS_USE_SPAWN
+ QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue);
+#endif
+ QCOMPARE(int(process.error()), int(QProcess::FailedToStart));
}
#endif
-//-----------------------------------------------------------------------------
void tst_QProcess::startFinishStartFinish()
{
QProcess process;
@@ -2266,12 +2318,14 @@ void tst_QProcess::startFinishStartFinish()
QCOMPARE(QString::fromLatin1(process.readLine().trimmed()),
QString("0 -this is a number"));
#endif
- if (process.state() != QProcess::NotRunning)
+ if (process.state() != QProcess::NotRunning) {
QVERIFY(process.waitForFinished(10000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+ }
}
}
-//-----------------------------------------------------------------------------
void tst_QProcess::invalidProgramString_data()
{
QTest::addColumn<QString>("programString");
@@ -2286,24 +2340,26 @@ void tst_QProcess::invalidProgramString()
QProcess process;
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
- QSignalSpy spy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy spy(&process, &QProcess::errorOccurred);
+ QSignalSpy spy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error));
QVERIFY(spy.isValid());
+ QVERIFY(spy2.isValid());
process.start(programString);
QCOMPARE(process.error(), QProcess::FailedToStart);
QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy2.count(), 1);
QVERIFY(!QProcess::startDetached(programString));
}
-//-----------------------------------------------------------------------------
void tst_QProcess::onlyOneStartedSignal()
{
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
QProcess process;
QSignalSpy spyStarted(&process, &QProcess::started);
- QSignalSpy spyFinished(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
+ QSignalSpy spyFinished(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished));
QVERIFY(spyStarted.isValid());
QVERIFY(spyFinished.isValid());
@@ -2319,19 +2375,19 @@ void tst_QProcess::onlyOneStartedSignal()
process.start("testProcessNormal/testProcessNormal");
QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
QCOMPARE(spyStarted.count(), 1);
QCOMPARE(spyFinished.count(), 1);
}
-//-----------------------------------------------------------------------------
-
class BlockOnReadStdOut : public QObject
{
Q_OBJECT
public:
BlockOnReadStdOut(QProcess *process)
{
- connect(process, SIGNAL(readyReadStandardOutput()), SLOT(block()));
+ connect(process, &QProcess::readyReadStandardOutput, this, &BlockOnReadStdOut::block);
}
public slots:
@@ -2346,7 +2402,8 @@ void tst_QProcess::finishProcessBeforeReadingDone()
QProcess process;
BlockOnReadStdOut blocker(&process);
QEventLoop loop;
- connect(&process, SIGNAL(finished(int)), &loop, SLOT(quit()));
+ connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished),
+ &loop, &QEventLoop::quit);
process.start("testProcessOutput/testProcessOutput");
QVERIFY(process.waitForStarted());
loop.exec();
@@ -2354,6 +2411,8 @@ void tst_QProcess::finishProcessBeforeReadingDone()
QRegExp(QStringLiteral("[\r\n]")), QString::SkipEmptyParts);
QVERIFY(!lines.isEmpty());
QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number"));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
}
//-----------------------------------------------------------------------------
@@ -2370,14 +2429,17 @@ void tst_QProcess::startStopStartStop()
QProcess process;
process.start("testProcessNormal/testProcessNormal");
QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
process.start("testExitCodes/testExitCodes", QStringList() << "1");
QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 1);
process.start("testProcessNormal/testProcessNormal");
QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
@@ -2449,6 +2511,7 @@ void tst_QProcess::startStopStartStopBuffers()
process.write("line3\n");
process.closeWriteChannel();
QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
if (channelMode2 == QProcess::MergedChannels) {
diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
index be9a38c499..2099101a91 100644
--- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
+++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
@@ -66,11 +66,19 @@ void tst_QProcessEnvironment::operator_eq()
QVERIFY(e1 == e2);
e1.clear();
- QVERIFY(e1 != e2);
+ QVERIFY(e1 == e2);
e2.clear();
+ QVERIFY(e1 == e2);
+
+ e1.insert("FOO", "bar");
+ QVERIFY(e1 != e2);
+ e2.insert("FOO", "bar");
QVERIFY(e1 == e2);
+
+ e2.insert("FOO", "baz");
+ QVERIFY(e1 != e2);
}
void tst_QProcessEnvironment::clearAndIsEmpty()
@@ -196,6 +204,15 @@ void tst_QProcessEnvironment::insertEnv()
QCOMPARE(e.value("Hello"), QString("Another World"));
QCOMPARE(e.value("FOO2"), QString("bar2"));
QCOMPARE(e.value("A2"), QString("bc2"));
+
+ QProcessEnvironment e3;
+ e3.insert("FOO2", "bar2");
+ e3.insert("A2", "bc2");
+ e3.insert("Hello", "Another World");
+
+ e3.insert(e3); // mustn't deadlock
+
+ QVERIFY(e3 == e2);
}
void tst_QProcessEnvironment::caseSensitivity()
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
index 5796636b92..6e6dc2df95 100644
--- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
+++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
@@ -99,7 +99,7 @@ static inline QByteArray msgCannotOpen(const QFileDevice &f)
void tst_QSaveFile::transactionalWrite()
{
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QFile::remove(targetFile);
QSaveFile file(targetFile);
@@ -134,7 +134,7 @@ void tst_QSaveFile::saveTwice()
// Check that we can reuse a QSaveFile object
// (and test the case of an existing target file)
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
@@ -153,7 +153,7 @@ void tst_QSaveFile::saveTwice()
void tst_QSaveFile::textStreamManualFlush()
{
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
@@ -174,7 +174,7 @@ void tst_QSaveFile::textStreamManualFlush()
void tst_QSaveFile::textStreamAutoFlush()
{
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
@@ -206,7 +206,7 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir()
#endif
QFETCH(bool, directWriteFallback);
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
QVERIFY(QFile(dir.path()).setPermissions(QFile::ReadOwner | QFile::ExeOwner));
PermissionRestorer permissionRestorer(dir.path());
@@ -264,7 +264,7 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnFile()
#endif
// Setup an existing but readonly file
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QFile file(targetFile);
PermissionRestorer permissionRestorer(targetFile);
@@ -285,7 +285,7 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnFile()
void tst_QSaveFile::transactionalWriteCanceled()
{
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QFile::remove(targetFile);
QSaveFile file(targetFile);
@@ -313,7 +313,7 @@ void tst_QSaveFile::transactionalWriteErrorRenaming()
QSKIP("Test is not applicable with root privileges");
#endif
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
@@ -347,7 +347,7 @@ void tst_QSaveFile::symlink()
#ifdef Q_OS_UNIX
QByteArray someData = "some data";
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString targetFile = dir.path() + QLatin1String("/outfile");
const QString linkFile = dir.path() + QLatin1String("/linkfile");
@@ -400,7 +400,7 @@ void tst_QSaveFile::symlink()
// link to a link in another directory
QTemporaryDir dir2;
- QVERIFY(dir2.isValid());
+ QVERIFY2(dir2.isValid(), qPrintable(dir2.errorString()));
const QString linkFile2 = dir2.path() + QLatin1String("/linkfile");
QVERIFY(QFile::link(linkFile, linkFile2));
@@ -458,7 +458,7 @@ void tst_QSaveFile::symlink()
void tst_QSaveFile::directory()
{
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
const QString subdir = dir.path() + QLatin1String("/subdir");
QVERIFY(QDir(dir.path()).mkdir(QStringLiteral("subdir")));
diff --git a/tests/auto/corelib/io/qsettings/BLACKLIST b/tests/auto/corelib/io/qsettings/BLACKLIST
new file mode 100644
index 0000000000..1cba99b66c
--- /dev/null
+++ b/tests/auto/corelib/io/qsettings/BLACKLIST
@@ -0,0 +1,2 @@
+[isWritable:native]
+osx-10.10
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index e2e1d99657..935eb7df89 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -37,6 +37,7 @@
#include <QtCore/QSettings>
#include <private/qsettings_p.h>
#include <QtCore/QCoreApplication>
+#include <QtCore/QDateTime>
#include <QtCore/QtGlobal>
#include <QtCore/QMetaType>
#include <QtCore/QString>
@@ -1201,6 +1202,9 @@ void tst_QSettings::testVariantTypes()
QList<QVariant> l4;
l4 << QVariant(m2) << QVariant(l2) << QVariant(l3);
testVal("key13", l4, QVariantList, List);
+ QDateTime dt = QDateTime::currentDateTime();
+ dt.setOffsetFromUtc(3600);
+ testVal("key14", dt, QDateTime, DateTime);
// We store key sequences as strings instead of binary variant blob, for improved
// readability in the resulting format.
@@ -3327,7 +3331,7 @@ void tst_QSettings::dontReorderIniKeysNeedlessly()
QString outFileName2;
QTemporaryFile outFile;
- outFile.open();
+ QVERIFY2(outFile.open(), qPrintable(outFile.errorString()));
outFile.write(contentsBefore);
outFileName = outFile.fileName();
outFile.close();
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index efb343cf85..24ff2f237f 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -56,6 +56,7 @@ class tst_qstandardpaths : public QObject
Q_OBJECT
private slots:
+ void initTestCase();
void dump();
void testDefaultLocations();
void testCustomLocations();
@@ -128,6 +129,14 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths
"AppConfigLocation"
};
+void tst_qstandardpaths::initTestCase()
+{
+ QVERIFY2(m_localConfigTempDir.isValid(), qPrintable(m_localConfigTempDir.errorString()));
+ QVERIFY2(m_globalConfigTempDir.isValid(), qPrintable(m_globalConfigTempDir.errorString()));
+ QVERIFY2(m_localAppTempDir.isValid(), qPrintable(m_localAppTempDir.errorString()));
+ QVERIFY2(m_globalAppTempDir.isValid(), qPrintable(m_globalAppTempDir.errorString()));
+}
+
void tst_qstandardpaths::dump()
{
#ifdef Q_XDG_PLATFORM
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
index a7a0cf4ddb..efbcdc78e0 100644
--- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
+++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
@@ -153,7 +153,7 @@ void tst_QStorageInfo::storageList()
void tst_QStorageInfo::tempFile()
{
QTemporaryFile file;
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QStorageInfo storage1(file.fileName());
#ifdef Q_OS_LINUX
@@ -174,7 +174,7 @@ void tst_QStorageInfo::tempFile()
void tst_QStorageInfo::caching()
{
QTemporaryFile file;
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QStorageInfo storage1(file.fileName());
#ifdef Q_OS_LINUX
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 3e98a369ce..58a3db9615 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -93,6 +93,7 @@ void tst_QTemporaryDir::construction()
QCOMPARE(dir.path().left(tmp.size()), tmp);
QVERIFY(dir.path().contains("tst_qtemporarydir"));
QVERIFY(QFileInfo(dir.path()).isDir());
+ QCOMPARE(dir.errorString(), QString());
}
// Testing get/set functions
@@ -251,6 +252,7 @@ void tst_QTemporaryDir::nonWritableCurrentDir()
QTemporaryDir dir("tempXXXXXX");
dir.setAutoRemove(true);
QVERIFY(!dir.isValid());
+ QVERIFY(!dir.errorString().isEmpty());
QVERIFY(dir.path().isEmpty());
#endif
}
@@ -287,7 +289,11 @@ void tst_QTemporaryDir::stressTest()
for (int i = 0; i < iterations; ++i) {
QTemporaryDir dir(pattern);
dir.setAutoRemove(false);
- QVERIFY2(dir.isValid(), qPrintable(QString::fromLatin1("Failed to create #%1 under %2.").arg(i).arg(QDir::toNativeSeparators(pattern))));
+ QVERIFY2(dir.isValid(),
+ qPrintable(QString::fromLatin1("Failed to create #%1 under %2: %3.")
+ .arg(i)
+ .arg(QDir::toNativeSeparators(pattern))
+ .arg(dir.errorString())));
QVERIFY(!names.contains(dir.path()));
names.insert(dir.path());
}
diff --git a/tests/auto/corelib/io/qtextstream/BLACKLIST b/tests/auto/corelib/io/qtextstream/BLACKLIST
new file mode 100644
index 0000000000..bc3f118b33
--- /dev/null
+++ b/tests/auto/corelib/io/qtextstream/BLACKLIST
@@ -0,0 +1,2 @@
+[stillOpenWhenAtEnd]
+windows
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 36da3b8770..ecec97f009 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -258,6 +258,7 @@ tst_QTextStream::tst_QTextStream()
void tst_QTextStream::initTestCase()
{
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
QVERIFY(!m_rfc3261FilePath.isEmpty());
QVERIFY(!m_shiftJisFilePath.isEmpty());
diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
index db0136dd20..769a96ac64 100644
--- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
+++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
@@ -177,6 +177,7 @@ void tst_QUrlQuery::constructing()
QVERIFY(copy.isEmpty());
QVERIFY(!copy.isDetached());
QVERIFY(copy == empty);
+ QCOMPARE(qHash(copy), qHash(empty));
QVERIFY(!(copy != empty));
copy = empty;
@@ -184,6 +185,7 @@ void tst_QUrlQuery::constructing()
copy = QUrlQuery();
QVERIFY(copy == empty);
+ QCOMPARE(qHash(copy), qHash(empty));
}
{
QUrlQuery copy(emptyQuery());
@@ -298,6 +300,7 @@ void tst_QUrlQuery::addRemove()
QVERIFY(query == original);
QVERIFY(!(query != original));
+ QCOMPARE(qHash(query), qHash(original));
}
{
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 64170b15dd..c4d2df7c3e 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -379,7 +379,7 @@ void tst_QAbstractItemModel::hasChildren()
{
QtTestModel model(1, 1);
QModelIndex idx = model.index(0, 0, QModelIndex());
- QVERIFY(model.hasChildren(idx) == false);
+ QVERIFY(!model.hasChildren(idx));
}
void tst_QAbstractItemModel::data()
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 8d331389f5..38e2900c25 100644
--- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -94,6 +94,9 @@ private slots:
void testChainedSelectionClear();
void testClearCurrentIndex();
+ void QTBUG48402_data();
+ void QTBUG48402();
+
private:
QAbstractItemModel *model;
QItemSelectionModel *selection;
@@ -1530,7 +1533,7 @@ void tst_QItemSelectionModel::resetModel()
model.reset();
QVERIFY(selectionModel->selection().isEmpty());
- QVERIFY(selectionModel->hasSelection() == false);
+ QVERIFY(!selectionModel->hasSelection());
selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
@@ -2756,5 +2759,96 @@ void tst_QItemSelectionModel::testClearCurrentIndex()
QVERIFY(currentIndexSpy.size() == 2);
}
+void tst_QItemSelectionModel::QTBUG48402_data()
+{
+ QTest::addColumn<int>("rows");
+ QTest::addColumn<int>("columns");
+
+ QTest::addColumn<int>("selectTop");
+ QTest::addColumn<int>("selectLeft");
+ QTest::addColumn<int>("selectBottom");
+ QTest::addColumn<int>("selectRight");
+
+ QTest::addColumn<int>("removeTop");
+ QTest::addColumn<int>("removeBottom");
+
+ QTest::addColumn<int>("deselectTop");
+ QTest::addColumn<int>("deselectLeft");
+ QTest::addColumn<int>("deselectBottom");
+ QTest::addColumn<int>("deselectRight");
+
+ QTest::newRow("4x4 top intersection")
+ << 4 << 4
+ << 0 << 2 << 1 << 3
+ << 1 << 1
+ << 1 << 2 << 1 << 3;
+
+ QTest::newRow("4x4 bottom intersection")
+ << 4 << 4
+ << 0 << 2 << 1 << 3
+ << 0 << 0
+ << 0 << 2 << 0 << 3;
+
+ QTest::newRow("4x4 middle intersection")
+ << 4 << 4
+ << 0 << 2 << 2 << 3
+ << 1 << 1
+ << 1 << 2 << 1 << 3;
+
+ QTest::newRow("4x4 full inclusion")
+ << 4 << 4
+ << 0 << 2 << 1 << 3
+ << 0 << 1
+ << 0 << 2 << 1 << 3;
+}
+class QTBUG48402_helper : public QObject
+{
+ Q_OBJECT
+public:
+ QModelIndex tl;
+ QModelIndex br;
+public slots:
+ void changed(const QItemSelection &, const QItemSelection &deselected)
+ {
+ tl = deselected.first().topLeft();
+ br = deselected.first().bottomRight();
+ }
+};
+
+void tst_QItemSelectionModel::QTBUG48402()
+{
+ QFETCH(int, rows);
+ QFETCH(int, columns);
+ QFETCH(int, selectTop);
+ QFETCH(int, selectLeft);
+ QFETCH(int, selectBottom);
+ QFETCH(int, selectRight);
+ QFETCH(int, removeTop);
+ QFETCH(int, removeBottom);
+ QFETCH(int, deselectTop);
+ QFETCH(int, deselectLeft);
+ QFETCH(int, deselectBottom);
+ QFETCH(int, deselectRight);
+
+ MyStandardItemModel model(rows, columns);
+ QItemSelectionModel selections(&model);
+
+ QModelIndex stl = model.index(selectTop, selectLeft);
+ QModelIndex sbr = model.index(selectBottom, selectRight);
+ QModelIndex dtl = model.index(deselectTop, deselectLeft);
+ QModelIndex dbr = model.index(deselectBottom, deselectRight);
+
+ selections.select(QItemSelection(stl, sbr), QItemSelectionModel::ClearAndSelect);
+ QTBUG48402_helper helper;
+ helper.connect(&selections, &QItemSelectionModel::selectionChanged, &helper, &QTBUG48402_helper::changed);
+ QVERIFY(selections.isSelected(stl));
+ QVERIFY(selections.isSelected(sbr));
+ QVERIFY(selections.hasSelection());
+
+ model.removeRows(removeTop, removeBottom - removeTop + 1);
+
+ QCOMPARE(QItemSelectionRange(helper.tl, helper.br), QItemSelectionRange(dtl, dbr));
+}
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 1c30adc8de..0302ae5cbf 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -87,6 +87,7 @@ private slots:
void filter_qtbug30662();
void changeSourceLayout();
+ void changeSourceLayoutFilteredOut();
void removeSourceRows_data();
void removeSourceRows();
void insertSourceRows_data();
@@ -1533,6 +1534,32 @@ void tst_QSortFilterProxyModel::changeSourceLayout()
}
}
+void tst_QSortFilterProxyModel::changeSourceLayoutFilteredOut()
+{
+ QStandardItemModel model(2, 1);
+ model.setData(model.index(0, 0), QString("b"));
+ model.setData(model.index(1, 0), QString("a"));
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+
+ int beforeSortFilter = proxy.rowCount();
+
+ QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved);
+ // Filter everything out
+ proxy.setFilterRegExp(QRegExp("c"));
+ QCOMPARE(removeSpy.count(), 1);
+ QCOMPARE(0, proxy.rowCount());
+
+ // change layout of source model
+ model.sort(0, Qt::AscendingOrder);
+
+ QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted);
+ // Remove filter; we expect an insert
+ proxy.setFilterRegExp(QRegExp(""));
+ QCOMPARE(insertSpy.count(), 1);
+ QCOMPARE(beforeSortFilter, proxy.rowCount());
+}
+
void tst_QSortFilterProxyModel::removeSourceRows_data()
{
QTest::addColumn<QStringList>("sourceItems");
diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
index 0602b9fc38..1039f2c08d 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
+++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
@@ -3,3 +3,4 @@ TARGET = tst_qcoreapplication
QT = core testlib core-private
SOURCES = tst_qcoreapplication.cpp
HEADERS = tst_qcoreapplication.h
+requires(contains(QT_CONFIG,private_tests))
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index 60e358232e..655719cffc 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -73,6 +73,21 @@ public:
}
};
+class Thread : public QDaemonThread
+{
+ void run() Q_DECL_OVERRIDE
+ {
+ QThreadData *data = QThreadData::current();
+ QVERIFY(!data->requiresCoreApplication); // daemon thread
+ data->requiresCoreApplication = requiresCoreApplication;
+ QThread::run();
+ }
+
+public:
+ Thread() : requiresCoreApplication(true) {}
+ bool requiresCoreApplication;
+};
+
void tst_QCoreApplication::sendEventsOnProcessEvents()
{
int argc = 1;
@@ -848,6 +863,68 @@ void tst_QCoreApplication::applicationEventFilters_auxThread()
QVERIFY(!spy.recordedEvents.contains(QEvent::User + 1));
}
+void tst_QCoreApplication::threadedEventDelivery_data()
+{
+ QTest::addColumn<bool>("requiresCoreApplication");
+ QTest::addColumn<bool>("createCoreApplication");
+ QTest::addColumn<bool>("eventsReceived");
+
+ // invalid combination:
+ //QTest::newRow("default-without-coreapp") << true << false << false;
+ QTest::newRow("default") << true << true << true;
+ QTest::newRow("independent-without-coreapp") << false << false << true;
+ QTest::newRow("independent-with-coreapp") << false << true << true;
+}
+
+// posts the event before the QCoreApplication is destroyed, starts thread after
+void tst_QCoreApplication::threadedEventDelivery()
+{
+ QFETCH(bool, requiresCoreApplication);
+ QFETCH(bool, createCoreApplication);
+ QFETCH(bool, eventsReceived);
+
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
+ QScopedPointer<TestApplication> app(createCoreApplication ? new TestApplication(argc, argv) : 0);
+
+ Thread thread;
+ thread.requiresCoreApplication = requiresCoreApplication;
+ ThreadedEventReceiver receiver;
+ receiver.moveToThread(&thread);
+ QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User + 1)));
+
+ thread.start();
+ QVERIFY(thread.wait(1000));
+ QCOMPARE(receiver.recordedEvents.contains(QEvent::User + 1), eventsReceived);
+}
+
+void tst_QCoreApplication::addRemoveLibPaths()
+{
+ QStringList paths = QCoreApplication::libraryPaths();
+ if (paths.isEmpty())
+ QSKIP("Cannot add/remove library paths if there are none.");
+
+ QString currentDir = QDir().absolutePath();
+ QCoreApplication::addLibraryPath(currentDir);
+ QVERIFY(QCoreApplication::libraryPaths().contains(currentDir));
+
+ QCoreApplication::removeLibraryPath(paths[0]);
+ QVERIFY(!QCoreApplication::libraryPaths().contains(paths[0]));
+
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
+ TestApplication app(argc, argv);
+
+ // Check that modifications stay alive across the creation of an application.
+ QVERIFY(QCoreApplication::libraryPaths().contains(currentDir));
+ QVERIFY(!QCoreApplication::libraryPaths().contains(paths[0]));
+
+ QStringList replace;
+ replace << currentDir << paths[0];
+ QCoreApplication::setLibraryPaths(replace);
+ QVERIFY(QCoreApplication::libraryPaths() == replace);
+}
+
static void createQObjectOnDestruction()
{
// Make sure that we can create a QObject after the last QObject has been
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
index 09e15723ac..d9296b3846 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
@@ -61,6 +61,9 @@ private slots:
void QTBUG31606_QEventDestructorDeadLock();
void applicationEventFilters_mainThread();
void applicationEventFilters_auxThread();
+ void threadedEventDelivery_data();
+ void threadedEventDelivery();
+ void addRemoveLibPaths();
};
#endif // TST_QCOREAPPLICATION_H
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
new file mode 100644
index 0000000000..00be65751b
--- /dev/null
+++ b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
@@ -0,0 +1,4 @@
+[sendPostedEvents]
+windows
+[registerTimer]
+windows
diff --git a/tests/auto/corelib/kernel/qeventloop/BLACKLIST b/tests/auto/corelib/kernel/qeventloop/BLACKLIST
new file mode 100644
index 0000000000..6ea6314b0a
--- /dev/null
+++ b/tests/auto/corelib/kernel/qeventloop/BLACKLIST
@@ -0,0 +1,2 @@
+[testQuitLock]
+windows
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
index f555d2e58e..c8bb4cda6e 100644
--- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
@@ -207,22 +207,11 @@ void tst_QEventLoop::processEvents()
QCOMPARE(awakeSpy.count(), 1);
// allow any session manager to complete its handshake, so that
- // there are no pending events left.
+ // there are no pending events left. This tests that we are able
+ // to process all events from the queue, otherwise it will hang.
while (eventLoop.processEvents())
;
- // On mac we get application started events at this point,
- // so process events one more time just to be sure.
- eventLoop.processEvents();
-
- // no events to process, QEventLoop::processEvents() should return
- // false
- aboutToBlockSpy.clear();
- awakeSpy.clear();
- QVERIFY(!eventLoop.processEvents());
- QCOMPARE(aboutToBlockSpy.count(), 0);
- QCOMPARE(awakeSpy.count(), 1);
-
// make sure the test doesn't block forever
int timerId = startTimer(100);
diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
index a18c9eb370..22c78f8e48 100644
--- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
+++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -38,14 +38,29 @@
#include <qobject.h>
#include <qmetaobject.h>
+struct CustomType
+{
+ int padding;
+ QString str;
+ CustomType(const QString &str = QString()) : str(str) {}
+ operator QString() const { return str; }
+ friend bool operator!=(const CustomType &a, const CustomType &b)
+ { return a.str != b.str; }
+};
+
+Q_DECLARE_METATYPE(CustomType)
+
class tst_QMetaProperty : public QObject
{
Q_OBJECT
Q_PROPERTY(EnumType value WRITE setValue READ getValue)
Q_PROPERTY(EnumType value2 WRITE set_value READ get_value)
+ Q_PROPERTY(QString value7 MEMBER value7 RESET resetValue7)
Q_PROPERTY(int value8 READ value8)
Q_PROPERTY(int value9 READ value9 CONSTANT)
Q_PROPERTY(int value10 READ value10 FINAL)
+ Q_PROPERTY(QMap<int, int> map MEMBER map)
+ Q_PROPERTY(CustomType custom MEMBER custom)
private slots:
void hasStdCppSet();
@@ -53,6 +68,8 @@ private slots:
void isFinal();
void gadget();
void readAndWriteWithLazyRegistration();
+ void mapProperty();
+ void conversion();
public:
enum EnumType { EnumType1 };
@@ -62,9 +79,14 @@ public:
void set_value(EnumType) {}
EnumType get_value() const { return EnumType1; }
+ void resetValue7() { value7 = QStringLiteral("reset"); }
int value8() const { return 1; }
int value9() const { return 1; }
int value10() const { return 1; }
+
+ QString value7;
+ QMap<int, int> map;
+ CustomType custom;
};
void tst_QMetaProperty::hasStdCppSet()
@@ -182,6 +204,51 @@ void tst_QMetaProperty::readAndWriteWithLazyRegistration()
QCOMPARE(o.property("write").value<CustomWriteObjectChild*>(), &data);
}
+void tst_QMetaProperty::mapProperty()
+{
+ map.insert(5, 9);
+ QVariant v1 = QVariant::fromValue(map);
+ QVariant v = property("map");
+ QVERIFY(v.isValid());
+ QCOMPARE(map, (v.value<QMap<int,int> >()));
+}
+
+void tst_QMetaProperty::conversion()
+{
+ QMetaType::registerConverter<QString, CustomType>();
+ QMetaType::registerConverter<CustomType, QString>();
+
+ QString hello = QStringLiteral("Hello");
+
+ // Write to a QString property using a CustomType in a QVariant
+ QMetaProperty value7P = metaObject()->property(metaObject()->indexOfProperty("value7"));
+ QVERIFY(value7P.isValid());
+ QVERIFY(value7P.write(this, QVariant::fromValue(CustomType(hello))));
+ QCOMPARE(value7, hello);
+
+ // Write to a CustomType property using a QString in a QVariant
+ QMetaProperty customP = metaObject()->property(metaObject()->indexOfProperty("custom"));
+ QVERIFY(customP.isValid());
+ QVERIFY(customP.write(this, hello));
+ QCOMPARE(custom.str, hello);
+
+ // Something that cannot be converted should fail
+ QVERIFY(!customP.write(this, 45));
+ QVERIFY(!customP.write(this, QVariant::fromValue(this)));
+ QVERIFY(!value7P.write(this, QVariant::fromValue(this)));
+ QVERIFY(!value7P.write(this, QVariant::fromValue<QObject*>(this)));
+
+ // none of this should have changed the values
+ QCOMPARE(value7, hello);
+ QCOMPARE(custom.str, hello);
+
+ // Empty variant should be converted to default object
+ QVERIFY(customP.write(this, QVariant()));
+ QCOMPARE(custom.str, QString());
+ // or reset resetable
+ QVERIFY(value7P.write(this, QVariant()));
+ QCOMPARE(value7, QLatin1Literal("reset"));
+}
QTEST_MAIN(tst_QMetaProperty)
#include "tst_qmetaproperty.moc"
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 9cdb1f47f8..10ffa06245 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -972,7 +972,7 @@ QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW)
QTest::newRow("QPair<P,C>") << ::qMetaTypeId<QPair<P,C> >() << false << true << false << false;
QTest::newRow("QPair<P,M>") << ::qMetaTypeId<QPair<P,M> >() << true << true << false << false;
QTest::newRow("QPair<P,P>") << ::qMetaTypeId<QPair<P,P> >() << true << false << false << false;
- QTest::newRow("FlagsDataEnum") << ::qMetaTypeId<FlagsDataEnum>() << false << true << false << true;
+ QTest::newRow("FlagsDataEnum") << ::qMetaTypeId<FlagsDataEnum>() << true << true << false << true;
// invalid ids.
QTest::newRow("-1") << -1 << false << false << false << false;
@@ -1052,9 +1052,9 @@ void tst_QMetaType::flagsBinaryCompatibility5_0()
QFETCH(quint32, id);
QFETCH(quint32, flags);
- quint32 mask_5_0 = 0x1ff; // Only compare the values that were already defined in 5.0
+ quint32 mask_5_0 = 0x1fb; // Only compare the values that were already defined in 5.0
- QCOMPARE(quint32(QMetaType::typeFlags(id)) & mask_5_0, flags);
+ QCOMPARE(quint32(QMetaType::typeFlags(id)) & mask_5_0, flags & mask_5_0);
}
void tst_QMetaType::construct_data()
diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
index 01bf16c295..d368d9961b 100644
--- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
+++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
@@ -70,7 +70,7 @@ void tst_QMimeData::clear() const
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasText());
mimeData.clear();
- QVERIFY(mimeData.hasText() == false);
+ QVERIFY(!mimeData.hasText());
// repopulate, verify not empty
mimeData.setData("text/plain", "pirates");
@@ -136,7 +136,7 @@ void tst_QMimeData::hasColor() const
QMimeData mimeData;
// initial state
- QVERIFY(mimeData.hasColor() == false);
+ QVERIFY(!mimeData.hasColor());
// set, verify
mimeData.setColorData(QColor(Qt::red));
@@ -144,11 +144,11 @@ void tst_QMimeData::hasColor() const
// clear, verify
mimeData.clear();
- QVERIFY(mimeData.hasColor() == false);
+ QVERIFY(!mimeData.hasColor());
// set something else, verify
mimeData.setData("text/plain", "pirates");
- QVERIFY(mimeData.hasColor() == false);
+ QVERIFY(!mimeData.hasColor());
}
void tst_QMimeData::hasFormat() const
@@ -156,17 +156,17 @@ void tst_QMimeData::hasFormat() const
QMimeData mimeData;
// initial state
- QVERIFY(mimeData.hasFormat("text/plain") == false);
+ QVERIFY(!mimeData.hasFormat("text/plain"));
// add, verify
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasFormat("text/plain"));
- QVERIFY(mimeData.hasFormat("text/html") == false);
+ QVERIFY(!mimeData.hasFormat("text/html"));
// clear, verify
mimeData.clear();
- QVERIFY(mimeData.hasFormat("text/plain") == false);
- QVERIFY(mimeData.hasFormat("text/html") == false);
+ QVERIFY(!mimeData.hasFormat("text/plain"));
+ QVERIFY(!mimeData.hasFormat("text/html"));
}
void tst_QMimeData::hasHtml() const
@@ -174,11 +174,11 @@ void tst_QMimeData::hasHtml() const
QMimeData mimeData;
// initial state
- QVERIFY(mimeData.hasHtml() == false);
+ QVERIFY(!mimeData.hasHtml());
// add plain, verify false
mimeData.setData("text/plain", "pirates");
- QVERIFY(mimeData.hasHtml() == false);
+ QVERIFY(!mimeData.hasHtml());
// add html, verify
mimeData.setData("text/html", "ninjas");
@@ -186,7 +186,7 @@ void tst_QMimeData::hasHtml() const
// clear, verify
mimeData.clear();
- QVERIFY(mimeData.hasHtml() == false);
+ QVERIFY(!mimeData.hasHtml());
// readd, verify
mimeData.setData("text/html", "ninjas");
@@ -198,11 +198,11 @@ void tst_QMimeData::hasImage() const
QMimeData mimeData;
// initial state
- QVERIFY(mimeData.hasImage() == false);
+ QVERIFY(!mimeData.hasImage());
// add text, verify false
mimeData.setData("text/plain", "pirates");
- QVERIFY(mimeData.hasImage() == false);
+ QVERIFY(!mimeData.hasImage());
// add image
mimeData.setImageData(QImage());
@@ -210,7 +210,7 @@ void tst_QMimeData::hasImage() const
// clear, verify
mimeData.clear();
- QVERIFY(mimeData.hasImage() == false);
+ QVERIFY(!mimeData.hasImage());
}
void tst_QMimeData::imageData() const
@@ -244,13 +244,13 @@ void tst_QMimeData::removeFormat() const
// remove, verify
mimeData.removeFormat("text/plain");
- QVERIFY(mimeData.hasFormat("text/plain") == false);
+ QVERIFY(!mimeData.hasFormat("text/plain"));
QVERIFY(mimeData.hasFormat("text/html"));
// remove, verify
mimeData.removeFormat("text/html");
- QVERIFY(mimeData.hasFormat("text/plain") == false);
- QVERIFY(mimeData.hasFormat("text/html") == false);
+ QVERIFY(!mimeData.hasFormat("text/plain"));
+ QVERIFY(!mimeData.hasFormat("text/html"));
}
void tst_QMimeData::setHtml() const
@@ -258,7 +258,7 @@ void tst_QMimeData::setHtml() const
QMimeData mimeData;
// initial state
- QVERIFY(mimeData.hasHtml() == false);
+ QVERIFY(!mimeData.hasHtml());
// add html, verify
mimeData.setHtml("ninjas");
@@ -277,7 +277,7 @@ void tst_QMimeData::setText() const
// verify initial state
QCOMPARE(mimeData.text(), QLatin1String(""));
- QVERIFY(mimeData.hasText() == false);
+ QVERIFY(!mimeData.hasText());
// set, verify
mimeData.setText("pirates");
@@ -294,7 +294,7 @@ void tst_QMimeData::setText() const
// clear, verify
mimeData.clear();
QCOMPARE(mimeData.text(), QLatin1String(""));
- QVERIFY(mimeData.hasText() == false);
+ QVERIFY(!mimeData.hasText());
}
// Publish retrieveData for verifying content validity
diff --git a/tests/auto/corelib/kernel/qobject/BLACKLIST b/tests/auto/corelib/kernel/qobject/BLACKLIST
new file mode 100644
index 0000000000..0887a73b4c
--- /dev/null
+++ b/tests/auto/corelib/kernel/qobject/BLACKLIST
@@ -0,0 +1,2 @@
+[moveToThread]
+windows
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 4617ce5e74..a3c6d8e9df 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -1925,7 +1925,7 @@ void tst_QObject::property()
QCOMPARE(object.property("string"), QVariant("String1"));
QVERIFY(object.setProperty("string", "String2"));
QCOMPARE(object.property("string"), QVariant("String2"));
- QVERIFY(!object.setProperty("string", QVariant()));
+ QVERIFY(object.setProperty("string", QVariant()));
const int idx = mo->indexOfProperty("variant");
QVERIFY(idx != -1);
@@ -2027,7 +2027,7 @@ void tst_QObject::property()
QCOMPARE(object.property("customString"), QVariant("String1"));
QVERIFY(object.setProperty("customString", "String2"));
QCOMPARE(object.property("customString"), QVariant("String2"));
- QVERIFY(!object.setProperty("customString", QVariant()));
+ QVERIFY(object.setProperty("customString", QVariant()));
}
void tst_QObject::metamethod()
diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
index 814c4bb691..d7cce4ada4 100644
--- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
+++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
@@ -50,6 +50,7 @@ private slots:
void destructor();
void assignment_operators();
void equality_operators();
+ void swap();
void isNull();
void dereference_operators();
void disconnect();
@@ -169,6 +170,22 @@ void tst_QPointer::equality_operators()
#endif
}
+void tst_QPointer::swap()
+{
+ QPointer<QObject> c1, c2;
+ {
+ QObject o;
+ c1 = &o;
+ QVERIFY(c2.isNull());
+ QCOMPARE(c1.data(), &o);
+ c1.swap(c2);
+ QVERIFY(c1.isNull());
+ QCOMPARE(c2.data(), &o);
+ }
+ QVERIFY(c1.isNull());
+ QVERIFY(c2.isNull());
+}
+
void tst_QPointer::isNull()
{
QPointer<QObject> p1;
diff --git a/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST
new file mode 100644
index 0000000000..e68bf84268
--- /dev/null
+++ b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST
@@ -0,0 +1,3 @@
+[unexpectedDisconnection]
+windows
+osx
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 1d1432f600..b34a3a6beb 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -72,6 +72,7 @@ private slots:
void singleShotStaticFunctionZeroTimeout();
void recurseOnTimeoutAndStopTimer();
void singleShotToFunctors();
+ void crossThreadSingleShotToFunctor();
void dontBlockEvents();
void postedEventsShouldNotStarveTimers();
@@ -440,6 +441,9 @@ void tst_QTimer::deleteLaterOnQTimer()
void tst_QTimer::moveToThread()
{
+#if defined(Q_OS_WIN32)
+ QSKIP("Does not work reliably on Windows :(");
+#endif
QTimer ti1;
QTimer ti2;
ti1.start(MOVETOTHREAD_TIMEOUT);
@@ -874,5 +878,28 @@ void tst_QTimer::postedEventsShouldNotStarveTimers()
QVERIFY(timerHelper.count > 5);
}
+struct DummyFunctor {
+ void operator()() {}
+};
+
+void tst_QTimer::crossThreadSingleShotToFunctor()
+{
+ // We're testing for crashes here, so the test simply running to
+ // completion is considered a success
+ QThread t;
+ t.start();
+
+ QObject* o = new QObject();
+ o->moveToThread(&t);
+
+ for (int i = 0; i < 10000; i++) {
+ QTimer::singleShot(0, o, DummyFunctor());
+ }
+
+ t.quit();
+ t.wait();
+ delete o;
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index a192ccde59..6da8f55e61 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -3357,9 +3357,6 @@ void tst_QVariant::numericalConvert_data()
void tst_QVariant::numericalConvert()
{
-#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
- QSKIP("Known to fail due to a GCC bug on at least Ubuntu 10.04 32-bit - check QTBUG-8959");
-#endif
QFETCH(QVariant, v);
QFETCH(bool, isInteger);
double num = isInteger ? 5 : 5.3;
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index 763bb58602..0171c4ac5a 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -35,6 +35,7 @@
#include "qstandardpaths.h"
+#include <QtCore/QElapsedTimer>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QStandardPaths>
@@ -126,6 +127,7 @@ tst_QMimeDatabase::tst_QMimeDatabase()
void tst_QMimeDatabase::initTestCase()
{
+ QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
QStandardPaths::setTestModeEnabled(true);
m_localMimeDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/mime";
if (QDir(m_localMimeDir).exists()) {
@@ -136,7 +138,8 @@ void tst_QMimeDatabase::initTestCase()
#ifdef USE_XDG_DATA_DIRS
// Create a temporary "global" XDG data dir for later use
// It will initially contain a copy of freedesktop.org.xml
- QVERIFY(m_temporaryDir.isValid());
+ QVERIFY2(m_temporaryDir.isValid(),
+ ("Could not create temporary subdir: " + m_temporaryDir.errorString()).toUtf8());
const QDir here = QDir(m_temporaryDir.path());
m_globalXdgDir = m_temporaryDir.path() + QStringLiteral("/global");
const QString globalPackageDir = m_globalXdgDir + QStringLiteral("/mime/packages");
@@ -825,16 +828,20 @@ static bool runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDa
return false;
}
+ QElapsedTimer timer;
QProcess proc;
proc.setProcessChannelMode(QProcess::MergedChannels); // silence output
+ qDebug().noquote() << "runUpdateMimeDatabase: running" << umd << path << "...";
+ timer.start();
proc.start(umd, QStringList(path));
if (!proc.waitForStarted()) {
qWarning("Cannot start %s: %s",
qPrintable(umd), qPrintable(proc.errorString()));
return false;
}
- proc.waitForFinished();
- //qDebug() << "runUpdateMimeDatabase" << path;
+ const bool success = proc.waitForFinished();
+ qDebug().noquote() << "runUpdateMimeDatabase: done,"
+ << success << timer.elapsed() << "ms";
return true;
}
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
index bdbb291d7f..72bd38d116 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
@@ -120,6 +120,7 @@ private slots:
void loadGarbage();
#endif
void relativePath();
+ void absolutePath();
void reloadPlugin();
void preloadedPlugin_data();
void preloadedPlugin();
@@ -311,7 +312,7 @@ void tst_QPluginLoader::loadCorruptElf()
void tst_QPluginLoader::loadMachO_data()
{
-#ifdef Q_OF_MACH_O
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OF_MACH_O)
QTest::addColumn<int>("parseResult");
QTest::newRow("/dev/null") << int(QMachOParser::NotSuitable);
@@ -347,7 +348,7 @@ void tst_QPluginLoader::loadMachO_data()
void tst_QPluginLoader::loadMachO()
{
-#ifdef Q_OF_MACH_O
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OF_MACH_O)
QFile f(QFINDTESTDATA(QTest::currentDataTag()));
QVERIFY(f.open(QIODevice::ReadOnly));
QByteArray data = f.readAll();
@@ -406,6 +407,20 @@ void tst_QPluginLoader::relativePath()
QVERIFY(loader.unload());
}
+void tst_QPluginLoader::absolutePath()
+{
+ // Windows binaries run from release and debug subdirs, so we can't rely on the current dir.
+ const QString binDir = QFINDTESTDATA("bin");
+ QVERIFY(!binDir.isEmpty());
+ QVERIFY(QDir::isAbsolutePath(binDir));
+ QPluginLoader loader(binDir + "/theplugin");
+ loader.load(); // not recommended, instance() should do the job.
+ PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance());
+ QVERIFY(instance);
+ QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok"));
+ QVERIFY(loader.unload());
+}
+
void tst_QPluginLoader::reloadPlugin()
{
QPluginLoader loader;
diff --git a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp
index ac3374b6a3..c64d55671a 100644
--- a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp
+++ b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp
@@ -47,6 +47,7 @@ private slots:
void historyInitialState();
void transitions();
void privateSignals();
+ void parallelStateAndInitialState();
};
class TestClass: public QObject
@@ -344,5 +345,35 @@ void tst_QState::privateSignals()
}
+void tst_QState::parallelStateAndInitialState()
+{
+ QStateMachine machine;
+
+ { // setting an initial state on a parallel state:
+ QState a(QState::ParallelStates, &machine);
+ QState b(&a);
+ QVERIFY(!a.initialState());
+ const QString warning
+ = QString::asprintf("QState::setInitialState: ignoring attempt to set initial state of parallel state group %p", &a);
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ a.setInitialState(&b); // should produce a warning and do nothing.
+ QVERIFY(!a.initialState());
+ }
+
+ { // setting the child-mode from ExclusiveStates to ParallelStates should remove the initial state:
+ QState a(QState::ExclusiveStates, &machine);
+ QState b(&a);
+ a.setInitialState(&b);
+ QCOMPARE(a.initialState(), &b);
+ const QString warning
+ = QString::asprintf("QState::setChildMode: setting the child-mode of state %p to "
+ "parallel removes the initial state", &a);
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ a.setChildMode(QState::ParallelStates); // should produce a warning and remove the initial state
+ QVERIFY(!a.initialState());
+ QCOMPARE(a.childMode(), QState::ParallelStates);
+ }
+}
+
QTEST_MAIN(tst_QState)
#include "tst_qstate.moc"
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
index 1292c3b98f..28df7cce7b 100644
--- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
@@ -250,6 +250,7 @@ private slots:
void internalTransition();
void conflictingTransition();
void qtbug_46059();
+ void qtbug_46703();
};
class TestState : public QState
@@ -265,7 +266,7 @@ public:
TestState(ChildMode mode, const QString &objectName = QString())
: QState(mode)
{ setObjectName(objectName); }
- QList<QPair<int, Event> > events;
+ QVector<QPair<int, Event> > events;
protected:
virtual void onEntry(QEvent *) {
events.append(qMakePair(globalTick++, Entry));
@@ -281,7 +282,7 @@ public:
TestTransition(QAbstractState *target, const QString &objectName = QString())
: QAbstractTransition()
{ setTargetState(target); setObjectName(objectName); }
- QList<int> triggers;
+ QVector<int> triggers;
protected:
virtual bool eventTest(QEvent *) {
return true;
@@ -4860,7 +4861,7 @@ public:
signalList.append(signal);
}
- QList<QMetaMethod> signalList;
+ QVector<QMetaMethod> signalList;
};
void tst_QStateMachine::testIncrementReceivers()
@@ -6485,5 +6486,59 @@ void tst_QStateMachine::qtbug_46059()
QVERIFY(machine.isRunning());
}
+void tst_QStateMachine::qtbug_46703()
+{
+ QStateMachine machine;
+ QState root(&machine);
+ QHistoryState h(&root);
+ QState p(QState::ParallelStates, &root);
+ QState a(&p);
+ QState a1(&a);
+ QState a2(&a);
+ QState a3(&a);
+ QState b(&p);
+ QState b1(&b);
+ QState b2(&b);
+
+ machine.setObjectName("machine");
+ root.setObjectName("root");
+ h.setObjectName("h");
+ p.setObjectName("p");
+ a.setObjectName("a");
+ a1.setObjectName("a1");
+ a2.setObjectName("a2");
+ a3.setObjectName("a3");
+ b.setObjectName("b");
+ b1.setObjectName("b1");
+ b2.setObjectName("b2");
+
+ machine.setInitialState(&root);
+ root.setInitialState(&h);
+ a.setInitialState(&a3);
+ b.setInitialState(&b1);
+ struct : public QAbstractTransition {
+ virtual bool eventTest(QEvent *) { return false; }
+ virtual void onTransition(QEvent *) {}
+ } defaultTransition;
+ defaultTransition.setTargetStates(QList<QAbstractState*>() << &a2 << &b2);
+ h.setDefaultTransition(&defaultTransition);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(machine.configuration().contains(&root), true);
+ QTRY_COMPARE(machine.configuration().contains(&h), false);
+ QTRY_COMPARE(machine.configuration().contains(&p), true);
+ QTRY_COMPARE(machine.configuration().contains(&a), true);
+ QTRY_COMPARE(machine.configuration().contains(&a1), false);
+ QTRY_COMPARE(machine.configuration().contains(&a2), true);
+ QTRY_COMPARE(machine.configuration().contains(&a3), false);
+ QTRY_COMPARE(machine.configuration().contains(&b), true);
+ QTRY_COMPARE(machine.configuration().contains(&b1), false);
+ QTRY_COMPARE(machine.configuration().contains(&b2), true);
+
+ QVERIFY(machine.isRunning());
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"
diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp
index e8c58a9fa5..72ae68f81a 100644
--- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp
+++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp
@@ -479,34 +479,34 @@ void tst_QAtomicInt::testAndSet_data()
QTest::addColumn<int>("value");
QTest::addColumn<int>("expected");
QTest::addColumn<int>("newval");
- QTest::addColumn<int>("result");
+ QTest::addColumn<bool>("result");
// these should succeed
- QTest::newRow("success0") << 0 << 0 << 0 << 1;
- QTest::newRow("success1") << 0 << 0 << 1 << 1;
- QTest::newRow("success2") << 0 << 0 << -1 << 1;
- QTest::newRow("success3") << 1 << 1 << 0 << 1;
- QTest::newRow("success4") << 1 << 1 << 1 << 1;
- QTest::newRow("success5") << 1 << 1 << -1 << 1;
- QTest::newRow("success6") << -1 << -1 << 0 << 1;
- QTest::newRow("success7") << -1 << -1 << 1 << 1;
- QTest::newRow("success8") << -1 << -1 << -1 << 1;
- QTest::newRow("success9") << INT_MIN+1 << INT_MIN+1 << INT_MIN+1 << 1;
- QTest::newRow("successA") << INT_MIN+1 << INT_MIN+1 << 1 << 1;
- QTest::newRow("successB") << INT_MIN+1 << INT_MIN+1 << -1 << 1;
- QTest::newRow("successC") << INT_MAX << INT_MAX << INT_MAX << 1;
- QTest::newRow("successD") << INT_MAX << INT_MAX << 1 << 1;
- QTest::newRow("successE") << INT_MAX << INT_MAX << -1 << 1;
+ QTest::newRow("success0") << 0 << 0 << 0 << true;
+ QTest::newRow("success1") << 0 << 0 << 1 << true;
+ QTest::newRow("success2") << 0 << 0 << -1 << true;
+ QTest::newRow("success3") << 1 << 1 << 0 << true;
+ QTest::newRow("success4") << 1 << 1 << 1 << true;
+ QTest::newRow("success5") << 1 << 1 << -1 << true;
+ QTest::newRow("success6") << -1 << -1 << 0 << true;
+ QTest::newRow("success7") << -1 << -1 << 1 << true;
+ QTest::newRow("success8") << -1 << -1 << -1 << true;
+ QTest::newRow("success9") << INT_MIN+1 << INT_MIN+1 << INT_MIN+1 << true;
+ QTest::newRow("successA") << INT_MIN+1 << INT_MIN+1 << 1 << true;
+ QTest::newRow("successB") << INT_MIN+1 << INT_MIN+1 << -1 << true;
+ QTest::newRow("successC") << INT_MAX << INT_MAX << INT_MAX << true;
+ QTest::newRow("successD") << INT_MAX << INT_MAX << 1 << true;
+ QTest::newRow("successE") << INT_MAX << INT_MAX << -1 << true;
// these should fail
- QTest::newRow("failure0") << 0 << 1 << ~0 << 0;
- QTest::newRow("failure1") << 0 << -1 << ~0 << 0;
- QTest::newRow("failure2") << 1 << 0 << ~0 << 0;
- QTest::newRow("failure3") << -1 << 0 << ~0 << 0;
- QTest::newRow("failure4") << 1 << -1 << ~0 << 0;
- QTest::newRow("failure5") << -1 << 1 << ~0 << 0;
- QTest::newRow("failure6") << INT_MIN+1 << INT_MAX << ~0 << 0;
- QTest::newRow("failure7") << INT_MAX << INT_MIN+1 << ~0 << 0;
+ QTest::newRow("failure0") << 0 << 1 << ~0 << false;
+ QTest::newRow("failure1") << 0 << -1 << ~0 << false;
+ QTest::newRow("failure2") << 1 << 0 << ~0 << false;
+ QTest::newRow("failure3") << -1 << 0 << ~0 << false;
+ QTest::newRow("failure4") << 1 << -1 << ~0 << false;
+ QTest::newRow("failure5") << -1 << 1 << ~0 << false;
+ QTest::newRow("failure6") << INT_MIN+1 << INT_MAX << ~0 << false;
+ QTest::newRow("failure7") << INT_MAX << INT_MIN+1 << ~0 << false;
}
void tst_QAtomicInt::testAndSet()
@@ -517,26 +517,26 @@ void tst_QAtomicInt::testAndSet()
{
QAtomicInt atomic = value;
- QTEST(atomic.testAndSetRelaxed(expected, newval) ? 1 : 0, "result");
+ QTEST(atomic.testAndSetRelaxed(expected, newval), "result");
}
{
QAtomicInt atomic = value;
- QTEST(atomic.testAndSetAcquire(expected, newval) ? 1 : 0, "result");
+ QTEST(atomic.testAndSetAcquire(expected, newval), "result");
}
{
QAtomicInt atomic = value;
- QTEST(atomic.testAndSetRelease(expected, newval) ? 1 : 0, "result");
+ QTEST(atomic.testAndSetRelease(expected, newval), "result");
}
{
QAtomicInt atomic = value;
- QTEST(atomic.testAndSetOrdered(expected, newval) ? 1 : 0, "result");
+ QTEST(atomic.testAndSetOrdered(expected, newval), "result");
}
#ifdef Q_ATOMIC_INT32_IS_SUPPORTED
- QFETCH(int, result);
+ QFETCH(bool, result);
// the new implementation has the version that loads the current value
{
diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
index 99978a9923..ad690a094b 100644
--- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
+++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
@@ -648,7 +648,7 @@ void tst_QFuture::cancel()
result.reportStarted();
f = result.future();
- QVERIFY(f.isCanceled() == false);
+ QVERIFY(!f.isCanceled());
result.reportCanceled();
QVERIFY(f.isCanceled());
result.reportFinished();
@@ -663,14 +663,14 @@ void tst_QFuture::cancel()
QFutureInterface<void> result;
QFuture<void> f;
- QVERIFY(f.isStarted() == true);
+ QVERIFY(f.isStarted());
result.reportStarted();
f = result.future();
- QVERIFY(f.isStarted() == true);
+ QVERIFY(f.isStarted());
- QVERIFY(result.isCanceled() == false);
+ QVERIFY(!result.isCanceled());
f.cancel();
QVERIFY(result.isCanceled());
@@ -683,12 +683,12 @@ void tst_QFuture::cancel()
QFutureInterface<void> result;
QFuture<void> f;
- QVERIFY(f.isStarted() == true);
+ QVERIFY(f.isStarted());
result.reportStarted();
f = result.future();
- QVERIFY(f.isStarted() == true);
+ QVERIFY(f.isStarted());
result.reportFinished();
@@ -805,12 +805,12 @@ void tst_QFuture::indexedResults()
{
QFutureInterface<QChar> Interface;
QFuture<QChar> f;
- QVERIFY(f.isStarted() == true);
+ QVERIFY(f.isStarted());
Interface.reportStarted();
f = Interface.future();
- QVERIFY(f.isStarted() == true);
+ QVERIFY(f.isStarted());
QChar result;
@@ -1126,14 +1126,14 @@ void tst_QFuture::iterators()
QVERIFY(it.hasNext());
QCOMPARE(it.peekNext(), resultCount - 1);
QCOMPARE(it.next(), resultCount - 1);
- QVERIFY(it.hasNext() == false);
+ QVERIFY(!it.hasNext());
}
{
QFutureIterator<int> it(f);
QVERIFY(it.hasNext());
it.toBack();
- QVERIFY(it.hasNext() == false);
+ QVERIFY(!it.hasNext());
it.toFront();
QVERIFY(it.hasNext());
}
@@ -1192,15 +1192,15 @@ void tst_QFuture::pause()
Interface.reportStarted();
QFuture<void> f = Interface.future();
- QVERIFY(Interface.isPaused() == false);
+ QVERIFY(!Interface.isPaused());
f.pause();
- QVERIFY(Interface.isPaused() == true);
+ QVERIFY(Interface.isPaused());
f.resume();
- QVERIFY(Interface.isPaused() == false);
+ QVERIFY(!Interface.isPaused());
f.togglePaused();
- QVERIFY(Interface.isPaused() == true);
+ QVERIFY(Interface.isPaused());
f.togglePaused();
- QVERIFY(Interface.isPaused() == false);
+ QVERIFY(!Interface.isPaused());
Interface.reportFinished();
}
@@ -1228,13 +1228,13 @@ void tst_QFuture::throttling()
i.reportStarted();
QFuture<void> f = i.future();
- QVERIFY(i.isThrottled() == false);
+ QVERIFY(!i.isThrottled());
i.setThrottled(true);
QVERIFY(i.isThrottled());
i.setThrottled(false);
- QVERIFY(i.isThrottled() == false);
+ QVERIFY(!i.isThrottled());
i.setThrottled(true);
QVERIFY(i.isThrottled());
diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
index 8831345ad7..5ec32b1d02 100644
--- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -68,6 +68,7 @@ private slots:
void incrementalFilterResults();
void qfutureSynchronizer();
void warnRace();
+ void matchFlags();
};
void sleeper()
@@ -743,7 +744,7 @@ void tst_QFutureWatcher::finishedState()
iface.reportFinished();
QVERIFY(future.isFinished());
- QVERIFY(watcher.isFinished() == false);
+ QVERIFY(!watcher.isFinished());
QTest::qWait(10);
QVERIFY(watcher.isFinished());
@@ -761,18 +762,18 @@ void tst_QFutureWatcher::throttling()
QFutureWatcher<int> watcher;
watcher.setFuture(future);
- QVERIFY(iface.isThrottled() == false);
+ QVERIFY(!iface.isThrottled());
for (int i = 0; i < 1000; ++i) {
int result = 0;
iface.reportResult(result);
}
- QVERIFY(iface.isThrottled() == true);
+ QVERIFY(iface.isThrottled());
QTest::qWait(100); // process events.
- QVERIFY(iface.isThrottled() == false);
+ QVERIFY(!iface.isThrottled());
iface.reportFinished();
}
@@ -930,5 +931,17 @@ void tst_QFutureWatcher::warnRace()
future.waitForFinished();
}
+void tst_QFutureWatcher::matchFlags()
+{
+ /* Regression test: expect a default watcher to be in the same state as a
+ * default future. */
+ QFutureWatcher<int> watcher;
+ QFuture<int> future;
+ QCOMPARE(watcher.isStarted(), future.isStarted());
+ QCOMPARE(watcher.isCanceled(), future.isCanceled());
+ QCOMPARE(watcher.isFinished(), future.isFinished());
+}
+
+
QTEST_MAIN(tst_QFutureWatcher)
#include "tst_qfuturewatcher.moc"
diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
new file mode 100644
index 0000000000..9f6f6e3ba6
--- /dev/null
+++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
@@ -0,0 +1,3 @@
+# Times out randomly on linux, windows, osx
+[tryAcquireWithTimeout]
+*
diff --git a/tests/auto/corelib/thread/qthread/BLACKLIST b/tests/auto/corelib/thread/qthread/BLACKLIST
new file mode 100644
index 0000000000..d75249454f
--- /dev/null
+++ b/tests/auto/corelib/thread/qthread/BLACKLIST
@@ -0,0 +1,2 @@
+[wait3_slowDestructor]
+windows
diff --git a/tests/auto/corelib/thread/qthreadpool/BLACKLIST b/tests/auto/corelib/thread/qthreadpool/BLACKLIST
new file mode 100644
index 0000000000..684f650a72
--- /dev/null
+++ b/tests/auto/corelib/thread/qthreadpool/BLACKLIST
@@ -0,0 +1,5 @@
+[expiryTimeoutRace]
+osx
+[tryStartCount]
+windows msvc-2012
+linux
diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
index 5e9b7370b9..ed7b446172 100644
--- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
+++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
@@ -240,7 +240,7 @@ void tst_QThreadStorage::adoptedThreads()
QTestEventLoop::instance().enterLoop(2);
QVERIFY(!QTestEventLoop::instance().timeout());
- QCOMPARE(Pointer::count, c);
+ QTRY_COMPARE(Pointer::count, c);
}
QBasicAtomicInt cleanupOrder = Q_BASIC_ATOMIC_INITIALIZER(0);
diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index 7eedd5bcf7..ae8ffe48be 100644
--- a/tests/auto/corelib/tools/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -2235,7 +2235,7 @@ void tst_Collections::qstring()
void tst_Collections::bitArray()
{
QBitArray ba(20);
- QVERIFY(ba.testBit(17) == false);
+ QVERIFY(!ba.testBit(17));
ba.setBit(17);
QVERIFY(ba.size() == 20);
QVERIFY(ba.testBit(17)==true);
diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
index 9bce948140..99e5c4c85d 100644
--- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp
@@ -31,6 +31,7 @@
**
****************************************************************************/
+#include "../../../../../src/corelib/tools/qalgorithms.h"
#include <QtTest/QtTest>
#include <iostream>
@@ -80,6 +81,24 @@ private slots:
void popCount32() { popCount_impl<quint32>(); }
void popCount64() { popCount_impl<quint64>(); }
+ void countTrailing08_data() { countTrailing_data_impl(sizeof(quint8 )); }
+ void countTrailing16_data() { countTrailing_data_impl(sizeof(quint16)); }
+ void countTrailing32_data() { countTrailing_data_impl(sizeof(quint32)); }
+ void countTrailing64_data() { countTrailing_data_impl(sizeof(quint64)); }
+ void countTrailing08() { countTrailing_impl<quint8 >(); }
+ void countTrailing16() { countTrailing_impl<quint16>(); }
+ void countTrailing32() { countTrailing_impl<quint32>(); }
+ void countTrailing64() { countTrailing_impl<quint64>(); }
+
+ void countLeading08_data() { countLeading_data_impl(sizeof(quint8 )); }
+ void countLeading16_data() { countLeading_data_impl(sizeof(quint16)); }
+ void countLeading32_data() { countLeading_data_impl(sizeof(quint32)); }
+ void countLeading64_data() { countLeading_data_impl(sizeof(quint64)); }
+ void countLeading08() { countLeading_impl<quint8 >(); }
+ void countLeading16() { countLeading_impl<quint16>(); }
+ void countLeading32() { countLeading_impl<quint32>(); }
+ void countLeading64() { countLeading_impl<quint64>(); }
+
private:
#if Q_TEST_PERFORMANCE
void performance();
@@ -87,6 +106,14 @@ private:
void popCount_data_impl(size_t sizeof_T_Int);
template <typename T_Int>
void popCount_impl();
+
+ void countTrailing_data_impl(size_t sizeof_T_Int);
+ template <typename T_Int>
+ void countTrailing_impl();
+
+ void countLeading_data_impl(size_t sizeof_T_Int);
+ template <typename T_Int>
+ void countLeading_impl();
};
class TestInt
@@ -1084,6 +1111,86 @@ void tst_QAlgorithms::popCount_impl()
QCOMPARE(qPopulationCount(value), expected);
}
+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);
+ 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;
+ }
+
+ quint64 type_mask;
+ if (sizeof_T_Int>=8)
+ type_mask = ~Q_UINT64_C(0);
+ else
+ type_mask = (Q_UINT64_C(1) << (sizeof_T_Int*8))-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 r = quint64(qrand()) << 32 | quint32(qrand());
+ 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;
+ }
+ }
+}
+
+template <typename T_Int>
+void tst_QAlgorithms::countTrailing_impl()
+{
+ QFETCH(quint64, input);
+ QFETCH(uint, expected);
+
+ const T_Int value = static_cast<T_Int>(input);
+
+ QCOMPARE(qCountTrailingZeroBits(value), expected);
+}
+
+void tst_QAlgorithms::countLeading_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);
+ 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);
+ }
+
+ // 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 r = quint64(qrand()) << 32 | quint32(qrand());
+ 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);
+ }
+ }
+}
+
+template <typename T_Int>
+void tst_QAlgorithms::countLeading_impl()
+{
+ QFETCH(quint64, input);
+ QFETCH(uint, expected);
+
+ const T_Int value = static_cast<T_Int>(input);
+
+ QCOMPARE(qCountLeadingZeroBits(value), expected);
+}
+
QTEST_APPLESS_MAIN(tst_QAlgorithms)
#include "tst_qalgorithms.moc"
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 410b34e894..f942eab800 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -67,6 +67,7 @@ private slots:
void endsWith_data();
void endsWith();
void endsWith_char();
+ void reverseIterators();
void split_data();
void split();
void base64_data();
@@ -540,6 +541,20 @@ void tst_QByteArray::endsWith_char()
QVERIFY(!QByteArray().endsWith('\0'));
}
+void tst_QByteArray::reverseIterators()
+{
+ QByteArray s = "1234";
+ QByteArray sr = s;
+ std::reverse(sr.begin(), sr.end());
+ const QByteArray &csr = sr;
+ QVERIFY(std::equal(s.begin(), s.end(), sr.rbegin()));
+ QVERIFY(std::equal(s.begin(), s.end(), sr.crbegin()));
+ QVERIFY(std::equal(s.begin(), s.end(), csr.rbegin()));
+ QVERIFY(std::equal(sr.rbegin(), sr.rend(), s.begin()));
+ QVERIFY(std::equal(sr.crbegin(), sr.crend(), s.begin()));
+ QVERIFY(std::equal(csr.rbegin(), csr.rend(), s.begin()));
+}
+
void tst_QByteArray::split_data()
{
QTest::addColumn<QByteArray>("sample");
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm b/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm
index c2b76cc41a..95d05904a2 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm
@@ -72,35 +72,31 @@ void tst_QByteArray_macTypes()
}
// QByteArray <-> NSData
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QByteArray qtByteArray("test bytearray");
const NSData *nsData = qtByteArray.toNSData();
QCOMPARE(QByteArray::fromNSData(nsData), qtByteArray);
- [autoreleasepool release];
}
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QByteArray qtByteArray("test bytearray");
const NSData *nsData = qtByteArray.toNSData();
QByteArray qtByteArrayCopy(qtByteArray);
qtByteArray = qtByteArray.toUpper(); // modify
QCOMPARE(QByteArray::fromNSData(nsData), qtByteArrayCopy);
- [autoreleasepool release];
}
// QByteArray <-> NSData Raw
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QByteArray qtByteArray("test bytearray");
const NSData *nsData = qtByteArray.toRawNSData();
QCOMPARE([nsData bytes], qtByteArray.constData());
- [autoreleasepool release];
}
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
const char data[] = "nsdata test";
const NSData *nsData = [NSData dataWithBytes:data length:sizeof(data)];
QByteArray qtByteArray = QByteArray::fromRawNSData(nsData);
QCOMPARE(qtByteArray.constData(), [nsData bytes]);
- [autoreleasepool release];
}
}
diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
index 7b1b7ce963..6e09ebb09b 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
@@ -73,6 +73,12 @@ int main(int argc, char *argv[])
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
parser.addOption(newlineOption);
+ // A hidden option
+ QCommandLineOption hiddenOption(QStringList() << QStringLiteral("hidden"));
+ hiddenOption.setDescription(QStringLiteral("THIS SHOULD NEVER APPEAR"));
+ hiddenOption.setHidden(true);
+ parser.addOption(hiddenOption);
+
// This program supports different options depending on the "command" (first argument).
// Call parse() to find out the positional arguments.
parser.parse(QCoreApplication::arguments());
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index 6ff46ed20b..fb0b971602 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -35,6 +35,7 @@
#include <QtCore/QCommandLineParser>
Q_DECLARE_METATYPE(char**)
+Q_DECLARE_METATYPE(QCommandLineParser::OptionsAfterPositionalArgumentsMode)
class tst_QCommandLineParser : public QObject
{
@@ -51,6 +52,8 @@ private slots:
void testPositionalArguments();
void testBooleanOption_data();
void testBooleanOption();
+ void testOptionsAndPositional_data();
+ void testOptionsAndPositional();
void testMultipleNames_data();
void testMultipleNames();
void testSingleValueOption_data();
@@ -130,7 +133,7 @@ void tst_QCommandLineParser::testBooleanOption()
QFETCH(bool, expectedIsSet);
QCoreApplication app(empty_argc, empty_argv);
QCommandLineParser parser;
- QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("b"), QStringLiteral("a boolean option"))));
+ QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("b"))));
QVERIFY(parser.parse(args));
QCOMPARE(parser.optionNames(), expectedOptionNames);
QCOMPARE(parser.isSet("b"), expectedIsSet);
@@ -141,6 +144,40 @@ void tst_QCommandLineParser::testBooleanOption()
QVERIFY(!parser.isSet("c"));
}
+void tst_QCommandLineParser::testOptionsAndPositional_data()
+{
+ QTest::addColumn<QStringList>("args");
+ QTest::addColumn<QStringList>("expectedOptionNames");
+ QTest::addColumn<bool>("expectedIsSet");
+ QTest::addColumn<QStringList>("expectedPositionalArguments");
+ QTest::addColumn<QCommandLineParser::OptionsAfterPositionalArgumentsMode>("parsingMode");
+
+ const QStringList arg = QStringList() << "arg";
+ QTest::newRow("before_positional_default") << (QStringList() << "tst_qcommandlineparser" << "-b" << "arg") << (QStringList() << "b") << true << arg << QCommandLineParser::ParseAsOptions;
+ QTest::newRow("after_positional_default") << (QStringList() << "tst_qcommandlineparser" << "arg" << "-b") << (QStringList() << "b") << true << arg << QCommandLineParser::ParseAsOptions;
+ QTest::newRow("before_positional_parseAsArg") << (QStringList() << "tst_qcommandlineparser" << "-b" << "arg") << (QStringList() << "b") << true << arg << QCommandLineParser::ParseAsPositionalArguments;
+ QTest::newRow("after_positional_parseAsArg") << (QStringList() << "tst_qcommandlineparser" << "arg" << "-b") << (QStringList()) << false << (QStringList() << "arg" << "-b") << QCommandLineParser::ParseAsPositionalArguments;
+}
+
+void tst_QCommandLineParser::testOptionsAndPositional()
+{
+ QFETCH(QStringList, args);
+ QFETCH(QStringList, expectedOptionNames);
+ QFETCH(bool, expectedIsSet);
+ QFETCH(QStringList, expectedPositionalArguments);
+ QFETCH(QCommandLineParser::OptionsAfterPositionalArgumentsMode, parsingMode);
+
+ QCoreApplication app(empty_argc, empty_argv);
+ QCommandLineParser parser;
+ parser.setOptionsAfterPositionalArgumentsMode(parsingMode);
+ QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("b"), QStringLiteral("a boolean option"))));
+ QVERIFY(parser.parse(args));
+ QCOMPARE(parser.optionNames(), expectedOptionNames);
+ QCOMPARE(parser.isSet("b"), expectedIsSet);
+ QCOMPARE(parser.values("b"), QStringList());
+ QCOMPARE(parser.positionalArguments(), expectedPositionalArguments);
+}
+
void tst_QCommandLineParser::testMultipleNames_data()
{
QTest::addColumn<QStringList>("args");
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm b/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm
index 6bdaa94e49..0ad9a8253b 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm
@@ -56,19 +56,17 @@ void tst_QDateTime_macTypes()
}
// QDateTime <-> NSDate
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
const NSDate *nsDate = qtDateTime.toNSDate();
QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTime);
- [autoreleasepool release];
}
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
const NSDate *nsDate = qtDateTime.toNSDate();
QDateTime qtDateTimeCopy(qtDateTime);
qtDateTime.setTime_t(10000); // modify
QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTimeCopy);
- [autoreleasepool release];
}
}
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 6ea33fb37f..6a5c6b5670 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -62,6 +62,7 @@ private slots:
void compare();
void compare2();
void iterators(); // sligthly modified from tst_QMap
+ void keyIterator();
void keys_values_uniqueKeys(); // slightly modified from tst_QMap
void noNeedlessRehashes();
@@ -965,6 +966,34 @@ void tst_QHash::iterators()
}
}
+void tst_QHash::keyIterator()
+{
+ QHash<int, int> hash;
+
+ for (int i = 0; i < 100; ++i)
+ hash.insert(i, i*100);
+
+ QHash<int, int>::key_iterator key_it = hash.keyBegin();
+ QHash<int, int>::const_iterator it = hash.cbegin();
+ for (int i = 0; i < 100; ++i) {
+ QCOMPARE(*key_it, it.key());
+ key_it++;
+ it++;
+ }
+
+ key_it = std::find(hash.keyBegin(), hash.keyEnd(), 50);
+ it = std::find(hash.cbegin(), hash.cend(), 50 * 100);
+
+ QVERIFY(key_it != hash.keyEnd());
+ QCOMPARE(*key_it, it.key());
+ QCOMPARE(*(key_it++), (it++).key());
+ QCOMPARE(*(key_it--), (it--).key());
+ QCOMPARE(*(++key_it), (++it).key());
+ QCOMPARE(*(--key_it), (--it).key());
+
+ QCOMPARE(std::count(hash.keyBegin(), hash.keyEnd(), 99), 1);
+}
+
void tst_QHash::rehash_isnt_quadratic()
{
// this test should be incredibly slow if rehash() is quadratic
diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
index 6961426f59..bde9433a24 100644
--- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
+++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
@@ -50,6 +50,8 @@ private Q_SLOTS:
void qthash();
void range();
void rangeCommutative();
+
+ void setGlobalQHashSeed();
};
void tst_QHashFunctions::qhash()
@@ -207,5 +209,21 @@ void tst_QHashFunctions::rangeCommutative()
(void)qHashRangeCommutative(hashables, hashables + numHashables);
}
+void tst_QHashFunctions::setGlobalQHashSeed()
+{
+ // Setter works as advertised
+ qSetGlobalQHashSeed(0x10101010);
+ QCOMPARE(qGlobalQHashSeed(), 0x10101010);
+
+ // Creating a new QHash doesn't reset the seed
+ QHash<QString, int> someHash;
+ someHash.insert("foo", 42);
+ QCOMPARE(qGlobalQHashSeed(), 0x10101010);
+
+ // Reset works as advertised
+ qSetGlobalQHashSeed(-1);
+ QVERIFY(qGlobalQHashSeed() != -1);
+}
+
QTEST_APPLESS_MAIN(tst_QHashFunctions)
#include "tst_qhashfunctions.moc"
diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
index 82303b4f72..d3ace40164 100644
--- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
+++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
@@ -204,6 +204,7 @@ private slots:
void removeOneInt() const;
void removeOneMovable() const;
void removeOneComplex() const;
+ void reverseIterators() const;
void startsWithInt() const;
void startsWithMovable() const;
void startsWithComplex() const;
@@ -527,12 +528,12 @@ void tst_QLinkedList::contains() const
QLinkedList<T> list;
list << T_FOO << T_BAR << T_BAZ;
- QVERIFY(list.contains(T_FOO) == true);
+ QVERIFY(list.contains(T_FOO));
QVERIFY(list.contains(T_BLAH) != true);
// add it and make sure it matches
list.append(T_BLAH);
- QVERIFY(list.contains(T_BLAH) == true);
+ QVERIFY(list.contains(T_BLAH));
}
void tst_QLinkedList::containsInt() const
@@ -754,6 +755,21 @@ void tst_QLinkedList::removeOneComplex() const
QCOMPARE(liveCount, Complex::getLiveCount());
}
+void tst_QLinkedList::reverseIterators() const
+{
+ QLinkedList<int> l;
+ l << 1 << 2 << 3 << 4;
+ QLinkedList<int> lr = l;
+ std::reverse(lr.begin(), lr.end());
+ const QLinkedList<int> &clr = lr;
+ QVERIFY(std::equal(l.begin(), l.end(), lr.rbegin()));
+ QVERIFY(std::equal(l.begin(), l.end(), lr.crbegin()));
+ QVERIFY(std::equal(l.begin(), l.end(), clr.rbegin()));
+ QVERIFY(std::equal(lr.rbegin(), lr.rend(), l.begin()));
+ QVERIFY(std::equal(lr.crbegin(), lr.crend(), l.begin()));
+ QVERIFY(std::equal(clr.rbegin(), clr.rend(), l.begin()));
+}
+
template<typename T>
void tst_QLinkedList::startsWith() const
{
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index 1207986dde..1bb31afa9c 100644
--- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -76,6 +76,13 @@ struct Movable {
return i == other.i;
}
+ bool operator<(const Movable &other) const
+ {
+ check(state, Constructed);
+ check(other.state, Constructed);
+ return i < other.i;
+ }
+
Movable &operator=(const Movable &other)
{
check(state, Constructed);
@@ -144,6 +151,13 @@ struct Optimal
return i == other.i;
}
+ bool operator<(const Optimal &other) const
+ {
+ check(state, Constructed);
+ check(other.state, Constructed);
+ return i < other.i;
+ }
+
Optimal &operator=(const Optimal &other)
{
check(state, Constructed);
@@ -220,6 +234,12 @@ struct Complex
return value == other.value;
}
+ bool operator<(Complex const &other) const
+ {
+ check(); other.check();
+ return value < other.value;
+ }
+
void check() const
{
QVERIFY(this == checkSum);
@@ -293,6 +313,8 @@ private slots:
void lastOptimal() const;
void lastMovable() const;
void lastComplex() const;
+ void constFirst() const;
+ void constLast() const;
void beginOptimal() const;
void beginMovable() const;
void beginComplex() const;
@@ -329,6 +351,9 @@ private slots:
void replaceOptimal() const;
void replaceMovable() const;
void replaceComplex() const;
+ void reverseIteratorsOptimal() const;
+ void reverseIteratorsMovable() const;
+ void reverseIteratorsComplex() const;
void startsWithOptimal() const;
void startsWithMovable() const;
void startsWithComplex() const;
@@ -376,6 +401,9 @@ private slots:
void eraseValidIteratorsOnSharedList() const;
void insertWithValidIteratorsOnSharedList() const;
+ void qhashOptimal() const { qhash<Optimal>(); }
+ void qhashMovable() const { qhash<Movable>(); }
+ void qhashComplex() const { qhash<Complex>(); }
void reserve() const;
private:
template<typename T> void length() const;
@@ -392,10 +420,12 @@ private:
template<typename T> void endsWith() const;
template<typename T> void lastIndexOf() const;
template<typename T> void move() const;
+ template<typename T> void qhash() const;
template<typename T> void removeAll() const;
template<typename T> void removeAt() const;
template<typename T> void removeOne() const;
template<typename T> void replace() const;
+ template<typename T> void reverseIterators() const;
template<typename T> void startsWith() const;
template<typename T> void swap() const;
template<typename T> void takeAt() const;
@@ -701,6 +731,140 @@ void tst_QList::firstComplex() const
QCOMPARE(liveCount, Complex::getLiveCount());
}
+void tst_QList::constFirst() const
+{
+ // Based on tst_QVector::constFirst()
+ QList<int> list;
+ list << 69 << 42 << 3;
+
+ // test it starts ok
+ QCOMPARE(list.constFirst(), 69);
+ QVERIFY(list.isDetached());
+
+ QList<int> listCopy = list;
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ QCOMPARE(list.constFirst(), 69);
+ QCOMPARE(listCopy.constFirst(), 69);
+
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ // test removal changes
+ list.removeAt(0);
+ QVERIFY(list.isDetached());
+ QVERIFY(!list.isSharedWith(listCopy));
+ QCOMPARE(list.constFirst(), 42);
+ QCOMPARE(listCopy.constFirst(), 69);
+
+ listCopy = list;
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ QCOMPARE(list.constFirst(), 42);
+ QCOMPARE(listCopy.constFirst(), 42);
+
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ // test prepend changes
+ list.prepend(23);
+ QVERIFY(list.isDetached());
+ QVERIFY(!list.isSharedWith(listCopy));
+ QCOMPARE(list.constFirst(), 23);
+ QCOMPARE(listCopy.constFirst(), 42);
+
+ listCopy = list;
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ QCOMPARE(list.constFirst(), 23);
+ QCOMPARE(listCopy.constFirst(), 23);
+
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+}
+
+void tst_QList::constLast() const
+{
+ // Based on tst_QVector::constLast()
+ QList<int> list;
+ list << 69 << 42 << 3;
+
+ // test it starts ok
+ QCOMPARE(list.constLast(), 3);
+ QVERIFY(list.isDetached());
+
+ QList<int> listCopy = list;
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ QCOMPARE(list.constLast(), 3);
+ QCOMPARE(listCopy.constLast(), 3);
+
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ // test removal changes
+ list.removeLast();
+ QVERIFY(list.isDetached());
+ QVERIFY(!list.isSharedWith(listCopy));
+ QCOMPARE(list.constLast(), 42);
+ QCOMPARE(listCopy.constLast(), 3);
+
+ listCopy = list;
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ QCOMPARE(list.constLast(), 42);
+ QCOMPARE(listCopy.constLast(), 42);
+
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ // test prepend changes
+ list.append(23);
+ QVERIFY(list.isDetached());
+ QVERIFY(!list.isSharedWith(listCopy));
+ QCOMPARE(list.constLast(), 23);
+ QCOMPARE(listCopy.constLast(), 42);
+
+ listCopy = list;
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+
+ QCOMPARE(list.constLast(), 23);
+ QCOMPARE(listCopy.constLast(), 23);
+
+ QVERIFY(!list.isDetached());
+ QVERIFY(!listCopy.isDetached());
+ QVERIFY(list.isSharedWith(listCopy));
+ QVERIFY(listCopy.isSharedWith(list));
+}
+
template<typename T>
void tst_QList::last() const
{
@@ -812,12 +976,12 @@ void tst_QList::contains() const
QList<T> list;
list << T_FOO << T_BAR << T_BAZ;
- QVERIFY(list.contains(T_FOO) == true);
+ QVERIFY(list.contains(T_FOO));
QVERIFY(list.contains(T_BLAH) != true);
// add it and make sure it matches
list.append(T_BLAH);
- QVERIFY(list.contains(T_BLAH) == true);
+ QVERIFY(list.contains(T_BLAH));
}
void tst_QList::containsOptimal() const
@@ -1220,6 +1384,43 @@ void tst_QList::replaceComplex() const
}
template<typename T>
+void tst_QList::reverseIterators() const
+{
+ QList<T> v;
+ v << T_CAT << T_DOG << T_BLAH << T_BAZ;
+ QList<T> vr = v;
+ std::reverse(vr.begin(), vr.end());
+ const QList<T> &cvr = vr;
+ QVERIFY(std::equal(v.begin(), v.end(), vr.rbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), vr.crbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), cvr.rbegin()));
+ QVERIFY(std::equal(vr.rbegin(), vr.rend(), v.begin()));
+ QVERIFY(std::equal(vr.crbegin(), vr.crend(), v.begin()));
+ QVERIFY(std::equal(cvr.rbegin(), cvr.rend(), v.begin()));
+}
+
+void tst_QList::reverseIteratorsOptimal() const
+{
+ const int liveCount = Optimal::getLiveCount();
+ reverseIterators<Optimal>();
+ QCOMPARE(liveCount, Optimal::getLiveCount());
+}
+
+void tst_QList::reverseIteratorsMovable() const
+{
+ const int liveCount = Movable::getLiveCount();
+ reverseIterators<Movable>();
+ QCOMPARE(liveCount, Movable::getLiveCount());
+}
+
+void tst_QList::reverseIteratorsComplex() const
+{
+ const int liveCount = Complex::getLiveCount();
+ reverseIterators<Complex>();
+ QCOMPARE(liveCount, Complex::getLiveCount());
+}
+
+template<typename T>
void tst_QList::startsWith() const
{
QList<T> list;
@@ -1576,6 +1777,19 @@ void tst_QList::testOperators() const
// []
QCOMPARE(list[0], T_FOO);
QCOMPARE(list[list.size() - 1], T_CAT);
+
+ // <, >, <=, >=
+ QVERIFY(!(list < listtwo));
+ QVERIFY(!(list > listtwo));
+ QVERIFY( list <= listtwo);
+ QVERIFY( list >= listtwo);
+ listtwo.push_back(T_CAT);
+ QVERIFY( list < listtwo);
+ QVERIFY(!(list > listtwo));
+ QVERIFY( list <= listtwo);
+ QVERIFY(!(list >= listtwo));
+ QVERIFY(listtwo > list);
+ QVERIFY(listtwo >= list);
}
void tst_QList::testOperatorsOptimal() const
@@ -1834,6 +2048,16 @@ void tst_QList::insertWithValidIteratorsOnSharedList() const
QCOMPARE(a.at(1), 15);
}
+template <typename T>
+void tst_QList::qhash() const
+{
+ QList<T> l1, l2;
+ QCOMPARE(qHash(l1), qHash(l2));
+ l1 << T_BAR;
+ l2 << T_BAR;
+ QCOMPARE(qHash(l1), qHash(l2));
+}
+
void tst_QList::reserve() const
{
// Note:
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index b1e13a0384..11b6922278 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -371,6 +371,8 @@ void tst_QLocale::ctor()
QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \
+ "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ QCOMPARE(l, QLocale(QLocale::exp_lang, QLocale::exp_country)); \
+ QCOMPARE(qHash(l), qHash(QLocale(QLocale::exp_lang, QLocale::exp_country))); \
}
QLocale::setDefault(QLocale(QLocale::C));
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index 8560a2f18c..bb6535b635 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -65,6 +65,7 @@ private slots:
void take();
void iterators();
+ void keyIterator();
void keys_values_uniqueKeys();
void qmultimap_specific();
@@ -835,6 +836,34 @@ void tst_QMap::iterators()
}
}
+void tst_QMap::keyIterator()
+{
+ QMap<int, int> map;
+
+ for (int i = 0; i < 100; ++i)
+ map.insert(i, i*100);
+
+ QMap<int, int>::key_iterator key_it = map.keyBegin();
+ QMap<int, int>::const_iterator it = map.cbegin();
+ for (int i = 0; i < 100; ++i) {
+ QCOMPARE(*key_it, it.key());
+ ++key_it;
+ ++it;
+ }
+
+ key_it = std::find(map.keyBegin(), map.keyEnd(), 50);
+ it = std::find(map.cbegin(), map.cend(), 50 * 100);
+
+ QVERIFY(key_it != map.keyEnd());
+ QCOMPARE(*key_it, it.key());
+ QCOMPARE(*(key_it++), (it++).key());
+ QCOMPARE(*(key_it--), (it--).key());
+ QCOMPARE(*(++key_it), (++it).key());
+ QCOMPARE(*(--key_it), (--it).key());
+
+ QCOMPARE(std::count(map.keyBegin(), map.keyEnd(), 99), 1);
+}
+
void tst_QMap::keys_values_uniqueKeys()
{
QMap<QString, int> map;
@@ -996,11 +1025,16 @@ void tst_QMap::const_shared_null()
void tst_QMap::equal_range()
{
QMap<int, QString> map;
+ const QMap<int, QString> &cmap = map;
QPair<QMap<int, QString>::iterator, QMap<int, QString>::iterator> result = map.equal_range(0);
QCOMPARE(result.first, map.end());
QCOMPARE(result.second, map.end());
+ QPair<QMap<int, QString>::const_iterator, QMap<int, QString>::const_iterator> cresult = cmap.equal_range(0);
+ QCOMPARE(cresult.first, cmap.cend());
+ QCOMPARE(cresult.second, cmap.cend());
+
map.insert(1, "one");
result = map.equal_range(0);
@@ -1015,6 +1049,18 @@ void tst_QMap::equal_range()
QCOMPARE(result.first, map.end());
QCOMPARE(result.second, map.end());
+ cresult = cmap.equal_range(0);
+ QCOMPARE(cresult.first, cmap.find(1));
+ QCOMPARE(cresult.second, cmap.find(1));
+
+ cresult = cmap.equal_range(1);
+ QCOMPARE(cresult.first, cmap.find(1));
+ QCOMPARE(cresult.second, cmap.cend());
+
+ cresult = cmap.equal_range(2);
+ QCOMPARE(cresult.first, cmap.cend());
+ QCOMPARE(cresult.second, cmap.cend());
+
for (int i = -10; i < 10; i += 2)
map.insert(i, QString("%1").arg(i));
@@ -1030,11 +1076,28 @@ void tst_QMap::equal_range()
QCOMPARE(result.first, map.find(2));
QCOMPARE(result.second, map.find(4));
+ cresult = cmap.equal_range(0);
+ QCOMPARE(cresult.first, cmap.find(0));
+ QCOMPARE(cresult.second, cmap.find(1));
+
+ cresult = cmap.equal_range(1);
+ QCOMPARE(cresult.first, cmap.find(1));
+ QCOMPARE(cresult.second, cmap.find(2));
+
+ cresult = cmap.equal_range(2);
+ QCOMPARE(cresult.first, cmap.find(2));
+ QCOMPARE(cresult.second, cmap.find(4));
+
map.insertMulti(1, "another one");
+
result = map.equal_range(1);
QCOMPARE(result.first, map.find(1));
QCOMPARE(result.second, map.find(2));
+ cresult = cmap.equal_range(1);
+ QCOMPARE(cresult.first, cmap.find(1));
+ QCOMPARE(cresult.second, cmap.find(2));
+
QCOMPARE(map.count(1), 2);
}
diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
index fefdec7496..b9a3fc13c5 100644
--- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
+++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
@@ -1224,6 +1224,9 @@ void tst_QRegExp::operator_eq()
for (int j = 0; j < I * J * K * ELL; ++j) {
QCOMPARE(rxtable[i] == rxtable[j], i / ELL == j / ELL);
QCOMPARE(rxtable[i] != rxtable[j], i / ELL != j / ELL);
+ // this just happens to have no hash collisions. If at some point
+ // we get collisions, restrict the test to only equal elements:
+ QCOMPARE(qHash(rxtable[i]) == qHash(rxtable[j]), i / ELL == j / ELL);
}
}
}
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index d185e64251..8ddd4979b6 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -1423,6 +1423,7 @@ static void verifyEquality(const QRegularExpression &re1, const QRegularExpressi
{
QVERIFY(re1 == re2);
QVERIFY(re2 == re1);
+ QCOMPARE(qHash(re1), qHash(re2));
QVERIFY(!(re1 != re2));
QVERIFY(!(re2 != re1));
@@ -1430,22 +1431,26 @@ static void verifyEquality(const QRegularExpression &re1, const QRegularExpressi
QVERIFY(re1 == re3);
QVERIFY(re3 == re1);
+ QCOMPARE(qHash(re1), qHash(re3));
QVERIFY(!(re1 != re3));
QVERIFY(!(re3 != re1));
QVERIFY(re2 == re3);
QVERIFY(re3 == re2);
+ QCOMPARE(qHash(re2), qHash(re3));
QVERIFY(!(re2 != re3));
QVERIFY(!(re3 != re2));
re3 = re2;
QVERIFY(re1 == re3);
QVERIFY(re3 == re1);
+ QCOMPARE(qHash(re1), qHash(re3));
QVERIFY(!(re1 != re3));
QVERIFY(!(re3 != re1));
QVERIFY(re2 == re3);
QVERIFY(re3 == re2);
+ QCOMPARE(qHash(re2), qHash(re3));
QVERIFY(!(re2 != re3));
QVERIFY(!(re3 != re2));
}
diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
index 8c29064457..77fc6ad6ae 100644
--- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
+++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
@@ -48,10 +48,12 @@ private slots:
void sizeWhenReserved();
void free();
void reserveAndRead();
+ void reserveFrontAndRead();
void chop();
void ungetChar();
void indexOf();
void appendAndRead();
+ void peek();
void readLine();
};
@@ -60,7 +62,7 @@ void tst_QRingBuffer::sizeWhenReserved()
QRingBuffer ringBuffer;
ringBuffer.reserve(5);
- QCOMPARE(ringBuffer.size(), 5);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(5));
}
void tst_QRingBuffer::sizeWhenReservedAndChopped()
@@ -69,14 +71,14 @@ void tst_QRingBuffer::sizeWhenReservedAndChopped()
ringBuffer.reserve(31337);
ringBuffer.chop(31337);
- QCOMPARE(ringBuffer.size(), 0);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(0));
}
void tst_QRingBuffer::sizeWhenEmpty()
{
QRingBuffer ringBuffer;
- QCOMPARE(ringBuffer.size(), 0);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(0));
}
void tst_QRingBuffer::readPointerAtPositionReadTooMuch()
@@ -86,7 +88,7 @@ void tst_QRingBuffer::readPointerAtPositionReadTooMuch()
qint64 length;
const char *buf = ringBuffer.readPointerAtPosition(42, length);
QVERIFY(buf == 0);
- QVERIFY(length == 0);
+ QCOMPARE(length, Q_INT64_C(0));
}
void tst_QRingBuffer::readPointerAtPositionWithHead()
@@ -101,22 +103,22 @@ void tst_QRingBuffer::readPointerAtPositionWithHead()
qint64 length;
const char* buf2 = ringBuffer.readPointerAtPosition(0, length);
- QCOMPARE(length, qint64(2));
- QVERIFY(*buf2 == '2');
- QVERIFY(*(buf2+1) == '3');
+ QCOMPARE(length, Q_INT64_C(2));
+ QCOMPARE(*buf2, '2');
+ QCOMPARE(*(buf2 + 1), '3');
// advance 2 more, ringBuffer should be empty then
ringBuffer.free(2);
buf2 = ringBuffer.readPointerAtPosition(0, length);
- QCOMPARE(length, qint64(0));
+ QCOMPARE(length, Q_INT64_C(0));
QVERIFY(buf2 == 0);
// check buffer with 2 blocks
memcpy(ringBuffer.reserve(4), "0123", 4);
ringBuffer.append(QByteArray("45678", 5));
ringBuffer.free(3);
- buf2 = ringBuffer.readPointerAtPosition(1, length);
- QCOMPARE(length, qint64(5));
+ buf2 = ringBuffer.readPointerAtPosition(Q_INT64_C(1), length);
+ QCOMPARE(length, Q_INT64_C(5));
}
void tst_QRingBuffer::readPointerAtPositionEmptyRead()
@@ -126,7 +128,7 @@ void tst_QRingBuffer::readPointerAtPositionEmptyRead()
qint64 length;
const char *buf = ringBuffer.readPointerAtPosition(0, length);
QVERIFY(buf == 0);
- QVERIFY(length == 0);
+ QCOMPARE(length, Q_INT64_C(0));
}
void tst_QRingBuffer::readPointerAtPositionWriteRead()
@@ -149,14 +151,14 @@ void tst_QRingBuffer::readPointerAtPositionWriteRead()
// write in chunks of 50 bytes
// this ensures there will be multiple QByteArrays inside the QRingBuffer
// since QRingBuffer is then only using individual arrays of around 4000 bytes
- qint64 thisWrite = qMin(remaining, qint64(50));
+ qint64 thisWrite = qMin(remaining, Q_INT64_C(50));
char *pos = ringBuffer.reserve(thisWrite);
inData.read(pos, thisWrite);
remaining -= thisWrite;
}
// was data put into it?
QVERIFY(ringBuffer.size() > 0);
- QCOMPARE(qint64(ringBuffer.size()), inData.size());
+ QCOMPARE(ringBuffer.size(), inData.size());
//read from the QRingBuffer in loop, put back into another QBuffer
QBuffer outData;
@@ -187,12 +189,12 @@ void tst_QRingBuffer::free()
ringBuffer.append(QByteArray("01234", 5));
ringBuffer.free(1);
- QCOMPARE(ringBuffer.size(), 4095 + 2048 + 5);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(4095 + 2048 + 5));
ringBuffer.free(4096);
- QCOMPARE(ringBuffer.size(), 2047 + 5);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(2047 + 5));
ringBuffer.free(48);
ringBuffer.free(2000);
- QCOMPARE(ringBuffer.size(), 4);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(4));
QVERIFY(memcmp(ringBuffer.readPointer(), "1234", 4) == 0);
}
@@ -211,11 +213,33 @@ void tst_QRingBuffer::reserveAndRead()
for (int i = 1; i < 256; ++i) {
QByteArray ba;
ba.resize(i);
- int thisRead = ringBuffer.read(ba.data(), i);
- QCOMPARE(thisRead, i);
- QVERIFY(ba.count(char(i)) == i);
+ qint64 thisRead = ringBuffer.read(ba.data(), i);
+ QCOMPARE(thisRead, qint64(i));
+ QCOMPARE(ba.count(char(i)), i);
}
- QVERIFY(ringBuffer.size() == 0);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(0));
+}
+
+void tst_QRingBuffer::reserveFrontAndRead()
+{
+ QRingBuffer ringBuffer;
+ // fill buffer with an arithmetic progression
+ for (int i = 1; i < 256; ++i) {
+ QByteArray ba(i, char(i));
+ char *ringPos = ringBuffer.reserveFront(i);
+ QVERIFY(ringPos);
+ memcpy(ringPos, ba.constData(), i);
+ }
+
+ // readback and check stored data
+ for (int i = 255; i > 0; --i) {
+ QByteArray ba;
+ ba.resize(i);
+ qint64 thisRead = ringBuffer.read(ba.data(), i);
+ QCOMPARE(thisRead, qint64(i));
+ QCOMPARE(ba.count(char(i)), i);
+ }
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(0));
}
void tst_QRingBuffer::chop()
@@ -227,12 +251,12 @@ void tst_QRingBuffer::chop()
ringBuffer.reserve(4096);
ringBuffer.chop(1);
- QCOMPARE(ringBuffer.size(), 5 + 2048 + 4095);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2048 + 4095));
ringBuffer.chop(4096);
- QCOMPARE(ringBuffer.size(), 5 + 2047);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2047));
ringBuffer.chop(48);
ringBuffer.chop(2000);
- QCOMPARE(ringBuffer.size(), 4);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(4));
QVERIFY(memcmp(ringBuffer.readPointer(), "0123", 4) == 0);
}
@@ -244,11 +268,11 @@ void tst_QRingBuffer::ungetChar()
for (int i = 1; i < 31; ++i) {
int c = ringBuffer.getChar();
- QVERIFY(c == 1);
+ QCOMPARE(c, 1);
ringBuffer.getChar();
ringBuffer.ungetChar(char(c)); // unget first char
}
- QCOMPARE(ringBuffer.size(), 1);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(1));
}
void tst_QRingBuffer::indexOf()
@@ -258,10 +282,10 @@ void tst_QRingBuffer::indexOf()
ringBuffer.putChar(char(i));
for (int i = 1; i < 256; ++i) {
- int index = ringBuffer.indexOf(char(i));
- QCOMPARE(i - 1, index);
- QCOMPARE(index, ringBuffer.indexOf(char(i), i));
- QVERIFY(ringBuffer.indexOf(char(i), i - 1) == -1); // test for absent char
+ qint64 index = ringBuffer.indexOf(char(i));
+ QCOMPARE(index, qint64(i - 1));
+ QCOMPARE(ringBuffer.indexOf(char(i), i), index);
+ QCOMPARE(ringBuffer.indexOf(char(i), i - 1), -1); // test for absent char
}
}
@@ -275,9 +299,34 @@ void tst_QRingBuffer::appendAndRead()
ringBuffer.append(ba2);
ringBuffer.append(ba3);
- QVERIFY(ringBuffer.read() == ba1);
- QVERIFY(ringBuffer.read() == ba2);
- QVERIFY(ringBuffer.read() == ba3);
+ QCOMPARE(ringBuffer.read(), ba1);
+ QCOMPARE(ringBuffer.read(), ba2);
+ QCOMPARE(ringBuffer.read(), ba3);
+}
+
+void tst_QRingBuffer::peek()
+{
+ QRingBuffer ringBuffer;
+ QByteArray testBuffer;
+ // fill buffer with an arithmetic progression
+ for (int i = 1; i < 256; ++i) {
+ char *ringPos = ringBuffer.reserve(i);
+ QVERIFY(ringPos);
+ memset(ringPos, i, i);
+ testBuffer.append(ringPos, i);
+ }
+
+ // check stored data
+ QByteArray resultBuffer;
+ int peekPosition = testBuffer.size();
+ for (int i = 1; i < 256; ++i) {
+ QByteArray ba(i, 0);
+ peekPosition -= i;
+ qint64 thisPeek = ringBuffer.peek(ba.data(), i, peekPosition);
+ QCOMPARE(thisPeek, qint64(i));
+ resultBuffer.prepend(ba);
+ }
+ QCOMPARE(resultBuffer, testBuffer);
}
void tst_QRingBuffer::readLine()
@@ -293,18 +342,18 @@ void tst_QRingBuffer::readLine()
char stringBuf[102];
stringBuf[101] = 0; // non-crash terminator
- QVERIFY(ringBuffer.readLine(stringBuf, sizeof(stringBuf) - 2) == ba1.size());
- QVERIFY(QByteArray(stringBuf, int(strlen(stringBuf))) == ba1);
+ QCOMPARE(ringBuffer.readLine(stringBuf, sizeof(stringBuf) - 2), qint64(ba1.size()));
+ QCOMPARE(QByteArray(stringBuf, int(strlen(stringBuf))), ba1);
// check first empty string reading
stringBuf[0] = char(0xFF);
- QCOMPARE(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2), ba2.size());
- QVERIFY(stringBuf[0] == ba2[0]);
+ QCOMPARE(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2), qint64(ba2.size()));
+ QCOMPARE(stringBuf[0], ba2.at(0));
- QVERIFY(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2) == (ba3.size() + ba4.size()
- + ba2.size()));
- QVERIFY(QByteArray(stringBuf, int(strlen(stringBuf))) == (ba3 + ba4 + ba2));
- QVERIFY(ringBuffer.size() == 0);
+ QCOMPARE(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2),
+ qint64(ba3.size() + ba4.size() + ba2.size()));
+ QCOMPARE(QByteArray(stringBuf, int(strlen(stringBuf))), ba3 + ba4 + ba2);
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(0));
}
QTEST_APPLESS_MAIN(tst_QRingBuffer)
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp
index f13d69514a..fe4d81085c 100644
--- a/tests/auto/corelib/tools/qset/tst_qset.cpp
+++ b/tests/auto/corelib/tools/qset/tst_qset.cpp
@@ -65,6 +65,7 @@ private slots:
void begin();
void end();
void insert();
+ void reverseIterators();
void setOperations();
void stlIterator();
void stlMutableIterator();
@@ -73,6 +74,7 @@ private slots:
void makeSureTheComfortFunctionsCompile();
void initializerList();
void qhash();
+ void intersects();
};
struct IdentityTracker {
@@ -554,6 +556,21 @@ void tst_QSet::insert()
}
}
+void tst_QSet::reverseIterators()
+{
+ QSet<int> s;
+ s << 1 << 17 << 61 << 127 << 911;
+ std::vector<int> v(s.begin(), s.end());
+ std::reverse(v.begin(), v.end());
+ const QSet<int> &cs = s;
+ QVERIFY(std::equal(v.begin(), v.end(), s.rbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), s.crbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), cs.rbegin()));
+ QVERIFY(std::equal(s.rbegin(), s.rend(), v.begin()));
+ QVERIFY(std::equal(s.crbegin(), s.crend(), v.begin()));
+ QVERIFY(std::equal(cs.rbegin(), cs.rend(), v.begin()));
+}
+
void tst_QSet::setOperations()
{
QSet<QString> set1, set2;
@@ -969,24 +986,6 @@ void tst_QSet::initializerList()
#endif
}
-QT_BEGIN_NAMESPACE
-extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed; // from qhash.cpp
-QT_END_NAMESPACE
-
-class QtQHashSeedSaver {
- int oldSeed, newSeed;
-public:
- explicit QtQHashSeedSaver(int seed)
- : oldSeed(qt_qhash_seed.fetchAndStoreRelaxed(seed)),
- newSeed(seed)
- {}
- ~QtQHashSeedSaver()
- {
- // only restore when no-one else changed the seed in the meantime:
- qt_qhash_seed.testAndSetRelaxed(newSeed, oldSeed);
- }
-};
-
void tst_QSet::qhash()
{
//
@@ -994,14 +993,14 @@ void tst_QSet::qhash()
//
{
// create some deterministic initial state:
- const QtQHashSeedSaver seed1(0);
+ qSetGlobalQHashSeed(0);
QSet<int> s1;
s1.reserve(4);
s1 << 400 << 300 << 200 << 100;
// also change the seed:
- const QtQHashSeedSaver seed2(0x10101010);
+ qSetGlobalQHashSeed(0x10101010);
QSet<int> s2;
s2.reserve(100); // provoke different bucket counts
@@ -1030,6 +1029,32 @@ void tst_QSet::qhash()
}
}
+void tst_QSet::intersects()
+{
+ QSet<int> s1;
+ QSet<int> s2;
+
+ QVERIFY(!s1.intersects(s1));
+ QVERIFY(!s1.intersects(s2));
+
+ s1 << 100;
+ QVERIFY(s1.intersects(s1));
+ QVERIFY(!s1.intersects(s2));
+
+ s2 << 200;
+ QVERIFY(!s1.intersects(s2));
+
+ s1 << 200;
+ QVERIFY(s1.intersects(s2));
+
+ qSetGlobalQHashSeed(0x10101010);
+ QSet<int> s3;
+ s3 << 500;
+ QVERIFY(!s1.intersects(s3));
+ s3 << 200;
+ QVERIFY(s1.intersects(s3));
+}
+
QTEST_APPLESS_MAIN(tst_QSet)
#include "tst_qset.moc"
diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
index c3a615fdff..2128eeb164 100644
--- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
@@ -641,6 +641,7 @@ namespace QTest {
make.setProcessChannelMode(channelMode);
static const char makes[] =
+ "jom.exe\0" //preferred for visual c++ or mingw
"nmake.exe\0" //for visual c++
"mingw32-make.exe\0" //for mingw
"gmake\0"
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 0d10a9c5bd..10747427c7 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -60,11 +60,241 @@
#include <qhash.h>
#include <string>
+#include <algorithm>
#define CREATE_REF(string) \
const QString padded = QString::fromLatin1(" %1 ").arg(string); \
QStringRef ref = padded.midRef(1, padded.size() - 2);
+namespace {
+
+// this wraps an argument to a QString function, as well as how to apply
+// the argument to a given QString member function.
+template <typename T>
+class Arg;
+
+template <typename T>
+class Reversed {}; // marker for Arg<QChar> to apply the operation in reverse order (for prepend())
+
+class ArgBase
+{
+protected:
+ QString pinned;
+ explicit ArgBase(const char *str)
+ : pinned(QString::fromLatin1(str)) {}
+};
+
+template <>
+class Arg<QChar> : protected ArgBase
+{
+public:
+ explicit Arg(const char *str) : ArgBase(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(ch); }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(a1, ch); }
+};
+
+template <>
+class Arg<Reversed<QChar> > : private Arg<QChar>
+{
+public:
+ explicit Arg(const char *str) : Arg<QChar>(str)
+ {
+ std::reverse(this->pinned.begin(), this->pinned.end());
+ }
+
+ using Arg<QChar>::apply0;
+ using Arg<QChar>::apply1;
+};
+
+template <>
+class Arg<QString> : ArgBase
+{
+public:
+ explicit Arg(const char *str) : ArgBase(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ { (s.*mf)(this->pinned); }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ { (s.*mf)(a1, this->pinned); }
+};
+
+template <>
+class Arg<QStringRef> : ArgBase
+{
+ QStringRef ref() const
+ { return this->pinned.isNull() ? QStringRef() : this->pinned.midRef(0) ; }
+public:
+ explicit Arg(const char *str) : ArgBase(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ { (s.*mf)(ref()); }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ { (s.*mf)(a1, ref()); }
+};
+
+template <>
+class Arg<QPair<const QChar *, int> > : ArgBase
+{
+public:
+ explicit Arg(const char *str) : ArgBase(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ { (s.*mf)(this->pinned.constData(), this->pinned.length()); }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ { (s.*mf)(a1, this->pinned.constData(), this->pinned.length()); }
+};
+
+template <>
+class Arg<QLatin1String>
+{
+ QLatin1String l1;
+public:
+ explicit Arg(const char *str) : l1(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ { (s.*mf)(l1); }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ { (s.*mf)(a1, l1); }
+};
+
+template <>
+class Arg<char>
+{
+protected:
+ const char *str;
+public:
+ explicit Arg(const char *str) : str(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ {
+ if (str) {
+ for (const char *it = str; *it; ++it)
+ (s.*mf)(*it);
+ }
+ }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ {
+ if (str) {
+ for (const char *it = str; *it; ++it)
+ (s.*mf)(a1, *it);
+ }
+ }
+};
+
+template <>
+class Arg<Reversed<char> > : private Arg<char>
+{
+ static const char *dupAndReverse(const char *s)
+ {
+ char *s2 = qstrdup(s);
+ std::reverse(s2, s2 + qstrlen(s2));
+ return s2;
+ }
+public:
+ explicit Arg(const char *str) : Arg<char>(dupAndReverse(str)) {}
+ ~Arg() { delete[] str; }
+
+ using Arg<char>::apply0;
+ using Arg<char>::apply1;
+};
+
+template <>
+class Arg<const char*>
+{
+ const char *str;
+public:
+ explicit Arg(const char *str) : str(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ { (s.*mf)(str); }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ { (s.*mf)(a1, str); }
+};
+
+template <>
+class Arg<QByteArray>
+{
+ QByteArray ba;
+public:
+ explicit Arg(const char *str) : ba(str) {}
+
+ template <typename MemFun>
+ void apply0(QString &s, MemFun mf) const
+ { (s.*mf)(ba); }
+
+ template <typename MemFun, typename A1>
+ void apply1(QString &s, MemFun mf, A1 a1) const
+ { (s.*mf)(a1, ba); }
+};
+
+// const char* is not allowed as columns in data-driven tests (causes static_assert failure),
+// so wrap it in a container (default ctor is a QMetaType/QVariant requirement):
+class CharStarContainer
+{
+ const char *str;
+public:
+ explicit Q_DECL_CONSTEXPR CharStarContainer(const char *s = Q_NULLPTR) : str(s) {}
+ Q_DECL_CONSTEXPR operator const char *() const { return str; }
+};
+
+} // unnamed namespace
+
+Q_DECLARE_METATYPE(CharStarContainer)
+
+// implementation helpers for append_impl/prepend_impl etc
+template <typename ArgType, typename MemFun>
+static void do_apply0(MemFun mf)
+{
+ QFETCH(QString, s);
+ QFETCH(CharStarContainer, arg);
+ QFETCH(QString, expected);
+
+ Arg<ArgType>(arg).apply0(s, mf);
+
+ QCOMPARE(s, expected);
+ QCOMPARE(s.isEmpty(), expected.isEmpty());
+ QCOMPARE(s.isNull(), expected.isNull());
+}
+
+template <typename ArgType, typename A1, typename MemFun>
+static void do_apply1(MemFun mf)
+{
+ QFETCH(QString, s);
+ QFETCH(CharStarContainer, arg);
+ QFETCH(A1, a1);
+ QFETCH(QString, expected);
+
+ Arg<ArgType>(arg).apply1(s, mf, a1);
+
+ QCOMPARE(s, expected);
+ QCOMPARE(s.isEmpty(), expected.isEmpty());
+ QCOMPARE(s.isNull(), expected.isNull());
+}
+
class tst_QString : public QObject
{
Q_OBJECT
@@ -73,6 +303,27 @@ class tst_QString : public QObject
void split_regexp(const QString &string, const QString &pattern, QStringList result);
template<typename List>
void split(const QString &string, const QString &separator, QStringList result);
+
+ template <typename ArgType, typename MemFun>
+ 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);
+ 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);
+ 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);
+ 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::*)(int, const ArgType&)>(); }
+ void insert_data(bool emptyIsNoop = false);
public:
tst_QString();
public slots:
@@ -121,19 +372,86 @@ private slots:
void remove_regexp_data();
void remove_regexp();
void swap();
- void prepend();
- void prepend_bytearray_data();
- void prepend_bytearray();
- void append();
- void append_bytearray_data();
- void append_bytearray();
- void operator_pluseq_bytearray_data();
- void operator_pluseq_bytearray();
+
+ void prepend_qstring() { prepend_impl<QString>(); }
+ void prepend_qstring_data() { prepend_data(true); }
+ void prepend_qstringref() { prepend_impl<QStringRef>(); }
+ void prepend_qstringref_data() { prepend_data(true); }
+ void prepend_qlatin1string() { prepend_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
+ void prepend_qlatin1string_data() { prepend_data(true); }
+ void prepend_qcharstar_int() { prepend_impl<QPair<const QChar *, int>, QString &(QString::*)(const QChar *, int)>(); }
+ void prepend_qcharstar_int_data() { prepend_data(true); }
+ void prepend_qchar() { prepend_impl<Reversed<QChar>, QString &(QString::*)(QChar)>(); }
+ void prepend_qchar_data() { prepend_data(true); }
+ void prepend_qbytearray() { prepend_impl<QByteArray>(); }
+ void prepend_qbytearray_data() { prepend_data(true); }
+ void prepend_char() { prepend_impl<Reversed<char>, QString &(QString::*)(QChar)>(); }
+ void prepend_char_data() { prepend_data(true); }
+ void prepend_charstar() { prepend_impl<const char *, QString &(QString::*)(const char *)>(); }
+ void prepend_charstar_data() { prepend_data(true); }
+ 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_qstringref() { append_impl<QStringRef>(); }
+ void append_qstringref_data() { append_data(); }
+ void append_qlatin1string() { append_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
+ void append_qlatin1string_data() { append_data(); }
+ void append_qcharstar_int() { append_impl<QPair<const QChar *, int>, QString&(QString::*)(const QChar *, int)>(); }
+ void append_qcharstar_int_data() { append_data(true); }
+ void append_qchar() { append_impl<QChar, QString &(QString::*)(QChar)>(); }
+ void append_qchar_data() { append_data(true); }
+ 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_charstar() { append_impl<const char *, QString &(QString::*)(const char *)>(); }
+ void append_charstar_data() { append_data(); }
+ void append_special_cases();
+ void append_bytearray_special_cases_data();
+ void append_bytearray_special_cases();
+
+ void operator_pluseq_qstring() { operator_pluseq_impl<QString>(); }
+ void operator_pluseq_qstring_data() { operator_pluseq_data(); }
+ void operator_pluseq_qstringref() { operator_pluseq_impl<QStringRef>(); }
+ void operator_pluseq_qstringref_data() { operator_pluseq_data(); }
+ void operator_pluseq_qlatin1string() { operator_pluseq_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); }
+ void operator_pluseq_qlatin1string_data() { operator_pluseq_data(); }
+ void operator_pluseq_qchar() { operator_pluseq_impl<QChar, QString &(QString::*)(QChar)>(); }
+ void operator_pluseq_qchar_data() { operator_pluseq_data(true); }
+ void operator_pluseq_qbytearray() { operator_pluseq_impl<QByteArray>(); }
+ void operator_pluseq_qbytearray_data() { operator_pluseq_data(); }
+ void operator_pluseq_char() { operator_pluseq_impl<char, QString &(QString::*)(char)>(); }
+ void operator_pluseq_char_data() { operator_pluseq_data(true); }
+ void operator_pluseq_charstar() { operator_pluseq_impl<const char *, QString &(QString::*)(const char *)>(); }
+ void operator_pluseq_charstar_data() { operator_pluseq_data(); }
+ void operator_pluseq_bytearray_special_cases_data();
+ void operator_pluseq_bytearray_special_cases();
+
void operator_eqeq_bytearray_data();
void operator_eqeq_bytearray();
void operator_eqeq_nullstring();
void operator_smaller();
- void insert();
+
+ void insert_qstring() { insert_impl<QString>(); }
+ void insert_qstring_data() { insert_data(true); }
+ void insert_qstringref() { insert_impl<QStringRef>(); }
+ void insert_qstringref_data() { insert_data(true); }
+ void insert_qlatin1string() { insert_impl<QLatin1String, QString &(QString::*)(int, QLatin1String)>(); }
+ void insert_qlatin1string_data() { insert_data(true); }
+ void insert_qcharstar_int() { insert_impl<QPair<const QChar *, int>, QString &(QString::*)(int, const QChar*, int) >(); }
+ void insert_qcharstar_int_data() { insert_data(true); }
+ void insert_qchar() { insert_impl<Reversed<QChar>, QString &(QString::*)(int, QChar)>(); }
+ void insert_qchar_data() { insert_data(true); }
+ void insert_qbytearray() { insert_impl<QByteArray>(); }
+ void insert_qbytearray_data() { insert_data(true); }
+ void insert_char() { insert_impl<Reversed<char>, QString &(QString::*)(int, QChar)>(); }
+ void insert_char_data() { insert_data(true); }
+ void insert_charstar() { insert_impl<const char *, QString &(QString::*)(int, const char*) >(); }
+ void insert_charstar_data() { insert_data(true); }
+ void insert_special_cases();
+
void simplified_data();
void simplified();
void trimmed();
@@ -183,6 +501,7 @@ private slots:
void fromLocal8Bit();
void local8Bit_data();
void local8Bit();
+ void nullFromLocal8Bit();
void fromLatin1Roundtrip_data();
void fromLatin1Roundtrip();
void toLatin1Roundtrip_data();
@@ -215,6 +534,7 @@ private slots:
void localeAwareCompare_data();
void localeAwareCompare();
#endif
+ void reverseIterators();
void split_data();
void split();
void split_regexp_data();
@@ -827,7 +1147,7 @@ void tst_QString::constructorQByteArray_data()
ba1[5] = 'e';
ba1[6] = 'f';
- QTest::newRow( "2" ) << ba1 << QString("abc");
+ QTest::newRow( "2" ) << ba1 << QStringLiteral("abc\0def");
QTest::newRow( "3" ) << QByteArray::fromRawData("abcd", 3) << QString("abc");
QTest::newRow( "4" ) << QByteArray("\xc3\xa9") << QString("\xc3\xa9");
@@ -848,12 +1168,6 @@ void tst_QString::constructorQByteArray()
QCOMPARE( strBA, expected );
// test operator= too
- if (src.constData()[src.length()] == '\0') {
- str1.clear();
- str1 = src.constData();
- QCOMPARE( str1, expected );
- }
-
strBA.clear();
strBA = src;
QCOMPARE( strBA, expected );
@@ -2066,7 +2380,46 @@ void tst_QString::simplified()
QCOMPARE(qMove(full).simplified(), simple);
}
-void tst_QString::insert()
+void tst_QString::insert_data(bool emptyIsNoop)
+{
+ QTest::addColumn<QString>("s");
+ QTest::addColumn<CharStarContainer>("arg");
+ QTest::addColumn<int>("a1");
+ QTest::addColumn<QString>("expected");
+
+ const CharStarContainer nullC;
+ const CharStarContainer emptyC("");
+ const CharStarContainer aC("a");
+ const CharStarContainer bC("b");
+ //const CharStarContainer abC("ab");
+ const CharStarContainer baC("ba");
+
+ const QString null;
+ const QString empty("");
+ const QString a("a");
+ const QString b("b");
+ const QString ab("ab");
+ const QString ba("ba");
+
+ 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;
+ QTest::newRow("empty.insert(0, null)") << empty << nullC << 0 << empty;
+ QTest::newRow("empty.insert(0, empty)") << empty << emptyC << 0 << empty;
+ QTest::newRow("empty.insert(0, a)") << empty << aC << 0 << a;
+ QTest::newRow("a.insert(0, null)") << a << nullC << 0 << a;
+ QTest::newRow("a.insert(0, empty)") << a << emptyC << 0 << a;
+ QTest::newRow("a.insert(0, b)") << a << bC << 0 << ba;
+ QTest::newRow("a.insert(0, ba)") << a << baC << 0 << (ba + a);
+ QTest::newRow("a.insert(1, null)") << a << nullC << 1 << a;
+ QTest::newRow("a.insert(1, empty)") << a << emptyC << 1 << a;
+ QTest::newRow("a.insert(1, b)") << a << bC << 1 << ab;
+ 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);
+}
+
+void tst_QString::insert_special_cases()
{
QString a;
@@ -2097,14 +2450,37 @@ void tst_QString::insert()
QCOMPARE(a.insert(0, QLatin1String("a")), QString("aMontreal"));
}
-void tst_QString::append()
+void tst_QString::append_data(bool emptyIsNoop)
{
- {
- QString a;
- a = "<>ABCABCABCABC";
- QCOMPARE(a.append(">"),QString("<>ABCABCABCABC>"));
- }
+ QTest::addColumn<QString>("s");
+ QTest::addColumn<CharStarContainer>("arg");
+ QTest::addColumn<QString>("expected");
+
+ const CharStarContainer nullC;
+ const CharStarContainer emptyC("");
+ const CharStarContainer aC("a");
+ const CharStarContainer bC("b");
+ //const CharStarContainer abC("ab");
+ const QString null;
+ const QString empty("");
+ const QString a("a");
+ //const QString b("b");
+ const QString ab("ab");
+
+ QTest::newRow("null + null") << null << nullC << null;
+ QTest::newRow("null + empty") << null << emptyC << (emptyIsNoop ? null : empty);
+ QTest::newRow("null + a") << null << aC << a;
+ QTest::newRow("empty + null") << empty << nullC << empty;
+ QTest::newRow("empty + empty") << empty << emptyC << empty;
+ QTest::newRow("empty + a") << empty << aC << a;
+ QTest::newRow("a + null") << a << nullC << a;
+ QTest::newRow("a + empty") << a << emptyC << a;
+ QTest::newRow("a + b") << a << bC << ab;
+}
+
+void tst_QString::append_special_cases()
+{
{
QString a;
static const QChar unicode[] = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!' };
@@ -2124,7 +2500,7 @@ void tst_QString::append()
}
}
-void tst_QString::append_bytearray_data()
+void tst_QString::append_bytearray_special_cases_data()
{
QTest::addColumn<QString>("str" );
QTest::addColumn<QByteArray>("ba" );
@@ -2158,7 +2534,7 @@ void tst_QString::append_bytearray_data()
QTest::newRow( "nonAsciiByteArray2") << QString() << QByteArray("\xc3\xa9") << QString::fromUtf8("\xc3\xa9");
}
-void tst_QString::append_bytearray()
+void tst_QString::append_bytearray_special_cases()
{
{
QFETCH( QString, str );
@@ -2176,22 +2552,19 @@ void tst_QString::append_bytearray()
QTEST( str, "res" );
}
+}
- QFETCH( QByteArray, ba );
- if (ba.constData()[ba.length()] == '\0') {
- QFETCH( QString, str );
-
- str.append(ba.constData());
- QTEST( str, "res" );
- }
+void tst_QString::operator_pluseq_data(bool emptyIsNoop)
+{
+ append_data(emptyIsNoop);
}
-void tst_QString::operator_pluseq_bytearray_data()
+void tst_QString::operator_pluseq_bytearray_special_cases_data()
{
- append_bytearray_data();
+ append_bytearray_special_cases_data();
}
-void tst_QString::operator_pluseq_bytearray()
+void tst_QString::operator_pluseq_bytearray_special_cases()
{
{
QFETCH( QString, str );
@@ -2209,14 +2582,6 @@ void tst_QString::operator_pluseq_bytearray()
QTEST( str, "res" );
}
-
- QFETCH( QByteArray, ba );
- if (ba.constData()[ba.length()] == '\0') {
- QFETCH( QString, str );
-
- str += ba.constData();
- QTEST( str, "res" );
- }
}
void tst_QString::operator_eqeq_bytearray_data()
@@ -2231,11 +2596,6 @@ void tst_QString::operator_eqeq_bytearray()
QVERIFY(expected == src);
QVERIFY(!(expected != src));
-
- if (src.constData()[src.length()] == '\0') {
- QVERIFY(expected == src.constData());
- QVERIFY(!(expected != src.constData()));
- }
}
void tst_QString::swap()
@@ -2248,14 +2608,37 @@ void tst_QString::swap()
QCOMPARE(s2,QLatin1String("s1"));
}
-void tst_QString::prepend()
+void tst_QString::prepend_data(bool emptyIsNoop)
{
- QString a;
- a = "<>ABCABCABCABC>";
- QCOMPARE(a.prepend("-"),(QString)"-<>ABCABCABCABC>");
+ QTest::addColumn<QString>("s");
+ QTest::addColumn<CharStarContainer>("arg");
+ QTest::addColumn<QString>("expected");
+
+ const CharStarContainer nullC;
+ const CharStarContainer emptyC("");
+ const CharStarContainer aC("a");
+ const CharStarContainer bC("b");
+ const CharStarContainer baC("ba");
+
+ const QString null;
+ const QString empty("");
+ const QString a("a");
+ //const QString b("b");
+ const QString ba("ba");
+
+ 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;
+ QTest::newRow("empty.prepend(null)") << empty << nullC << empty;
+ QTest::newRow("empty.prepend(empty)") << empty << emptyC << empty;
+ QTest::newRow("empty.prepend(a)") << empty << aC << a;
+ QTest::newRow("a.prepend(null)") << a << nullC << a;
+ 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);
}
-void tst_QString::prepend_bytearray_data()
+void tst_QString::prepend_bytearray_special_cases_data()
{
QTest::addColumn<QString>("str" );
QTest::addColumn<QByteArray>("ba" );
@@ -2270,7 +2653,7 @@ void tst_QString::prepend_bytearray_data()
// byte array with only a 0
ba.resize( 1 );
ba[0] = 0;
- QTest::newRow( "emptyString" ) << QString("foobar ") << ba << QString("foobar ");
+ QTest::newRow( "emptyString" ) << QString("foobar ") << ba << QStringLiteral("\0foobar ");
// empty byte array
ba.resize( 0 );
@@ -2281,7 +2664,7 @@ void tst_QString::prepend_bytearray_data()
QTest::newRow( "nonAsciiByteArray2") << QString() << QByteArray("\xc3\xa9") << QString::fromUtf8("\xc3\xa9");
}
-void tst_QString::prepend_bytearray()
+void tst_QString::prepend_bytearray_special_cases()
{
{
QFETCH( QString, str );
@@ -2300,14 +2683,6 @@ void tst_QString::prepend_bytearray()
QTEST( str, "res" );
}
-
- QFETCH( QByteArray, ba );
- if (ba.constData()[ba.length()] == '\0') {
- QFETCH( QString, str );
-
- str.prepend(ba.constData());
- QTEST( str, "res" );
- }
}
void tst_QString::replace_uint_uint()
@@ -3697,6 +4072,12 @@ void tst_QString::nullFromUtf8()
a = QString::fromUtf8("");
QVERIFY(!a.isNull());
QVERIFY(a.isEmpty());
+ a = QString::fromUtf8(QByteArray());
+ QVERIFY(a.isNull());
+ QVERIFY(a.isEmpty());
+ a = QString::fromUtf8(QByteArray(""));
+ QVERIFY(!a.isNull());
+ QVERIFY(a.isEmpty());
}
void tst_QString::fromLocal8Bit_data()
@@ -3779,6 +4160,23 @@ void tst_QString::local8Bit()
QCOMPARE(local8Bit.toLocal8Bit(), QByteArray(result));
}
+void tst_QString::nullFromLocal8Bit()
+{
+ QString a;
+ a = QString::fromLocal8Bit(0);
+ QVERIFY(a.isNull());
+ QVERIFY(a.isEmpty());
+ a = QString::fromLocal8Bit("");
+ QVERIFY(!a.isNull());
+ QVERIFY(a.isEmpty());
+ a = QString::fromLocal8Bit(QByteArray());
+ QVERIFY(a.isNull());
+ QVERIFY(a.isEmpty());
+ a = QString::fromLocal8Bit(QByteArray(""));
+ QVERIFY(!a.isNull());
+ QVERIFY(a.isEmpty());
+}
+
void tst_QString::stringRef_local8Bit_data()
{
local8Bit_data();
@@ -3945,6 +4343,12 @@ void tst_QString::fromLatin1()
a = QString::fromLatin1( "" );
QVERIFY( !a.isNull() );
QVERIFY( a.isEmpty() );
+ a = QString::fromLatin1(QByteArray());
+ QVERIFY(a.isNull());
+ QVERIFY(a.isEmpty());
+ a = QString::fromLatin1(QByteArray(""));
+ QVERIFY(!a.isNull());
+ QVERIFY(a.isEmpty());
a = QString::fromLatin1(0, 0);
QVERIFY(a.isNull());
@@ -5012,6 +5416,20 @@ void tst_QString::localeAwareCompare()
}
#endif //!defined(Q_OS_WIN) || defined(Q_OS_WIN_AND_WINCE)
+void tst_QString::reverseIterators()
+{
+ QString s = "1234";
+ QString sr = s;
+ std::reverse(sr.begin(), sr.end());
+ const QString &csr = sr;
+ QVERIFY(std::equal(s.begin(), s.end(), sr.rbegin()));
+ QVERIFY(std::equal(s.begin(), s.end(), sr.crbegin()));
+ QVERIFY(std::equal(s.begin(), s.end(), csr.rbegin()));
+ QVERIFY(std::equal(sr.rbegin(), sr.rend(), s.begin()));
+ QVERIFY(std::equal(sr.crbegin(), sr.crend(), s.begin()));
+ QVERIFY(std::equal(csr.rbegin(), csr.rend(), s.begin()));
+}
+
void tst_QString::split_data()
{
QTest::addColumn<QString>("str");
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm
index f4b748e62a..550f835bea 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm
+++ b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm
@@ -55,23 +55,19 @@ void tst_QString_macTypes()
}
// QString <-> NSString
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QString qtString("test string");
const NSString *nsString = qtString.toNSString();
QCOMPARE(QString::fromNSString(nsString), qtString);
-
- [pool release];
}
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QString qtString("test string");
const NSString *nsString = qtString.toNSString();
QString qtStringCopy(qtString);
qtString = qtString.toUpper(); // modify
QCOMPARE(QString::fromNSString(nsString), qtStringCopy);
-
- [pool release];
}
}
diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
index 7fc855a359..82d103c460 100644
--- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
+++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
@@ -82,6 +82,7 @@ private slots:
void integer_conversion_data();
void integer_conversion();
void trimmed();
+ void truncate();
void left();
void right();
void mid();
@@ -1839,6 +1840,30 @@ void tst_QStringRef::trimmed()
QCOMPARE(b.trimmed().compare(QStringLiteral("a")), 0);
}
+void tst_QStringRef::truncate()
+{
+ const QString str = "OriginalString~";
+ const QStringRef cref = str.midRef(0);
+ {
+ QStringRef ref = cref;
+ ref.truncate(1000);
+ QCOMPARE(ref, cref);
+ for (int i = str.size(); i >= 0; --i) {
+ ref.truncate(i);
+ QCOMPARE(ref.size(), i);
+ QCOMPARE(ref, cref.left(i));
+ }
+ QVERIFY(ref.isEmpty());
+ }
+
+ {
+ QStringRef ref = cref;
+ QVERIFY(!ref.isEmpty());
+ ref.truncate(-1);
+ QVERIFY(ref.isEmpty());
+ }
+}
+
void tst_QStringRef::left()
{
QString originalString = "OrginalString~";
diff --git a/tests/auto/corelib/tools/qtimeline/BLACKLIST b/tests/auto/corelib/tools/qtimeline/BLACKLIST
new file mode 100644
index 0000000000..b5861756d8
--- /dev/null
+++ b/tests/auto/corelib/tools/qtimeline/BLACKLIST
@@ -0,0 +1,4 @@
+[interpolation]
+windows
+[duration]
+windows
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index 975ed129fc..507f7e3992 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -208,7 +208,7 @@ void tst_QTimeLine::frameRate()
timeLine.start();
QTest::qWait(timeLine.duration()*2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- QVERIFY(slowCount < spy.count());
+ QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count()));
}
void tst_QTimeLine::value()
diff --git a/tests/auto/corelib/tools/qtimezone/BLACKLIST b/tests/auto/corelib/tools/qtimezone/BLACKLIST
new file mode 100644
index 0000000000..665e78bc08
--- /dev/null
+++ b/tests/auto/corelib/tools/qtimezone/BLACKLIST
@@ -0,0 +1,2 @@
+[tzTest]
+opensuse-13.1
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 94d81e0a5a..82f78b2b0b 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -47,10 +47,12 @@ private slots:
void appendCausingRealloc();
void resize();
void realloc();
+ void reverseIterators();
void count();
void first();
void last();
void squeeze();
+ void operators();
void indexOf();
void lastIndexOf();
void contains();
@@ -563,6 +565,21 @@ void tst_QVarLengthArray::realloc()
QVERIFY(reallocTestProceed);
}
+void tst_QVarLengthArray::reverseIterators()
+{
+ QVarLengthArray<int> v;
+ v << 1 << 2 << 3 << 4;
+ QVarLengthArray<int> vr = v;
+ std::reverse(vr.begin(), vr.end());
+ const QVarLengthArray<int> &cvr = vr;
+ QVERIFY(std::equal(v.begin(), v.end(), vr.rbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), vr.crbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), cvr.rbegin()));
+ QVERIFY(std::equal(vr.rbegin(), vr.rend(), v.begin()));
+ QVERIFY(std::equal(vr.crbegin(), vr.crend(), v.begin()));
+ QVERIFY(std::equal(cvr.rbegin(), cvr.rend(), v.begin()));
+}
+
void tst_QVarLengthArray::count()
{
// tests size(), count() and length(), since they're the same thing
@@ -691,6 +708,49 @@ void tst_QVarLengthArray::squeeze()
QCOMPARE(list.capacity(), sizeOnHeap);
}
+void tst_QVarLengthArray::operators()
+{
+ QVarLengthArray<QString> myvla;
+ myvla << "A" << "B" << "C";
+ QVarLengthArray<QString> myvlatwo;
+ myvlatwo << "D" << "E" << "F";
+ QVarLengthArray<QString> combined;
+ combined << "A" << "B" << "C" << "D" << "E" << "F";
+
+ // !=
+ QVERIFY(myvla != myvlatwo);
+
+ // +=: not provided, emulate
+ //myvla += myvlatwo;
+ Q_FOREACH (const QString &s, myvlatwo)
+ myvla.push_back(s);
+ QCOMPARE(myvla, combined);
+
+ // ==
+ QVERIFY(myvla == combined);
+
+ // <, >, <=, >=
+ QVERIFY(!(myvla < combined));
+ QVERIFY(!(myvla > combined));
+ QVERIFY( myvla <= combined);
+ QVERIFY( myvla >= combined);
+ combined.push_back("G");
+ QVERIFY( myvla < combined);
+ QVERIFY(!(myvla > combined));
+ QVERIFY( myvla <= combined);
+ QVERIFY(!(myvla >= combined));
+ QVERIFY(combined > myvla);
+ QVERIFY(combined >= myvla);
+
+ // []
+ QCOMPARE(myvla[0], QLatin1String("A"));
+ QCOMPARE(myvla[1], QLatin1String("B"));
+ QCOMPARE(myvla[2], QLatin1String("C"));
+ QCOMPARE(myvla[3], QLatin1String("D"));
+ QCOMPARE(myvla[4], QLatin1String("E"));
+ QCOMPARE(myvla[5], QLatin1String("F"));
+}
+
void tst_QVarLengthArray::indexOf()
{
QVarLengthArray<QString> myvec;
diff --git a/tests/auto/corelib/tools/qvector/qvector.pro b/tests/auto/corelib/tools/qvector/qvector.pro
index 22edde3412..c1e0564915 100644
--- a/tests/auto/corelib/tools/qvector/qvector.pro
+++ b/tests/auto/corelib/tools/qvector/qvector.pro
@@ -1,4 +1,5 @@
CONFIG += testcase parallel_test
+contains(QT_CONFIG, c++11):CONFIG += c++11
TARGET = tst_qvector
QT = core testlib
SOURCES = $$PWD/tst_qvector.cpp
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 69da6e450e..87822bca6f 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -86,6 +86,8 @@ private:
}
};
+inline uint qHash(const Movable &key, uint seed = 0) { return qHash(key.i, seed); }
+
QAtomicInt Movable::counter = 0;
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(Movable, Q_MOVABLE_TYPE);
@@ -123,6 +125,13 @@ struct Custom {
return i == other.i;
}
+ bool operator<(const Custom &other) const
+ {
+ check(&other);
+ check(this);
+ return i < other.i;
+ }
+
Custom &operator=(const Custom &other)
{
check(&other);
@@ -148,6 +157,8 @@ private:
};
QAtomicInt Custom::counter = 0;
+inline uint qHash(const Custom &key, uint seed = 0) { return qHash(key.i, seed); }
+
Q_DECLARE_METATYPE(Custom);
// tests depends on the fact that:
@@ -179,6 +190,7 @@ private slots:
void appendInt() const;
void appendMovable() const;
void appendCustom() const;
+ void appendRvalue() const;
void at() const;
void capacityInt() const;
void capacityMovable() const;
@@ -187,6 +199,8 @@ private slots:
void clearMovable() const;
void clearCustom() const;
void constData() const;
+ void constFirst() const;
+ void constLast() const;
void contains() const;
void countInt() const;
void countMovable() const;
@@ -227,9 +241,15 @@ private slots:
void last() const;
void lastIndexOf() const;
void mid() const;
+ void moveInt() const;
+ void moveMovable() const;
+ void moveCustom() const;
void prependInt() const;
void prependMovable() const;
void prependCustom() const;
+ void qhashInt() const { qhash<int>(); }
+ void qhashMovable() const { qhash<Movable>(); }
+ void qhashCustom() const { qhash<Custom>(); }
void removeInt() const;
void removeMovable() const;
void removeCustom() const;
@@ -241,6 +261,7 @@ private slots:
void resizeComplex_data() const;
void resizeComplex() const;
void resizeCtorAndDtor() const;
+ void reverseIterators() const;
void sizeInt() const;
void sizeMovable() const;
void sizeCustom() const;
@@ -294,6 +315,8 @@ private:
template<typename T> void fill() const;
template<typename T> void fromList() const;
template<typename T> void insert() const;
+ template<typename T> void qhash() const;
+ template<typename T> void move() const;
template<typename T> void prepend() const;
template<typename T> void remove() const;
template<typename T> void size() const;
@@ -332,6 +355,14 @@ const Movable SimpleValue<Movable>::Values[] = { 110, 105, 101, 114, 111, 98 };
template<>
const Custom SimpleValue<Custom>::Values[] = { 110, 105, 101, 114, 111, 98 };
+// Make some macros for the tests to use in order to be slightly more readable...
+#define T_FOO SimpleValue<T>::at(0)
+#define T_BAR SimpleValue<T>::at(1)
+#define T_BAZ SimpleValue<T>::at(2)
+#define T_CAT SimpleValue<T>::at(3)
+#define T_DOG SimpleValue<T>::at(4)
+#define T_BLAH SimpleValue<T>::at(5)
+
void tst_QVector::constructors_empty() const
{
QVector<int> emptyInt;
@@ -608,6 +639,21 @@ void tst_QVector::appendCustom() const
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
+void tst_QVector::appendRvalue() const
+{
+#ifdef Q_COMPILER_RVALUE_REFS
+ QVector<QString> v;
+ v.append("hello");
+ QString world = "world";
+ v.append(std::move(world));
+ QVERIFY(world.isEmpty());
+ QCOMPARE(v.front(), QString("hello"));
+ QCOMPARE(v.back(), QString("world"));
+#else
+ QSKIP("This test requires that C++11 move semantics support is enabled in the compiler");
+#endif
+}
+
void tst_QVector::at() const
{
QVector<QString> myvec;
@@ -1206,16 +1252,86 @@ void tst_QVector::first() const
// test it starts ok
QCOMPARE(myvec.first(), 69);
+ QCOMPARE(myvec.constFirst(), 69);
// test removal changes
myvec.remove(0);
QCOMPARE(myvec.first(), 42);
+ QCOMPARE(myvec.constFirst(), 42);
// test prepend changes
myvec.prepend(23);
QCOMPARE(myvec.first(), 23);
+ QCOMPARE(myvec.constFirst(), 23);
+}
+
+void tst_QVector::constFirst() const
+{
+ QVector<int> myvec;
+ myvec << 69 << 42 << 3;
+
+ // test it starts ok
+ QCOMPARE(myvec.constFirst(), 69);
+ QVERIFY(myvec.isDetached());
+
+ QVector<int> myvecCopy = myvec;
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ QCOMPARE(myvec.constFirst(), 69);
+ QCOMPARE(myvecCopy.constFirst(), 69);
+
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ // test removal changes
+ myvec.remove(0);
+ QVERIFY(myvec.isDetached());
+ QVERIFY(!myvec.isSharedWith(myvecCopy));
+ QCOMPARE(myvec.constFirst(), 42);
+ QCOMPARE(myvecCopy.constFirst(), 69);
+
+ myvecCopy = myvec;
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ QCOMPARE(myvec.constFirst(), 42);
+ QCOMPARE(myvecCopy.constFirst(), 42);
+
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ // test prepend changes
+ myvec.prepend(23);
+ QVERIFY(myvec.isDetached());
+ QVERIFY(!myvec.isSharedWith(myvecCopy));
+ QCOMPARE(myvec.constFirst(), 23);
+ QCOMPARE(myvecCopy.constFirst(), 42);
+
+ myvecCopy = myvec;
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ QCOMPARE(myvec.constFirst(), 23);
+ QCOMPARE(myvecCopy.constFirst(), 23);
+
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
}
+
template<typename T>
void tst_QVector::fromList() const
{
@@ -1393,14 +1509,83 @@ void tst_QVector::last() const
// test starts ok
QCOMPARE(myvec.last(), QLatin1String("C"));
+ QCOMPARE(myvec.constLast(), QLatin1String("C"));
// test it changes ok
myvec.append(QLatin1String("X"));
QCOMPARE(myvec.last(), QLatin1String("X"));
+ QCOMPARE(myvec.constLast(), QLatin1String("X"));
// and remove again
myvec.remove(3);
QCOMPARE(myvec.last(), QLatin1String("C"));
+ QCOMPARE(myvec.constLast(), QLatin1String("C"));
+}
+
+void tst_QVector::constLast() const
+{
+ QVector<int> myvec;
+ myvec << 69 << 42 << 3;
+
+ // test it starts ok
+ QCOMPARE(myvec.constLast(), 3);
+ QVERIFY(myvec.isDetached());
+
+ QVector<int> myvecCopy = myvec;
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ QCOMPARE(myvec.constLast(), 3);
+ QCOMPARE(myvecCopy.constLast(), 3);
+
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ // test removal changes
+ myvec.removeLast();
+ QVERIFY(myvec.isDetached());
+ QVERIFY(!myvec.isSharedWith(myvecCopy));
+ QCOMPARE(myvec.constLast(), 42);
+ QCOMPARE(myvecCopy.constLast(), 3);
+
+ myvecCopy = myvec;
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ QCOMPARE(myvec.constLast(), 42);
+ QCOMPARE(myvecCopy.constLast(), 42);
+
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ // test prepend changes
+ myvec.append(23);
+ QVERIFY(myvec.isDetached());
+ QVERIFY(!myvec.isSharedWith(myvecCopy));
+ QCOMPARE(myvec.constLast(), 23);
+ QCOMPARE(myvecCopy.constLast(), 42);
+
+ myvecCopy = myvec;
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
+
+ QCOMPARE(myvec.constLast(), 23);
+ QCOMPARE(myvecCopy.constLast(), 23);
+
+ QVERIFY(!myvec.isDetached());
+ QVERIFY(!myvecCopy.isDetached());
+ QVERIFY(myvec.isSharedWith(myvecCopy));
+ QVERIFY(myvecCopy.isSharedWith(myvec));
}
void tst_QVector::lastIndexOf() const
@@ -1437,6 +1622,54 @@ void tst_QVector::mid() const
QCOMPARE(list.mid(4), QVector<QString>() << "buck" << "hello" << "kitty");
}
+template <typename T>
+void tst_QVector::qhash() const
+{
+ QVector<T> l1, l2;
+ QCOMPARE(qHash(l1), qHash(l2));
+ l1 << SimpleValue<T>::at(0);
+ l2 << SimpleValue<T>::at(0);
+ QCOMPARE(qHash(l1), qHash(l2));
+}
+
+template <typename T>
+void tst_QVector::move() const
+{
+ QVector<T> list;
+ list << T_FOO << T_BAR << T_BAZ;
+
+ // move an item
+ list.move(0, list.count() - 1);
+ QCOMPARE(list, QVector<T>() << T_BAR << T_BAZ << T_FOO);
+
+ // move it back
+ list.move(list.count() - 1, 0);
+ QCOMPARE(list, QVector<T>() << T_FOO << T_BAR << T_BAZ);
+
+ // move an item in the middle
+ list.move(1, 0);
+ QCOMPARE(list, QVector<T>() << T_BAR << T_FOO << T_BAZ);
+}
+
+void tst_QVector::moveInt() const
+{
+ move<int>();
+}
+
+void tst_QVector::moveMovable() const
+{
+ const int instancesCount = Movable::counter.loadAcquire();
+ move<Movable>();
+ QCOMPARE(instancesCount, Movable::counter.loadAcquire());
+}
+
+void tst_QVector::moveCustom() const
+{
+ const int instancesCount = Custom::counter.loadAcquire();
+ move<Custom>();
+ QCOMPARE(instancesCount, Custom::counter.loadAcquire());
+}
+
template<typename T>
void tst_QVector::prepend() const
{
@@ -1907,6 +2140,21 @@ void tst_QVector::resizeCtorAndDtor() const
QCOMPARE(Custom::counter.loadAcquire(), items);
}
+void tst_QVector::reverseIterators() const
+{
+ QVector<int> v;
+ v << 1 << 2 << 3 << 4;
+ QVector<int> vr = v;
+ std::reverse(vr.begin(), vr.end());
+ const QVector<int> &cvr = vr;
+ QVERIFY(std::equal(v.begin(), v.end(), vr.rbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), vr.crbegin()));
+ QVERIFY(std::equal(v.begin(), v.end(), cvr.rbegin()));
+ QVERIFY(std::equal(vr.rbegin(), vr.rend(), v.begin()));
+ QVERIFY(std::equal(vr.crbegin(), vr.crend(), v.begin()));
+ QVERIFY(std::equal(cvr.rbegin(), cvr.rend(), v.begin()));
+}
+
template<typename T>
void tst_QVector::size() const
{
@@ -2076,6 +2324,19 @@ void tst_QVector::testOperators() const
// ==
QVERIFY(myvec == combined);
+ // <, >, <=, >=
+ QVERIFY(!(myvec < combined));
+ QVERIFY(!(myvec > combined));
+ QVERIFY( myvec <= combined);
+ QVERIFY( myvec >= combined);
+ combined.push_back("G");
+ QVERIFY( myvec < combined);
+ QVERIFY(!(myvec > combined));
+ QVERIFY( myvec <= combined);
+ QVERIFY(!(myvec >= combined));
+ QVERIFY(combined > myvec);
+ QVERIFY(combined >= myvec);
+
// []
QCOMPARE(myvec[0], QLatin1String("A"));
QCOMPARE(myvec[1], QLatin1String("B"));
diff --git a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro
index 1e74d42bbd..ba4b2b40cb 100644
--- a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro
+++ b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro
@@ -1,4 +1,5 @@
CONFIG += testcase parallel_test
+contains(QT_CONFIG, c++11):CONFIG += c++11 c++14
TARGET = tst_qversionnumber
-QT = core-private testlib
+QT = core testlib
SOURCES = tst_qversionnumber.cpp
diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
index 4202b87b2d..0b8b63a1e8 100644
--- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
+++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
@@ -33,7 +33,7 @@
****************************************************************************/
#include <QtTest/QtTest>
-#include <private/qversionnumber_p.h>
+#include <QtCore/qversionnumber.h>
class tst_QVersionNumber : public QObject
{
diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro
index cd845d7043..bd1fef5193 100644
--- a/tests/auto/dbus/dbus.pro
+++ b/tests/auto/dbus/dbus.pro
@@ -3,6 +3,7 @@ SUBDIRS=\
qdbusabstractadaptor \
qdbusabstractinterface \
qdbusconnection \
+ qdbusconnection_no_app \
qdbusconnection_no_bus \
qdbuscontext \
qdbusinterface \
@@ -16,7 +17,7 @@ SUBDIRS=\
qdbusservicewatcher \
qdbustype \
qdbusthreading \
- qdbusxmlparser \
+ qdbusxmlparser
!contains(QT_CONFIG,private_tests): SUBDIRS -= \
qdbusmarshall \
diff --git a/tests/auto/dbus/qdbusabstractadaptor/BLACKLIST b/tests/auto/dbus/qdbusabstractadaptor/BLACKLIST
new file mode 100644
index 0000000000..d3d970f4f4
--- /dev/null
+++ b/tests/auto/dbus/qdbusabstractadaptor/BLACKLIST
@@ -0,0 +1,2 @@
+[overloadedSignalEmission]
+linux
diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
index e51d03c811..d26af847cf 100644
--- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
+++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
@@ -346,7 +346,7 @@ void syncPeer()
// wait for the sync signal with the right ID
QEventLoop loop;
QDBusConnection con("peer");
- con.connect(serviceName, objectPath, interfaceName, "syncReceived",
+ con.connect(QString(), objectPath, interfaceName, "syncReceived",
QStringList() << reqId, QString(), &loop, SLOT(quit()));
QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "requestSync");
diff --git a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
index 403e500d8c..cd23f2cb47 100644
--- a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
+++ b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
@@ -1012,8 +1012,14 @@ void tst_QDBusAbstractInterface::followSignal()
QVERIFY(!con.interface()->isServiceRegistered(serviceToFollow));
Pinger control = getPinger("");
- // we need to connect the signal somewhere in order for D-Bus to enable the rules
- QTestEventLoop::instance().connect(p.data(), SIGNAL(voidSignal()), SLOT(exitLoop()));
+ // connect our test signal
+ // FRAGILE CODE AHEAD:
+ // Connection order is important: we connect the control first because that
+ // needs to be delivered last, to ensure that we don't exitLoop() before
+ // the signal delivery to QSignalSpy is posted to the current thread. That
+ // happens because QDBusConnectionPrivate runs in a separate thread and
+ // uses a QMultiHash and insertMulti prepends to the list of items with the
+ // same key.
QTestEventLoop::instance().connect(control.data(), SIGNAL(voidSignal()), SLOT(exitLoop()));
QSignalSpy s(p.data(), SIGNAL(voidSignal()));
diff --git a/tests/auto/dbus/qdbusconnection/qdbusconnection.pro b/tests/auto/dbus/qdbusconnection/qdbusconnection.pro
index 2fd62a234b..83ae29de0a 100644
--- a/tests/auto/dbus/qdbusconnection/qdbusconnection.pro
+++ b/tests/auto/dbus/qdbusconnection/qdbusconnection.pro
@@ -2,4 +2,5 @@ CONFIG += testcase
TARGET = tst_qdbusconnection
QT = core dbus testlib
SOURCES += tst_qdbusconnection.cpp
+HEADERS += tst_qdbusconnection.h
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
index 32c228c186..e91f87d6c8 100644
--- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
+++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Intel Corporation.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -30,34 +31,15 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
+#include "tst_qdbusconnection.h"
+
#include <qcoreapplication.h>
#include <qdebug.h>
#include <QtTest/QtTest>
#include <QtDBus/QtDBus>
-class BaseObject: public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "local.BaseObject")
-public:
- BaseObject(QObject *parent = 0) : QObject(parent) { }
-public slots:
- void anotherMethod() { }
-};
-
-class MyObject: public BaseObject
-{
- Q_OBJECT
-public slots:
- void method(const QDBusMessage &msg);
-
-public:
- static QString path;
- int callCount;
- MyObject(QObject *parent = 0) : BaseObject(parent), callCount(0) {}
-};
-
void MyObject::method(const QDBusMessage &msg)
{
path = msg.path();
@@ -65,19 +47,6 @@ void MyObject::method(const QDBusMessage &msg)
//qDebug() << msg;
}
-class MyObjectWithoutInterface: public QObject
-{
- Q_OBJECT
-public slots:
- void method(const QDBusMessage &msg);
-
-public:
- static QString path;
- static QString interface;
- int callCount;
- MyObjectWithoutInterface(QObject *parent = 0) : QObject(parent), callCount(0) {}
-};
-
void MyObjectWithoutInterface::method(const QDBusMessage &msg)
{
path = msg.path();
@@ -86,70 +55,6 @@ void MyObjectWithoutInterface::method(const QDBusMessage &msg)
//qDebug() << msg;
}
-class tst_QDBusConnection: public QObject
-{
- Q_OBJECT
-
- int signalsReceived;
-public slots:
- void oneSlot() { ++signalsReceived; }
- void exitLoop() { ++signalsReceived; QTestEventLoop::instance().exitLoop(); }
- void secondCallWithCallback();
-
-private slots:
- void noConnection();
- void connectToBus();
- void connectToPeer();
- void connect();
- void send();
- void sendWithGui();
- void sendAsync();
- void sendSignal();
-
- void registerObject_data();
- void registerObject();
- void registerObjectWithInterface_data();
- void registerObjectWithInterface();
- void registerObjectPeer_data();
- void registerObjectPeer();
- void registerObject2();
- void registerObjectPeer2();
-
- void registerQObjectChildren();
- void registerQObjectChildrenPeer();
-
- void callSelf();
- void callSelfByAnotherName_data();
- void callSelfByAnotherName();
- void multipleInterfacesInQObject();
-
- void slotsWithLessParameters();
- void nestedCallWithCallback();
-
- void serviceRegistrationRaceCondition();
-
- void registerVirtualObject();
- void callVirtualObject();
- void callVirtualObjectLocal();
-
-public:
- QString serviceName() const { return "org.qtproject.Qt.Autotests.QDBusConnection"; }
- bool callMethod(const QDBusConnection &conn, const QString &path);
- bool callMethod(const QDBusConnection &conn, const QString &path, const QString &interface);
- bool callMethodPeer(const QDBusConnection &conn, const QString &path);
-};
-
-class QDBusSpy: public QObject
-{
- Q_OBJECT
-public slots:
- void handlePing(const QString &str) { args.clear(); args << str; }
- void asyncReply(const QDBusMessage &msg) { args = msg.arguments(); }
-
-public:
- QList<QVariant> args;
-};
-
void tst_QDBusConnection::noConnection()
{
QDBusConnection con = QDBusConnection::connectToBus("unix:path=/dev/null", "testconnection");
@@ -185,8 +90,55 @@ void tst_QDBusConnection::sendSignal()
msg << QLatin1String("ping");
QVERIFY(con.send(msg));
+}
+
+void tst_QDBusConnection::sendSignalToName()
+{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication"); // because of the qWait()
+
+ QDBusSpy spy;
+
+ QDBusConnection con = QDBusConnection::sessionBus();
+
+ con.connect(con.baseService(), "/org/kde/selftest", "org.kde.selftest", "ping", &spy,
+ SLOT(handlePing(QString)));
+
+ QDBusMessage msg =
+ QDBusMessage::createTargetedSignal(con.baseService(), "/org/kde/selftest",
+ "org.kde.selftest", "ping");
+ msg << QLatin1String("ping");
+
+ QVERIFY(con.send(msg));
+
+ QTest::qWait(1000);
+
+ QCOMPARE(spy.args.count(), 1);
+ QCOMPARE(spy.args.at(0).toString(), QString("ping"));
+}
+
+void tst_QDBusConnection::sendSignalToOtherName()
+{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication"); // because of the qWait()
+
+ QDBusSpy spy;
+
+ QDBusConnection con = QDBusConnection::sessionBus();
+
+ con.connect(con.baseService(), "/org/kde/selftest", "org.kde.selftest", "ping", &spy,
+ SLOT(handlePing(QString)));
+
+ QDBusMessage msg =
+ QDBusMessage::createTargetedSignal("some.other.service", "/org/kde/selftest",
+ "org.kde.selftest", "ping");
+ msg << QLatin1String("ping");
+
+ QVERIFY(con.send(msg));
QTest::qWait(1000);
+
+ QCOMPARE(spy.args.count(), 0);
}
void tst_QDBusConnection::send()
@@ -207,6 +159,9 @@ void tst_QDBusConnection::send()
void tst_QDBusConnection::sendWithGui()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
QDBusConnection con = QDBusConnection::sessionBus();
QVERIFY(con.isConnected());
@@ -223,6 +178,9 @@ void tst_QDBusConnection::sendWithGui()
void tst_QDBusConnection::sendAsync()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
QDBusConnection con = QDBusConnection::sessionBus();
QVERIFY(con.isConnected());
@@ -244,6 +202,9 @@ void tst_QDBusConnection::connect()
QDBusConnection con = QDBusConnection::sessionBus();
+ if (!QCoreApplication::instance())
+ return; // cannot receive signals in this thread without QCoreApplication
+
con.connect(con.baseService(), "/org/kde/selftest", "org.kde.selftest", "ping", &spy,
SLOT(handlePing(QString)));
@@ -437,58 +398,6 @@ void tst_QDBusConnection::registerObjectWithInterface()
QVERIFY(!callMethod(con, path, interface));
}
-class MyServer : public QDBusServer
-{
- Q_OBJECT
-public:
- MyServer(QString path) : m_path(path), m_connections()
- {
- connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection)));
- }
-
- bool registerObject(const QDBusConnection& c)
- {
- QDBusConnection conn(c);
- if (!conn.registerObject(m_path, &m_obj, QDBusConnection::ExportAllSlots))
- return false;
- if (!(conn.objectRegisteredAt(m_path) == &m_obj))
- return false;
- return true;
- }
-
- bool registerObject()
- {
- Q_FOREACH (const QString &name, m_connections) {
- if (!registerObject(QDBusConnection(name)))
- return false;
- }
- return true;
- }
-
- void unregisterObject()
- {
- Q_FOREACH (const QString &name, m_connections) {
- QDBusConnection c(name);
- c.unregisterObject(m_path);
- }
- }
-
-public slots:
- void handleConnection(const QDBusConnection& c)
- {
- m_connections << c.name();
- QVERIFY(isConnected());
- QVERIFY(c.isConnected());
- QVERIFY(registerObject(c));
- }
-
-private:
- MyObject m_obj;
- QString m_path;
- QStringList m_connections;
-};
-
-
void tst_QDBusConnection::registerObjectPeer_data()
{
QTest::addColumn<QString>("path");
@@ -502,16 +411,22 @@ void tst_QDBusConnection::registerObjectPeer_data()
void tst_QDBusConnection::registerObjectPeer()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
QFETCH(QString, path);
MyServer server(path);
QDBusConnection::connectToPeer(server.address(), "beforeFoo");
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
{
QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo");
- QCoreApplication::processEvents();
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(con.isConnected());
MyObject obj;
@@ -520,6 +435,7 @@ void tst_QDBusConnection::registerObjectPeer()
}
QDBusConnection::connectToPeer(server.address(), "afterFoo");
+ QTestEventLoop::instance().enterLoop(2);
{
QDBusConnection con("foo");
@@ -572,7 +488,6 @@ void tst_QDBusConnection::registerObject2()
MyObject obj;
QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethod(con, "/"));
- qDebug() << obj.path;
QCOMPARE(obj.path, QString("/"));
}
// make sure it's gone
@@ -584,7 +499,6 @@ void tst_QDBusConnection::registerObject2()
QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(!callMethod(con, "/"));
QVERIFY(callMethod(con, "/p1"));
- qDebug() << obj.path;
QCOMPARE(obj.path, QString("/p1"));
// re-register it somewhere else
@@ -648,38 +562,15 @@ void tst_QDBusConnection::registerObject2()
}
}
-class MyServer2 : public QDBusServer
-{
- Q_OBJECT
-public:
- MyServer2() : m_conn("none")
- {
- connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection)));
- }
-
- QDBusConnection connection()
- {
- return m_conn;
- }
-
-public slots:
- void handleConnection(const QDBusConnection& c)
- {
- m_conn = c;
- QVERIFY(isConnected());
- QVERIFY(m_conn.isConnected());
- }
-
-private:
- MyObject m_obj;
- QDBusConnection m_conn;
-};
-
void tst_QDBusConnection::registerObjectPeer2()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
MyServer2 server;
QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo");
- QCoreApplication::processEvents();
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(con.isConnected());
QDBusConnection srv_con = server.connection();
@@ -696,7 +587,6 @@ void tst_QDBusConnection::registerObjectPeer2()
MyObject obj;
QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethodPeer(srv_con, "/"));
- qDebug() << obj.path;
QCOMPARE(obj.path, QString("/"));
}
// make sure it's gone
@@ -708,7 +598,6 @@ void tst_QDBusConnection::registerObjectPeer2()
QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(!callMethodPeer(srv_con, "/"));
QVERIFY(callMethodPeer(srv_con, "/p1"));
- qDebug() << obj.path;
QCOMPARE(obj.path, QString("/p1"));
// re-register it somewhere else
@@ -832,8 +721,13 @@ void tst_QDBusConnection::registerQObjectChildren()
void tst_QDBusConnection::registerQObjectChildrenPeer()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
MyServer2 server;
QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo");
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
QCoreApplication::processEvents();
QVERIFY(con.isConnected());
@@ -923,22 +817,6 @@ bool tst_QDBusConnection::callMethodPeer(const QDBusConnection &conn, const QStr
return (MyObject::path == path);
}
-class TestObject : public QObject
-{
-Q_OBJECT
-public:
- TestObject(QObject *parent = 0) : QObject(parent) {}
- ~TestObject() {}
-
- QString func;
-
-public slots:
- void test0() { func = "test0"; }
- void test1(int i) { func = "test1 " + QString::number(i); }
- int test2() { func = "test2"; return 43; }
- int test3(int i) { func = "test2"; return i + 1; }
-};
-
void tst_QDBusConnection::callSelf()
{
TestObject testObject;
@@ -975,6 +853,9 @@ void tst_QDBusConnection::callSelfByAnotherName_data()
void tst_QDBusConnection::callSelfByAnotherName()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
static int counter = 0;
QString sname = serviceName() + QString::number(counter++);
@@ -1047,6 +928,9 @@ void tst_QDBusConnection::multipleInterfacesInQObject()
void tst_QDBusConnection::slotsWithLessParameters()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
QDBusConnection con = QDBusConnection::sessionBus();
QDBusMessage signal = QDBusMessage::createSignal("/", "org.qtproject.TestCase",
@@ -1073,7 +957,6 @@ void tst_QDBusConnection::slotsWithLessParameters()
void tst_QDBusConnection::secondCallWithCallback()
{
- qDebug("Hello");
QDBusConnection con = QDBusConnection::sessionBus();
QDBusMessage msg = QDBusMessage::createMethodCall(con.baseService(), "/test", QString(),
"test0");
@@ -1082,6 +965,9 @@ void tst_QDBusConnection::secondCallWithCallback()
void tst_QDBusConnection::nestedCallWithCallback()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
TestObject testObject;
QDBusConnection connection = QDBusConnection::sessionBus();
QVERIFY(connection.registerObject("/test", &testObject,
@@ -1097,22 +983,11 @@ void tst_QDBusConnection::nestedCallWithCallback()
QCOMPARE(signalsReceived, 1);
}
-class RaceConditionSignalWaiter : public QObject
-{
- Q_OBJECT
-public:
- int count;
- RaceConditionSignalWaiter() : count (0) {}
- virtual ~RaceConditionSignalWaiter() {}
-
-public slots:
- void countUp() { ++count; emit done(); }
-signals:
- void done();
-};
-
void tst_QDBusConnection::serviceRegistrationRaceCondition()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
// There was a race condition in the updating of list of name owners in
// Qt D-Bus. When the user connects to a signal coming from a given
// service, we must listen for NameOwnerChanged signals relevant to that
@@ -1164,39 +1039,6 @@ void tst_QDBusConnection::serviceRegistrationRaceCondition()
QCOMPARE(recv.count, 1);
}
-class VirtualObject: public QDBusVirtualObject
-{
- Q_OBJECT
-public:
- VirtualObject() :success(true) {}
-
- QString introspect(const QString & /* path */) const
- {
- return QString();
- }
-
- bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) {
- ++callCount;
- lastMessage = message;
-
- if (success) {
- QDBusMessage reply = message.createReply(replyArguments);
- connection.send(reply);
- }
- emit messageReceived(message);
- return success;
- }
-signals:
- void messageReceived(const QDBusMessage &message) const;
-
-public:
- mutable QDBusMessage lastMessage;
- QVariantList replyArguments;
- mutable int callCount;
- bool success;
-};
-
-
void tst_QDBusConnection::registerVirtualObject()
{
QDBusConnection con = QDBusConnection::sessionBus();
@@ -1279,6 +1121,9 @@ void tst_QDBusConnection::registerVirtualObject()
void tst_QDBusConnection::callVirtualObject()
{
+ if (!QCoreApplication::instance())
+ QSKIP("Test requires a QCoreApplication");
+
QDBusConnection con = QDBusConnection::sessionBus();
QVERIFY(con.isConnected());
@@ -1336,7 +1181,6 @@ void tst_QDBusConnection::callVirtualObject()
QVERIFY(!QTestEventLoop::instance().timeout());
QTest::qWait(100);
QVERIFY(errorReply.isError());
- qDebug() << errorReply.reply().arguments();
QCOMPARE(errorReply.reply().errorName(), QString("org.freedesktop.DBus.Error.UnknownObject"));
QDBusConnection::disconnectFromBus("con2");
@@ -1377,7 +1221,7 @@ void tst_QDBusConnection::callVirtualObjectLocal()
QString MyObject::path;
QString MyObjectWithoutInterface::path;
QString MyObjectWithoutInterface::interface;
-QTEST_MAIN(tst_QDBusConnection)
-
-#include "tst_qdbusconnection.moc"
+#ifndef tst_QDBusConnection
+QTEST_MAIN(tst_QDBusConnection)
+#endif
diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h
new file mode 100644
index 0000000000..a53ba320f8
--- /dev/null
+++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h
@@ -0,0 +1,287 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TST_QDBUSCONNECTION_H
+#define TST_QDBUSCONNECTION_H
+
+#include <QObject>
+#include <QtDBus/QtDBus>
+#include <QtTest/QtTest>
+
+class BaseObject: public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "local.BaseObject")
+public:
+ BaseObject(QObject *parent = 0) : QObject(parent) { }
+public slots:
+ void anotherMethod() { }
+};
+
+class MyObject: public BaseObject
+{
+ Q_OBJECT
+public slots:
+ void method(const QDBusMessage &msg);
+
+public:
+ static QString path;
+ int callCount;
+ MyObject(QObject *parent = 0) : BaseObject(parent), callCount(0) {}
+};
+
+class MyObjectWithoutInterface: public QObject
+{
+ Q_OBJECT
+public slots:
+ void method(const QDBusMessage &msg);
+
+public:
+ static QString path;
+ static QString interface;
+ int callCount;
+ MyObjectWithoutInterface(QObject *parent = 0) : QObject(parent), callCount(0) {}
+};
+
+class tst_QDBusConnection: public QObject
+{
+ Q_OBJECT
+
+ int signalsReceived;
+public slots:
+ void oneSlot() { ++signalsReceived; }
+ void exitLoop() { ++signalsReceived; QTestEventLoop::instance().exitLoop(); }
+ void secondCallWithCallback();
+
+private slots:
+ void noConnection();
+ void connectToBus();
+ void connectToPeer();
+ void connect();
+ void send();
+ void sendWithGui();
+ void sendAsync();
+ void sendSignal();
+ void sendSignalToName();
+ void sendSignalToOtherName();
+
+ void registerObject_data();
+ void registerObject();
+ void registerObjectWithInterface_data();
+ void registerObjectWithInterface();
+ void registerObjectPeer_data();
+ void registerObjectPeer();
+ void registerObject2();
+ void registerObjectPeer2();
+
+ void registerQObjectChildren();
+ void registerQObjectChildrenPeer();
+
+ void callSelf();
+ void callSelfByAnotherName_data();
+ void callSelfByAnotherName();
+ void multipleInterfacesInQObject();
+
+ void slotsWithLessParameters();
+ void nestedCallWithCallback();
+
+ void serviceRegistrationRaceCondition();
+
+ void registerVirtualObject();
+ void callVirtualObject();
+ void callVirtualObjectLocal();
+
+public:
+ QString serviceName() const { return "org.qtproject.Qt.Autotests.QDBusConnection"; }
+ bool callMethod(const QDBusConnection &conn, const QString &path);
+ bool callMethod(const QDBusConnection &conn, const QString &path, const QString &interface);
+ bool callMethodPeer(const QDBusConnection &conn, const QString &path);
+};
+
+class QDBusSpy: public QObject
+{
+ Q_OBJECT
+public slots:
+ void handlePing(const QString &str) { args.clear(); args << str; }
+ void asyncReply(const QDBusMessage &msg) { args = msg.arguments(); }
+
+public:
+ QList<QVariant> args;
+};
+
+class MyServer : public QDBusServer
+{
+ Q_OBJECT
+public:
+ MyServer(QString path) : m_path(path), m_connections()
+ {
+ connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection)));
+ }
+
+ bool registerObject(const QDBusConnection& c)
+ {
+ QDBusConnection conn(c);
+ if (!conn.registerObject(m_path, &m_obj, QDBusConnection::ExportAllSlots))
+ return false;
+ if (!(conn.objectRegisteredAt(m_path) == &m_obj))
+ return false;
+ return true;
+ }
+
+ bool registerObject()
+ {
+ Q_FOREACH (const QString &name, m_connections) {
+ if (!registerObject(QDBusConnection(name)))
+ return false;
+ }
+ return true;
+ }
+
+ void unregisterObject()
+ {
+ Q_FOREACH (const QString &name, m_connections) {
+ QDBusConnection c(name);
+ c.unregisterObject(m_path);
+ }
+ }
+
+public slots:
+ void handleConnection(const QDBusConnection& c)
+ {
+ m_connections << c.name();
+ QVERIFY(isConnected());
+ QVERIFY(c.isConnected());
+ QVERIFY(registerObject(c));
+ QTestEventLoop::instance().exitLoop();
+ }
+
+private:
+ MyObject m_obj;
+ QString m_path;
+ QStringList m_connections;
+};
+
+class MyServer2 : public QDBusServer
+{
+ Q_OBJECT
+public:
+ MyServer2() : m_conn("none")
+ {
+ connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection)));
+ }
+
+ QDBusConnection connection()
+ {
+ return m_conn;
+ }
+
+public slots:
+ void handleConnection(const QDBusConnection& c)
+ {
+ m_conn = c;
+ QVERIFY(isConnected());
+ QVERIFY(m_conn.isConnected());
+ QTestEventLoop::instance().exitLoop();
+ }
+
+private:
+ MyObject m_obj;
+ QDBusConnection m_conn;
+};
+
+class TestObject : public QObject
+{
+Q_OBJECT
+public:
+ TestObject(QObject *parent = 0) : QObject(parent) {}
+ ~TestObject() {}
+
+ QString func;
+
+public slots:
+ void test0() { func = "test0"; }
+ void test1(int i) { func = "test1 " + QString::number(i); }
+ int test2() { func = "test2"; return 43; }
+ int test3(int i) { func = "test2"; return i + 1; }
+};
+
+class RaceConditionSignalWaiter : public QObject
+{
+ Q_OBJECT
+public:
+ int count;
+ RaceConditionSignalWaiter() : count (0) {}
+ virtual ~RaceConditionSignalWaiter() {}
+
+public slots:
+ void countUp() { ++count; emit done(); }
+signals:
+ void done();
+};
+
+class VirtualObject: public QDBusVirtualObject
+{
+ Q_OBJECT
+public:
+ VirtualObject() :success(true) {}
+
+ QString introspect(const QString & /* path */) const
+ {
+ return QString();
+ }
+
+ bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) {
+ ++callCount;
+ lastMessage = message;
+
+ if (success) {
+ QDBusMessage reply = message.createReply(replyArguments);
+ connection.send(reply);
+ }
+ emit messageReceived(message);
+ return success;
+ }
+signals:
+ void messageReceived(const QDBusMessage &message) const;
+
+public:
+ mutable QDBusMessage lastMessage;
+ QVariantList replyArguments;
+ mutable int callCount;
+ bool success;
+};
+
+
+#endif // TST_QDBUSCONNECTION_H
+
diff --git a/tests/auto/dbus/qdbusconnection_no_app/qdbusconnection_no_app.pro b/tests/auto/dbus/qdbusconnection_no_app/qdbusconnection_no_app.pro
new file mode 100644
index 0000000000..ba3a13caa9
--- /dev/null
+++ b/tests/auto/dbus/qdbusconnection_no_app/qdbusconnection_no_app.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qdbusconnection_no_app
+QT = core dbus testlib
+SOURCES += tst_qdbusconnection_no_app.cpp
+HEADERS += ../qdbusconnection/tst_qdbusconnection.h
+DEFINES += SRCDIR=\\\"$$PWD/\\\" tst_QDBusConnection=tst_QDBusConnection_NoApplication
diff --git a/tests/auto/dbus/qdbusconnection_no_app/tst_qdbusconnection_no_app.cpp b/tests/auto/dbus/qdbusconnection_no_app/tst_qdbusconnection_no_app.cpp
new file mode 100644
index 0000000000..816f75f82e
--- /dev/null
+++ b/tests/auto/dbus/qdbusconnection_no_app/tst_qdbusconnection_no_app.cpp
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// Ugly hack, look away
+#include "../qdbusconnection/tst_qdbusconnection.cpp"
+
+QTEST_APPLESS_MAIN(tst_QDBusConnection_NoApplication)
diff --git a/tests/auto/dbus/qdbusmarshall/BLACKLIST b/tests/auto/dbus/qdbusmarshall/BLACKLIST
new file mode 100644
index 0000000000..036378d204
--- /dev/null
+++ b/tests/auto/dbus/qdbusmarshall/BLACKLIST
@@ -0,0 +1,3 @@
+[receiveUnknownType]
+ubuntu-14.04
+opensuse-13.1
diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
index 16314a5dc5..57fd5084be 100644
--- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -150,7 +150,11 @@ int tst_QDBusMarshall::fileDescriptorForTest()
{
if (!tempFile.isOpen()) {
tempFile.setFileTemplate(QDir::tempPath() + "/qdbusmarshalltestXXXXXX.tmp");
- tempFile.open();
+ if (!tempFile.open()) {
+ qWarning("%s: Cannot create temporary file: %s", Q_FUNC_INFO,
+ qPrintable(tempFile.errorString()));
+ return 0;
+ }
}
return tempFile.handle();
}
@@ -869,7 +873,7 @@ void tst_QDBusMarshall::sendSignalErrors()
"signalName");
msg << QVariant::fromValue(QDBusObjectPath());
- QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments");
+ QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments");
QVERIFY(!con.send(msg));
msg.setArguments(QVariantList());
@@ -879,19 +883,19 @@ void tst_QDBusMarshall::sendSignalErrors()
path.setPath("abc");
msg << QVariant::fromValue(path);
- QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments");
+ QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments");
QVERIFY(!con.send(msg));
QDBusSignature sig;
msg.setArguments(QVariantList() << QVariant::fromValue(sig));
- QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments");
+ QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments");
QVERIFY(!con.send(msg));
QTest::ignoreMessage(QtWarningMsg, "QDBusSignature: invalid signature \"a\"");
sig.setSignature("a");
msg.setArguments(QVariantList());
msg << QVariant::fromValue(sig);
- QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments");
+ QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments");
QVERIFY(!con.send(msg));
}
@@ -1079,7 +1083,7 @@ static bool canSendUnixFd(DBusConnection *connection)
# if DBUS_VERSION-0 >= 0x010400
can_send_type = dbus_connection_can_send_type;
# endif
-#else
+#elif !defined(QT_NO_LIBRARY)
// run-time check if the next functions are available
can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type");
#endif
diff --git a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
index 9c334f77a2..cc12ef8bcc 100644
--- a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
+++ b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Intel Corporation.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -172,10 +173,6 @@ QDBusPendingCall tst_QDBusPendingCall::sendError()
void tst_QDBusPendingCall::waitForFinished()
{
QDBusPendingCall ac = sendMessage();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
ac.waitForFinished();
QVERIFY(ac.isFinished());
QVERIFY(!ac.isError());
@@ -195,10 +192,6 @@ void tst_QDBusPendingCall::waitForFinished()
void tst_QDBusPendingCall::waitForFinished_error()
{
QDBusPendingCall ac = sendError();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
ac.waitForFinished();
QVERIFY(ac.isFinished());
QVERIFY(ac.isError());
@@ -254,10 +247,6 @@ void tst_QDBusPendingCall::callWithCallback_localLoop_errorReply()
void tst_QDBusPendingCall::watcher()
{
QDBusPendingCall ac = sendMessage();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
callCount = 0;
watchArgument = 0;
@@ -284,10 +273,6 @@ void tst_QDBusPendingCall::watcher()
void tst_QDBusPendingCall::watcher_error()
{
QDBusPendingCall ac = sendError();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
callCount = 0;
watchArgument = 0;
@@ -312,10 +297,6 @@ void tst_QDBusPendingCall::watcher_error()
void tst_QDBusPendingCall::watcher_waitForFinished()
{
QDBusPendingCall ac = sendMessage();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
callCount = 0;
watchArgument = 0;
@@ -391,10 +372,6 @@ void tst_QDBusPendingCall::watcher_waitForFinished_threaded()
void tst_QDBusPendingCall::watcher_waitForFinished_alreadyFinished()
{
QDBusPendingCall ac = sendMessage();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
ac.waitForFinished();
QVERIFY(ac.isFinished());
QVERIFY(!ac.isError());
@@ -425,10 +402,6 @@ void tst_QDBusPendingCall::watcher_waitForFinished_alreadyFinished()
void tst_QDBusPendingCall::watcher_waitForFinished_alreadyFinished_eventLoop()
{
QDBusPendingCall ac = sendMessage();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
ac.waitForFinished();
QVERIFY(ac.isFinished());
QVERIFY(!ac.isError());
@@ -462,10 +435,6 @@ void tst_QDBusPendingCall::watcher_waitForFinished_alreadyFinished_eventLoop()
void tst_QDBusPendingCall::watcher_waitForFinished_error()
{
QDBusPendingCall ac = sendError();
- QVERIFY(!ac.isFinished());
- QVERIFY(!ac.isError());
- QVERIFY(ac.reply().type() == QDBusMessage::InvalidMessage);
-
callCount = 0;
watchArgument = 0;
diff --git a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
index 9dd2e4bb83..e7fa1e6484 100644
--- a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
+++ b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp
@@ -49,8 +49,11 @@ private slots:
void watchForCreation();
void watchForDisappearance();
+ void watchForDisappearanceUniqueConnection();
void watchForOwnerChange();
void modeChange();
+ void disconnectedConnection();
+ void setConnection();
};
tst_QDBusServiceWatcher::tst_QDBusServiceWatcher()
@@ -155,6 +158,40 @@ void tst_QDBusServiceWatcher::watchForDisappearance()
QVERIFY(spyO.at(0).at(2).toString().isEmpty());
}
+void tst_QDBusServiceWatcher::watchForDisappearanceUniqueConnection()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+
+ // second connection
+ QString watchedName = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "session2").baseService();
+ QVERIFY(!watchedName.isEmpty());
+
+ QDBusServiceWatcher watcher(watchedName, con, QDBusServiceWatcher::WatchForUnregistration);
+ watcher.setObjectName("watcher for disappearance");
+
+ QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString)));
+ QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString)));
+ QSignalSpy spyO(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
+ QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceUnregistered(QString)), SLOT(exitLoop()));
+
+ // unregister it:
+ QDBusConnection::disconnectFromBus("session2");
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 0);
+
+ QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.at(0).at(0).toString(), watchedName);
+
+ QCOMPARE(spyO.count(), 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());
+}
+
void tst_QDBusServiceWatcher::watchForOwnerChange()
{
QDBusConnection con = QDBusConnection::sessionBus();
@@ -263,5 +300,72 @@ void tst_QDBusServiceWatcher::modeChange()
QVERIFY(spyO.at(0).at(2).toString().isEmpty());
}
+void tst_QDBusServiceWatcher::disconnectedConnection()
+{
+ QDBusConnection con("");
+ QVERIFY(!con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration);
+ watcher.addWatchedService("com.example.somethingelse");
+ watcher.addWatchedService("org.freedesktop.DBus");
+
+ watcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
+ watcher.setWatchMode(QDBusServiceWatcher::WatchForOwnerChange);
+
+ watcher.setWatchedServices(QStringList());
+}
+
+void tst_QDBusServiceWatcher::setConnection()
+{
+ // begin with a disconnected connection
+ QDBusConnection con("");
+ QVERIFY(!con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration);
+
+ QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString)));
+ QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString)));
+ QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), SLOT(exitLoop()));
+
+ // move to the session bus
+ con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+ watcher.setConnection(con);
+
+ // register a name
+ QVERIFY(con.registerService(serviceName));
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 1);
+ QCOMPARE(spyR.at(0).at(0).toString(), serviceName);
+ QCOMPARE(spyU.count(), 0);
+
+ // is the system bus available?
+ if (!QDBusConnection::systemBus().isConnected())
+ return;
+
+ // connect to the system bus and ask to watch that base service
+ QString watchedName = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "system2").baseService();
+ watcher.setWatchedServices(QStringList() << watchedName);
+ watcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
+
+ // move to the system bus
+ watcher.setConnection(QDBusConnection::systemBus());
+ spyR.clear();
+ spyU.clear();
+
+ QDBusConnection::disconnectFromBus("system2");
+
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QCOMPARE(spyR.count(), 0);
+
+ QCOMPARE(spyU.count(), 1);
+ QCOMPARE(spyU.at(0).at(0).toString(), watchedName);
+}
+
QTEST_MAIN(tst_QDBusServiceWatcher)
#include "tst_qdbusservicewatcher.moc"
diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
index 63444b61ad..4408729e7c 100644
--- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
+++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp
@@ -94,7 +94,11 @@ static void addFixedTypes()
// the library recognizes this as valid type first.
// The following function was added for Unix FD support, so if it is
// present, so is support for Unix FDs.
+# ifndef QT_NO_LIBRARY
bool supportsUnixFds = qdbus_resolve_conditionally("dbus_connection_can_send_type");
+# else
+ bool supportsUnixFds = false;
+# endif
# else
bool supportsUnixFds = true;
# endif
diff --git a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp
index 4dbe0aae7d..c57292b7db 100644
--- a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp
+++ b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp
@@ -64,15 +64,10 @@ private slots:
void properties();
};
-QT_BEGIN_NAMESPACE
-// Avoid QHash randomization so that the order of the XML attributes is stable
-extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed; // from qhash.cpp
-QT_END_NAMESPACE
-
void tst_QDBusXmlParser::initTestCase()
{
// Always initialize the hash seed to 0 to get reliable test results
- qt_qhash_seed.store(0);
+ qSetGlobalQHashSeed(0);
}
void tst_QDBusXmlParser::parsing_data()
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
index d2fae0e5e3..bff762fd04 100644
--- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
+++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
@@ -324,6 +324,11 @@ void tst_QIcoImageFormat::pngCompression()
QImage image;
reader.jumpToImage(index);
+
+ QSize size = reader.size();
+ QCOMPARE(size.width(), width);
+ QCOMPARE(size.height(), height);
+
reader.read(&image);
QCOMPARE(image.width(), width);
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp
index 20a08e10a2..9ed3873682 100644
--- a/tests/auto/gui/image/qicon/tst_qicon.cpp
+++ b/tests/auto/gui/image/qicon/tst_qicon.cpp
@@ -75,14 +75,8 @@ private:
const QString m_pngImageFileName;
const QString m_pngRectFileName;
const QString m_sourceFileName;
-
- const static QIcon staticIcon;
};
-// Creating an icon statically should not cause a crash.
-// But we do not officially support this. See QTBUG-8666
-const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find");
-
bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat)
{
return QImageReader::supportedImageFormats().contains(desiredFormat);
@@ -354,10 +348,10 @@ void tst_QIcon::cacheKey()
qint64 icon1_key = icon1.cacheKey();
QIcon icon2 = icon1;
- QVERIFY(icon2.cacheKey() == icon1.cacheKey());
+ QCOMPARE(icon2.cacheKey(), icon1.cacheKey());
icon2.detach();
QVERIFY(icon2.cacheKey() != icon1.cacheKey());
- QVERIFY(icon1.cacheKey() == icon1_key);
+ QCOMPARE(icon1.cacheKey(), icon1_key);
}
void tst_QIcon::detach()
@@ -374,7 +368,7 @@ void tst_QIcon::detach()
img1 = icon1.pixmap(32, 32).toImage();
img2 = icon2.pixmap(32, 32).toImage();
- QVERIFY(img1 == img2);
+ QCOMPARE(img1, img2);
}
void tst_QIcon::addFile()
@@ -562,7 +556,7 @@ void tst_QIcon::fromTheme()
QString firstSearchPath = QLatin1String(":/icons");
QString secondSearchPath = QLatin1String(":/second_icons");
QIcon::setThemeSearchPaths(QStringList() << firstSearchPath << secondSearchPath);
- QVERIFY(QIcon::themeSearchPaths().size() == 2);
+ QCOMPARE(QIcon::themeSearchPaths().size(), 2);
QCOMPARE(firstSearchPath, QIcon::themeSearchPaths()[0]);
QCOMPARE(secondSearchPath, QIcon::themeSearchPaths()[1]);
@@ -599,7 +593,7 @@ void tst_QIcon::fromTheme()
// Test non existing icon with fallback
noIcon = QIcon::fromTheme("broken-icon", abIcon);
- QVERIFY(noIcon.cacheKey() == abIcon.cacheKey());
+ QCOMPARE(noIcon.cacheKey(), abIcon.cacheKey());
// Test svg-only icon
noIcon = QIcon::fromTheme("svg-icon", abIcon);
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 8286c800c2..08f48abd20 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -478,7 +478,7 @@ void tst_QImage::setAlphaChannel()
image.setAlphaChannel(alphaChannel);
image = image.convertToFormat(QImage::Format_ARGB32);
- QVERIFY(image.format() == QImage::Format_ARGB32);
+ QCOMPARE(image.format(), QImage::Format_ARGB32);
// alpha of 0 becomes black at a=0 due to premultiplication
QRgb pixel = alpha == 0 ? 0 : qRgba(red, green, blue, alpha);
@@ -1565,12 +1565,12 @@ void tst_QImage::createHeuristicMask()
// line 2
QVERIFY(newMask.pixel(0,1) != newMask.pixel(1,1));
- QVERIFY(newMask.pixel(1,1) == newMask.pixel(2,1));
+ QCOMPARE(newMask.pixel(1,1), newMask.pixel(2,1));
QVERIFY(newMask.pixel(2,1) != newMask.pixel(3,1));
// line 3
QVERIFY(newMask.pixel(0,2) != newMask.pixel(1,2));
- QVERIFY(newMask.pixel(1,2) == newMask.pixel(2,2));
+ QCOMPARE(newMask.pixel(1,2), newMask.pixel(2,2));
QVERIFY(newMask.pixel(2,2) != newMask.pixel(3,2));
}
#endif
@@ -1581,10 +1581,10 @@ void tst_QImage::cacheKey()
qint64 image1_key = image1.cacheKey();
QImage image2 = image1;
- QVERIFY(image2.cacheKey() == image1.cacheKey());
+ QCOMPARE(image2.cacheKey(), image1.cacheKey());
image2.detach();
QVERIFY(image2.cacheKey() != image1.cacheKey());
- QVERIFY(image1.cacheKey() == image1_key);
+ QCOMPARE(image1.cacheKey(), image1_key);
}
void tst_QImage::smoothScale()
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index 4b3e2606fd..16fe959b11 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -194,7 +194,7 @@ void tst_QImageReader::initTestCase()
prefix = QFINDTESTDATA("images/");
if (prefix.isEmpty())
QFAIL("Can't find images directory!");
- QVERIFY(m_temporaryDir.isValid());
+ QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
}
void tst_QImageReader::cleanupTestCase()
@@ -733,7 +733,7 @@ void tst_QImageReader::gifHandlerBugs()
QVERIFY(io.loopCount() != 1);
int count=0;
for (; io.canRead(); io.read(), ++count) ;
- QVERIFY(count == 34);
+ QCOMPARE(count, 34);
}
// Task 95166
@@ -810,7 +810,7 @@ void tst_QImageReader::gifImageCount()
QVERIFY(io.canRead());
QImage greenFrame = io.read();
- QVERIFY(io.imageCount() == 4);
+ QCOMPARE(io.imageCount(), 4);
QVERIFY(io.canRead());
QImage blueFrame = io.read();
@@ -925,8 +925,8 @@ void tst_QImageReader::gifImageCount()
}
{
QImageReader io(":images/trolltech.gif");
- QVERIFY(io.imageCount() == 34);
- QVERIFY(io.size() == QSize(128,64));
+ QCOMPARE(io.imageCount(), 34);
+ QCOMPARE(io.size(), QSize(128,64));
}
}
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index 4f04e50294..06c775dded 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -416,7 +416,7 @@ void tst_QImageWriter::testCanWrite()
{
// check if canWrite won't leave an empty file
QTemporaryDir dir;
- QVERIFY(dir.isValid());
+ QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
QString fileName(dir.path() + QLatin1String("/001.garble"));
QVERIFY(!QFileInfo(fileName).exists());
QImageWriter writer(fileName);
@@ -524,7 +524,7 @@ void tst_QImageWriter::saveToTemporaryFile()
{
// 1) Via QImageWriter's API, with a standard temp file name
QTemporaryFile file;
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QImageWriter writer(&file, "PNG");
if (writer.canWrite())
QVERIFY(writer.write(image));
@@ -538,7 +538,7 @@ void tst_QImageWriter::saveToTemporaryFile()
{
// 2) Via QImage's API, with a standard temp file name
QTemporaryFile file;
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QVERIFY(image.save(&file, "PNG"));
file.reset();
QImage tmp;
@@ -548,7 +548,7 @@ void tst_QImageWriter::saveToTemporaryFile()
{
// 3) Via QImageWriter's API, with a named temp file
QTemporaryFile file("tempXXXXXX");
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QImageWriter writer(&file, "PNG");
QVERIFY(writer.write(image));
#if defined(Q_OS_WINCE)
@@ -559,7 +559,7 @@ void tst_QImageWriter::saveToTemporaryFile()
{
// 4) Via QImage's API, with a named temp file
QTemporaryFile file("tempXXXXXX");
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QVERIFY(image.save(&file, "PNG"));
file.reset();
QImage tmp;
diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
index c61c88d1a6..b8c99ca324 100644
--- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp
+++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
@@ -188,8 +188,8 @@ void tst_QMovie::jumpToFrame()
QMovie movie(QFINDTESTDATA(fileName));
movie.start();
movie.stop();
- QVERIFY(movie.jumpToFrame(-1) == false);
- QVERIFY(movie.currentFrameNumber() == 0);
+ QVERIFY(!movie.jumpToFrame(-1));
+ QCOMPARE(movie.currentFrameNumber(), 0);
}
void tst_QMovie::changeMovieFile()
@@ -198,7 +198,7 @@ void tst_QMovie::changeMovieFile()
movie.start();
movie.stop();
movie.setFileName(QFINDTESTDATA("animations/trolltech.gif"));
- QVERIFY(movie.currentFrameNumber() == -1);
+ QCOMPARE(movie.currentFrameNumber(), -1);
}
#ifndef QT_NO_WIDGETS
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 58cc5824bd..67d7e57fd4 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -447,7 +447,7 @@ void tst_QPixmap::scroll()
QString fileName = QString(":/images/%1.png").arg(QTest::currentDataTag());
QPixmap output(fileName);
- QVERIFY(input.isNull() == output.isNull());
+ QCOMPARE(input.isNull(), output.isNull());
QVERIFY(lenientCompare(pixmap, output));
QCOMPARE(exp, exposed);
}
@@ -713,11 +713,11 @@ void tst_QPixmap::cacheKey()
QVERIFY(pixmap1.cacheKey() != pixmap2.cacheKey());
pixmap2 = pixmap1;
- QVERIFY(pixmap2.cacheKey() == pixmap1.cacheKey());
+ QCOMPARE(pixmap2.cacheKey(), pixmap1.cacheKey());
pixmap2.detach();
QVERIFY(pixmap2.cacheKey() != pixmap1.cacheKey());
- QVERIFY(pixmap1.cacheKey() == pixmap1_key);
+ QCOMPARE(pixmap1.cacheKey(), pixmap1_key);
}
// Test drawing a bitmap on a pixmap.
@@ -743,7 +743,7 @@ void tst_QPixmap::isNull()
{
{
QPixmap pixmap(1,1);
- QVERIFY(pixmap.isNull() == false);
+ QVERIFY(!pixmap.isNull());
}
{
QPixmap pixmap(0,0);
@@ -783,11 +783,11 @@ void tst_QPixmap::convertFromImageNoDetach()
QPixmap pix = QPixmap::fromImage(orig);
QImage copy = pix.toImage();
- QVERIFY(copy.format() == screenFormat);
+ QCOMPARE(copy.format(), screenFormat);
const QImage constOrig = orig;
const QImage constCopy = copy;
- QVERIFY(constOrig.bits() == constCopy.bits());
+ QCOMPARE(constOrig.bits(), constCopy.bits());
}
void tst_QPixmap::convertFromImageDetach()
@@ -821,7 +821,7 @@ void tst_QPixmap::convertFromImageCacheKey()
QPixmap pix = QPixmap::fromImage(orig);
QImage copy = pix.toImage();
- QVERIFY(copy.format() == screenFormat);
+ QCOMPARE(copy.format(), screenFormat);
QCOMPARE(orig.cacheKey(), pix.cacheKey());
QCOMPARE(copy.cacheKey(), pix.cacheKey());
@@ -1135,9 +1135,9 @@ void tst_QPixmap::copy()
void tst_QPixmap::depthOfNullObjects()
{
QBitmap b1;
- QVERIFY(b1.depth() == 0);
+ QCOMPARE(b1.depth(), 0);
QPixmap p4;
- QVERIFY(p4.depth() == 0);
+ QCOMPARE(p4.depth(), 0);
}
void tst_QPixmap::transformed()
@@ -1437,7 +1437,7 @@ void tst_QPixmap::task_246446()
{
QPixmap pm2(pm);
}
- QVERIFY(pm.width() == 10);
+ QCOMPARE(pm.width(), 10);
QVERIFY(pm.mask().isNull());
}
@@ -1490,14 +1490,14 @@ void tst_QPixmap::loadAsBitmapOrPixmap()
// The do the same check for bitmaps..
QBitmap bitmap("temp_image.png");
QVERIFY(!bitmap.isNull());
- QVERIFY(bitmap.depth() == 1);
+ QCOMPARE(bitmap.depth(), 1);
QVERIFY(bitmap.isQBitmap());
bitmap = QBitmap();
ok = bitmap.load("temp_image.png");
QVERIFY(ok);
QVERIFY(!bitmap.isNull());
- QVERIFY(bitmap.depth() == 1);
+ QCOMPARE(bitmap.depth(), 1);
QVERIFY(bitmap.isQBitmap());
}
diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
index f22aa63112..a3cf66da18 100644
--- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
@@ -111,7 +111,7 @@ void tst_QPixmapCache::setCacheLimit()
delete p1;
QPixmapCache::setCacheLimit(0);
- QVERIFY(QPixmapCache::find("P1") == 0);
+ QVERIFY(!QPixmapCache::find("P1"));
p1 = new QPixmap(2, 3);
QPixmapCache::setCacheLimit(1000);
@@ -346,12 +346,12 @@ void tst_QPixmapCache::remove()
QVERIFY(p1.toImage() == p1.toImage()); // sanity check
QPixmapCache::remove("red");
- QVERIFY(QPixmapCache::find("red") == 0);
+ QVERIFY(!QPixmapCache::find("red"));
QPixmapCache::remove("red");
- QVERIFY(QPixmapCache::find("red") == 0);
+ QVERIFY(!QPixmapCache::find("red"));
QPixmapCache::remove("green");
- QVERIFY(QPixmapCache::find("green") == 0);
+ QVERIFY(!QPixmapCache::find("green"));
//The int part of the API
QPixmapCache::clear();
@@ -424,7 +424,7 @@ void tst_QPixmapCache::clear()
QPixmapCache::clear();
for (int k = 0; k < numberOfKeys; ++k)
- QVERIFY(QPixmapCache::find(QString::number(k)) == 0);
+ QVERIFY(!QPixmapCache::find(QString::number(k)));
//The int part of the API
QPixmap p2(10, 10);
diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
index 2448b89296..ff263c166a 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
@@ -278,9 +278,12 @@ void tst_QStandardItem::getSetFlags()
QVERIFY(item.isCheckable());
QCOMPARE(item.checkState(), Qt::Unchecked);
QVERIFY(item.flags() & Qt::ItemIsUserCheckable);
- item.setTristate(true);
- QVERIFY(item.isTristate());
- QVERIFY(item.flags() & Qt::ItemIsTristate);
+ item.setUserTristate(true);
+ QVERIFY(item.isUserTristate());
+ QVERIFY(item.flags() & Qt::ItemIsUserTristate);
+ item.setAutoTristate(true);
+ QVERIFY(item.isAutoTristate());
+ QVERIFY(item.flags() & Qt::ItemIsAutoTristate);
#ifndef QT_NO_DRAGANDDROP
item.setDragEnabled(true);
QVERIFY(item.isDragEnabled());
@@ -306,10 +309,12 @@ void tst_QStandardItem::getSetFlags()
item.setCheckable(false);
QVERIFY(!item.isCheckable());
QVERIFY(!(item.flags() & Qt::ItemIsUserCheckable));
- QVERIFY(item.isTristate());
- item.setTristate(false);
- QVERIFY(!item.isTristate());
- QVERIFY(!(item.flags() & Qt::ItemIsTristate));
+ item.setUserTristate(false);
+ QVERIFY(!item.isUserTristate());
+ QVERIFY(!(item.flags() & Qt::ItemIsUserTristate));
+ item.setAutoTristate(false);
+ QVERIFY(!item.isAutoTristate());
+ QVERIFY(!(item.flags() & Qt::ItemIsAutoTristate));
#ifndef QT_NO_DRAGANDDROP
QVERIFY(item.isDragEnabled());
item.setDragEnabled(false);
@@ -325,6 +330,13 @@ void tst_QStandardItem::getSetFlags()
item.setCheckState(Qt::Checked);
item.setCheckable(true);
QCOMPARE(item.checkState(), Qt::Checked);
+
+ // deprecated API
+ item.setTristate(true);
+ QVERIFY(item.isTristate());
+ QVERIFY(item.flags() & Qt::ItemIsTristate);
+ item.setTristate(false);
+ QVERIFY(!(item.flags() & Qt::ItemIsTristate));
}
void tst_QStandardItem::getSetRowAndColumnCount()
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index d573d97495..d18f9664fc 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -171,7 +171,7 @@ void tst_QGuiApplication::focusObject()
int argc = 0;
QGuiApplication app(argc, 0);
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QObject obj1, obj2, obj3;
@@ -342,7 +342,7 @@ void tst_QGuiApplication::changeFocusWindow()
int argc = 0;
QGuiApplication app(argc, 0);
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();
@@ -416,11 +416,11 @@ void tst_QGuiApplication::keyboardModifiers()
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// shortcut events
- QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_5, Qt::MetaModifier);
+ QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_5, Qt::MetaModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::MetaModifier);
- QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_Period, Qt::NoModifier);
+ QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_Period, Qt::NoModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier);
- QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_0, Qt::ControlModifier);
+ QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_0, Qt::ControlModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// key events
@@ -928,7 +928,7 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents()
QGuiApplication app(argc, argv);
QVERIFY(QGuiApplication::primaryScreen());
- QVERIFY(QGuiApplication::primaryScreen()->orientation() == testOrientationToSend);
+ QCOMPARE(QGuiApplication::primaryScreen()->orientation(), testOrientationToSend);
QCOMPARE(testReceiver.customEvents, 0);
QCoreApplication::sendPostedEvents(&testReceiver);
diff --git a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
index c37e633d75..1294751224 100644
--- a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
+++ b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
@@ -56,7 +56,7 @@ void tst_QGuiVariantNoApplication::variantWithoutApplication()
{
QVariant v = QString("red");
- QVERIFY(qvariant_cast<QColor>(v) == QColor(Qt::red));
+ QCOMPARE(qvariant_cast<QColor>(v), QColor(Qt::red));
}
diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
index 58c595ad07..0e822ced5b 100644
--- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
+++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
@@ -140,13 +140,13 @@ void tst_QGuiVariant::constructor_invalid()
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(static_cast<QVariant::Type>(typeId));
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(typeId, /* copy */ 0);
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
}
@@ -611,9 +611,9 @@ void tst_QGuiVariant::writeToReadFromDataStream()
// the uninitialized float can be NaN (observed on Windows Mobile 5 ARMv4i)
float readFloat = qvariant_cast<float>(readVariant);
float writtenFloat = qvariant_cast<float>(writeVariant);
- QVERIFY(qIsNaN(readFloat) == qIsNaN(writtenFloat));
+ QCOMPARE(qIsNaN(readFloat), qIsNaN(writtenFloat));
if (!qIsNaN(readFloat))
- QVERIFY(readFloat == writtenFloat);
+ QCOMPARE(readFloat, writtenFloat);
}
break;
}
@@ -632,7 +632,7 @@ void tst_QGuiVariant::writeToReadFromOldDataStream()
dataFileStream.setVersion(QDataStream::Qt_4_9);
QVariant readVariant;
dataFileStream >> readVariant;
- QVERIFY(readVariant.userType() == QMetaType::QPolygonF);
+ QCOMPARE(readVariant.userType(), int(QMetaType::QPolygonF));
QCOMPARE(testVariant, readVariant);
file.close();
}
@@ -656,7 +656,7 @@ void tst_QGuiVariant::writeToReadFromOldDataStream()
QDataStream readVarData(variantData);
readVarData >> dummy;
readVarData >> polyData50;
- QVERIFY(polyData49 == polyData50);
+ QCOMPARE(polyData49, polyData50);
}
}
diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
index a36e31e2e2..e3b71e40d1 100644
--- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
+++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
@@ -191,7 +191,7 @@ void tst_qinputmethod::cursorRectangle()
{
QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF());
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
DummyWindow window;
@@ -289,9 +289,12 @@ void tst_qinputmethod::inputDirection()
void tst_qinputmethod::inputMethodAccepted()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
+ if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive))
+ QSKIP("XCB: depends on dedicated platform context.");
+
InputItem disabledItem;
disabledItem.setEnabled(false);
diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
index dcead8bfbf..1fc4967b12 100644
--- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
+++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
@@ -248,7 +248,7 @@ public:
GLuint fbo = 0xFFFF;
QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *) &fbo);
- QVERIFY(fbo == 0);
+ QCOMPARE(fbo, GLuint(0));
}
void paintGL() Q_DECL_OVERRIDE {
@@ -272,7 +272,7 @@ public:
GLuint fbo = 0xFFFF;
QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *) &fbo);
- QVERIFY(fbo == 0);
+ QCOMPARE(fbo, GLuint(0));
}
};
diff --git a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
index 0d5991ef41..a5f86c6c09 100644
--- a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
+++ b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
@@ -53,7 +53,7 @@ void tst_QPixelFormat::testOperators()
{
QPixelFormat first = qPixelFormatRgba(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied);
QPixelFormat second = qPixelFormatRgba(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied);
- QVERIFY(first == second);
+ QCOMPARE(first, second);
QPixelFormat third = qPixelFormatRgba(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtEnd, QPixelFormat::NotPremultiplied);
QVERIFY(first != third);
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index fd3cfd55ff..d754e0b3c3 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -39,33 +39,8 @@
#include <QtWidgets/QWidget>
#include <QtTest>
#include <qpa/qwindowsysteminterface.h>
-
-// FIXME: Use static functions of QWindowSystemInterface introduced with HighDPI scaling in 5.6 instead.
-static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt)
-{
- QWindowSystemInterface::TouchPoint p;
- p.id = pt.id();
- p.flags = pt.flags();
- p.normalPosition = pt.normalizedPos();
- p.area = pt.screenRect();
- p.pressure = pt.pressure();
- p.state = pt.state();
- p.velocity = pt.velocity();
- p.rawPositions = pt.rawScreenPositions();
- return p;
-}
-
-static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
-{
- QList<struct QWindowSystemInterface::TouchPoint> newList;
-
- Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
- {
- newList.append(touchPoint(p));
- }
- return newList;
-}
-
+#include <qpa/qwindowsysteminterface_p.h>
+#include <private/qhighdpiscaling_p.h>
class tst_QTouchEventWidget : public QWidget
{
@@ -622,11 +597,10 @@ void tst_QTouchEvent::basicRawEventTranslation()
rawPosList << QPointF(12, 34) << QPointF(56, 78);
rawTouchPoint.setRawScreenPositions(rawPosList);
const ulong timestamp = 1234;
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- timestamp,
- touchScreenDevice,
- touchPointList(
- QList<QTouchEvent::TouchPoint>() << rawTouchPoint));
+ QWindow *window = touchWidget.windowHandle();
+ QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window);
+ QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -653,16 +627,16 @@ void tst_QTouchEvent::basicRawEventTranslation()
QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect());
QCOMPARE(touchBeginPoint.pressure(), qreal(1.));
QCOMPARE(touchBeginPoint.velocity(), QVector2D());
- QCOMPARE(touchBeginPoint.rawScreenPositions(), rawPosList);
+ if (!QHighDpiScaling::isActive())
+ QCOMPARE(touchBeginPoint.rawScreenPositions(), rawPosList);
// moving the point should translate to TouchUpdate
rawTouchPoint.setState(Qt::TouchPointMoved);
rawTouchPoint.setScreenPos(screenPos + delta);
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(QList<QTouchEvent::TouchPoint>() << rawTouchPoint));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
@@ -692,10 +666,9 @@ void tst_QTouchEvent::basicRawEventTranslation()
rawTouchPoint.setState(Qt::TouchPointReleased);
rawTouchPoint.setScreenPos(screenPos + delta + delta);
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(QList<QTouchEvent::TouchPoint>() << rawTouchPoint));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
@@ -762,10 +735,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
rawTouchPoints[1].setState(Qt::TouchPointPressed);
rawTouchPoints[1].setScreenPos(rightScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(rawTouchPoints));
+ QWindow *window = touchWidget.windowHandle();
+ QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -827,10 +800,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
rawTouchPoints[1].setState(Qt::TouchPointMoved);
rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(rawTouchPoints));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -892,10 +864,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
rawTouchPoints[1].setState(Qt::TouchPointReleased);
rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(rawTouchPoints));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -992,10 +963,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
rawTouchPoints[1].setState(Qt::TouchPointPressed);
rawTouchPoints[1].setScreenPos(rightScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchPadDevice,
- touchPointList(rawTouchPoints));
+ QWindow *window = touchWidget.windowHandle();
+ QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -1058,10 +1029,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
rawTouchPoints[1].setState(Qt::TouchPointMoved);
rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchPadDevice,
- touchPointList(rawTouchPoints));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -1123,10 +1093,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
rawTouchPoints[1].setState(Qt::TouchPointReleased);
rawTouchPoints[1].setScreenPos(centerScreenPos);
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchPadDevice,
- touchPointList(rawTouchPoints));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -1385,10 +1354,10 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry));
// generate begin events on all widgets, the left widget should die
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(rawTouchPoints));
+ QWindow *window = touchWidget.windowHandle();
+ QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(leftWidget.isNull());
QVERIFY(!centerWidget.isNull());
@@ -1398,20 +1367,18 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
rawTouchPoints[0].setState(Qt::TouchPointMoved);
rawTouchPoints[1].setState(Qt::TouchPointMoved);
rawTouchPoints[2].setState(Qt::TouchPointMoved);
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(rawTouchPoints));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
// generate end events on all widget, the right widget should die
rawTouchPoints[0].setState(Qt::TouchPointReleased);
rawTouchPoints[1].setState(Qt::TouchPointReleased);
rawTouchPoints[2].setState(Qt::TouchPointReleased);
- QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(),
- 0,
- touchScreenDevice,
- touchPointList(rawTouchPoints));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
}
@@ -1447,6 +1414,8 @@ void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin()
void tst_QTouchEvent::touchBeginWithGraphicsWidget()
{
+ if (QHighDpiScaling::isActive())
+ QSKIP("Fails when scaling is active");
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowTitle(QTest::currentTestFunction());
@@ -1605,12 +1574,15 @@ void tst_QTouchEvent::testMultiDevice()
QWindowSystemInterface::TouchPoint tp;
tp.id = 0;
tp.state = Qt::TouchPointPressed;
- tp.area = QRectF(120, 120, 20, 20);
+ const QPoint screenOrigin = w.screen()->geometry().topLeft();
+ const QRect area0(120, 120, 20, 20);
+ tp.area = QHighDpi::toNative(area0, QHighDpiScaling::factor(&w), screenOrigin);
pointsOne.append(tp);
pointsTwo.append(tp);
tp.id = 1;
- tp.area = QRectF(140, 140, 20, 20);
+ const QRect area1(140, 140, 20, 20);
+ tp.area = QHighDpi::toNative(area1, QHighDpiScaling::factor(&w), screenOrigin);
pointsTwo.append(tp);
QWindowSystemInterface::handleTouchEvent(&w, deviceOne, pointsOne);
@@ -1625,12 +1597,12 @@ void tst_QTouchEvent::testMultiDevice()
QCOMPARE(filter.d.value(deviceOne).points.count(), 1);
QCOMPARE(filter.d.value(deviceTwo).points.count(), 2);
- QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), pointsOne[0].area);
+ QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), QRectF(area0));
QCOMPARE(filter.d.value(deviceOne).points.at(0).state(), pointsOne[0].state);
- QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), pointsTwo[0].area);
+ QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), QRectF(area0));
QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state);
- QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenRect(), pointsTwo[1].area);
+ QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenRect(), QRectF(area1));
QCOMPARE(filter.d.value(deviceTwo).points.at(1).state(), pointsTwo[1].state);
}
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index d361aa12a6..2219306b81 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -35,6 +35,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
+#include <private/qhighdpiscaling_p.h>
#include <QtGui/QPainter>
#include <QtTest/QtTest>
@@ -265,6 +266,19 @@ void tst_QWindow::positioning_data()
#endif
}
+// Compare a window position that may go through scaling in the platform plugin with fuzz.
+static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz)
+{
+ return (p1 - p2).manhattanLength() <= fuzz;
+}
+
+static QString msgPointMismatch(const QPoint &p1, const QPoint p2)
+{
+ QString result;
+ QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength();
+ return result;
+}
+
void tst_QWindow::positioning()
{
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(
@@ -272,7 +286,7 @@ void tst_QWindow::positioning()
QSKIP("This platform does not support non-fullscreen windows");
}
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
// Some platforms enforce minimum widths for windows, which can cause extra resize
@@ -327,21 +341,25 @@ void tst_QWindow::positioning()
// if our positioning is actually fully respected by the window manager
// test whether it correctly handles frame positioning as well
if (originalPos == geometry.topLeft() && (originalMargins.top() != 0 || originalMargins.left() != 0)) {
- QPoint framePos = QPlatformScreen::platformScreenForWindow(&window)->availableGeometry().center();
+ const QScreen *screen = window.screen();
+ const QRect availableGeometry = screen->availableGeometry();
+ const QPoint framePos = availableGeometry.center();
window.reset();
const QPoint oldFramePos = window.framePosition();
window.setFramePosition(framePos);
QTRY_VERIFY(window.received(QEvent::Move));
- if (window.framePosition() != framePos) {
+ const int fuzz = int(QHighDpiScaling::factor(&window));
+ if (!qFuzzyCompareWindowPosition(window.framePosition(), framePos, fuzz)) {
qDebug() << "About to fail auto-test. Here is some additional information:";
qDebug() << "window.framePosition() == " << window.framePosition();
qDebug() << "old frame position == " << oldFramePos;
qDebug() << "We received " << window.received(QEvent::Move) << " move events";
qDebug() << "frame positions after each move event:" << window.m_framePositionsOnMove;
}
- QTRY_COMPARE(framePos, window.framePosition());
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(window.framePosition(), framePos, fuzz),
+ qPrintable(msgPointMismatch(window.framePosition(), framePos)));
QTRY_COMPARE(originalMargins, window.frameMargins());
QCOMPARE(window.position(), window.framePosition() + QPoint(originalMargins.left(), originalMargins.top()));
@@ -357,7 +375,8 @@ void tst_QWindow::positioning()
void tst_QWindow::positioningDuringMinimized()
{
// QTBUG-39544, setting a geometry in minimized state should work as well.
- if (QGuiApplication::platformName().compare("windows", Qt::CaseInsensitive))
+ if (QGuiApplication::platformName().compare("windows", Qt::CaseInsensitive) != 0
+ && QGuiApplication::platformName().compare("cocoa", Qt::CaseInsensitive) != 0)
QSKIP("Not supported on this platform");
Window window;
window.setTitle(QStringLiteral("positioningDuringMinimized"));
@@ -418,14 +437,14 @@ void tst_QWindow::platformSurface()
QCOMPARE(window.geometry(), geometry);
window.create();
- QTRY_VERIFY(window.received(QEvent::PlatformSurface) == 1);
- QTRY_VERIFY(window.surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated);
+ QTRY_COMPARE(window.received(QEvent::PlatformSurface), 1);
+ QTRY_COMPARE(window.surfaceEventType(), QPlatformSurfaceEvent::SurfaceCreated);
QTRY_VERIFY(window.handle() != Q_NULLPTR);
window.destroy();
- QTRY_VERIFY(window.received(QEvent::PlatformSurface) == 2);
- QTRY_VERIFY(window.surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);
- QTRY_VERIFY(window.handle() == Q_NULLPTR);
+ QTRY_COMPARE(window.received(QEvent::PlatformSurface), 2);
+ QTRY_COMPARE(window.surfaceEventType(), QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);
+ QTRY_VERIFY(!window.handle());
// Check for synchronous delivery of platform surface events and that the platform
// surface always existed upon event delivery
@@ -457,7 +476,7 @@ void tst_QWindow::isExposed()
window.hide();
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This is flaky. Figure out why.");
QCoreApplication::processEvents();
@@ -468,7 +487,7 @@ void tst_QWindow::isExposed()
void tst_QWindow::isActive()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
Window window;
@@ -487,7 +506,7 @@ void tst_QWindow::isActive()
context.swapBuffers(&window);
#endif
QTRY_COMPARE(window.received(QEvent::Resize), 1);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QVERIFY(window.isActive());
Window child;
@@ -499,7 +518,7 @@ void tst_QWindow::isActive()
child.requestActivate();
- QTRY_VERIFY(QGuiApplication::focusWindow() == &child);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &child);
QVERIFY(child.isActive());
// parent shouldn't receive new resize events from child being shown
@@ -522,7 +541,7 @@ void tst_QWindow::isActive()
QTRY_VERIFY(dialog.isExposed());
QCoreApplication::processEvents();
QTRY_COMPARE(dialog.received(QEvent::Resize), 1);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &dialog);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &dialog);
QVERIFY(dialog.isActive());
// transient child has focus
@@ -533,7 +552,7 @@ void tst_QWindow::isActive()
window.requestActivate();
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QCoreApplication::processEvents();
QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1);
QTRY_COMPARE(window.received(QEvent::FocusIn), 2);
@@ -654,15 +673,13 @@ void tst_QWindow::testInputEvents()
window.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- QWindowSystemInterface::handleKeyEvent(&window, QEvent::KeyPress, Qt::Key_A, Qt::NoModifier);
- QWindowSystemInterface::handleKeyEvent(&window, QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier);
+ QTest::keyClick(&window, Qt::Key_A, Qt::NoModifier);
QCoreApplication::processEvents();
QCOMPARE(window.keyPressCode, int(Qt::Key_A));
QCOMPARE(window.keyReleaseCode, int(Qt::Key_A));
QPointF local(12, 34);
- QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton);
- QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::NoButton);
+ QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, local.toPoint());
QCoreApplication::processEvents();
QCOMPARE(window.mousePressButton, int(Qt::LeftButton));
QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton));
@@ -688,15 +705,17 @@ void tst_QWindow::testInputEvents()
// Now with null pointer as window. local param should not be utilized:
// handleMouseEvent() with tlw == 0 means the event is in global coords only.
window.mousePressButton = window.mouseReleaseButton = 0;
- QPointF nonWindowGlobal(window.geometry().topRight() + QPoint(200, 50)); // not inside the window
- QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::LeftButton);
- QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::NoButton);
+ const QPointF nonWindowGlobal(window.geometry().topRight() + QPoint(200, 50)); // not inside the window
+ const QPointF deviceNonWindowGlobal = QHighDpi::toNativePixels(nonWindowGlobal, window.screen());
+ QWindowSystemInterface::handleMouseEvent(0, deviceNonWindowGlobal, deviceNonWindowGlobal, Qt::LeftButton);
+ QWindowSystemInterface::handleMouseEvent(0, deviceNonWindowGlobal, deviceNonWindowGlobal, Qt::NoButton);
QCoreApplication::processEvents();
QCOMPARE(window.mousePressButton, 0);
QCOMPARE(window.mouseReleaseButton, 0);
- QPointF windowGlobal = window.mapToGlobal(local.toPoint());
- QWindowSystemInterface::handleMouseEvent(0, windowGlobal, windowGlobal, Qt::LeftButton);
- QWindowSystemInterface::handleMouseEvent(0, windowGlobal, windowGlobal, Qt::NoButton);
+ const QPointF windowGlobal = window.mapToGlobal(local.toPoint());
+ const QPointF deviceWindowGlobal = QHighDpi::toNativePixels(windowGlobal, window.screen());
+ QWindowSystemInterface::handleMouseEvent(0, deviceWindowGlobal, deviceWindowGlobal, Qt::LeftButton);
+ QWindowSystemInterface::handleMouseEvent(0, deviceWindowGlobal, deviceWindowGlobal, Qt::NoButton);
QCoreApplication::processEvents();
QCOMPARE(window.mousePressButton, int(Qt::LeftButton));
QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton));
@@ -718,7 +737,7 @@ void tst_QWindow::touchToMouseTranslation()
const QRectF moveArea(105, 108, 4, 4);
tp1.id = 1;
tp1.state = Qt::TouchPointPressed;
- tp1.area = pressArea;
+ tp1.area = QHighDpi::toNativePixels(pressArea, &window);
tp2.id = 2;
tp2.state = Qt::TouchPointPressed;
points << tp1 << tp2;
@@ -729,7 +748,7 @@ void tst_QWindow::touchToMouseTranslation()
tp1.state = Qt::TouchPointStationary;
tp2.id = 1;
tp2.state = Qt::TouchPointMoved;
- tp2.area = moveArea;
+ tp2.area = QHighDpi::toNativePixels(moveArea, &window);
points.clear();
points << tp1 << tp2;
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
@@ -946,12 +965,15 @@ void tst_QWindow::touchCancelWithTouchToMouse()
tp1.id = 1;
tp1.state = Qt::TouchPointPressed;
- tp1.area = QRect(100, 100, 4, 4);
+ const QRect area(100, 100, 4, 4);
+ tp1.area = QHighDpi::toNativePixels(area, &window);
points << tp1;
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
QCoreApplication::processEvents();
QTRY_COMPARE(window.mousePressButton, int(Qt::LeftButton));
- QTRY_COMPARE(window.mousePressScreenPos, points[0].area.center());
+ const int fuzz = 2 * int(QHighDpiScaling::factor(&window));
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(window.mousePressScreenPos.toPoint(), area.center(), fuzz),
+ qPrintable(msgPointMismatch(window.mousePressScreenPos.toPoint(), area.center())));
// Cancel the touch. Should result in a mouse release for windows that have
// have an active touch-to-mouse sequence.
@@ -1112,7 +1134,7 @@ void tst_QWindow::close()
void tst_QWindow::activateAndClose()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
for (int i = 0; i < 10; ++i) {
@@ -1149,8 +1171,9 @@ void tst_QWindow::mouseEventSequence()
ulong timestamp = 0;
QPointF local(12, 34);
- QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton);
- QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton);
+ const QPointF deviceLocal = QHighDpi::toNativePixels(local, &window);
+ QWindowSystemInterface::handleMouseEvent(&window, timestamp++, deviceLocal, deviceLocal, Qt::LeftButton);
+ QWindowSystemInterface::handleMouseEvent(&window, timestamp++, deviceLocal, deviceLocal, Qt::NoButton);
QCoreApplication::processEvents();
QCOMPARE(window.mousePressedCount, 1);
QCOMPARE(window.mouseReleasedCount, 1);
@@ -1308,14 +1331,14 @@ void tst_QWindow::inputReentrancy()
class TabletTestWindow : public QWindow
{
public:
- TabletTestWindow() : eventType(0) { }
+ TabletTestWindow() : eventType(QEvent::None) { }
void tabletEvent(QTabletEvent *ev) {
eventType = ev->type();
eventGlobal = ev->globalPosF();
eventLocal = ev->posF();
eventDevice = ev->device();
}
- int eventType;
+ QEvent::Type eventType;
QPointF eventGlobal, eventLocal;
int eventDevice;
bool eventFilter(QObject *obj, QEvent *ev) {
@@ -1337,25 +1360,27 @@ void tst_QWindow::tabletEvents()
window.setGeometry(QRect(m_availableTopLeft + QPoint(10, 10), m_testWindowSize));
qGuiApp->installEventFilter(&window);
- QPoint local(10, 10);
- QPoint global = window.mapToGlobal(local);
- QWindowSystemInterface::handleTabletEvent(&window, true, local, global, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0);
+ const QPoint local(10, 10);
+ const QPoint global = window.mapToGlobal(local);
+ const QPoint deviceLocal = QHighDpi::toNativeLocalPosition(local, &window);
+ const QPoint deviceGlobal = QHighDpi::toNativePixels(global, window.screen());
+ QWindowSystemInterface::handleTabletEvent(&window, true, deviceLocal, deviceGlobal, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0);
QCoreApplication::processEvents();
QTRY_VERIFY(window.eventType == QEvent::TabletPress);
QTRY_COMPARE(window.eventGlobal.toPoint(), global);
QTRY_COMPARE(window.eventLocal.toPoint(), local);
- QWindowSystemInterface::handleTabletEvent(&window, false, local, global, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0);
+ QWindowSystemInterface::handleTabletEvent(&window, false, deviceLocal, deviceGlobal, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0);
QCoreApplication::processEvents();
- QTRY_VERIFY(window.eventType == QEvent::TabletRelease);
+ QTRY_COMPARE(window.eventType, QEvent::TabletRelease);
QWindowSystemInterface::handleTabletEnterProximityEvent(1, 2, 3);
QCoreApplication::processEvents();
- QTRY_VERIFY(window.eventType == QEvent::TabletEnterProximity);
+ QTRY_COMPARE(window.eventType, QEvent::TabletEnterProximity);
QTRY_COMPARE(window.eventDevice, 1);
QWindowSystemInterface::handleTabletLeaveProximityEvent(1, 2, 3);
QCoreApplication::processEvents();
- QTRY_VERIFY(window.eventType == QEvent::TabletLeaveProximity);
+ QTRY_COMPARE(window.eventType, QEvent::TabletLeaveProximity);
QTRY_COMPARE(window.eventDevice, 1);
#endif
@@ -1363,7 +1388,7 @@ void tst_QWindow::tabletEvents()
void tst_QWindow::windowModality_QTBUG27039()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QWindow parent;
@@ -1458,7 +1483,7 @@ void tst_QWindow::mask()
void tst_QWindow::initialSize()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QSize defaultSize(0,0);
@@ -1499,7 +1524,7 @@ void tst_QWindow::initialSize()
void tst_QWindow::modalDialog()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QWindow normalWindow;
@@ -1525,7 +1550,7 @@ void tst_QWindow::modalDialog()
void tst_QWindow::modalDialogClosingOneOfTwoModal()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QWindow normalWindow;
@@ -1563,7 +1588,7 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal()
void tst_QWindow::modalWithChildWindow()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QWindow normalWindow;
@@ -1597,7 +1622,7 @@ void tst_QWindow::modalWithChildWindow()
void tst_QWindow::modalWindowModallity()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QWindow normal_window;
@@ -1703,13 +1728,13 @@ void tst_QWindow::requestUpdate()
QCoreApplication::processEvents();
QTRY_VERIFY(window.isExposed());
- QVERIFY(window.received(QEvent::UpdateRequest) == 0);
+ QCOMPARE(window.received(QEvent::UpdateRequest), 0);
window.requestUpdate();
- QTRY_VERIFY(window.received(QEvent::UpdateRequest) == 1);
+ QTRY_COMPARE(window.received(QEvent::UpdateRequest), 1);
window.requestUpdate();
- QTRY_VERIFY(window.received(QEvent::UpdateRequest) == 2);
+ QTRY_COMPARE(window.received(QEvent::UpdateRequest), 2);
}
#include <tst_qwindow.moc>
diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index e7659a25bd..463322ff2a 100644
--- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -673,7 +673,7 @@ void tst_QMatrixNxN::compare2x2()
QMatrix2x2 m2(uniqueValues2);
QMatrix2x2 m3(transposedValues2);
- QVERIFY(m1 == m2);
+ QCOMPARE(m1, m2);
QVERIFY(!(m1 != m2));
QVERIFY(m1 != m3);
QVERIFY(!(m1 == m3));
@@ -686,7 +686,7 @@ void tst_QMatrixNxN::compare3x3()
QMatrix3x3 m2(uniqueValues3);
QMatrix3x3 m3(transposedValues3);
- QVERIFY(m1 == m2);
+ QCOMPARE(m1, m2);
QVERIFY(!(m1 != m2));
QVERIFY(m1 != m3);
QVERIFY(!(m1 == m3));
@@ -699,7 +699,7 @@ void tst_QMatrixNxN::compare4x4()
QMatrix4x4 m2(uniqueValues4);
QMatrix4x4 m3(transposedValues4);
- QVERIFY(m1 == m2);
+ QCOMPARE(m1, m2);
QVERIFY(!(m1 != m2));
QVERIFY(m1 != m3);
QVERIFY(!(m1 == m3));
@@ -712,7 +712,7 @@ void tst_QMatrixNxN::compare4x3()
QMatrix4x3 m2(uniqueValues4x3);
QMatrix4x3 m3(transposedValues3x4);
- QVERIFY(m1 == m2);
+ QCOMPARE(m1, m2);
QVERIFY(!(m1 != m2));
QVERIFY(m1 != m3);
QVERIFY(!(m1 == m3));
@@ -1858,7 +1858,7 @@ void tst_QMatrixNxN::inverted4x4()
if (invertible)
QVERIFY(m1.determinant() != 0.0f);
else
- QVERIFY(m1.determinant() == 0.0f);
+ QCOMPARE(m1.determinant(), 0.0f);
Matrix4 m1alt;
memcpy(m1alt.v, (const float *)m1Values, sizeof(m1alt.v));
@@ -1992,7 +1992,7 @@ void tst_QMatrixNxN::scale4x4()
if (z == 1.0f) {
QMatrix4x4 m2b;
m2b.scale(x, y);
- QVERIFY(m2b == m2);
+ QCOMPARE(m2b, m2);
}
QVector3D v1(2.0f, 3.0f, -4.0f);
@@ -2051,7 +2051,7 @@ void tst_QMatrixNxN::scale4x4()
if (z == 1.0f) {
QMatrix4x4 m4b(m3);
m4b.scale(x, y);
- QVERIFY(m4b == m4);
+ QCOMPARE(m4b, m4);
}
// Test coverage when the special matrix type is unknown.
@@ -2138,7 +2138,7 @@ void tst_QMatrixNxN::translate4x4()
if (z == 0.0f) {
QMatrix4x4 m2b;
m2b.translate(x, y);
- QVERIFY(m2b == m2);
+ QCOMPARE(m2b, m2);
}
QVector3D v1(2.0f, 3.0f, -4.0f);
@@ -2179,7 +2179,7 @@ void tst_QMatrixNxN::translate4x4()
if (z == 0.0f) {
QMatrix4x4 m4b(m3);
m4b.translate(x, y);
- QVERIFY(m4b == m4);
+ QCOMPARE(m4b, m4);
}
}
@@ -3073,7 +3073,7 @@ void tst_QMatrixNxN::convertQMatrix()
QPointF p2 = m2 * QPointF(100.0, 150.0);
QCOMPARE((double)p2.x(), 100.0 - 3.5);
QCOMPARE((double)p2.y(), 150.0 + 2.0);
- QVERIFY(m1 == m2.toAffine());
+ QCOMPARE(m1, m2.toAffine());
QMatrix m3;
m3.scale(1.5, -2.0);
@@ -3085,7 +3085,7 @@ void tst_QMatrixNxN::convertQMatrix()
QPointF p4 = m4 * QPointF(100.0, 150.0);
QCOMPARE((double)p4.x(), 1.5 * 100.0);
QCOMPARE((double)p4.y(), -2.0 * 150.0);
- QVERIFY(m3 == m4.toAffine());
+ QCOMPARE(m3, m4.toAffine());
QMatrix m5;
m5.rotate(45.0);
@@ -3120,7 +3120,7 @@ void tst_QMatrixNxN::convertQTransform()
QPointF p2 = m2 * QPointF(100.0, 150.0);
QCOMPARE((double)p2.x(), 100.0 - 3.5);
QCOMPARE((double)p2.y(), 150.0 + 2.0);
- QVERIFY(m1 == m2.toTransform());
+ QCOMPARE(m1, m2.toTransform());
QTransform m3;
m3.scale(1.5, -2.0);
@@ -3132,7 +3132,7 @@ void tst_QMatrixNxN::convertQTransform()
QPointF p4 = m4 * QPointF(100.0, 150.0);
QCOMPARE((double)p4.x(), 1.5 * 100.0);
QCOMPARE((double)p4.y(), -2.0 * 150.0);
- QVERIFY(m3 == m4.toTransform());
+ QCOMPARE(m3, m4.toTransform());
QTransform m5;
m5.rotate(45.0);
@@ -3206,16 +3206,16 @@ void tst_QMatrixNxN::mapRect()
QRect recti(qRound(x), qRound(y), qRound(width), qRound(height));
QMatrix4x4 m1;
- QVERIFY(m1.mapRect(rect) == rect);
- QVERIFY(m1.mapRect(recti) == recti);
+ QCOMPARE(m1.mapRect(rect), rect);
+ QCOMPARE(m1.mapRect(recti), recti);
QMatrix4x4 m2;
m2.translate(-100.5f, 64.0f);
QRectF translated = rect.translated(-100.5f, 64.0f);
QRect translatedi = QRect(qRound(recti.x() - 100.5f), recti.y() + 64,
recti.width(), recti.height());
- QVERIFY(m2.mapRect(rect) == translated);
- QVERIFY(m2.mapRect(recti) == translatedi);
+ QCOMPARE(m2.mapRect(rect), translated);
+ QCOMPARE(m2.mapRect(recti), translatedi);
QMatrix4x4 m3;
m3.scale(-100.5f, 64.0f);
@@ -3232,7 +3232,7 @@ void tst_QMatrixNxN::mapRect()
scaley -= scaleht;
}
QRectF scaled(scalex, scaley, scalewid, scaleht);
- QVERIFY(m3.mapRect(rect) == scaled);
+ QCOMPARE(m3.mapRect(rect), scaled);
scalex = recti.x() * -100.5f;
scaley = recti.y() * 64.0f;
scalewid = recti.width() * -100.5f;
@@ -3247,7 +3247,7 @@ void tst_QMatrixNxN::mapRect()
}
QRect scaledi(qRound(scalex), qRound(scaley),
qRound(scalewid), qRound(scaleht));
- QVERIFY(m3.mapRect(recti) == scaledi);
+ QCOMPARE(m3.mapRect(recti), scaledi);
QMatrix4x4 m4;
m4.translate(-100.5f, 64.0f);
@@ -3261,7 +3261,7 @@ void tst_QMatrixNxN::mapRect()
if (transy1 > transy2)
qSwap(transy1, transy2);
QRectF trans(transx1, transy1, transx2 - transx1, transy2 - transy1);
- QVERIFY(m4.mapRect(rect) == trans);
+ QCOMPARE(m4.mapRect(rect), trans);
transx1 = recti.x() * -2.5f - 100.5f;
transy1 = recti.y() * 4.0f + 64.0f;
transx2 = (recti.x() + recti.width()) * -2.5f - 100.5f;
@@ -3273,7 +3273,7 @@ void tst_QMatrixNxN::mapRect()
QRect transi(qRound(transx1), qRound(transy1),
qRound(transx2) - qRound(transx1),
qRound(transy2) - qRound(transy1));
- QVERIFY(m4.mapRect(recti) == transi);
+ QCOMPARE(m4.mapRect(recti), transi);
m4.rotate(45.0f, 0.0f, 0.0f, 1.0f);
@@ -3290,7 +3290,7 @@ void tst_QMatrixNxN::mapRect()
QRect mri = m4.mapRect(recti);
QRect tri = t4.mapRect(recti);
- QVERIFY(mri == tri);
+ QCOMPARE(mri, tri);
}
void tst_QMatrixNxN::mapVector_data()
@@ -3389,14 +3389,14 @@ void tst_QMatrixNxN::properties()
void tst_QMatrixNxN::metaTypes()
{
- QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4);
+ QCOMPARE(QMetaType::type("QMatrix4x4"), int(QMetaType::QMatrix4x4));
QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)),
QByteArray("QMatrix4x4"));
QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4));
- QVERIFY(qMetaTypeId<QMatrix4x4>() == QMetaType::QMatrix4x4);
+ QCOMPARE(qMetaTypeId<QMatrix4x4>(), int(QMetaType::QMatrix4x4));
}
QTEST_APPLESS_MAIN(tst_QMatrixNxN)
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index ec7af97f07..1fbad5b829 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -446,7 +446,7 @@ void tst_QQuaternion::compare()
QQuaternion v5(8, 1, 2, 3);
QQuaternion v6(3, 1, 2, 4);
- QVERIFY(v1 == v2);
+ QCOMPARE(v1, v2);
QVERIFY(v1 != v3);
QVERIFY(v1 != v4);
QVERIFY(v1 != v5);
@@ -522,7 +522,7 @@ void tst_QQuaternion::add()
QQuaternion v4(v1);
v4 += v2;
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
QCOMPARE(v4.x(), v1.x() + v2.x());
QCOMPARE(v4.y(), v1.y() + v2.y());
@@ -560,7 +560,7 @@ void tst_QQuaternion::subtract()
QQuaternion v4(v3);
v4 -= v1;
- QVERIFY(v4 == v2);
+ QCOMPARE(v4, v2);
QCOMPARE(v4.x(), v3.x() - v1.x());
QCOMPARE(v4.y(), v3.y() - v1.y());
@@ -569,7 +569,7 @@ void tst_QQuaternion::subtract()
QQuaternion v5(v3);
v5 -= v2;
- QVERIFY(v5 == v1);
+ QCOMPARE(v5, v1);
QCOMPARE(v5.x(), v3.x() - v2.x());
QCOMPARE(v5.y(), v3.y() - v2.y());
@@ -704,7 +704,7 @@ void tst_QQuaternion::multiplyFactor()
QQuaternion v3(v1);
v3 *= factor;
- QVERIFY(v3 == v2);
+ QCOMPARE(v3, v2);
QCOMPARE(v3.x(), v1.x() * factor);
QCOMPARE(v3.y(), v1.y() * factor);
@@ -740,7 +740,7 @@ void tst_QQuaternion::divide()
QQuaternion v3(v2);
v3 /= factor;
- QVERIFY(v3 == v1);
+ QCOMPARE(v3, v1);
QCOMPARE(v3.x(), v2.x() / factor);
QCOMPARE(v3.y(), v2.y() / factor);
@@ -764,7 +764,7 @@ void tst_QQuaternion::negate()
QQuaternion v1(w1, x1, y1, z1);
QQuaternion v2(-w1, -x1, -y1, -z1);
- QVERIFY(-v1 == v2);
+ QCOMPARE(-v1, v2);
}
// Test quaternion conjugate calculations.
@@ -783,7 +783,7 @@ void tst_QQuaternion::conjugate()
QQuaternion v1(w1, x1, y1, z1);
QQuaternion v2(w1, -x1, -y1, -z1);
- QVERIFY(v1.conjugate() == v2);
+ QCOMPARE(v1.conjugate(), v2);
}
// Test quaternion creation from an axis and an angle.
@@ -1325,14 +1325,14 @@ void tst_QQuaternion::properties()
void tst_QQuaternion::metaTypes()
{
- QVERIFY(QMetaType::type("QQuaternion") == QMetaType::QQuaternion);
+ QCOMPARE(QMetaType::type("QQuaternion"), int(QMetaType::QQuaternion));
QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QQuaternion)),
QByteArray("QQuaternion"));
QVERIFY(QMetaType::isRegistered(QMetaType::QQuaternion));
- QVERIFY(qMetaTypeId<QQuaternion>() == QMetaType::QQuaternion);
+ QCOMPARE(qMetaTypeId<QQuaternion>(), int(QMetaType::QQuaternion));
}
QTEST_APPLESS_MAIN(tst_QQuaternion)
diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
index d2e0bbe375..eeff2c3bae 100644
--- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
+++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
@@ -885,7 +885,7 @@ void tst_QVectorND::compare2()
QVector2D v3(3, 2);
QVector2D v4(1, 3);
- QVERIFY(v1 == v2);
+ QCOMPARE(v1, v2);
QVERIFY(v1 != v3);
QVERIFY(v1 != v4);
}
@@ -899,7 +899,7 @@ void tst_QVectorND::compare3()
QVector3D v4(1, 3, 4);
QVector3D v5(1, 2, 3);
- QVERIFY(v1 == v2);
+ QCOMPARE(v1, v2);
QVERIFY(v1 != v3);
QVERIFY(v1 != v4);
QVERIFY(v1 != v5);
@@ -915,7 +915,7 @@ void tst_QVectorND::compare4()
QVector4D v5(1, 2, 3, 8);
QVector4D v6(1, 2, 4, 3);
- QVERIFY(v1 == v2);
+ QCOMPARE(v1, v2);
QVERIFY(v1 != v3);
QVERIFY(v1 != v4);
QVERIFY(v1 != v5);
@@ -969,7 +969,7 @@ void tst_QVectorND::add2()
QVector2D v4(v1);
v4 += v2;
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
QCOMPARE(v4.x(), v1.x() + v2.x());
QCOMPARE(v4.y(), v1.y() + v2.y());
@@ -1033,7 +1033,7 @@ void tst_QVectorND::add3()
QVector3D v4(v1);
v4 += v2;
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
QCOMPARE(v4.x(), v1.x() + v2.x());
QCOMPARE(v4.y(), v1.y() + v2.y());
@@ -1109,7 +1109,7 @@ void tst_QVectorND::add4()
QVector4D v4(v1);
v4 += v2;
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
QCOMPARE(v4.x(), v1.x() + v2.x());
QCOMPARE(v4.y(), v1.y() + v2.y());
@@ -1141,14 +1141,14 @@ void tst_QVectorND::subtract2()
QVector2D v4(v3);
v4 -= v1;
- QVERIFY(v4 == v2);
+ QCOMPARE(v4, v2);
QCOMPARE(v4.x(), v3.x() - v1.x());
QCOMPARE(v4.y(), v3.y() - v1.y());
QVector2D v5(v3);
v5 -= v2;
- QVERIFY(v5 == v1);
+ QCOMPARE(v5, v1);
QCOMPARE(v5.x(), v3.x() - v2.x());
QCOMPARE(v5.y(), v3.y() - v2.y());
@@ -1181,7 +1181,7 @@ void tst_QVectorND::subtract3()
QVector3D v4(v3);
v4 -= v1;
- QVERIFY(v4 == v2);
+ QCOMPARE(v4, v2);
QCOMPARE(v4.x(), v3.x() - v1.x());
QCOMPARE(v4.y(), v3.y() - v1.y());
@@ -1189,7 +1189,7 @@ void tst_QVectorND::subtract3()
QVector3D v5(v3);
v5 -= v2;
- QVERIFY(v5 == v1);
+ QCOMPARE(v5, v1);
QCOMPARE(v5.x(), v3.x() - v2.x());
QCOMPARE(v5.y(), v3.y() - v2.y());
@@ -1226,7 +1226,7 @@ void tst_QVectorND::subtract4()
QVector4D v4(v3);
v4 -= v1;
- QVERIFY(v4 == v2);
+ QCOMPARE(v4, v2);
QCOMPARE(v4.x(), v3.x() - v1.x());
QCOMPARE(v4.y(), v3.y() - v1.y());
@@ -1235,7 +1235,7 @@ void tst_QVectorND::subtract4()
QVector4D v5(v3);
v5 -= v2;
- QVERIFY(v5 == v1);
+ QCOMPARE(v5, v1);
QCOMPARE(v5.x(), v3.x() - v2.x());
QCOMPARE(v5.y(), v3.y() - v2.y());
@@ -1290,7 +1290,7 @@ void tst_QVectorND::multiply2()
QVector2D v4(v1);
v4 *= v2;
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
QCOMPARE(v4.x(), v1.x() * v2.x());
QCOMPARE(v4.y(), v1.y() * v2.y());
@@ -1354,7 +1354,7 @@ void tst_QVectorND::multiply3()
QVector3D v4(v1);
v4 *= v2;
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
QCOMPARE(v4.x(), v1.x() * v2.x());
QCOMPARE(v4.y(), v1.y() * v2.y());
@@ -1430,7 +1430,7 @@ void tst_QVectorND::multiply4()
QVector4D v4(v1);
v4 *= v2;
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
QCOMPARE(v4.x(), v1.x() * v2.x());
QCOMPARE(v4.y(), v1.y() * v2.y());
@@ -1488,7 +1488,7 @@ void tst_QVectorND::multiplyFactor2()
QVector2D v3(v1);
v3 *= factor;
- QVERIFY(v3 == v2);
+ QCOMPARE(v3, v2);
QCOMPARE(v3.x(), v1.x() * factor);
QCOMPARE(v3.y(), v1.y() * factor);
@@ -1553,7 +1553,7 @@ void tst_QVectorND::multiplyFactor3()
QVector3D v3(v1);
v3 *= factor;
- QVERIFY(v3 == v2);
+ QCOMPARE(v3, v2);
QCOMPARE(v3.x(), v1.x() * factor);
QCOMPARE(v3.y(), v1.y() * factor);
@@ -1628,7 +1628,7 @@ void tst_QVectorND::multiplyFactor4()
QVector4D v3(v1);
v3 *= factor;
- QVERIFY(v3 == v2);
+ QCOMPARE(v3, v2);
QCOMPARE(v3.x(), v1.x() * factor);
QCOMPARE(v3.y(), v1.y() * factor);
@@ -1660,7 +1660,7 @@ void tst_QVectorND::divide2()
QVector2D v4(v3);
v4 /= v2;
- QVERIFY(v4 == v1);
+ QCOMPARE(v4, v1);
QCOMPARE(v4.x(), v3.x() / v2.x());
QCOMPARE(v4.y(), v3.y() / v2.y());
@@ -1670,7 +1670,7 @@ void tst_QVectorND::divide2()
QVector2D v4(v3);
v4 /= v1;
- QVERIFY(v4 == v2);
+ QCOMPARE(v4, v2);
QCOMPARE(v4.x(), v3.x() / v1.x());
QCOMPARE(v4.y(), v3.y() / v1.y());
@@ -1704,7 +1704,7 @@ void tst_QVectorND::divide3()
QVector3D v4(v3);
v4 /= v2;
- QVERIFY(v4 == v1);
+ QCOMPARE(v4, v1);
QCOMPARE(v4.x(), v3.x() / v2.x());
QCOMPARE(v4.y(), v3.y() / v2.y());
@@ -1715,7 +1715,7 @@ void tst_QVectorND::divide3()
QVector3D v4(v3);
v4 /= v1;
- QVERIFY(v4 == v2);
+ QCOMPARE(v4, v2);
QCOMPARE(v4.x(), v3.x() / v1.x());
QCOMPARE(v4.y(), v3.y() / v1.y());
@@ -1753,7 +1753,7 @@ void tst_QVectorND::divide4()
QVector4D v4(v3);
v4 /= v2;
- QVERIFY(v4 == v1);
+ QCOMPARE(v4, v1);
QCOMPARE(v4.x(), v3.x() / v2.x());
QCOMPARE(v4.y(), v3.y() / v2.y());
@@ -1765,7 +1765,7 @@ void tst_QVectorND::divide4()
QVector4D v4(v3);
v4 /= v1;
- QVERIFY(v4 == v2);
+ QCOMPARE(v4, v2);
QCOMPARE(v4.x(), v3.x() / v1.x());
QCOMPARE(v4.y(), v3.y() / v1.y());
@@ -1798,7 +1798,7 @@ void tst_QVectorND::divideFactor2()
QVector2D v3(v2);
v3 /= factor;
- QVERIFY(v3 == v1);
+ QCOMPARE(v3, v1);
QCOMPARE(v3.x(), v2.x() / factor);
QCOMPARE(v3.y(), v2.y() / factor);
@@ -1830,7 +1830,7 @@ void tst_QVectorND::divideFactor3()
QVector3D v3(v2);
v3 /= factor;
- QVERIFY(v3 == v1);
+ QCOMPARE(v3, v1);
QCOMPARE(v3.x(), v2.x() / factor);
QCOMPARE(v3.y(), v2.y() / factor);
@@ -1865,7 +1865,7 @@ void tst_QVectorND::divideFactor4()
QVector4D v3(v2);
v3 /= factor;
- QVERIFY(v3 == v1);
+ QCOMPARE(v3, v1);
QCOMPARE(v3.x(), v2.x() / factor);
QCOMPARE(v3.y(), v2.y() / factor);
@@ -1887,7 +1887,7 @@ void tst_QVectorND::negate2()
QVector2D v1(x1, y1);
QVector2D v2(-x1, -y1);
- QVERIFY(-v1 == v2);
+ QCOMPARE(-v1, v2);
}
// Test vector negation for 3D vectors.
@@ -1905,7 +1905,7 @@ void tst_QVectorND::negate3()
QVector3D v1(x1, y1, z1);
QVector3D v2(-x1, -y1, -z1);
- QVERIFY(-v1 == v2);
+ QCOMPARE(-v1, v2);
}
// Test vector negation for 4D vectors.
@@ -1924,7 +1924,7 @@ void tst_QVectorND::negate4()
QVector4D v1(x1, y1, z1, w1);
QVector4D v2(-x1, -y1, -z1, -w1);
- QVERIFY(-v1 == v2);
+ QCOMPARE(-v1, v2);
}
// Test the computation of vector cross-products.
@@ -1976,7 +1976,7 @@ void tst_QVectorND::crossProduct()
QVector3D v3(x3, y3, z3);
QVector3D v4 = QVector3D::crossProduct(v1, v2);
- QVERIFY(v4 == v3);
+ QCOMPARE(v4, v3);
// Compute the cross-product long-hand and check again.
float xres = y1 * z2 - z1 * y2;
@@ -2667,9 +2667,9 @@ void tst_QVectorND::properties()
void tst_QVectorND::metaTypes()
{
- QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D);
- QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D);
- QVERIFY(QMetaType::type("QVector4D") == QMetaType::QVector4D);
+ QCOMPARE(QMetaType::type("QVector2D"), int(QMetaType::QVector2D));
+ QCOMPARE(QMetaType::type("QVector3D"), int(QMetaType::QVector3D));
+ QCOMPARE(QMetaType::type("QVector4D"), int(QMetaType::QVector4D));
QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector2D)),
QByteArray("QVector2D"));
@@ -2682,9 +2682,9 @@ void tst_QVectorND::metaTypes()
QVERIFY(QMetaType::isRegistered(QMetaType::QVector3D));
QVERIFY(QMetaType::isRegistered(QMetaType::QVector4D));
- QVERIFY(qMetaTypeId<QVector2D>() == QMetaType::QVector2D);
- QVERIFY(qMetaTypeId<QVector3D>() == QMetaType::QVector3D);
- QVERIFY(qMetaTypeId<QVector4D>() == QMetaType::QVector4D);
+ QCOMPARE(qMetaTypeId<QVector2D>(), int(QMetaType::QVector2D));
+ QCOMPARE(qMetaTypeId<QVector3D>(), int(QMetaType::QVector3D));
+ QCOMPARE(qMetaTypeId<QVector4D>(), int(QMetaType::QVector4D));
}
QTEST_APPLESS_MAIN(tst_QVectorND)
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
index 4f58178f2c..30982f1e24 100644
--- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
+++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
@@ -461,8 +461,8 @@ void tst_QBrush::textureBrushComparison()
imageBrush1.setTextureImage(image1);
imageBrush2.setTextureImage(image2);
- QVERIFY(imageBrush1 == imageBrush2);
- QVERIFY(pixmapBrush == imageBrush1);
+ QCOMPARE(imageBrush1, imageBrush2);
+ QCOMPARE(pixmapBrush, imageBrush1);
}
QTEST_MAIN(tst_QBrush)
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 4fafbf9827..b81a4e2c4c 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -39,6 +39,7 @@
#include <qcolor.h>
#include <qdebug.h>
#include <private/qdrawingprimitive_sse2_p.h>
+#include <qrgba64.h>
class tst_QColor : public QObject
{
@@ -105,6 +106,10 @@ private slots:
void premultiply();
void unpremultiply_sse4();
+ void qrgba64();
+ void qrgba64MemoryLayout();
+ void qrgba64Premultiply();
+ void qrgba64Equivalence();
#ifdef Q_DEAD_CODE_FROM_QT4_X11
void setallowX11ColorNames();
@@ -249,7 +254,7 @@ void tst_QColor::isValid()
{
QFETCH(QColor, color);
QFETCH(bool, isValid);
- QVERIFY(color.isValid() == isValid);
+ QCOMPARE(color.isValid(), isValid);
}
Q_DECLARE_METATYPE(QColor::NameFormat);
@@ -1321,19 +1326,19 @@ void tst_QColor::convertTo()
QColor color(Qt::black);
QColor rgb = color.convertTo(QColor::Rgb);
- QVERIFY(rgb.spec() == QColor::Rgb);
+ QCOMPARE(rgb.spec(), QColor::Rgb);
QColor hsv = color.convertTo(QColor::Hsv);
- QVERIFY(hsv.spec() == QColor::Hsv);
+ QCOMPARE(hsv.spec(), QColor::Hsv);
QColor cmyk = color.convertTo(QColor::Cmyk);
- QVERIFY(cmyk.spec() == QColor::Cmyk);
+ QCOMPARE(cmyk.spec(), QColor::Cmyk);
QColor hsl = color.convertTo(QColor::Hsl);
- QVERIFY(hsl.spec() == QColor::Hsl);
+ QCOMPARE(hsl.spec(), QColor::Hsl);
QColor invalid = color.convertTo(QColor::Invalid);
- QVERIFY(invalid.spec() == QColor::Invalid);
+ QCOMPARE(invalid.spec(), QColor::Invalid);
}
void tst_QColor::light()
@@ -1464,5 +1469,102 @@ void tst_QColor::unpremultiply_sse4()
QSKIP("SSE4 not supported on this CPU.");
}
+void tst_QColor::qrgba64()
+{
+ QRgba64 rgb64 = QRgba64::fromRgba(0x22, 0x33, 0x44, 0xff);
+ QCOMPARE(rgb64.red(), quint16(0x2222));
+ QCOMPARE(rgb64.green(), quint16(0x3333));
+ QCOMPARE(rgb64.blue(), quint16(0x4444));
+ QCOMPARE(rgb64.alpha(), quint16(0xffff));
+
+ QColor c(rgb64);
+ QCOMPARE(c.red(), 0x22);
+ QCOMPARE(c.green(), 0x33);
+ QCOMPARE(c.blue(), 0x44);
+
+ QCOMPARE(c.rgba64(), rgb64);
+
+ QColor c2 = QColor::fromRgb(0x22, 0x33, 0x44, 0xff);
+ QCOMPARE(c, c2);
+ QCOMPARE(c2.rgba64(), rgb64);
+
+ rgb64.setAlpha(0x8000);
+ rgb64.setGreen(0x8844);
+ rgb64 = rgb64.premultiplied();
+ QCOMPARE(rgb64.red(), quint16(0x1111));
+ QCOMPARE(rgb64.blue(), quint16(0x2222));
+ QCOMPARE(rgb64.green(), quint16(0x4422));
+}
+
+void tst_QColor::qrgba64MemoryLayout()
+{
+ QRgba64 rgb64 = QRgba64::fromRgba64(0x0123, 0x4567, 0x89ab, 0xcdef);
+ QCOMPARE(rgb64.red(), quint16(0x0123));
+ QCOMPARE(rgb64.green(), quint16(0x4567));
+ QCOMPARE(rgb64.blue(), quint16(0x89ab));
+ QCOMPARE(rgb64.alpha(), quint16(0xcdef));
+
+ // Check in-memory order, so it can be used by things like SSE
+ Q_STATIC_ASSERT(sizeof(QRgba64) == sizeof(quint64));
+ quint16 memory[4];
+ memcpy(memory, &rgb64, sizeof(QRgba64));
+ QCOMPARE(memory[0], quint16(0x0123));
+ QCOMPARE(memory[1], quint16(0x4567));
+ QCOMPARE(memory[2], quint16(0x89ab));
+ QCOMPARE(memory[3], quint16(0xcdef));
+}
+
+void tst_QColor::qrgba64Premultiply()
+{
+ // Tests that qPremultiply(qUnpremultiply(rgba64)) returns rgba64.
+ for (uint a = 0; a < 0x10000; a+=7) {
+ const uint step = std::max(a/1024, 1u);
+ for (uint c = 0; c <= a; c+=step) {
+ QRgba64 p = qRgba64(c, a-c, a-c/2, a);
+ QRgba64 pp = qPremultiply(qUnpremultiply(p));
+ QCOMPARE(pp, p);
+ }
+ }
+}
+
+void tst_QColor::qrgba64Equivalence()
+{
+ // Any ARGB32 converted back and forth.
+ for (uint a = 0; a < 256; a++) {
+ for (uint c = 0; c < 256; c++) {
+ QRgb p1 = qRgba(c, 255-c, 255-c, a);
+ QRgba64 p64 = QRgba64::fromArgb32(p1);
+ QCOMPARE(p64.toArgb32(), p1);
+ }
+ }
+ // Any unpremultiplied ARGB32 value premultipled in RGB64 (except alpha 0).
+ for (uint a = 1; a < 256; a++) {
+ for (uint c = 0; c < 256; c++) {
+ QRgb p1 = qRgba(c, 255-c, 255-c, a);
+ QRgb pp1 = qPremultiply(p1);
+ QRgba64 pp64 = qPremultiply(QRgba64::fromArgb32(p1));
+ QRgb pp2 = pp64.toArgb32();
+ // 64bit premultiplied is more accurate than 32bit, so allow slight difference.
+ QCOMPARE(qAlpha(pp2), qAlpha(pp1));
+ QVERIFY(qAbs(qRed(pp2)-qRed(pp1)) <= 1);
+ QVERIFY(qAbs(qGreen(pp2)-qGreen(pp1)) <= 1);
+ QVERIFY(qAbs(qBlue(pp2)-qBlue(pp1)) <= 1);
+ // But verify the added accuracy means we can return to accurate unpremultiplied ARGB32.
+ QRgba64 pu64 = qUnpremultiply(pp64);
+ QRgb p2 = pu64.toArgb32();
+ QCOMPARE(p2, p1);
+ }
+ }
+ // Any premultiplied ARGB32 value unpremultipled in RGB64.
+ for (uint a = 0; a < 256; a++) {
+ for (uint c = 0; c <= a; c++) {
+ QRgb pp = qRgba(c, a-c, a-c, a);
+ QRgb pu = qUnpremultiply(pp);
+ QRgba64 pu64 = qUnpremultiply(QRgba64::fromArgb32(pp));
+ QCOMPARE(pu64.toArgb32(), pu);
+ }
+ }
+}
+
QTEST_MAIN(tst_QColor)
#include "tst_qcolor.moc"
diff --git a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
index 964487f566..0f2f51d9b6 100644
--- a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
+++ b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
@@ -76,7 +76,7 @@ void tst_QPageLayout::basics()
QCOMPARE(simple.paintRectPixels(72), QRect(0, 0, 595, 842));
const QPageLayout a4portrait = simple;
- QVERIFY(a4portrait == simple);
+ QCOMPARE(a4portrait, simple);
// Change orientation
simple.setOrientation(QPageLayout::Landscape);
diff --git a/tests/auto/gui/painting/qpainter/qpainter.pro b/tests/auto/gui/painting/qpainter/qpainter.pro
index 7e9d438e1b..e90b516ef2 100644
--- a/tests/auto/gui/painting/qpainter/qpainter.pro
+++ b/tests/auto/gui/painting/qpainter/qpainter.pro
@@ -2,7 +2,7 @@ CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qpainter
-QT += testlib
+QT += testlib gui-private core-private
qtHaveModule(widgets): QT += widgets widgets-private
SOURCES += tst_qpainter.cpp
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 752ab0fd8c..1ed78fa0ef 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -53,6 +53,7 @@
#endif
#include <qpixmap.h>
+#include <private/qdrawhelper_p.h>
#include <qpainter.h>
#ifndef QT_NO_WIDGETS
@@ -125,8 +126,12 @@ private slots:
void fillRect3();
void fillRect4_data() { fillRect2_data(); }
void fillRect4();
+ void fillRectNonPremul_data();
void fillRectNonPremul();
+ void fillRectRGB30_data();
+ void fillRectRGB30();
+
void drawEllipse_data();
void drawEllipse();
void drawClippedEllipse_data();
@@ -198,6 +203,11 @@ private slots:
void gradientPixelFormat_data();
void gradientPixelFormat();
+ void linearGradientRgb30_data();
+ void linearGradientRgb30();
+ void radialGradientRgb30_data();
+ void radialGradientRgb30();
+
void fpe_pixmapTransform();
void fpe_zeroLengthLines();
void fpe_divByZero();
@@ -789,7 +799,7 @@ void tst_QPainter::drawPixmapFragments()
QImage origImage = origPixmap.toImage().convertToFormat(QImage::Format_ARGB32);
QImage resImage = resPixmap.toImage().convertToFormat(QImage::Format_ARGB32);
- QVERIFY(resImage.size() == resPixmap.size());
+ QCOMPARE(resImage.size(), resPixmap.size());
QVERIFY(resImage.pixel(5, 5) == origImage.pixel(15, 15));
QVERIFY(resImage.pixel(5, 15) == origImage.pixel(15, 5));
QVERIFY(resImage.pixel(15, 5) == origImage.pixel(5, 15));
@@ -797,16 +807,16 @@ void tst_QPainter::drawPixmapFragments()
QPainter::PixmapFragment fragment = QPainter::PixmapFragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2));
- QVERIFY(fragment.x == 20);
- QVERIFY(fragment.y == 20);
- QVERIFY(fragment.sourceLeft == 30);
- QVERIFY(fragment.sourceTop == 30);
- QVERIFY(fragment.width == 2);
- QVERIFY(fragment.height == 2);
- QVERIFY(fragment.scaleX == 1);
- QVERIFY(fragment.scaleY == 1);
- QVERIFY(fragment.rotation == 0);
- QVERIFY(fragment.opacity == 1);
+ QCOMPARE(fragment.x, qreal(20));
+ QCOMPARE(fragment.y, qreal(20));
+ QCOMPARE(fragment.sourceLeft, qreal(30));
+ QCOMPARE(fragment.sourceTop, qreal(30));
+ QCOMPARE(fragment.width, qreal(2));
+ QCOMPARE(fragment.height, qreal(2));
+ QCOMPARE(fragment.scaleX, qreal(1));
+ QCOMPARE(fragment.scaleY, qreal(1));
+ QCOMPARE(fragment.rotation, qreal(0));
+ QCOMPARE(fragment.opacity, qreal(1));
}
void tst_QPainter::drawPixmapNegativeScale()
@@ -1245,22 +1255,87 @@ void tst_QPainter::fillRect4()
QCOMPARE(image, expected);
}
+void tst_QPainter::fillRectNonPremul_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<uint>("color");
+
+ QTest::newRow("argb32 7f1f3f7f") << QImage::Format_ARGB32 << qRgba(31, 63, 127, 127);
+ QTest::newRow("rgba8888 7f1f3f7f") << QImage::Format_RGBA8888 << qRgba(31, 63, 127, 127);
+
+ QTest::newRow("argb32 3f1f3f7f") << QImage::Format_ARGB32 << qRgba(31, 63, 127, 63);
+ QTest::newRow("rgba8888 3f1f3f7f") << QImage::Format_RGBA8888 << qRgba(31, 63, 127, 63);
+
+ QTest::newRow("argb32 070375f4") << QImage::Format_ARGB32 << qRgba(3, 117, 244, 7);
+ QTest::newRow("rgba8888 070375f4") << QImage::Format_RGBA8888 << qRgba(3, 117, 244, 7);
+
+ QTest::newRow("argb32 0301fe0c") << QImage::Format_ARGB32 << qRgba(1, 254, 12, 3);
+ QTest::newRow("rgba8888 0301fe0c") << QImage::Format_RGBA8888 << qRgba(1, 254, 12, 3);
+
+ QTest::newRow("argb32 01804010") << QImage::Format_ARGB32 << qRgba(128, 64, 32, 1);
+ QTest::newRow("rgba8888 01804010") << QImage::Format_RGBA8888 << qRgba(128, 64, 32, 1);
+}
+
void tst_QPainter::fillRectNonPremul()
{
- QImage img1(1, 1, QImage::Format_ARGB32);
- QImage img2(1, 1, QImage::Format_RGBA8888);
+ QFETCH(QImage::Format, format);
+ QFETCH(uint, color);
+
+ QImage image(1, 1, format);
+ QRectF rect(0, 0, 1, 1);
+
+ // Fill with CompositionMode_SourceOver tests blend_color
+ image.fill(Qt::transparent);
+ QPainter painter(&image);
+ painter.fillRect(rect, QColor::fromRgba(color));
+ painter.end();
+
+ // Fill with CompositionMode_Source tests rectfill.
+ painter.begin(&image);
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ painter.fillRect(rect, QColor::fromRgba(color));
+ painter.end();
+
+ QRgb p = image.pixel(0, 0);
+ QCOMPARE(qAlpha(p), qAlpha(color));
+ QVERIFY(qAbs(qRed(p)-qRed(color)) <= 1);
+ QVERIFY(qAbs(qGreen(p)-qGreen(color)) <= 1);
+ QVERIFY(qAbs(qBlue(p)-qBlue(color)) <= 1);
+}
+
+void tst_QPainter::fillRectRGB30_data()
+{
+ QTest::addColumn<uint>("color");
- QPainter p1(&img1);
- QPainter p2(&img2);
+ QTest::newRow("17|43|259") << (0xc0000000 | (17 << 20) | (43 << 10) | 259);
+ QTest::newRow("2|33|444") << (0xc0000000 | (2 << 20) | (33 << 10) | 444);
+ QTest::newRow("1000|1000|1000") << (0xc0000000 | (1000 << 20) | (1000 << 10) | 1000);
+}
+void tst_QPainter::fillRectRGB30()
+{
+ QFETCH(uint, color);
QRectF rect(0, 0, 1, 1);
- p1.fillRect(rect, qRgba(31, 63, 127, 127));
- p2.fillRect(rect, qRgba(31, 63, 127, 127));
- p1.end();
- p2.end();
+ // Fill with CompositionMode_SourceOver tests blend_color
+ QImage image1(1, 1, QImage::Format_A2BGR30_Premultiplied);
+ image1.fill(Qt::transparent);
+ QPainter painter(&image1);
+ painter.fillRect(rect, QColor::fromRgba64(qConvertA2rgb30ToRgb64<PixelOrderBGR>(color)));
+ painter.end();
+
+ uint pixel1 = ((const uint*)(image1.bits()))[0];
+ QCOMPARE(pixel1, color);
+
+ // Fill with CompositionMode_Source tests rectfill.
+ QImage image2(1, 1, QImage::Format_RGB30);
+ painter.begin(&image2);
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ painter.fillRect(rect, QColor::fromRgba64(qConvertA2rgb30ToRgb64<PixelOrderRGB>(color)));
+ painter.end();
- QCOMPARE(img1.pixel(0, 0), img2.pixel(0,0));
+ uint pixel2 = ((const uint*)(image2.bits()))[0];
+ QCOMPARE(pixel2, color);
}
void tst_QPainter::drawPath_data()
@@ -1406,7 +1481,7 @@ void tst_QPainter::drawPath3()
p.drawPath(path);
p.end();
- QVERIFY(imgA == imgB);
+ QCOMPARE(imgA, imgB);
imgA.invertPixels();
imgB.fill(0xffffff);
@@ -1420,7 +1495,7 @@ void tst_QPainter::drawPath3()
p.drawPath(path);
p.end();
- QVERIFY(imgA == imgB);
+ QCOMPARE(imgA, imgB);
path.setFillRule(Qt::WindingFill);
imgB.fill(0xffffff);
@@ -2381,36 +2456,50 @@ void tst_QPainter::setOpacity_data()
QTest::newRow("RGBx8888 on RGBx8888") << QImage::Format_RGBX8888
<< QImage::Format_RGBX8888;
- QTest::newRow("RGBA8888P on ARGB32P") << QImage::Format_RGBA8888_Premultiplied
+ QTest::newRow("RGBA8888P on ARGB32P") << QImage::Format_ARGB32_Premultiplied
+ << QImage::Format_RGBA8888_Premultiplied;
+
+ QTest::newRow("RGBx8888 on ARGB32P") << QImage::Format_ARGB32_Premultiplied
+ << QImage::Format_RGBX8888;
+
+ QTest::newRow("ARGB32P on RGBA8888P") << QImage::Format_RGBA8888_Premultiplied
<< QImage::Format_ARGB32_Premultiplied;
- QTest::newRow("RGBx8888 on ARGB32P") << QImage::Format_RGBX8888
- << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGBX8888
+ << QImage::Format_RGB32;
- QTest::newRow("ARGB32P on RGBA8888P") << QImage::Format_ARGB32_Premultiplied
- << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("RGB30 on RGB32") << QImage::Format_RGB32
+ << QImage::Format_BGR30;
- QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGB32
- << QImage::Format_RGBX8888;
+ QTest::newRow("BGR30 on ARGB32P") << QImage::Format_ARGB32_Premultiplied
+ << QImage::Format_BGR30;
+
+ QTest::newRow("A2RGB30P on ARGB32P") << QImage::Format_ARGB32_Premultiplied
+ << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("A2RGB30P on A2RGB30P") << QImage::Format_A2RGB30_Premultiplied
<< QImage::Format_A2RGB30_Premultiplied;
- QTest::newRow("ARGB32P on A2RGB30P") << QImage::Format_ARGB32_Premultiplied
- << QImage::Format_A2RGB30_Premultiplied;
+ QTest::newRow("ARGB32P on A2RGB30P") << QImage::Format_A2RGB30_Premultiplied
+ << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("RGB32 on A2BGR30P") << QImage::Format_A2BGR30_Premultiplied
+ << QImage::Format_RGB32;
- QTest::newRow("RGB32 on A2BGR30P") << QImage::Format_ARGB32_Premultiplied
- << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("RGB30 on A2BGR30P") << QImage::Format_A2BGR30_Premultiplied
+ << QImage::Format_RGB30;
- QTest::newRow("A2RGB30P on A2BGR30P") << QImage::Format_A2RGB30_Premultiplied
- << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("A2RGB30P on A2BGR30P") << QImage::Format_A2BGR30_Premultiplied
+ << QImage::Format_A2RGB30_Premultiplied;
- QTest::newRow("ARGB32P on BGR30") << QImage::Format_ARGB32_Premultiplied
- << QImage::Format_BGR30;
+ QTest::newRow("ARGB32P on BGR30") << QImage::Format_BGR30
+ << QImage::Format_ARGB32_Premultiplied;
- QTest::newRow("ARGB32P on RGB30") << QImage::Format_A2RGB30_Premultiplied
- << QImage::Format_RGB30;
+ QTest::newRow("ARGB32P on RGB30") << QImage::Format_RGB30
+ << QImage::Format_ARGB32_Premultiplied;
+
+ QTest::newRow("A2RGB30P on RGB30") << QImage::Format_RGB30
+ << QImage::Format_A2RGB30_Premultiplied;
}
@@ -2492,7 +2581,7 @@ void tst_QPainter::drawhelper_blend_untransformed()
QImage expected(size - 2, size, destFormat);
p.begin(&expected);
p.fillRect(0, 0, expected.width(), expected.height(),
- QColor(dest.pixel(1, 0)));
+ dest.pixelColor(1, 0));
p.end();
const QImage subDest(dest.bits() + dest.depth() / 8,
@@ -2500,9 +2589,7 @@ void tst_QPainter::drawhelper_blend_untransformed()
dest.bytesPerLine(), dest.format());
if (dest.format() == QImage::Format_ARGB8565_Premultiplied ||
- dest.format() == QImage::Format_ARGB8555_Premultiplied ||
- dest.format() == QImage::Format_A2BGR30_Premultiplied ||
- dest.format() == QImage::Format_A2RGB30_Premultiplied ) {
+ dest.format() == QImage::Format_ARGB8555_Premultiplied) {
// Test skipped due to rounding errors...
continue;
}
@@ -2551,7 +2638,7 @@ void tst_QPainter::drawhelper_blend_tiled_untransformed()
QImage expected(size - 2, size, destFormat);
p.begin(&expected);
p.fillRect(0, 0, expected.width(), expected.height(),
- QColor(dest.pixel(1, 0)));
+ dest.pixelColor(1, 0));
p.end();
const QImage subDest(dest.bits() + dest.depth() / 8,
@@ -2619,28 +2706,6 @@ void tst_QPainter::porterDuff_warning()
QVERIFY(qInstallMessageHandler(old) == porterDuff_warningChecker);
}
-class quint24
-{
-public:
- inline quint24(quint32 v)
- {
- data[0] = qBlue(v);
- data[1] = qGreen(v);
- data[2] = qRed(v);
- }
-
- inline operator quint32 ()
- {
- return qRgb(data[2], data[1], data[0]);
- }
-
- inline bool operator==(const quint24 &v) const {
- return (data[0] == v.data[0] && data[1] == v.data[1] && data[2] == v.data[2]);
- }
-
- uchar data[3];
-};
-
void tst_QPainter::drawhelper_blend_color()
{
QImage dest(32, 32, QImage::Format_ARGB8555_Premultiplied);
@@ -3889,6 +3954,65 @@ void tst_QPainter::gradientInterpolation()
}
}
+void tst_QPainter::linearGradientRgb30_data()
+{
+ QTest::addColumn<QColor>("stop0");
+ QTest::addColumn<QColor>("stop1");
+
+ QTest::newRow("white->black") << QColor(Qt::white) << QColor(Qt::black);
+ QTest::newRow("blue->black") << QColor(Qt::blue) << QColor(Qt::black);
+ QTest::newRow("white->red") << QColor(Qt::white) << QColor(Qt::red);
+}
+
+void tst_QPainter::linearGradientRgb30()
+{
+ QFETCH(QColor, stop0);
+ QFETCH(QColor, stop1);
+
+ QLinearGradient gradient(0, 0, 1000, 1);
+ gradient.setColorAt(0.0, stop0);
+ gradient.setColorAt(1.0, stop1);
+
+ QImage image(1000, 1, QImage::Format_RGB30);
+ QPainter painter(&image);
+ painter.fillRect(image.rect(), gradient);
+ painter.end();
+
+ for (int i = 1; i < 1000; ++i) {
+ QColor p1 = image.pixelColor(i - 1, 0);
+ QColor p2 = image.pixelColor(i, 0);
+ QVERIFY(p1 != p2);
+ QVERIFY(qGray(p1.rgb()) >= qGray(p2.rgb()));
+ }
+}
+
+void tst_QPainter::radialGradientRgb30_data()
+{
+ linearGradientRgb30_data();
+}
+
+void tst_QPainter::radialGradientRgb30()
+{
+ QFETCH(QColor, stop0);
+ QFETCH(QColor, stop1);
+
+ QRadialGradient gradient(0, 0, 1000);
+ gradient.setColorAt(0.0, stop0);
+ gradient.setColorAt(1.0, stop1);
+
+ QImage image(1000, 1, QImage::Format_A2BGR30_Premultiplied);
+ QPainter painter(&image);
+ painter.fillRect(image.rect(), gradient);
+ painter.end();
+
+ for (int i = 1; i < 1000; ++i) {
+ QColor p1 = image.pixelColor(i - 1, 0);
+ QColor p2 = image.pixelColor(i, 0);
+ QVERIFY(p1 != p2);
+ QVERIFY(qGray(p1.rgb()) >= qGray(p2.rgb()));
+ }
+}
+
void tst_QPainter::drawPolygon()
{
QImage img(128, 128, QImage::Format_ARGB32_Premultiplied);
@@ -4064,10 +4188,10 @@ void tst_QPainter::extendedBlendModes()
QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_Plus, 0.3));
QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Plus, 0.3));
- QVERIFY(testCompositionMode(127, 128, 165, QPainter::CompositionMode_Plus, 0.3));
- QVERIFY(testCompositionMode(127, 0, 37, QPainter::CompositionMode_Plus, 0.3));
+ QVERIFY(testCompositionMode(126, 128, 165, QPainter::CompositionMode_Plus, 0.3));
+ QVERIFY(testCompositionMode(127, 0, 38, QPainter::CompositionMode_Plus, 0.3));
QVERIFY(testCompositionMode( 0, 127, 127, QPainter::CompositionMode_Plus, 0.3));
- QVERIFY(testCompositionMode(255, 0, 75, QPainter::CompositionMode_Plus, 0.3));
+ QVERIFY(testCompositionMode(255, 0, 76, QPainter::CompositionMode_Plus, 0.3));
QVERIFY(testCompositionMode( 0, 255, 255, QPainter::CompositionMode_Plus, 0.3));
QVERIFY(testCompositionMode(128, 128, 166, QPainter::CompositionMode_Plus, 0.3));
QVERIFY(testCompositionMode(186, 200, 255, QPainter::CompositionMode_Plus, 0.3));
@@ -4752,6 +4876,22 @@ void tst_QPainter::blendARGBonRGB_data()
<< QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 125;
QTest::newRow("ARGB_PM source-in RGB666") << QImage::Format_RGB666 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 125;
+ QTest::newRow("ARGB over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 85) << 85;
+ QTest::newRow("ARGB_PM over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85;
+ QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85;
+ QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85;
+ QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85;
+ QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170;
+ QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85;
+ QTest::newRow("ARGB_PM source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceIn << qRgba(85, 0, 0, 85) << 85;
}
void tst_QPainter::blendARGBonRGB()
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index 0a073f5c84..ae30719ee7 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -602,16 +602,16 @@ void tst_QPainterPath::testOperatorEquals()
{
QPainterPath empty1;
QPainterPath empty2;
- QVERIFY(empty1 == empty2);
+ QCOMPARE(empty1, empty2);
QPainterPath rect1;
rect1.addRect(100, 100, 100, 100);
- QVERIFY(rect1 == rect1);
+ QCOMPARE(rect1, rect1);
QVERIFY(rect1 != empty1);
QPainterPath rect2;
rect2.addRect(100, 100, 100, 100);
- QVERIFY(rect1 == rect2);
+ QCOMPARE(rect1, rect2);
rect2.setFillRule(Qt::WindingFill);
QVERIFY(rect1 != rect2);
@@ -622,7 +622,7 @@ void tst_QPainterPath::testOperatorEquals()
QPainterPath ellipse2;
ellipse2.addEllipse(50, 50, 100, 100);
- QVERIFY(ellipse1 == ellipse2);
+ QCOMPARE(ellipse1, ellipse2);
}
void tst_QPainterPath::testOperatorEquals_fuzzy()
@@ -638,12 +638,12 @@ void tst_QPainterPath::testOperatorEquals_fuzzy()
QPainterPath pb;
pb.addRect(b);
- QVERIFY(pa == pb);
+ QCOMPARE(pa, pb);
QTransform transform;
transform.translate(-100, -100);
- QVERIFY(transform.map(pa) == transform.map(pb));
+ QCOMPARE(transform.map(pa), transform.map(pb));
}
// higher tolerance for error when path's bounding rect is big
@@ -656,12 +656,12 @@ void tst_QPainterPath::testOperatorEquals_fuzzy()
QPainterPath pb;
pb.addRect(b);
- QVERIFY(pa == pb);
+ QCOMPARE(pa, pb);
QTransform transform;
transform.translate(-1, -1);
- QVERIFY(transform.map(pa) == transform.map(pb));
+ QCOMPARE(transform.map(pa), transform.map(pb));
}
// operator== should return true for a path that has
@@ -676,7 +676,7 @@ void tst_QPainterPath::testOperatorEquals_fuzzy()
QPainterPath b = transform.inverted().map(transform.map(a));
- QVERIFY(a == b);
+ QCOMPARE(a, b);
}
{
@@ -720,7 +720,7 @@ void tst_QPainterPath::testOperatorDatastream()
stream >> other;
}
- QVERIFY(other == path);
+ QCOMPARE(other, path);
}
void tst_QPainterPath::closing()
@@ -1066,19 +1066,19 @@ void tst_QPainterPath::setElementPositionAt()
{
QPainterPath path(QPointF(42., 42.));
QCOMPARE(path.elementCount(), 1);
- QVERIFY(path.elementAt(0).type == QPainterPath::MoveToElement);
+ QCOMPARE(path.elementAt(0).type, QPainterPath::MoveToElement);
QCOMPARE(path.elementAt(0).x, qreal(42.));
QCOMPARE(path.elementAt(0).y, qreal(42.));
QPainterPath copy = path;
copy.setElementPositionAt(0, qreal(0), qreal(0));
QCOMPARE(copy.elementCount(), 1);
- QVERIFY(copy.elementAt(0).type == QPainterPath::MoveToElement);
+ QCOMPARE(copy.elementAt(0).type, QPainterPath::MoveToElement);
QCOMPARE(copy.elementAt(0).x, qreal(0));
QCOMPARE(copy.elementAt(0).y, qreal(0));
QCOMPARE(path.elementCount(), 1);
- QVERIFY(path.elementAt(0).type == QPainterPath::MoveToElement);
+ QCOMPARE(path.elementAt(0).type, QPainterPath::MoveToElement);
QCOMPARE(path.elementAt(0).x, qreal(42.));
QCOMPARE(path.elementAt(0).y, qreal(42.));
}
@@ -1253,10 +1253,10 @@ void tst_QPainterPath::connectPathMoveTo()
path1.connectPath(path2);
- QVERIFY(path1.elementAt(0).type == QPainterPath::MoveToElement);
- QVERIFY(path2.elementAt(0).type == QPainterPath::MoveToElement);
- QVERIFY(path3.elementAt(0).type == QPainterPath::MoveToElement);
- QVERIFY(path4.elementAt(0).type == QPainterPath::MoveToElement);
+ QCOMPARE(path1.elementAt(0).type, QPainterPath::MoveToElement);
+ QCOMPARE(path2.elementAt(0).type, QPainterPath::MoveToElement);
+ QCOMPARE(path3.elementAt(0).type, QPainterPath::MoveToElement);
+ QCOMPARE(path4.elementAt(0).type, QPainterPath::MoveToElement);
}
void tst_QPainterPath::translate()
diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
index 4bc31baba8..5eaee1192a 100644
--- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
+++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
@@ -50,8 +50,7 @@ private slots:
void tst_QPdfWriter::basics()
{
QTemporaryFile file;
- if (!file.open())
- QSKIP("Couldn't open temp file!");
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QPdfWriter writer(file.fileName());
QCOMPARE(writer.title(), QString());
@@ -150,8 +149,7 @@ void tst_QPdfWriter::testPageMetrics()
QSizeF sizeMMf = QSizeF(widthMMf, heightMMf);
QTemporaryFile file;
- if (!file.open())
- QSKIP("Couldn't open temp file!");
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QPdfWriter writer(file.fileName());
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index c0e3c6d187..33f81cc10e 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -173,7 +173,7 @@ void tst_QRegion::setRects()
QRect rect;
region.setRects(&rect, 0);
QVERIFY(region.isEmpty());
- QVERIFY(region == QRegion());
+ QCOMPARE(region, QRegion());
QVERIFY(!region.boundingRect().isValid());
QVERIFY(region.rects().isEmpty());
}
diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
index 13b15d09dd..60b89aa6ab 100644
--- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
+++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
@@ -57,6 +57,7 @@ private slots:
void mapRect();
void assignments();
void mapToPolygon();
+ void qhash();
void translate();
void scale();
void matrix();
@@ -361,6 +362,22 @@ void tst_QTransform::mapToPolygon()
QVERIFY(equal);
}
+void tst_QTransform::qhash()
+{
+ QMatrix m1;
+ m1.shear(3.0, 2.0);
+ m1.rotate(44);
+
+ QMatrix m2 = m1;
+
+ QTransform t1(m1);
+ QTransform t2(m2);
+
+ // not really much to test here, so just the bare minimum:
+ QCOMPARE(qHash(m1), qHash(m2));
+ QCOMPARE(qHash(t1), qHash(t2));
+}
+
void tst_QTransform::translate()
{
@@ -411,14 +428,14 @@ void tst_QTransform::matrix()
mat1.m21(), mat1.m22(), 0,
mat1.dx(), mat1.dy(), 1);
- QVERIFY(tran1 == dummy);
- QVERIFY(tran1.inverted() == dummy.inverted());
- QVERIFY(tran1.inverted() == QTransform(mat1.inverted()));
- QVERIFY(tran2.inverted() == QTransform(mat2.inverted()));
+ QCOMPARE(tran1, dummy);
+ QCOMPARE(tran1.inverted(), dummy.inverted());
+ QCOMPARE(tran1.inverted(), QTransform(mat1.inverted()));
+ QCOMPARE(tran2.inverted(), QTransform(mat2.inverted()));
QMatrix mat3 = mat1 * mat2;
QTransform tran3 = tran1 * tran2;
- QVERIFY(QTransform(mat3) == tran3);
+ QCOMPARE(QTransform(mat3), tran3);
/* QMatrix::operator==() doesn't use qFuzzyCompare(), which
* on win32-g++ results in a failure. So we work around it by
@@ -430,15 +447,15 @@ void tst_QTransform::matrix()
QRect rect(43, 70, 200, 200);
QPoint pt(43, 66);
- QVERIFY(tranInv.map(pt) == matInv.map(pt));
- QVERIFY(tranInv.map(pt) == matInv.map(pt));
+ QCOMPARE(tranInv.map(pt), matInv.map(pt));
+ QCOMPARE(tranInv.map(pt), matInv.map(pt));
QPainterPath path;
path.moveTo(55, 60);
path.lineTo(110, 110);
path.quadTo(220, 50, 10, 20);
path.closeSubpath();
- QVERIFY(tranInv.map(path) == matInv.map(path));
+ QCOMPARE(tranInv.map(path), matInv.map(path));
}
void tst_QTransform::testOffset()
@@ -724,8 +741,8 @@ void tst_QTransform::inverted()
const QTransform inverted = matrix.inverted();
- QVERIFY(matrix.isIdentity() == inverted.isIdentity());
- QVERIFY(matrix.type() == inverted.type());
+ QCOMPARE(matrix.isIdentity(), inverted.isIdentity());
+ QCOMPARE(matrix.type(), inverted.type());
QVERIFY((matrix * inverted).isIdentity());
QVERIFY((inverted * matrix).isIdentity());
diff --git a/tests/auto/gui/qopengl/BLACKLIST b/tests/auto/gui/qopengl/BLACKLIST
new file mode 100644
index 0000000000..7f167d81df
--- /dev/null
+++ b/tests/auto/gui/qopengl/BLACKLIST
@@ -0,0 +1,8 @@
+[fboRendering]
+windows
+[QTBUG15621_triangulatingStrokerDivZero]
+windows
+[imageFormatPainting]
+windows
+[openGLPaintDevice]
+windows
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 8c6c28b492..8103f27911 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -86,6 +86,8 @@ private slots:
void fboRenderingRGB30_data();
void fboRenderingRGB30();
void fboHandleNulledAfterContextDestroyed();
+ void fboMRT();
+ void fboMRT_differentFormats();
void openGLPaintDevice_data();
void openGLPaintDevice();
void aboutToBeDestroyed();
@@ -514,7 +516,7 @@ void tst_QOpenGL::fboTextureOwnership()
// pull out the texture
GLuint texture = fbo->takeTexture();
QVERIFY(texture != 0);
- QVERIFY(fbo->texture() == 0);
+ QCOMPARE(fbo->texture(), GLuint(0));
// verify that the next bind() creates a new texture
fbo->bind();
@@ -594,6 +596,14 @@ void tst_QOpenGL::fboRenderingRGB30_data()
common_data();
}
+#ifndef GL_RGB5_A1
+#define GL_RGB5_A1 0x8057
+#endif
+
+#ifndef GL_RGBA8
+#define GL_RGBA8 0x8058
+#endif
+
#ifndef GL_RGB10_A2
#define GL_RGB10_A2 0x8059
#endif
@@ -606,6 +616,24 @@ void tst_QOpenGL::fboRenderingRGB30_data()
#define GL_FULL_SUPPORT 0x82B7
#endif
+static bool hasRGB10A2(QOpenGLContext *ctx)
+{
+ if (ctx->format().majorVersion() < 3)
+ return false;
+#ifndef QT_OPENGL_ES_2
+ if (!ctx->isOpenGLES() && ctx->format().majorVersion() >= 4) {
+ GLint value = -1;
+ QOpenGLFunctions_4_2_Core* vFuncs = ctx->versionFunctions<QOpenGLFunctions_4_2_Core>();
+ if (vFuncs && vFuncs->initializeOpenGLFunctions()) {
+ vFuncs->glGetInternalformativ(GL_TEXTURE_2D, GL_RGB10_A2, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
+ if (value != GL_FULL_SUPPORT)
+ return false;
+ }
+ }
+#endif
+ return true;
+}
+
void tst_QOpenGL::fboRenderingRGB30()
{
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
@@ -623,24 +651,9 @@ void tst_QOpenGL::fboRenderingRGB30()
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
- if (ctx.format().majorVersion() < 3)
+ if (!hasRGB10A2(&ctx))
QSKIP("An internal RGB30_A2 format is not guaranteed on this platform");
-#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
- // NVidia currently only supports RGB30 and RGB30_A2 in their Quadro drivers,
- // but they do provide an extension for querying the support. We use the query
- // in case they implement the required formats later.
- if (!ctx.isOpenGLES() && ctx.format().majorVersion() >= 4) {
- GLint value = -1;
- QOpenGLFunctions_4_2_Core* vFuncs = ctx.versionFunctions<QOpenGLFunctions_4_2_Core>();
- if (vFuncs && vFuncs->initializeOpenGLFunctions()) {
- vFuncs->glGetInternalformativ(GL_TEXTURE_2D, GL_RGB10_A2, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
- if (value != GL_FULL_SUPPORT)
- QSKIP("The required RGB30_A2 format is not supported by this driver");
- }
- }
-#endif
-
// No multisample with combined depth/stencil attachment:
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
@@ -720,6 +733,150 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
QCOMPARE(fbo->handle(), 0U);
}
+void tst_QOpenGL::fboMRT()
+{
+ QWindow window;
+ window.setSurfaceType(QWindow::OpenGLSurface);
+ window.setGeometry(0, 0, 10, 10);
+ window.create();
+
+ QOpenGLContext ctx;
+ QVERIFY(ctx.create());
+ ctx.makeCurrent(&window);
+
+ if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QOpenGLFramebufferObject not supported on this platform");
+
+ if (!ctx.functions()->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets))
+ QSKIP("Multiple render targets not supported on this platform");
+
+ QOpenGLExtraFunctions *ef = ctx.extraFunctions();
+
+ {
+ // 3 color attachments, different sizes, same internal format, no depth/stencil.
+ QVector<QSize> sizes;
+ sizes << QSize(128, 128) << QSize(192, 128) << QSize(432, 123);
+ QOpenGLFramebufferObject fbo(sizes[0]);
+ fbo.addColorAttachment(sizes[1]);
+ fbo.addColorAttachment(sizes[2]);
+ QVERIFY(fbo.bind());
+ QCOMPARE(fbo.attachment(), QOpenGLFramebufferObject::NoAttachment);
+ QCOMPARE(sizes, fbo.sizes());
+ QCOMPARE(sizes[0], fbo.size());
+ // Clear the three buffers to red, green and blue.
+ GLenum drawBuf = GL_COLOR_ATTACHMENT0;
+ ef->glDrawBuffers(1, &drawBuf);
+ ef->glClearColor(1, 0, 0, 1);
+ ef->glClear(GL_COLOR_BUFFER_BIT);
+ drawBuf = GL_COLOR_ATTACHMENT0 + 1;
+ ef->glDrawBuffers(1, &drawBuf);
+ ef->glClearColor(0, 1, 0, 1);
+ ef->glClear(GL_COLOR_BUFFER_BIT);
+ drawBuf = GL_COLOR_ATTACHMENT0 + 2;
+ ef->glDrawBuffers(1, &drawBuf);
+ ef->glClearColor(0, 0, 1, 1);
+ ef->glClear(GL_COLOR_BUFFER_BIT);
+ // Verify, keeping in mind that only a 128x123 area is touched in the buffers.
+ // Some drivers do not get this right, unfortunately, so do not rely on it.
+ const char *vendor = (const char *) ef->glGetString(GL_VENDOR);
+ bool hasCorrectMRT = false;
+ if (vendor && strstr(vendor, "NVIDIA")) // maybe others too
+ hasCorrectMRT = true;
+ QImage img = fbo.toImage(false, 0);
+ QCOMPARE(img.size(), sizes[0]);
+ QCOMPARE(img.pixel(0, 0), qRgb(255, 0, 0));
+ if (hasCorrectMRT)
+ QCOMPARE(img.pixel(127, 122), qRgb(255, 0, 0));
+ img = fbo.toImage(false, 1);
+ QCOMPARE(img.size(), sizes[1]);
+ QCOMPARE(img.pixel(0, 0), qRgb(0, 255, 0));
+ if (hasCorrectMRT)
+ QCOMPARE(img.pixel(127, 122), qRgb(0, 255, 0));
+ img = fbo.toImage(false, 2);
+ QCOMPARE(img.size(), sizes[2]);
+ QCOMPARE(img.pixel(0, 0), qRgb(0, 0, 255));
+ if (hasCorrectMRT)
+ QCOMPARE(img.pixel(127, 122), qRgb(0, 0, 255));
+ fbo.release();
+ }
+
+ {
+ // 2 color attachments, same size, same internal format, depth/stencil.
+ QVector<QSize> sizes;
+ sizes.fill(QSize(128, 128), 2);
+ QOpenGLFramebufferObject fbo(sizes[0], QOpenGLFramebufferObject::CombinedDepthStencil);
+ fbo.addColorAttachment(sizes[1]);
+ QVERIFY(fbo.bind());
+ QCOMPARE(fbo.attachment(), QOpenGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(sizes, fbo.sizes());
+ QCOMPARE(sizes[0], fbo.size());
+ ef->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ ef->glFinish();
+ fbo.release();
+ }
+}
+
+void tst_QOpenGL::fboMRT_differentFormats()
+{
+ QWindow window;
+ window.setSurfaceType(QWindow::OpenGLSurface);
+ window.setGeometry(0, 0, 10, 10);
+ window.create();
+
+ QOpenGLContext ctx;
+ QVERIFY(ctx.create());
+ ctx.makeCurrent(&window);
+
+ QOpenGLFunctions *f = ctx.functions();
+ const char * vendor = (const char *) f->glGetString(GL_VENDOR);
+ if (vendor && strstr(vendor, "VMware, Inc."))
+ QSKIP("The tested formats may not be supported on this platform");
+
+ if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QOpenGLFramebufferObject not supported on this platform");
+
+ if (!f->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets))
+ QSKIP("Multiple render targets not supported on this platform");
+
+ if (!hasRGB10A2(&ctx))
+ QSKIP("RGB10_A2 not supported on this platform");
+
+ // 3 color attachments, same size, different internal format, depth/stencil.
+ QVector<QSize> sizes;
+ sizes.fill(QSize(128, 128), 3);
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ QVector<GLenum> internalFormats;
+ internalFormats << GL_RGBA8 << GL_RGB10_A2 << GL_RGB5_A1;
+ format.setInternalTextureFormat(internalFormats[0]);
+ QOpenGLFramebufferObject fbo(sizes[0], format);
+ fbo.addColorAttachment(sizes[1], internalFormats[1]);
+ fbo.addColorAttachment(sizes[2], internalFormats[2]);
+
+ QVERIFY(fbo.bind());
+ QCOMPARE(fbo.attachment(), QOpenGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(sizes, fbo.sizes());
+ QCOMPARE(sizes[0], fbo.size());
+
+ QOpenGLExtraFunctions *ef = ctx.extraFunctions();
+ QVERIFY(ef->glGetError() == 0);
+ ef->glClearColor(1, 0, 0, 1);
+ GLenum drawBuf[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0 + 1, GL_COLOR_ATTACHMENT0 + 2 };
+ ef->glDrawBuffers(3, drawBuf);
+ ef->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ QVERIFY(ef->glGetError() == 0);
+
+ QImage img = fbo.toImage(true, 0);
+ QCOMPARE(img.size(), sizes[0]);
+ QCOMPARE(img.pixel(0, 0), qRgb(255, 0, 0));
+ img = fbo.toImage(true, 1);
+ QCOMPARE(img.size(), sizes[1]);
+ QCOMPARE(img.format(), QImage::Format_A2BGR30_Premultiplied);
+ QCOMPARE(img.pixel(0, 0), qRgb(255, 0, 0));
+
+ fbo.release();
+}
+
void tst_QOpenGL::imageFormatPainting()
{
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
@@ -1174,18 +1331,18 @@ void tst_QOpenGL::textureblitterPartTargetRectTransform()
void tst_QOpenGL::defaultSurfaceFormat()
{
QSurfaceFormat fmt;
- QVERIFY(QSurfaceFormat::defaultFormat() == fmt);
+ QCOMPARE(QSurfaceFormat::defaultFormat(), fmt);
fmt.setDepthBufferSize(16);
QSurfaceFormat::setDefaultFormat(fmt);
- QVERIFY(QSurfaceFormat::defaultFormat() == fmt);
+ QCOMPARE(QSurfaceFormat::defaultFormat(), fmt);
QCOMPARE(QSurfaceFormat::defaultFormat().depthBufferSize(), 16);
QScopedPointer<QWindow> window(new QWindow);
- QVERIFY(window->requestedFormat() == fmt);
+ QCOMPARE(window->requestedFormat(), fmt);
QScopedPointer<QOpenGLContext> context(new QOpenGLContext);
- QVERIFY(context->format() == fmt);
+ QCOMPARE(context->format(), fmt);
}
#ifdef USE_GLX
@@ -1214,7 +1371,7 @@ void tst_QOpenGL::glxContextWrap()
QOpenGLContext *ctx = new QOpenGLContext;
ctx->setNativeHandle(QVariant::fromValue<QGLXNativeContext>(QGLXNativeContext(context)));
QVERIFY(ctx->create());
- QVERIFY(ctx->nativeHandle().value<QGLXNativeContext>().context() == context);
+ QCOMPARE(ctx->nativeHandle().value<QGLXNativeContext>().context(), context);
QVERIFY(nativeIf->nativeResourceForContext(QByteArrayLiteral("glxcontext"), ctx) == (void *) context);
QVERIFY(ctx->makeCurrent(window));
diff --git a/tests/auto/gui/qopenglconfig/buglist.json b/tests/auto/gui/qopenglconfig/buglist.json
index c7b8e61bc8..ef311612b2 100644
--- a/tests/auto/gui/qopenglconfig/buglist.json
+++ b/tests/auto/gui/qopenglconfig/buglist.json
@@ -103,6 +103,28 @@
]
},
{
+ "id": 7,
+ "description": "driver description test",
+ "driver_description": "Long And Special Driver Description",
+ "os": {
+ "type": "win"
+ },
+ "features": [
+ "feature2"
+ ]
+ },
+ {
+ "id": 8,
+ "description": "Windows version test",
+ "os": {
+ "type": "win",
+ "release": [ "10" ]
+ },
+ "features": [
+ "win10_feature"
+ ]
+ },
+ {
"id": 128,
"description": "check for matching GL_VENDOR",
"gl_vendor": "The Qt Company",
diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
index f88cbdc758..1cb7972cc6 100644
--- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
+++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
@@ -47,6 +47,7 @@
#include <QtCore/QVariant>
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
+#include <QtCore/QJsonDocument>
#include <algorithm>
@@ -107,6 +108,7 @@ private slots:
void testConfiguration();
void testGlConfiguration();
void testBugList();
+ void testDefaultWindowsBlacklist();
};
static void dumpConfiguration(QTextStream &str)
@@ -243,29 +245,61 @@ void tst_QOpenGlConfig::testBugList()
QSet<QString> expectedFeatures;
expectedFeatures << "feature1";
+ // adapter info
QVersionNumber driverVersion(QVector<int>() << 9 << 18 << 13 << 4460);
- QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromDevice(0x10DE, 0x0DE9, driverVersion);
+ QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromDevice(0x10DE, 0x0DE9, driverVersion, QByteArrayLiteral("Unknown"));
QSet<QString> actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"),
- QVersionNumber(6, 3), fileName);
+ QVersionNumber(6, 3), QStringLiteral("7"), fileName);
QVERIFY2(expectedFeatures == actualFeatures,
msgSetMismatch(expectedFeatures, actualFeatures));
+ // driver_description
+ gpu = QOpenGLConfig::Gpu::fromDevice(0xDEAD, 0xBEEF, driverVersion, QByteArrayLiteral("Very Long And Special Driver Description"));
+ actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"),
+ QVersionNumber(6, 3), QStringLiteral("8"), fileName);
+ expectedFeatures = QSet<QString>() << "feature2";
+ QVERIFY2(expectedFeatures == actualFeatures,
+ msgSetMismatch(expectedFeatures, actualFeatures));
+
+ // os.release
+ gpu = QOpenGLConfig::Gpu::fromDevice(0xDEAD, 0xBEEF, driverVersion, QByteArrayLiteral("WinVerTest"));
+ actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"),
+ QVersionNumber(12, 34), QStringLiteral("10"), fileName);
+ expectedFeatures = QSet<QString>() << "win10_feature";
+ QVERIFY2(expectedFeatures == actualFeatures,
+ msgSetMismatch(expectedFeatures, actualFeatures));
+
+ // gl_vendor
gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("Somebody Else"));
expectedFeatures.clear();
actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"),
- QVersionNumber(1, 0), fileName);
+ QVersionNumber(1, 0), QString(), fileName);
QVERIFY2(expectedFeatures == actualFeatures,
msgSetMismatch(expectedFeatures, actualFeatures));
gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("The Qt Company"));
expectedFeatures = QSet<QString>() << "cool_feature";
actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"),
- QVersionNumber(1, 0), fileName);
+ QVersionNumber(1, 0), QString(), fileName);
QVERIFY2(expectedFeatures == actualFeatures,
msgSetMismatch(expectedFeatures, actualFeatures));
}
+void tst_QOpenGlConfig::testDefaultWindowsBlacklist()
+{
+ if (QGuiApplication::platformName().compare(QLatin1String("windows"), Qt::CaseInsensitive))
+ QSKIP("Only applicable to Windows");
+
+ QFile f(QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json"));
+ QVERIFY(f.open(QIODevice::ReadOnly | QIODevice::Text));
+ QJsonParseError err;
+ QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &err);
+ QVERIFY2(err.error == 0,
+ QStringLiteral("Failed to parse built-in Windows GPU blacklist. %1 : %2")
+ .arg(err.offset).arg(err.errorString()).toLatin1());
+}
+
QTEST_MAIN(tst_QOpenGlConfig)
#include "tst_qopenglconfig.moc"
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 5d78bc1d01..b1beb0ffd0 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -203,8 +203,8 @@ void tst_QCssParser::scanner()
QCss::Scanner::scan(QCss::Scanner::preprocess(QString::fromUtf8(inputFile.readAll())), &symbols);
QVERIFY(symbols.count() > 1);
- QVERIFY(symbols.last().token == QCss::S);
- QVERIFY(symbols.last().lexem() == QLatin1String("\n"));
+ QCOMPARE(symbols.last().token, QCss::S);
+ QCOMPARE(symbols.last().lexem(), QLatin1String("\n"));
symbols.remove(symbols.count() - 1, 1);
QFile outputFile(output);
@@ -861,7 +861,7 @@ void tst_QCssParser::colorValue()
QCss::Declaration decl;
QVERIFY(parser.parseNextDeclaration(&decl));
const QColor col = decl.colorValue();
- QVERIFY(expectedColor.isValid() == col.isValid());
+ QCOMPARE(expectedColor.isValid(), col.isValid());
QCOMPARE(col, expectedColor);
}
@@ -1304,7 +1304,7 @@ void tst_QCssParser::rulesForNode()
decls += rules.at(i).declarations;
}
- QVERIFY(decls.count() == declCount);
+ QCOMPARE(decls.count(), declCount);
if (declCount > 0)
QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), value0);
@@ -1364,7 +1364,7 @@ void tst_QCssParser::shorthandBackgroundProperty()
v.extractBackground(&brush, &image, &repeat, &alignment, &origin, &attachment, &ignoredOrigin);
QFETCH(QBrush, expectedBrush);
- QVERIFY(expectedBrush.color() == brush.color());
+ QCOMPARE(expectedBrush.color(), brush.color());
QTEST(image, "expectedImage");
QTEST(int(repeat), "expectedRepeatValue");
@@ -1372,7 +1372,7 @@ void tst_QCssParser::shorthandBackgroundProperty()
//QTBUG-9674 : a second evaluation should give the same results
QVERIFY(v.extractBackground(&brush, &image, &repeat, &alignment, &origin, &attachment, &ignoredOrigin));
- QVERIFY(expectedBrush.color() == brush.color());
+ QCOMPARE(expectedBrush.color(), brush.color());
QTEST(image, "expectedImage");
QTEST(int(repeat), "expectedRepeatValue");
QTEST(int(alignment), "expectedAlignment");
@@ -1438,7 +1438,7 @@ void tst_QCssParser::pseudoElement()
decls += rules.at(i).declarations;
}
- QVERIFY(decls.count() == declCount);
+ QCOMPARE(decls.count(), declCount);
}
void tst_QCssParser::gradient_data()
@@ -1517,21 +1517,21 @@ void tst_QCssParser::gradient()
QBrush sbg, abg;
QVERIFY(ve.extractPalette(&fg, &sfg, &sbg, &abg));
if (type == "linear") {
- QVERIFY(sbg.style() == Qt::LinearGradientPattern);
+ QCOMPARE(sbg.style(), Qt::LinearGradientPattern);
const QLinearGradient *lg = static_cast<const QLinearGradient *>(sbg.gradient());
QCOMPARE(lg->start(), start);
QCOMPARE(lg->finalStop(), finalStop);
} else if (type == "conical") {
- QVERIFY(sbg.style() == Qt::ConicalGradientPattern);
+ QCOMPARE(sbg.style(), Qt::ConicalGradientPattern);
const QConicalGradient *cg = static_cast<const QConicalGradient *>(sbg.gradient());
QCOMPARE(cg->center(), start);
}
const QGradient *g = sbg.gradient();
QCOMPARE(g->spread(), QGradient::Spread(spread));
- QVERIFY(g->stops().at(0).first == stop0);
- QVERIFY(g->stops().at(0).second == color0);
- QVERIFY(g->stops().at(1).first == stop1);
- QVERIFY(g->stops().at(1).second == color1);
+ QCOMPARE(g->stops().at(0).first, stop0);
+ QCOMPARE(g->stops().at(0).second, color0);
+ QCOMPARE(g->stops().at(1).first, stop1);
+ QCOMPARE(g->stops().at(1).second, color1);
}
void tst_QCssParser::extractFontFamily_data()
@@ -1637,15 +1637,15 @@ void tst_QCssParser::extractBorder()
QSize radii[4];
extractor.extractBorder(widths, colors, styles, radii);
- QVERIFY(widths[QCss::TopEdge] == expectedTopWidth);
- QVERIFY(styles[QCss::TopEdge] == expectedTopStyle);
- QVERIFY(colors[QCss::TopEdge] == expectedTopColor);
+ QCOMPARE(widths[QCss::TopEdge], expectedTopWidth);
+ QCOMPARE(int(styles[QCss::TopEdge]), expectedTopStyle);
+ QCOMPARE(colors[QCss::TopEdge].color(), expectedTopColor);
//QTBUG-9674 : a second evaluation should give the same results
QVERIFY(extractor.extractBorder(widths, colors, styles, radii));
- QVERIFY(widths[QCss::TopEdge] == expectedTopWidth);
- QVERIFY(styles[QCss::TopEdge] == expectedTopStyle);
- QVERIFY(colors[QCss::TopEdge] == expectedTopColor);
+ QCOMPARE(widths[QCss::TopEdge], expectedTopWidth);
+ QCOMPARE(int(styles[QCss::TopEdge]), expectedTopStyle);
+ QCOMPARE(colors[QCss::TopEdge].color(), expectedTopColor);
}
void tst_QCssParser::noTextDecoration()
diff --git a/tests/auto/gui/text/qfont/BLACKLIST b/tests/auto/gui/text/qfont/BLACKLIST
new file mode 100644
index 0000000000..d859dee03e
--- /dev/null
+++ b/tests/auto/gui/text/qfont/BLACKLIST
@@ -0,0 +1,2 @@
+[exactMatch]
+opensuse-13.1
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 64b06e9856..93e308b96a 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -149,7 +149,7 @@ void tst_QFont::exactMatch()
#endif
- if (QGuiApplication::platformName() == QLatin1String("xcb")) {
+ if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) {
QVERIFY(QFont("sans").exactMatch());
QVERIFY(QFont("sans-serif").exactMatch());
QVERIFY(QFont("serif").exactMatch());
@@ -217,15 +217,15 @@ void tst_QFont::exactMatch()
|| fontinfo.family().isEmpty());
}
if (font.pointSize() != -1) {
- QVERIFY(font.pointSize() == fontinfo.pointSize());
+ QCOMPARE(font.pointSize(), fontinfo.pointSize());
} else {
- QVERIFY(font.pixelSize() == fontinfo.pixelSize());
+ QCOMPARE(font.pixelSize(), fontinfo.pixelSize());
}
- QVERIFY(font.italic() == fontinfo.italic());
+ QCOMPARE(font.italic(), fontinfo.italic());
if (font.weight() != fontinfo.weight()) {
qDebug("font is %s", font.toString().toLatin1().constData());
}
- QVERIFY(font.weight() == fontinfo.weight());
+ QCOMPARE(font.weight(), fontinfo.weight());
} else {
font.setFixedPitch(!fontinfo.fixedPitch());
QFontInfo fontinfo1(font);
@@ -274,12 +274,12 @@ void tst_QFont::exactMatch()
|| fontinfo.family().contains(font.family())
|| fontinfo.family().isEmpty());
if (font.pointSize() != -1) {
- QVERIFY(font.pointSize() == fontinfo.pointSize());
+ QCOMPARE(font.pointSize(), fontinfo.pointSize());
} else {
- QVERIFY(font.pixelSize() == fontinfo.pixelSize());
+ QCOMPARE(font.pixelSize(), fontinfo.pixelSize());
}
- QVERIFY(font.italic() == fontinfo.italic());
- QVERIFY(font.weight() == fontinfo.weight());
+ QCOMPARE(font.italic(), fontinfo.italic());
+ QCOMPARE(font.weight(), fontinfo.weight());
} else {
font.setFixedPitch(!fontinfo.fixedPitch());
QFontInfo fontinfo1(font, (QFont::Script) script);
@@ -371,42 +371,42 @@ void tst_QFont::compare()
QVERIFY(font != font2);
QCOMPARE(font < font2,!(font2 < font));
font2.setItalic(false);
- QVERIFY(font == font2);
+ QCOMPARE(font, font2);
QVERIFY(!(font < font2));
font2.setWeight(QFont::Bold);
QVERIFY(font != font2);
QCOMPARE(font < font2,!(font2 < font));
font2.setWeight(QFont::Normal);
- QVERIFY(font == font2);
+ QCOMPARE(font, font2);
QVERIFY(!(font < font2));
font.setUnderline(true);
QVERIFY(font != font2);
QCOMPARE(font < font2,!(font2 < font));
font.setUnderline(false);
- QVERIFY(font == font2);
+ QCOMPARE(font, font2);
QVERIFY(!(font < font2));
font.setStrikeOut(true);
QVERIFY(font != font2);
QCOMPARE(font < font2,!(font2 < font));
font.setStrikeOut(false);
- QVERIFY(font == font2);
+ QCOMPARE(font, font2);
QVERIFY(!(font < font2));
font.setOverline(true);
QVERIFY(font != font2);
QCOMPARE(font < font2,!(font2 < font));
font.setOverline(false);
- QVERIFY(font == font2);
+ QCOMPARE(font, font2);
QVERIFY(!(font < font2));
font.setCapitalization(QFont::SmallCaps);
QVERIFY(font != font2);
QCOMPARE(font < font2,!(font2 < font));
font.setCapitalization(QFont::MixedCase);
- QVERIFY(font == font2);
+ QCOMPARE(font, font2);
QVERIFY(!(font < font2));
}
}
@@ -426,27 +426,27 @@ void tst_QFont::resolve()
font1.setWeight(QFont::Bold);
QFont font2 = font1.resolve(font);
- QVERIFY(font2.weight() == font1.weight());
+ QCOMPARE(font2.weight(), font1.weight());
- QVERIFY(font2.pointSize() == font.pointSize());
- QVERIFY(font2.italic() == font.italic());
- QVERIFY(font2.underline() == font.underline());
- QVERIFY(font2.overline() == font.overline());
- QVERIFY(font2.strikeOut() == font.strikeOut());
- QVERIFY(font2.stretch() == font.stretch());
+ QCOMPARE(font2.pointSize(), font.pointSize());
+ QCOMPARE(font2.italic(), font.italic());
+ QCOMPARE(font2.underline(), font.underline());
+ QCOMPARE(font2.overline(), font.overline());
+ QCOMPARE(font2.strikeOut(), font.strikeOut());
+ QCOMPARE(font2.stretch(), font.stretch());
QFont font3;
font3.setStretch(QFont::UltraCondensed);
QFont font4 = font3.resolve(font1).resolve(font);
- QVERIFY(font4.stretch() == font3.stretch());
+ QCOMPARE(font4.stretch(), font3.stretch());
- QVERIFY(font4.weight() == font.weight());
- QVERIFY(font4.pointSize() == font.pointSize());
- QVERIFY(font4.italic() == font.italic());
- QVERIFY(font4.underline() == font.underline());
- QVERIFY(font4.overline() == font.overline());
- QVERIFY(font4.strikeOut() == font.strikeOut());
+ QCOMPARE(font4.weight(), font.weight());
+ QCOMPARE(font4.pointSize(), font.pointSize());
+ QCOMPARE(font4.italic(), font.italic());
+ QCOMPARE(font4.underline(), font.underline());
+ QCOMPARE(font4.overline(), font.overline());
+ QCOMPARE(font4.strikeOut(), font.strikeOut());
QFont f1,f2,f3;
@@ -479,8 +479,8 @@ void tst_QFont::resetFont()
child->setFont(QFont()); // reset font
- QVERIFY(child->font().resolve() == 0);
- QVERIFY(child->font().pointSize() == parent.font().pointSize());
+ QCOMPARE(child->font().resolve(), uint(0));
+ QCOMPARE(child->font().pointSize(), parent.font().pointSize());
QVERIFY(parent.font().resolve() != 0);
}
#endif
@@ -608,6 +608,11 @@ void tst_QFont::serialize_data()
font.setStyleName("Regular Black Condensed");
// This wasn't read until 5.4.
QTest::newRow("styleName") << font << QDataStream::Qt_5_4;
+
+ font = basicFont;
+ font.setCapitalization(QFont::AllUppercase);
+ // This wasn't read until 5.6.
+ QTest::newRow("capitalization") << font << QDataStream::Qt_5_6;
}
void tst_QFont::serialize()
@@ -728,24 +733,24 @@ void tst_QFont::sharing()
QCOMPARE(QFontPrivate::get(f)->engineData->ref.load(), 1 + refs_by_cache);
QFont f2(f);
- QVERIFY(QFontPrivate::get(f2) == QFontPrivate::get(f));
+ QCOMPARE(QFontPrivate::get(f2), QFontPrivate::get(f));
QCOMPARE(QFontPrivate::get(f2)->ref.load(), 2);
QVERIFY(QFontPrivate::get(f2)->engineData);
- QVERIFY(QFontPrivate::get(f2)->engineData == QFontPrivate::get(f)->engineData);
+ QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData);
QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 1 + refs_by_cache);
f2.setKerning(!f.kerning());
QVERIFY(QFontPrivate::get(f2) != QFontPrivate::get(f));
QCOMPARE(QFontPrivate::get(f2)->ref.load(), 1);
QVERIFY(QFontPrivate::get(f2)->engineData);
- QVERIFY(QFontPrivate::get(f2)->engineData == QFontPrivate::get(f)->engineData);
+ QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData);
QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 2 + refs_by_cache);
f2 = f;
- QVERIFY(QFontPrivate::get(f2) == QFontPrivate::get(f));
+ QCOMPARE(QFontPrivate::get(f2), QFontPrivate::get(f));
QCOMPARE(QFontPrivate::get(f2)->ref.load(), 2);
QVERIFY(QFontPrivate::get(f2)->engineData);
- QVERIFY(QFontPrivate::get(f2)->engineData == QFontPrivate::get(f)->engineData);
+ QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData);
QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 1 + refs_by_cache);
if (f.pointSize() > 0)
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
index d8e9836112..ec62bafd6c 100644
--- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
@@ -65,6 +65,7 @@ private slots:
void inFontUcs4();
void lineWidth();
void mnemonicTextWidth();
+ void leadingBelowLine();
};
tst_QFontMetrics::tst_QFontMetrics()
@@ -343,5 +344,16 @@ void tst_QFontMetrics::mnemonicTextWidth()
QCOMPARE(fm.size(Qt::TextShowMnemonic, f1), fm.size(Qt::TextShowMnemonic, f2));
QCOMPARE(fm.size(Qt::TextHideMnemonic, f1), fm.size(Qt::TextHideMnemonic, f2));
}
+
+void tst_QFontMetrics::leadingBelowLine()
+{
+ QScriptLine line;
+ line.leading = 10;
+ line.leadingIncluded = true;
+ line.ascent = 5;
+ QCOMPARE(line.height(), line.ascent + line.descent + line.leading);
+ QCOMPARE(line.base(), line.ascent);
+}
+
QTEST_MAIN(tst_QFontMetrics)
#include "tst_qfontmetrics.moc"
diff --git a/tests/auto/gui/text/qrawfont/BLACKLIST b/tests/auto/gui/text/qrawfont/BLACKLIST
new file mode 100644
index 0000000000..a614595689
--- /dev/null
+++ b/tests/auto/gui/text/qrawfont/BLACKLIST
@@ -0,0 +1,4 @@
+[correctFontData]
+osx-10.8
+[unsupportedWritingSystem]
+osx-10.8
diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
index 014ed4c7c8..06448d11fe 100644
--- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
+++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
@@ -120,7 +120,7 @@ void tst_QSyntaxHighlighter::cleanup()
class TestHighlighter : public QSyntaxHighlighter
{
public:
- inline TestHighlighter(const QList<QTextLayout::FormatRange> &fmts, QTextDocument *parent)
+ inline TestHighlighter(const QVector<QTextLayout::FormatRange> &fmts, QTextDocument *parent)
: QSyntaxHighlighter(parent), formats(fmts), highlighted(false), callCount(0) {}
inline TestHighlighter(QObject *parent)
: QSyntaxHighlighter(parent) {}
@@ -138,24 +138,15 @@ public:
++callCount;
}
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
bool highlighted;
int callCount;
QString highlightedText;
};
-QT_BEGIN_NAMESPACE
-bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs)
-{
- return lhs.start == rhs.start
- && lhs.length == rhs.length
- && lhs.format == rhs.format;
-}
-QT_END_NAMESPACE
-
void tst_QSyntaxHighlighter::basic()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 2;
@@ -179,7 +170,7 @@ void tst_QSyntaxHighlighter::basic()
QVERIFY(hl->highlighted);
QVERIFY(lout->documentChangedCalled);
- QVERIFY(doc->begin().layout()->additionalFormats() == formats);
+ QCOMPARE(doc->begin().layout()->formats(), formats);
}
class CommentTestHighlighter : public QSyntaxHighlighter
@@ -222,7 +213,7 @@ void tst_QSyntaxHighlighter::basicTwo()
void tst_QSyntaxHighlighter::removeFormatsOnDelete()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 9;
@@ -237,9 +228,9 @@ void tst_QSyntaxHighlighter::removeFormatsOnDelete()
QVERIFY(lout->documentChangedCalled);
lout->documentChangedCalled = false;
- QVERIFY(!doc->begin().layout()->additionalFormats().isEmpty());
+ QVERIFY(!doc->begin().layout()->formats().isEmpty());
delete hl;
- QVERIFY(doc->begin().layout()->additionalFormats().isEmpty());
+ QVERIFY(doc->begin().layout()->formats().isEmpty());
QVERIFY(lout->documentChangedCalled);
}
@@ -405,7 +396,7 @@ void tst_QSyntaxHighlighter::highlightToEndOfDocument2()
void tst_QSyntaxHighlighter::preservePreeditArea()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 8;
@@ -432,12 +423,12 @@ void tst_QSyntaxHighlighter::preservePreeditArea()
hl->callCount = 0;
cursor.beginEditBlock();
- layout->setAdditionalFormats(formats);
+ layout->setFormats(formats);
cursor.endEditBlock();
QCOMPARE(hl->callCount, 1);
- formats = layout->additionalFormats();
+ formats = layout->formats();
QCOMPARE(formats.count(), 3);
range = formats.at(0);
@@ -483,7 +474,7 @@ void tst_QSyntaxHighlighter::avoidUnnecessaryRehighlight()
void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight()
{
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QTextLayout::FormatRange range;
range.start = 0;
range.length = 10;
diff --git a/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp b/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp
index 967fe3114e..49300871d9 100644
--- a/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp
+++ b/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp
@@ -102,7 +102,7 @@ void tst_QTextBlock::fragmentOverBlockBoundaries()
// Block separators are always a fragment of their self. Thus:
// |Hello|\b|World|\b|
#if !defined(Q_OS_WIN)
- QVERIFY(doc->docHandle()->fragmentMap().numNodes() == 4);
+ QCOMPARE(doc->docHandle()->fragmentMap().numNodes(), 4);
#endif
QCOMPARE(cursor.block().text(), QString("Hello"));
cursor.movePosition(QTextCursor::NextBlock);
@@ -126,7 +126,7 @@ void tst_QTextBlock::excludeParagraphSeparatorFragment()
++it;
QVERIFY(it.atEnd());
- QVERIFY(it == block.end());
+ QCOMPARE(it, block.end());
}
void tst_QTextBlock::backwardsBlockIterator()
diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
index 42b3c53bc5..9396cd678b 100644
--- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
@@ -178,15 +178,15 @@ void tst_QTextCursor::navigation1()
QVERIFY(doc->toPlainText() == "Hello World");
cursor.movePosition(QTextCursor::End);
- QVERIFY(cursor.position() == 11);
+ QCOMPARE(cursor.position(), 11);
cursor.deletePreviousChar();
- QVERIFY(cursor.position() == 10);
+ QCOMPARE(cursor.position(), 10);
cursor.deletePreviousChar();
cursor.deletePreviousChar();
cursor.deletePreviousChar();
cursor.deletePreviousChar();
cursor.deletePreviousChar();
- QVERIFY(doc->toPlainText() == "Hello");
+ QCOMPARE(doc->toPlainText(), QLatin1String("Hello"));
QTextCursor otherCursor(doc);
otherCursor.movePosition(QTextCursor::Start);
@@ -195,12 +195,12 @@ void tst_QTextCursor::navigation1()
cursor.movePosition(QTextCursor::Right);
QVERIFY(cursor != otherCursor);
otherCursor.insertText("Hey");
- QVERIFY(cursor.position() == 5);
+ QCOMPARE(cursor.position(), 5);
doc->undo();
- QVERIFY(cursor.position() == 2);
+ QCOMPARE(cursor.position(), 2);
doc->redo();
- QVERIFY(cursor.position() == 5);
+ QCOMPARE(cursor.position(), 5);
doc->undo();
@@ -209,29 +209,29 @@ void tst_QTextCursor::navigation1()
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 6);
- QVERIFY(cursor.position() == 6);
+ QCOMPARE(cursor.position(), 6);
otherCursor = cursor;
otherCursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 2);
otherCursor.deletePreviousChar();
otherCursor.deletePreviousChar();
otherCursor.deletePreviousChar();
- QVERIFY(cursor.position() == 5);
+ QCOMPARE(cursor.position(), 5);
cursor.movePosition(QTextCursor::End);
cursor.insertBlock();
{
int oldPos = cursor.position();
cursor.movePosition(QTextCursor::End);
- QVERIFY(cursor.position() == oldPos);
+ QCOMPARE(cursor.position(), oldPos);
}
QVERIFY(cursor.atBlockStart());
- QVERIFY(cursor.position() == 9);
+ QCOMPARE(cursor.position(), 9);
QTextCharFormat fmt;
fmt.setForeground(Qt::blue);
cursor.insertText("Test", fmt);
- QVERIFY(fmt == cursor.charFormat());
- QVERIFY(cursor.position() == 13);
+ QCOMPARE(fmt, cursor.charFormat());
+ QCOMPARE(cursor.position(), 13);
}
void tst_QTextCursor::navigation2_data()
@@ -497,7 +497,7 @@ void tst_QTextCursor::navigation10()
QVERIFY(ok);
QCOMPARE(cursor.position(), 99);
ok = cursor.movePosition(QTextCursor::NextCell);
- QVERIFY(ok == false);
+ QVERIFY(!ok);
QCOMPARE(cursor.position(), 99); // didn't move.
QVERIFY(cursor.currentTable());
@@ -573,8 +573,8 @@ void tst_QTextCursor::insertBlock()
QTextBlockFormat fmt;
fmt.setTopMargin(100);
cursor.insertBlock(fmt);
- QVERIFY(cursor.position() == 1);
- QVERIFY(cursor.blockFormat() == fmt);
+ QCOMPARE(cursor.position(), 1);
+ QCOMPARE(cursor.blockFormat(), fmt);
}
void tst_QTextCursor::insertWithBlockSeparator1()
@@ -584,28 +584,28 @@ void tst_QTextCursor::insertWithBlockSeparator1()
cursor.insertText(text);
cursor.movePosition(QTextCursor::PreviousBlock);
- QVERIFY(cursor.position() == 0);
+ QCOMPARE(cursor.position(), 0);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 6);
+ QCOMPARE(cursor.position(), 6);
}
void tst_QTextCursor::insertWithBlockSeparator2()
{
cursor.insertText(QString(QChar::ParagraphSeparator));
- QVERIFY(cursor.position() == 1);
+ QCOMPARE(cursor.position(), 1);
}
void tst_QTextCursor::insertWithBlockSeparator3()
{
cursor.insertText(QString(QChar::ParagraphSeparator) + "Hi" + QString(QChar::ParagraphSeparator));
- QVERIFY(cursor.position() == 4);
+ QCOMPARE(cursor.position(), 4);
}
void tst_QTextCursor::insertWithBlockSeparator4()
{
cursor.insertText(QString(QChar::ParagraphSeparator) + QString(QChar::ParagraphSeparator));
- QVERIFY(cursor.position() == 2);
+ QCOMPARE(cursor.position(), 2);
}
void tst_QTextCursor::clearObjectType1()
@@ -656,7 +656,7 @@ void tst_QTextCursor::comparisonOperators1()
midCursor.movePosition(QTextCursor::NextWord);
QVERIFY(midCursor <= cursor);
- QVERIFY(midCursor == cursor);
+ QCOMPARE(midCursor, cursor);
QVERIFY(midCursor >= cursor);
QVERIFY(midCursor > startCursor);
@@ -690,7 +690,7 @@ void tst_QTextCursor::comparisonOperators2()
QTextCursor cursor2(&doc2);
QVERIFY(cursor1 != cursor2);
- QVERIFY(cursor1 == QTextCursor(&doc1));
+ QCOMPARE(cursor1, QTextCursor(&doc1));
}
void tst_QTextCursor::selection1()
@@ -718,97 +718,97 @@ void tst_QTextCursor::dontCopyTableAttributes()
void tst_QTextCursor::checkFrame1()
{
- QVERIFY(cursor.position() == 0);
+ QCOMPARE(cursor.position(), 0);
QPointer<QTextFrame> frame = cursor.insertFrame(QTextFrameFormat());
QVERIFY(frame != 0);
QTextFrame *root = frame->parentFrame();
QVERIFY(root != 0);
- QVERIFY(frame->firstPosition() == 1);
- QVERIFY(frame->lastPosition() == 1);
+ QCOMPARE(frame->firstPosition(), 1);
+ QCOMPARE(frame->lastPosition(), 1);
QVERIFY(frame->parentFrame() != 0);
- QVERIFY(root->childFrames().size() == 1);
+ QCOMPARE(root->childFrames().size(), 1);
- QVERIFY(cursor.position() == 1);
- QVERIFY(cursor.selectionStart() == 1);
- QVERIFY(cursor.selectionEnd() == 1);
+ QCOMPARE(cursor.position(), 1);
+ QCOMPARE(cursor.selectionStart(), 1);
+ QCOMPARE(cursor.selectionEnd(), 1);
doc->undo();
QVERIFY(!frame);
- QVERIFY(root->childFrames().size() == 0);
+ QCOMPARE(root->childFrames().size(), 0);
- QVERIFY(cursor.position() == 0);
- QVERIFY(cursor.selectionStart() == 0);
- QVERIFY(cursor.selectionEnd() == 0);
+ QCOMPARE(cursor.position(), 0);
+ QCOMPARE(cursor.selectionStart(), 0);
+ QCOMPARE(cursor.selectionEnd(), 0);
doc->redo();
frame = doc->frameAt(1);
QVERIFY(frame);
- QVERIFY(frame->firstPosition() == 1);
- QVERIFY(frame->lastPosition() == 1);
+ QCOMPARE(frame->firstPosition(), 1);
+ QCOMPARE(frame->lastPosition(), 1);
QVERIFY(frame->parentFrame() != 0);
- QVERIFY(root->childFrames().size() == 1);
+ QCOMPARE(root->childFrames().size(), 1);
- QVERIFY(cursor.position() == 1);
- QVERIFY(cursor.selectionStart() == 1);
- QVERIFY(cursor.selectionEnd() == 1);
+ QCOMPARE(cursor.position(), 1);
+ QCOMPARE(cursor.selectionStart(), 1);
+ QCOMPARE(cursor.selectionEnd(), 1);
// cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
-// QVERIFY(cursor.position() == 2);
-// QVERIFY(cursor.selectionStart() == 0);
-// QVERIFY(cursor.selectionEnd() == 2);
+// QCOMPARE(cursor.position(), 2);
+// QCOMPARE(cursor.selectionStart(), 0);
+// QCOMPARE(cursor.selectionEnd(), 2);
}
void tst_QTextCursor::checkFrame2()
{
- QVERIFY(cursor.position() == 0);
+ QCOMPARE(cursor.position(), 0);
cursor.insertText("A");
- QVERIFY(cursor.position() == 1);
+ QCOMPARE(cursor.position(), 1);
cursor.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor);
QPointer<QTextFrame> frame = cursor.insertFrame(QTextFrameFormat());
QTextFrame *root = frame->parentFrame();
- QVERIFY(frame->firstPosition() == 1);
- QVERIFY(frame->lastPosition() == 2);
+ QCOMPARE(frame->firstPosition(), 1);
+ QCOMPARE(frame->lastPosition(), 2);
QVERIFY(frame->parentFrame() != 0);
- QVERIFY(root->childFrames().size() == 1);
+ QCOMPARE(root->childFrames().size(), 1);
- QVERIFY(cursor.position() == 1);
- QVERIFY(cursor.selectionStart() == 1);
- QVERIFY(cursor.selectionEnd() == 2);
+ QCOMPARE(cursor.position(), 1);
+ QCOMPARE(cursor.selectionStart(), 1);
+ QCOMPARE(cursor.selectionEnd(), 2);
doc->undo();
QVERIFY(!frame);
- QVERIFY(root->childFrames().size() == 0);
+ QCOMPARE(root->childFrames().size(), 0);
- QVERIFY(cursor.position() == 0);
- QVERIFY(cursor.selectionStart() == 0);
- QVERIFY(cursor.selectionEnd() == 1);
+ QCOMPARE(cursor.position(), 0);
+ QCOMPARE(cursor.selectionStart(), 0);
+ QCOMPARE(cursor.selectionEnd(), 1);
doc->redo();
frame = doc->frameAt(1);
QVERIFY(frame);
- QVERIFY(frame->firstPosition() == 1);
- QVERIFY(frame->lastPosition() == 2);
+ QCOMPARE(frame->firstPosition(), 1);
+ QCOMPARE(frame->lastPosition(), 2);
QVERIFY(frame->parentFrame() != 0);
- QVERIFY(root->childFrames().size() == 1);
+ QCOMPARE(root->childFrames().size(), 1);
- QVERIFY(cursor.position() == 1);
- QVERIFY(cursor.selectionStart() == 1);
- QVERIFY(cursor.selectionEnd() == 2);
+ QCOMPARE(cursor.position(), 1);
+ QCOMPARE(cursor.selectionStart(), 1);
+ QCOMPARE(cursor.selectionEnd(), 2);
cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
- QVERIFY(cursor.position() == 0);
- QVERIFY(cursor.selectionStart() == 0);
- QVERIFY(cursor.selectionEnd() == 3);
+ QCOMPARE(cursor.position(), 0);
+ QCOMPARE(cursor.selectionStart(), 0);
+ QCOMPARE(cursor.selectionEnd(), 3);
}
void tst_QTextCursor::insertBlockToUseCharFormat()
@@ -833,9 +833,9 @@ void tst_QTextCursor::insertBlockToUseCharFormat()
void tst_QTextCursor::tableMovement()
{
- QVERIFY(cursor.position() == 0);
+ QCOMPARE(cursor.position(), 0);
cursor.insertText("AA");
- QVERIFY(cursor.position() == 2);
+ QCOMPARE(cursor.position(), 2);
cursor.movePosition(QTextCursor::Left);
cursor.insertTable(3, 3);
@@ -1030,7 +1030,7 @@ void tst_QTextCursor::insertBlockShouldRemoveSelection()
cursor.insertBlock();
QVERIFY(!cursor.hasSelection());
- QVERIFY(doc->toPlainText().indexOf("Hello") == -1);
+ QCOMPARE(doc->toPlainText().indexOf("Hello"), -1);
}
void tst_QTextCursor::insertBlockShouldRemoveSelection2()
@@ -1046,7 +1046,7 @@ void tst_QTextCursor::insertBlockShouldRemoveSelection2()
cursor.insertBlock(fmt);
QVERIFY(!cursor.hasSelection());
- QVERIFY(doc->toPlainText().indexOf("Hello") == -1);
+ QCOMPARE(doc->toPlainText().indexOf("Hello"), -1);
}
void tst_QTextCursor::mergeCellShouldUpdateSelection()
@@ -1159,7 +1159,7 @@ void tst_QTextCursor::setBlockFormatInTable()
cursor.setBlockFormat(fmt);
cursor.movePosition(QTextCursor::Start);
- QVERIFY(cursor.blockFormat().background().color() == Qt::blue);
+ QCOMPARE(cursor.blockFormat().background().color(), QColor(Qt::blue));
}
void tst_QTextCursor::blockCharFormat2()
@@ -1174,7 +1174,7 @@ void tst_QTextCursor::blockCharFormat2()
cursor.movePosition(QTextCursor::Start);
cursor.insertText("Red");
cursor.movePosition(QTextCursor::PreviousCharacter);
- QVERIFY(cursor.charFormat().foreground().color() == Qt::red);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::red));
}
void tst_QTextCursor::blockCharFormat3()
@@ -1189,21 +1189,23 @@ void tst_QTextCursor::blockCharFormat3()
cursor.insertText("Test");
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextCharacter);
- QVERIFY(cursor.charFormat().foreground().color() == Qt::green);
+ const QColor red(Qt::red);
+ const QColor green(Qt::green);
+ QCOMPARE(cursor.charFormat().foreground().color(), green);
cursor.movePosition(QTextCursor::Start);
- QVERIFY(cursor.charFormat().foreground().color() == Qt::green);
+ QCOMPARE(cursor.charFormat().foreground().color(), green);
fmt.setForeground(Qt::red);
cursor.setBlockCharFormat(fmt);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::red);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), red);
cursor.movePosition(QTextCursor::End);
cursor.movePosition(QTextCursor::Start);
- QVERIFY(cursor.charFormat().foreground().color() == Qt::green);
+ QCOMPARE(cursor.charFormat().foreground().color(), green);
cursor.insertText("Test");
- QVERIFY(cursor.charFormat().foreground().color() == Qt::green);
+ QCOMPARE(cursor.charFormat().foreground().color(), green);
cursor.select(QTextCursor::Document);
cursor.removeSelectedText();
@@ -1212,7 +1214,7 @@ void tst_QTextCursor::blockCharFormat3()
QVERIFY(cursor.atStart());
cursor.insertText("Test");
- QVERIFY(cursor.charFormat().foreground().color() == Qt::red);
+ QCOMPARE(cursor.charFormat().foreground().color(), red);
}
void tst_QTextCursor::blockCharFormat()
@@ -1222,12 +1224,12 @@ void tst_QTextCursor::blockCharFormat()
cursor.insertBlock(QTextBlockFormat(), fmt);
cursor.insertText("Hm");
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::blue);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::blue));
fmt.setForeground(Qt::red);
cursor.setBlockCharFormat(fmt);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::red);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::red));
}
void tst_QTextCursor::blockCharFormatOnSelection()
@@ -1249,11 +1251,11 @@ void tst_QTextCursor::blockCharFormatOnSelection()
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::blue);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::blue));
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::red);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::red));
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::white);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::white));
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextBlock);
@@ -1264,17 +1266,17 @@ void tst_QTextCursor::blockCharFormatOnSelection()
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::cyan);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::cyan));
cursor.movePosition(QTextCursor::Right);
cursor.movePosition(QTextCursor::Right);
- QVERIFY(cursor.charFormat().foreground().color() == Qt::green);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::green));
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::cyan);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::cyan));
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::white);
+ QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::white));
}
void tst_QTextCursor::anchorInitialized1()
@@ -1404,7 +1406,7 @@ void tst_QTextCursor::selectBlock()
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter);
+ QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter);
QCOMPARE(cursor.block().text(), QString("blah"));
}
@@ -1449,7 +1451,7 @@ void tst_QTextCursor::insertFragmentShouldUseCurrentCharFormat()
cursor.insertFragment(fragment);
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextCharacter);
- QVERIFY(cursor.charFormat() == fmt);
+ QCOMPARE(cursor.charFormat(), fmt);
}
int tst_QTextCursor::blockCount()
@@ -1910,15 +1912,15 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo()
int cursorPositionAfter = cursor.position();
cursor.endEditBlock();
- QVERIFY(doc->toPlainText() == "*AAAA*BBBB*CCCC*DDDD");
+ QCOMPARE(doc->toPlainText(), QLatin1String("*AAAA*BBBB*CCCC*DDDD"));
QCOMPARE(12, cursorPositionBefore);
QCOMPARE(1, cursorPositionAfter);
doc->undo(&cursor);
- QVERIFY(doc->toPlainText() == "AAAABBBBCCCCDDDD");
+ QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBBCCCCDDDD"));
QCOMPARE(cursor.position(), cursorPositionBefore);
doc->redo(&cursor);
- QVERIFY(doc->toPlainText() == "*AAAA*BBBB*CCCC*DDDD");
+ QCOMPARE(doc->toPlainText(), QLatin1String("*AAAA*BBBB*CCCC*DDDD"));
QCOMPARE(cursor.position(), cursorPositionAfter);
}
@@ -1932,11 +1934,11 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo2()
cursor.insertText("AAAABBBBCCCCDDDD");
cursor.endEditBlock();
doc->undo(&cursor);
- QVERIFY(doc->toPlainText() == "AAAABBBB");
+ QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBB"));
QCOMPARE(cursor.position(), cursorPositionBefore);
cursor.insertText("CCCC");
- QVERIFY(doc->toPlainText() == "AAAABBBBCCCC");
+ QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBBCCCC"));
cursorPositionBefore = cursor.position();
cursor.setPosition(0, QTextCursor::KeepAnchor);
@@ -1951,7 +1953,7 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo2()
doc->undo(&cursor);
- QVERIFY(doc->toPlainText() == "AAAABBBBCCCC");
+ QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBBCCCC"));
QCOMPARE(cursor.position(), cursorPositionBefore);
}
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 5e6b606d83..7378ca85ee 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -744,7 +744,7 @@ void tst_QTextDocument::mightBeRichText()
{
QFETCH(QString, input);
QFETCH(bool, result);
- QVERIFY(result == Qt::mightBeRichText(input));
+ QCOMPARE(result, Qt::mightBeRichText(input));
}
Q_DECLARE_METATYPE(QTextDocumentFragment)
@@ -2222,7 +2222,7 @@ void tst_QTextDocument::clonePreservesUserStates()
b2 = b2.next();
QCOMPARE(b1.userState(), b2.userState());
}
- QVERIFY(b2 == clone->end());
+ QCOMPARE(b2, clone->end());
delete clone;
}
@@ -2269,7 +2269,7 @@ void tst_QTextDocument::resolvedFontInEmptyFormat()
doc->setDefaultFont(font);
QTextCharFormat fmt = doc->begin().charFormat();
QVERIFY(fmt.properties().isEmpty());
- QVERIFY(fmt.font() == font);
+ QCOMPARE(fmt.font(), font);
}
void tst_QTextDocument::defaultRootFrameMargin()
@@ -2369,6 +2369,7 @@ void tst_QTextDocument::deleteTextObjectsOnClear()
void tst_QTextDocument::defaultStyleSheet()
{
+ const QColor green("green");
const QString sheet("p { background-color: green; }");
QVERIFY(doc->defaultStyleSheet().isEmpty());
doc->setDefaultStyleSheet(sheet);
@@ -2376,30 +2377,30 @@ void tst_QTextDocument::defaultStyleSheet()
cursor.insertHtml("<p>test");
QTextBlockFormat fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
doc->clear();
cursor.insertHtml("<p>test");
fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
QTextDocument *clone = doc->clone();
QCOMPARE(clone->defaultStyleSheet(), sheet);
cursor = QTextCursor(clone);
cursor.insertHtml("<p>test");
fmt = clone->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
delete clone;
cursor = QTextCursor(doc);
cursor.insertHtml("<p>test");
fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
doc->clear();
cursor.insertHtml("<style>p { background-color: red; }</style><p>test");
fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("red"));
+ QCOMPARE(fmt.background().color(), QColor(Qt::red));
doc->clear();
doc->setDefaultStyleSheet("invalid style sheet....");
@@ -2567,7 +2568,7 @@ void tst_QTextDocument::setTextPreservesUndoRedoEnabled()
void tst_QTextDocument::firstLast()
{
QCOMPARE(doc->blockCount(), 1);
- QVERIFY(doc->firstBlock() == doc->lastBlock());
+ QCOMPARE(doc->firstBlock(), doc->lastBlock());
doc->setPlainText("Hello\nTest\nWorld");
@@ -3013,8 +3014,8 @@ void tst_QTextDocument::QTBUG27354_spaceAndSoftSpace()
QTextBlock block = td.begin();
while (block.isValid()) {
QTextBlockFormat fmt = block.blockFormat();
- QVERIFY(fmt.lineHeightType() == QTextBlockFormat::SingleHeight);
- QVERIFY(fmt.lineHeight() == 0);
+ QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::SingleHeight));
+ QCOMPARE(fmt.lineHeight(), qreal(0));
block = block.next();
}
}
@@ -3164,8 +3165,8 @@ void tst_QTextDocument::cssInheritance()
QTextBlock block = td.begin();
while (block.isValid()) {
QTextBlockFormat fmt = block.blockFormat();
- QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight);
- QVERIFY(fmt.lineHeight() == 200);
+ QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::ProportionalHeight));
+ QCOMPARE(fmt.lineHeight(), qreal(200));
block = block.next();
}
}
@@ -3175,12 +3176,12 @@ void tst_QTextDocument::cssInheritance()
"<p style=\"line-height: 40px\">Foo</p><p>Bar</p><p>Baz</p></body></html>");
QTextBlock block = td.begin();
QTextBlockFormat fmt = block.blockFormat();
- QVERIFY(fmt.lineHeightType() == QTextBlockFormat::FixedHeight);
- QVERIFY(fmt.lineHeight() == 40);
+ QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::FixedHeight));
+ QCOMPARE(fmt.lineHeight(), qreal(40));
block = block.next();
fmt = block.blockFormat();
- QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight);
- QVERIFY(fmt.lineHeight() == 300);
+ QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::ProportionalHeight));
+ QCOMPARE(fmt.lineHeight(), qreal(300));
}
{
QTextDocument td;
@@ -3188,7 +3189,7 @@ void tst_QTextDocument::cssInheritance()
"<p>Foo</p><p>Bar</p><p>Baz</p></body></html>");
QTextBlock block = td.begin();
while (block.isValid()) {
- QVERIFY(block.blockFormat().background() == QBrush());
+ QCOMPARE(block.blockFormat().background(), QBrush());
QVERIFY(block.charFormat().font().bold());
block = block.next();
}
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 8f0d306cba..1cd9d9bcbe 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -727,7 +727,7 @@ void tst_QTextDocumentFragment::html_listIndents5()
QCOMPARE(list->format().indent(), 1);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.currentList() == list);
+ QCOMPARE(cursor.currentList(), list);
QCOMPARE(cursor.blockFormat().indent(), 0);
}
@@ -778,7 +778,7 @@ void tst_QTextDocumentFragment::blockCharFormatCopied()
cleanup();
init();
cursor.insertFragment(frag);
- QVERIFY(cursor.blockCharFormat() == fmt);
+ QCOMPARE(cursor.blockCharFormat(), fmt);
}
void tst_QTextDocumentFragment::initialBlock()
@@ -794,19 +794,19 @@ void tst_QTextDocumentFragment::clone()
mod.setAlignment(Qt::AlignCenter);
cursor.mergeBlockFormat(mod);
cursor.insertText("Blah");
- QVERIFY(cursor.blockFormat().alignment() == Qt::AlignCenter);
+ QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignCenter);
QTextDocumentFragment frag(doc);
cleanup();
init();
cursor.insertFragment(frag);
cursor.movePosition(QTextCursor::Start);
- QVERIFY(cursor.blockFormat().alignment() == Qt::AlignCenter);
+ QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignCenter);
}
void tst_QTextDocumentFragment::dontRemoveInitialBlockIfItHoldsObjectIndexedCharFormat()
{
const char html[] = "<table><tr><td>cell one<td>cell two</tr><tr><td>cell three<td>cell four</tr></table>";
- QVERIFY(doc->begin().charFormat().objectIndex() == -1);
+ QCOMPARE(doc->begin().charFormat().objectIndex(), -1);
setHtml(QString::fromLatin1(html));
int cnt = 0;
@@ -841,13 +841,13 @@ void tst_QTextDocumentFragment::unorderedListEnumeration()
setHtml(QString::fromLatin1(html));
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDisc);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDisc);
const char html2[] = "<ul><ul><ul type=circle><li>Blah</li></ul></ul>";
setHtml(QString::fromLatin1(html2));
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListCircle);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListCircle);
}
@@ -873,7 +873,7 @@ void tst_QTextDocumentFragment::hrefAnchor()
setHtml(QString::fromLatin1(html));
QVERIFY(doc->begin().begin().fragment().charFormat().isAnchor());
QCOMPARE(doc->begin().begin().fragment().charFormat().anchorHref(), QString::fromLatin1("test"));
- QVERIFY(doc->begin().begin().fragment().charFormat().fontUnderline() == true);
+ QVERIFY(doc->begin().begin().fragment().charFormat().fontUnderline());
}
{
@@ -881,7 +881,7 @@ void tst_QTextDocumentFragment::hrefAnchor()
const char html[] = "<a>blah</a>";
setHtml(QString::fromLatin1(html));
QVERIFY(doc->begin().begin().fragment().charFormat().isAnchor());
- QVERIFY(doc->begin().begin().fragment().charFormat().fontUnderline() == false);
+ QVERIFY(!doc->begin().begin().fragment().charFormat().fontUnderline());
}
}
@@ -901,7 +901,7 @@ void tst_QTextDocumentFragment::namedAnchorFragments()
// the 'a'
QVERIFY(it.fragment().isValid());
QCOMPARE(it.fragment().text(), QString::fromLatin1("a"));
- QVERIFY(it.fragment().charFormat().isAnchor() == false);
+ QVERIFY(!it.fragment().charFormat().isAnchor());
// the 'b' of 'blah' as separate fragment with the anchor attribute
++it;
@@ -913,7 +913,7 @@ void tst_QTextDocumentFragment::namedAnchorFragments()
++it;
QVERIFY(it.fragment().isValid());
QVERIFY(it.fragment().text().startsWith("lah"));
- QVERIFY(it.fragment().charFormat().isAnchor() == false);
+ QVERIFY(!it.fragment().charFormat().isAnchor());
}
void tst_QTextDocumentFragment::namedAnchorFragments2()
@@ -982,7 +982,7 @@ void tst_QTextDocumentFragment::cellBlockCount()
int blockCount = 0;
for (QTextFrame::iterator it = cell.begin(); !it.atEnd(); ++it) {
- QVERIFY(it.currentFrame() == 0);
+ QVERIFY(!it.currentFrame());
QVERIFY(it.currentBlock().isValid());
++blockCount;
}
@@ -1003,7 +1003,7 @@ void tst_QTextDocumentFragment::cellBlockCount2()
int blockCount = 0;
for (QTextFrame::iterator it = cell.begin(); !it.atEnd(); ++it) {
- QVERIFY(it.currentFrame() == 0);
+ QVERIFY(!it.currentFrame());
QVERIFY(it.currentBlock().isValid());
++blockCount;
}
@@ -1037,7 +1037,7 @@ void tst_QTextDocumentFragment::emptyTable3()
QCOMPARE(table->columns(), 2);
QTextTableCell cell = table->cellAt(0, 0);
QVERIFY(cell.isValid());
- QVERIFY(cell.firstPosition() == cell.lastPosition());
+ QCOMPARE(cell.firstPosition(), cell.lastPosition());
cell = table->cellAt(0, 1);
QTextCursor cursor = cell.firstCursorPosition();
cursor.setPosition(cell.lastPosition(), QTextCursor::KeepAnchor);
@@ -1065,7 +1065,7 @@ void tst_QTextDocumentFragment::inheritAlignment()
const char html[] = "<body align=right><p>Hey";
setHtml(QString::fromLatin1(html));
// html alignment is absolute
- QVERIFY(doc->begin().blockFormat().alignment() == Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute));
+ QCOMPARE(doc->begin().blockFormat().alignment(), Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute));
}
void tst_QTextDocumentFragment::dontEmitEmptyNodeWhenEmptyTagIsFollowedByCloseTag()
@@ -1073,8 +1073,8 @@ void tst_QTextDocumentFragment::dontEmitEmptyNodeWhenEmptyTagIsFollowedByCloseTa
// make sure the Hey does not end up as tag text for the img tag
const char html[] = "<body align=right><p align=left>Blah<img></img><p>Hey";
setHtml(QString::fromLatin1(html));
- QVERIFY(doc->begin().blockFormat().alignment() == Qt::Alignment(Qt::AlignLeft|Qt::AlignAbsolute));
- QVERIFY(doc->begin().next().blockFormat().alignment() == Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute));
+ QCOMPARE(doc->begin().blockFormat().alignment(), Qt::Alignment(Qt::AlignLeft|Qt::AlignAbsolute));
+ QCOMPARE(doc->begin().next().blockFormat().alignment(), Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute));
}
void tst_QTextDocumentFragment::toPlainText()
@@ -1378,8 +1378,8 @@ void tst_QTextDocumentFragment::html_listStart1()
{
// don't create a block for the <ul> element, even if there's some whitespace between
// it and the <li>
- const char html[] = "<ul> <li>list item</li><ul>";
- cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0]))));
+ const QString html = QStringLiteral("<ul> <li>list item</li><ul>");
+ cursor.insertFragment(QTextDocumentFragment::fromHtml(html));
QCOMPARE(doc->blockCount(), 1);
}
@@ -1387,8 +1387,8 @@ void tst_QTextDocumentFragment::html_listStart1()
void tst_QTextDocumentFragment::html_listStart2()
{
// unlike with html_listStart1 we want a block showing the 'buggy' text here
- const char html[] = "<ul>buggy, but text should appear<li>list item</li><ul>";
- cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0]))));
+ const QString html = QStringLiteral("<ul>buggy, but text should appear<li>list item</li><ul>");
+ cursor.insertFragment(QTextDocumentFragment::fromHtml(html));
QCOMPARE(doc->blockCount(), 2);
}
@@ -1480,19 +1480,19 @@ void tst_QTextDocumentFragment::html_subAndSuperScript()
const char alignmentInherited[] = "<sub><font face=\"Verdana\">Subby</font></sub>";
setHtml(subHtml);
- QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSubScript);
+ QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSubScript);
setHtml(subHtmlCss);
- QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSubScript);
+ QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSubScript);
setHtml(superHtml);
- QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSuperScript);
+ QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSuperScript);
setHtml(superHtmlCss);
- QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSuperScript);
+ QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSuperScript);
setHtml(alignmentInherited);
- QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSubScript);
+ QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSubScript);
}
void tst_QTextDocumentFragment::html_cssColors()
@@ -1695,7 +1695,7 @@ void tst_QTextDocumentFragment::html_bodyBackground()
const char html[] = "<body background=\"foo.png\">Foo</body>";
doc->setHtml(html);
- QVERIFY(doc->rootFrame()->frameFormat().background().style() == Qt::TexturePattern);
+ QCOMPARE(doc->rootFrame()->frameFormat().background().style(), Qt::TexturePattern);
}
void tst_QTextDocumentFragment::html_tableCellBackground()
@@ -1709,7 +1709,7 @@ void tst_QTextDocumentFragment::html_tableCellBackground()
QVERIFY(table);
QTextTableCell cell = table->cellAt(0, 0);
- QVERIFY(cell.format().background().style() == Qt::TexturePattern);
+ QCOMPARE(cell.format().background().style(), Qt::TexturePattern);
}
void tst_QTextDocumentFragment::css_bodyBackground()
@@ -1717,7 +1717,7 @@ void tst_QTextDocumentFragment::css_bodyBackground()
const char html[] = "<body style=\"background-image:url('foo.png')\">Foo</body>";
doc->setHtml(html);
- QVERIFY(doc->rootFrame()->frameFormat().background().style() == Qt::TexturePattern);
+ QCOMPARE(doc->rootFrame()->frameFormat().background().style(), Qt::TexturePattern);
}
void tst_QTextDocumentFragment::css_tableCellBackground()
@@ -1731,7 +1731,7 @@ void tst_QTextDocumentFragment::css_tableCellBackground()
QVERIFY(table);
QTextTableCell cell = table->cellAt(0, 0);
- QVERIFY(cell.format().background().style() == Qt::TexturePattern);
+ QCOMPARE(cell.format().background().style(), Qt::TexturePattern);
}
void tst_QTextDocumentFragment::css_cellPaddings()
@@ -1767,7 +1767,7 @@ void tst_QTextDocumentFragment::html_blockLevelDiv()
setHtml(html);
QCOMPARE(doc->begin().blockFormat().alignment(), Qt::AlignRight|Qt::AlignAbsolute);
- QVERIFY(doc->begin().next() == doc->end());
+ QCOMPARE(doc->begin().next(), doc->end());
}
void tst_QTextDocumentFragment::html_spanNesting()
@@ -1805,7 +1805,7 @@ void tst_QTextDocumentFragment::html_nestedLists()
cursor.movePosition(QTextCursor::NextBlock);
QTextList *thirdList = cursor.currentList();
QVERIFY(thirdList);
- QVERIFY(thirdList == firstList);
+ QCOMPARE(thirdList, firstList);
}
void tst_QTextDocumentFragment::noSpecialCharactersInPlainText()
@@ -1837,7 +1837,7 @@ void tst_QTextDocumentFragment::html_doNotInheritBackground()
for (QTextBlock block = doc->begin();
block.isValid(); block = block.next()) {
- QVERIFY(block.blockFormat().hasProperty(QTextFormat::BackgroundBrush) == false);
+ QVERIFY(!block.blockFormat().hasProperty(QTextFormat::BackgroundBrush));
}
QVERIFY(doc->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush));
@@ -2022,7 +2022,7 @@ void tst_QTextDocumentFragment::html_frameImport()
cursor.insertFragment(frag);
QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames();
- QVERIFY(childFrames.count() == 1);
+ QCOMPARE(childFrames.count(), 1);
QTextFrame *frame = childFrames.first();
QCOMPARE(frame->frameFormat().margin(), ffmt.margin());
QCOMPARE(frame->frameFormat().border(), ffmt.border());
@@ -2050,7 +2050,7 @@ void tst_QTextDocumentFragment::html_frameImport2()
cursor.insertFragment(frag);
QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames();
- QVERIFY(childFrames.count() == 1);
+ QCOMPARE(childFrames.count(), 1);
QTextFrame *frame = childFrames.first();
QCOMPARE(frame->frameFormat().topMargin(), ffmt.topMargin());
QCOMPARE(frame->frameFormat().bottomMargin(), ffmt.bottomMargin());
@@ -2065,7 +2065,7 @@ void tst_QTextDocumentFragment::html_dontAddMarginsAcrossTableCells()
cursor.insertFragment(QTextDocumentFragment::fromHtml(QString::fromLatin1(html)));
QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames();
- QVERIFY(childFrames.count() == 1);
+ QCOMPARE(childFrames.count(), 1);
QTextFrame *frame = childFrames.first();
cursor = frame->firstCursorPosition();
QCOMPARE(cursor.blockFormat().leftMargin(), qreal(50.0));
@@ -2078,7 +2078,7 @@ void tst_QTextDocumentFragment::html_dontMergeCenterBlocks()
QCOMPARE(doc->blockCount(), 2);
QTextBlock blk = doc->begin();
- QVERIFY(blk.blockFormat().alignment() == Qt::AlignCenter);
+ QCOMPARE(blk.blockFormat().alignment(), Qt::AlignCenter);
blk = blk.next();
QVERIFY(blk.blockFormat().alignment() != Qt::AlignCenter);
}
@@ -2112,7 +2112,7 @@ void tst_QTextDocumentFragment::html_tableCellBgColor2()
QTextFrame::Iterator it = cell.begin();
QVERIFY(!it.atEnd());
- QVERIFY(it.currentFrame() == 0);
+ QVERIFY(!it.currentFrame());
QVERIFY(it.currentBlock().isValid());
++it;
@@ -2122,9 +2122,9 @@ void tst_QTextDocumentFragment::html_tableCellBgColor2()
++it;
QVERIFY(!it.atEnd());
- QVERIFY(it.currentFrame() == 0);
+ QVERIFY(!it.currentFrame());
QVERIFY(it.currentBlock().isValid());
- QVERIFY(it.currentBlock().blockFormat().background() == QBrush(Qt::NoBrush));
+ QCOMPARE(it.currentBlock().blockFormat().background(), QBrush(Qt::NoBrush));
++it;
QVERIFY(it.atEnd());
@@ -2245,8 +2245,8 @@ void tst_QTextDocumentFragment::html_blockVsInline()
{
{
setHtml("<html><body><div><b>Foo<div>Bar");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
{
setHtml("<html><body><p><b>Foo<p>Bar");
@@ -2255,23 +2255,23 @@ void tst_QTextDocumentFragment::html_blockVsInline()
}
{
setHtml("<html><body><b><center>Foo</center></b>");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
{
setHtml("<html><body><b><p>Foo");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
{
setHtml("<html><body><b><p>Foo<p>Bar");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
{
setHtml("<div><b>Foo<div>Bar");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
{
setHtml("<p><b>Foo<p>Bar");
@@ -2280,18 +2280,18 @@ void tst_QTextDocumentFragment::html_blockVsInline()
}
{
setHtml("<b><center>Foo</center></b>");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
{
setHtml("<b><p>Foo");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
{
setHtml("<b><p>Foo<p>Bar");
- QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
- QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold));
+ QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold));
}
}
@@ -2338,7 +2338,7 @@ void tst_QTextDocumentFragment::html_nestedTables()
QTextTable *firstNestedTable = cursor.currentTable();
QVERIFY(firstNestedTable);
- QVERIFY(firstNestedTable->parentFrame() == table);
+ QCOMPARE(firstNestedTable->parentFrame(), table);
QCOMPARE(firstNestedTable->rows(), 1);
QCOMPARE(firstNestedTable->columns(), 1);
QCOMPARE(firstNestedTable->cellAt(0, 0).firstCursorPosition().block().text(), QString("Hello"));
@@ -2348,13 +2348,13 @@ void tst_QTextDocumentFragment::html_nestedTables()
;
QVERIFY(!cursor.isNull());
- QVERIFY(cursor.currentTable() == table);
+ QCOMPARE(cursor.currentTable(), table);
cursor.movePosition(QTextCursor::NextBlock);
QTextTable *secondNestedTable = cursor.currentTable();
QVERIFY(secondNestedTable);
- QVERIFY(secondNestedTable->parentFrame() == table);
+ QCOMPARE(secondNestedTable->parentFrame(), table);
QCOMPARE(secondNestedTable->rows(), 1);
QCOMPARE(secondNestedTable->columns(), 1);
QCOMPARE(secondNestedTable->cellAt(0, 0).firstCursorPosition().block().text(), QString("World"));
@@ -2454,7 +2454,7 @@ void tst_QTextDocumentFragment::html_anchorColor()
setHtml("<span style=\"color: red;\"><a href=\"http://www.kde.org/\">Blue</a></span>");
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextCharacter);
- QVERIFY(cursor.charFormat().foreground().color() == QGuiApplication::palette().link().color());
+ QCOMPARE(cursor.charFormat().foreground().color(), QGuiApplication::palette().link().color());
setHtml("<span style=\"color: red;\"><a href=\"http://www.kde.org/\" style=\"color: yellow;\">Green</a></span>");
cursor.movePosition(QTextCursor::Start);
@@ -2525,17 +2525,17 @@ void tst_QTextDocumentFragment::html_columnWidths()
const QVector<QTextLength> columnWidths = fmt.columnWidthConstraints();
QCOMPARE(columnWidths.count(), 2);
- QVERIFY(columnWidths.at(0).type() == QTextLength::VariableLength);
- QVERIFY(columnWidths.at(1).type() == QTextLength::PercentageLength);
- QVERIFY(columnWidths.at(1).rawValue() == 1);
+ QCOMPARE(columnWidths.at(0).type(), QTextLength::VariableLength);
+ QCOMPARE(columnWidths.at(1).type(), QTextLength::PercentageLength);
+ QCOMPARE(columnWidths.at(1).rawValue(), qreal(1));
}
void tst_QTextDocumentFragment::css_fontWeight()
{
setHtml("<p style=\"font-weight:bold\">blah</p>");
- QVERIFY(doc->begin().charFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(doc->begin().charFormat().fontWeight(), int(QFont::Bold));
setHtml("<p style=\"font-weight:600\">blah</p>");
- QVERIFY(doc->begin().charFormat().fontWeight() == QFont::Bold);
+ QCOMPARE(doc->begin().charFormat().fontWeight(), int(QFont::Bold));
}
@@ -2548,7 +2548,7 @@ void tst_QTextDocumentFragment::css_float()
QVERIFY(o);
QTextFormat f = o->format();
QVERIFY(f.isFrameFormat());
- QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::FloatRight);
+ QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::FloatRight);
setHtml("<img src=\"foo\" align=right>");
fmt = doc->begin().begin().fragment().charFormat();
@@ -2557,7 +2557,7 @@ void tst_QTextDocumentFragment::css_float()
QVERIFY(o);
f = o->format();
QVERIFY(f.isFrameFormat());
- QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::FloatRight);
+ QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::FloatRight);
setHtml("<img src=\"foo\" align=left>");
fmt = doc->begin().begin().fragment().charFormat();
@@ -2566,7 +2566,7 @@ void tst_QTextDocumentFragment::css_float()
QVERIFY(o);
f = o->format();
QVERIFY(f.isFrameFormat());
- QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::FloatLeft);
+ QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::FloatLeft);
}
void tst_QTextDocumentFragment::css_textIndent()
@@ -2585,7 +2585,7 @@ void tst_QTextDocumentFragment::css_inline()
"<p>test</p>"
);
QTextBlockFormat fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), QColor("green"));
}
void tst_QTextDocumentFragment::css_external()
@@ -2596,11 +2596,12 @@ void tst_QTextDocumentFragment::css_external()
"<p>test</p>"
);
QTextBlockFormat fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), QColor("green"));
}
void tst_QTextDocumentFragment::css_import()
{
+ const QColor green("green");
doc->addResource(QTextDocument::StyleSheetResource, QUrl("test.css"), QString("@import \"other.css\";"));
doc->addResource(QTextDocument::StyleSheetResource, QUrl("other.css"), QString("@import url(\"other2.css\");"));
doc->addResource(QTextDocument::StyleSheetResource, QUrl("other2.css"), QString("p { background-color: green; }"));
@@ -2609,14 +2610,14 @@ void tst_QTextDocumentFragment::css_import()
"<p>test</p>"
);
QTextBlockFormat fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
doc->setHtml(""
"<style>@import \"test.css\" screen;</style>"
"<p>test</p>"
);
fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
}
void tst_QTextDocumentFragment::css_selectors_data()
@@ -2662,9 +2663,9 @@ void tst_QTextDocumentFragment::css_selectors()
QTextBlockFormat fmt = doc->begin().blockFormat();
if (match)
- QVERIFY(fmt.background().color() == QColor("red"));
+ QCOMPARE(fmt.background().color(), QColor("red"));
else
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), QColor("green"));
}
void tst_QTextDocumentFragment::css_nodeNameCaseInsensitivity()
@@ -2674,7 +2675,7 @@ void tst_QTextDocumentFragment::css_nodeNameCaseInsensitivity()
"</style>"
"<p>test</p>");
QTextBlockFormat fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), QColor("green"));
}
void tst_QTextDocumentFragment::css_textUnderlineStyle_data()
@@ -2710,14 +2711,14 @@ void tst_QTextDocumentFragment::css_textUnderlineStyleAndDecoration()
QTextFragment fragment = doc->begin().begin().fragment();
QVERIFY(fragment.isValid());
- QVERIFY(fragment.charFormat().underlineStyle() == QTextCharFormat::SingleUnderline);
+ QCOMPARE(fragment.charFormat().underlineStyle(), QTextCharFormat::SingleUnderline);
QVERIFY(fragment.charFormat().fontOverline());
doc->setHtml("<span style=\"text-underline-style: solid; text-decoration: overline\">Test</span>");
fragment = doc->begin().begin().fragment();
QVERIFY(fragment.isValid());
- QVERIFY(fragment.charFormat().underlineStyle() == QTextCharFormat::SingleUnderline);
+ QCOMPARE(fragment.charFormat().underlineStyle(), QTextCharFormat::SingleUnderline);
QVERIFY(fragment.charFormat().fontOverline());
}
@@ -2726,48 +2727,48 @@ void tst_QTextDocumentFragment::css_listStyleType()
doc->setHtml("<ol style=\"list-style-type: disc\"><li>Blah</li></ol>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDisc);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDisc);
doc->setHtml("<ul style=\"list-style-type: square\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListSquare);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListSquare);
doc->setHtml("<ul style=\"list-style-type: circle\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListCircle);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListCircle);
doc->setHtml("<ul style=\"list-style-type: decimal\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDecimal);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDecimal);
doc->setHtml("<ul style=\"list-style-type: lower-alpha\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListLowerAlpha);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListLowerAlpha);
doc->setHtml("<ul style=\"list-style-type: upper-alpha\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListUpperAlpha);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListUpperAlpha);
doc->setHtml("<ul style=\"list-style-type: upper-roman\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListUpperRoman);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListUpperRoman);
doc->setHtml("<ul style=\"list-style-type: lower-roman\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListLowerRoman);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListLowerRoman);
// ignore the unsupported list-style-position inside the list-style shorthand property
doc->setHtml("<ul style=\"list-style: outside decimal\"><li>Blah</li></ul>");
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDecimal);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDecimal);
}
void tst_QTextDocumentFragment::css_linkPseudo()
@@ -2785,13 +2786,13 @@ void tst_QTextDocumentFragment::css_linkPseudo()
void tst_QTextDocumentFragment::css_pageBreaks()
{
doc->setHtml("<p>Foo</p>");
- QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == QTextFormat::PageBreak_Auto);
+ QCOMPARE(doc->begin().blockFormat().pageBreakPolicy(), QTextFormat::PageBreak_Auto);
doc->setHtml("<p style=\" page-break-before:always;\">Foo</p>");
- QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == QTextFormat::PageBreak_AlwaysBefore);
+ QCOMPARE(doc->begin().blockFormat().pageBreakPolicy(), QTextFormat::PageBreak_AlwaysBefore);
doc->setHtml("<p style=\" page-break-after:always;\">Foo</p>");
- QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == QTextFormat::PageBreak_AlwaysAfter);
+ QCOMPARE(doc->begin().blockFormat().pageBreakPolicy(), QTextFormat::PageBreak_AlwaysAfter);
doc->setHtml("<p style=\" page-break-before:always; page-break-after:always;\">Foo</p>");
QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == (QTextFormat::PageBreak_AlwaysAfter | QTextFormat::PageBreak_AlwaysBefore));
@@ -2832,13 +2833,14 @@ void tst_QTextDocumentFragment::universalSelectors()
QTextBlockFormat fmt = doc->begin().blockFormat();
if (match)
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), QColor("green"));
else
QVERIFY(!fmt.hasProperty(QTextFormat::BackgroundBrush));
}
void tst_QTextDocumentFragment::screenMedia()
{
+ const QColor green("green");
setHtml("<style>"
"@media screen {"
"p { background-color: green }"
@@ -2847,7 +2849,7 @@ void tst_QTextDocumentFragment::screenMedia()
"<p>test</p>"
"");
QTextBlockFormat fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
setHtml("<style>"
"@media foobar {"
@@ -2857,7 +2859,7 @@ void tst_QTextDocumentFragment::screenMedia()
"<p>test</p>"
"");
fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() != QColor("green"));
+ QVERIFY(fmt.background().color() != green);
setHtml("<style>"
"@media sCrEeN {"
@@ -2867,7 +2869,7 @@ void tst_QTextDocumentFragment::screenMedia()
"<p>test</p>"
"");
fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), green);
}
void tst_QTextDocumentFragment::htmlResourceLoading()
@@ -2881,7 +2883,7 @@ void tst_QTextDocumentFragment::htmlResourceLoading()
doc->clear();
QTextCursor(doc).insertFragment(frag);
QTextBlockFormat fmt = doc->begin().blockFormat();
- QVERIFY(fmt.background().color() == QColor("green"));
+ QCOMPARE(fmt.background().color(), QColor("green"));
}
void tst_QTextDocumentFragment::someCaseInsensitiveAttributeValues()
@@ -2890,7 +2892,7 @@ void tst_QTextDocumentFragment::someCaseInsensitiveAttributeValues()
setHtml(QString::fromLatin1(html1));
cursor.movePosition(QTextCursor::End);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListSquare);
+ QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListSquare);
const char html2[] = "<div align=ceNTeR><b>Hello World";
setHtml(html2);
@@ -2925,7 +2927,7 @@ void tst_QTextDocumentFragment::backgroundImage()
doc.testPixmap.fill(Qt::blue);
doc.setHtml("<p style=\"background-image: url(testPixmap)\">Hello</p>");
QBrush bg = doc.begin().blockFormat().background();
- QVERIFY(bg.style() == Qt::TexturePattern);
+ QCOMPARE(bg.style(), Qt::TexturePattern);
QCOMPARE(bg.texture().cacheKey(), doc.testPixmap.cacheKey());
}
@@ -3109,7 +3111,7 @@ void tst_QTextDocumentFragment::html_tableStrangeNewline()
QCOMPARE(table->columns(), 1);
const QTextTableCell cell = table->cellAt(0, 0);
QCOMPARE(cell.firstCursorPosition().block().text(), QString("Foo"));
- QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block());
+ QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block());
}
void tst_QTextDocumentFragment::html_tableStrangeNewline2()
@@ -3123,7 +3125,7 @@ void tst_QTextDocumentFragment::html_tableStrangeNewline2()
QCOMPARE(table->columns(), 1);
const QTextTableCell cell = table->cellAt(0, 0);
QCOMPARE(cell.firstCursorPosition().block().text(), QString("Foo"));
- QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block());
+ QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block());
}
void tst_QTextDocumentFragment::html_tableStrangeNewline3()
@@ -3152,11 +3154,11 @@ void tst_QTextDocumentFragment::html_tableStrangeNewline3()
QTextTableCell cell = table->cellAt(0, 0);
QCOMPARE(cell.firstCursorPosition().block().text(), QString("Meh"));
- QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block());
+ QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block());
cell = table->cellAt(0, 1);
QCOMPARE(cell.firstCursorPosition().block().text(), QString("Foo"));
- QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block());
+ QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block());
}
void tst_QTextDocumentFragment::html_caption()
@@ -3170,7 +3172,7 @@ void tst_QTextDocumentFragment::html_caption()
cursor.movePosition(QTextCursor::NextBlock);
QCOMPARE(cursor.block().text(), QString("This is a Caption!"));
- QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter);
+ QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter);
cursor.movePosition(QTextCursor::NextBlock);
QTextTable *table = cursor.currentTable();
@@ -3427,7 +3429,7 @@ void tst_QTextDocumentFragment::html_dontInheritAlignmentForFloatingImages()
QVERIFY(o);
QTextFormat f = o->format();
QVERIFY(f.isFrameFormat());
- QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::InFlow);
+ QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::InFlow);
}
void tst_QTextDocumentFragment::html_verticalImageAlignment()
@@ -3437,35 +3439,35 @@ void tst_QTextDocumentFragment::html_verticalImageAlignment()
cursor.movePosition(QTextCursor::NextCharacter);
QVERIFY(cursor.charFormat().isImageFormat());
QTextImageFormat fmt = cursor.charFormat().toImageFormat();
- QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignNormal);
+ QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignNormal);
doc->setHtml("<img src=\"foo\" align=middle />");
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextCharacter);
QVERIFY(cursor.charFormat().isImageFormat());
fmt = cursor.charFormat().toImageFormat();
- QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignMiddle);
+ QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignMiddle);
doc->setHtml("<img src=\"foo\" style=\"vertical-align: middle\" />");
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextCharacter);
QVERIFY(cursor.charFormat().isImageFormat());
fmt = cursor.charFormat().toImageFormat();
- QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignMiddle);
+ QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignMiddle);
doc->setHtml("<img src=\"foo\" align=top />");
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextCharacter);
QVERIFY(cursor.charFormat().isImageFormat());
fmt = cursor.charFormat().toImageFormat();
- QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignTop);
+ QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignTop);
doc->setHtml("<img src=\"foo\" style=\"vertical-align: top\" />");
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextCharacter);
QVERIFY(cursor.charFormat().isImageFormat());
fmt = cursor.charFormat().toImageFormat();
- QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignTop);
+ QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignTop);
}
void tst_QTextDocumentFragment::html_verticalCellAlignment()
@@ -3944,11 +3946,11 @@ void tst_QTextDocumentFragment::html_directionWithHtml()
block = block.next();
QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection));
- QVERIFY(block.blockFormat().layoutDirection() == Qt::RightToLeft);
+ QCOMPARE(block.blockFormat().layoutDirection(), Qt::RightToLeft);
block = block.next();
QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection));
- QVERIFY(block.blockFormat().layoutDirection() == Qt::LeftToRight);
+ QCOMPARE(block.blockFormat().layoutDirection(), Qt::LeftToRight);
}
void tst_QTextDocumentFragment::html_directionWithRichText()
@@ -3961,11 +3963,11 @@ void tst_QTextDocumentFragment::html_directionWithRichText()
block = block.next();
QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection));
- QVERIFY(block.blockFormat().layoutDirection() == Qt::RightToLeft);
+ QCOMPARE(block.blockFormat().layoutDirection(), Qt::RightToLeft);
block = block.next();
QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection));
- QVERIFY(block.blockFormat().layoutDirection() == Qt::LeftToRight);
+ QCOMPARE(block.blockFormat().layoutDirection(), Qt::LeftToRight);
}
void tst_QTextDocumentFragment::html_metaInBody()
diff --git a/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST
new file mode 100644
index 0000000000..b13b2497d3
--- /dev/null
+++ b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST
@@ -0,0 +1,2 @@
+[imageAtRightAlignedTab]
+linux
diff --git a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
index 7c742bc864..5a401031e2 100644
--- a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
+++ b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
@@ -101,7 +101,7 @@ void tst_QTextFormat::defaultAlignment()
QTextBlockFormat fmt;
QVERIFY(!fmt.hasProperty(QTextFormat::BlockAlignment));
QCOMPARE(fmt.intProperty(QTextFormat::BlockAlignment), 0);
- QVERIFY(fmt.alignment() == Qt::AlignLeft);
+ QCOMPARE(fmt.alignment(), Qt::AlignLeft);
}
void tst_QTextFormat::testUnderlinePropertyPrecedence()
@@ -209,7 +209,7 @@ void tst_QTextFormat::resolveFont()
QVector<QTextFormat> formats = doc.allFormats();
QCOMPARE(formats.count(), 3);
- QVERIFY(formats.at(2).type() == QTextFormat::CharFormat);
+ QCOMPARE(formats.at(2).type(), int(QTextFormat::CharFormat));
fmt = formats.at(2).toCharFormat();
QVERIFY(!fmt.font().underline());
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 51f726ac86..de0c2d6dbe 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -1675,6 +1675,7 @@ void tst_QTextLayout::testTabDPIScale()
case QPaintDevice::PdmPhysicalDpiY:
return 72;
case QPaintDevice::PdmDevicePixelRatio:
+ case QPaintDevice::PdmDevicePixelRatioScaled:
; // fall through
}
return 0;
@@ -1744,7 +1745,7 @@ void tst_QTextLayout::capitalization_allUpperCase()
QTextEngine *engine = layout.engine();
engine->itemize();
QCOMPARE(engine->layoutData->items.count(), 1);
- QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase);
+ QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Uppercase));
}
void tst_QTextLayout::capitalization_allUpperCase_newline()
@@ -1764,9 +1765,9 @@ void tst_QTextLayout::capitalization_allUpperCase_newline()
QTextEngine *engine = layout.engine();
engine->itemize();
QCOMPARE(engine->layoutData->items.count(), 3);
- QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase);
- QVERIFY(engine->layoutData->items.at(1).analysis.flags == QScriptAnalysis::LineOrParagraphSeparator);
- QVERIFY(engine->layoutData->items.at(2).analysis.flags == QScriptAnalysis::Uppercase);
+ QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Uppercase));
+ QCOMPARE(engine->layoutData->items.at(1).analysis.flags, ushort(QScriptAnalysis::LineOrParagraphSeparator));
+ QCOMPARE(engine->layoutData->items.at(2).analysis.flags, ushort(QScriptAnalysis::Uppercase));
}
void tst_QTextLayout::capitalization_allLowerCase()
@@ -1782,7 +1783,7 @@ void tst_QTextLayout::capitalization_allLowerCase()
QTextEngine *engine = layout.engine();
engine->itemize();
QCOMPARE(engine->layoutData->items.count(), 1);
- QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Lowercase);
+ QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Lowercase));
}
void tst_QTextLayout::capitalization_smallCaps()
@@ -1798,8 +1799,8 @@ void tst_QTextLayout::capitalization_smallCaps()
QTextEngine *engine = layout.engine();
engine->itemize();
QCOMPARE(engine->layoutData->items.count(), 2);
- QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::None);
- QVERIFY(engine->layoutData->items.at(1).analysis.flags == QScriptAnalysis::SmallCaps);
+ QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::None));
+ QCOMPARE(engine->layoutData->items.at(1).analysis.flags, ushort(QScriptAnalysis::SmallCaps));
}
void tst_QTextLayout::capitalization_capitalize()
@@ -1815,11 +1816,11 @@ void tst_QTextLayout::capitalization_capitalize()
QTextEngine *engine = layout.engine();
engine->itemize();
QCOMPARE(engine->layoutData->items.count(), 5);
- QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase);
- QVERIFY(engine->layoutData->items.at(1).analysis.flags == QScriptAnalysis::None);
- QVERIFY(engine->layoutData->items.at(2).analysis.flags == QScriptAnalysis::Tab);
- QVERIFY(engine->layoutData->items.at(3).analysis.flags == QScriptAnalysis::Uppercase);
- QVERIFY(engine->layoutData->items.at(4).analysis.flags == QScriptAnalysis::None);
+ QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Uppercase));
+ QCOMPARE(engine->layoutData->items.at(1).analysis.flags, ushort(QScriptAnalysis::None));
+ QCOMPARE(engine->layoutData->items.at(2).analysis.flags, ushort(QScriptAnalysis::Tab));
+ QCOMPARE(engine->layoutData->items.at(3).analysis.flags, ushort(QScriptAnalysis::Uppercase));
+ QCOMPARE(engine->layoutData->items.at(4).analysis.flags, ushort(QScriptAnalysis::None));
}
void tst_QTextLayout::longText()
@@ -1984,7 +1985,12 @@ void tst_QTextLayout::textWidthVsWIdth()
"./libs -I/home/ettrich/dev/creator/tools -I../../plugins -I../../shared/scriptwrapper -I../../libs/3rdparty/botan/build -Idialogs -Iactionmanager -Ieditorma"
"nager -Iprogressmanager -Iscriptmanager -I.moc/debug-shared -I.uic -o .obj/debug-shared/sidebar.o sidebar.cpp"));
- // textWidth includes right bearing, but it should never be LARGER than width if there is space for at least one character
+ // The naturalTextWidth includes right bearing, but should never be LARGER than line width if
+ // there is space for at least one character. Unfortunately that assumption may not hold if the
+ // font engine fails to report an accurate minimum right bearing for the font, eg. when the
+ // minimum right bearing reported by the font engine doesn't cover all the glyphs in the font.
+ // The result is that this test may fail in some cases. We should fix this by running the test
+ // with a font that we know have no suprising right bearings. See qtextlayout.cpp for details.
for (int width = 100; width < 1000; ++width) {
layout.beginLayout();
QTextLine line = layout.createLine();
@@ -2096,8 +2102,8 @@ void tst_QTextLayout::cursorInNonStopChars()
QTextLine line = layout.createLine();
layout.endLayout();
- QVERIFY(line.cursorToX(1) == line.cursorToX(3));
- QVERIFY(line.cursorToX(2) == line.cursorToX(3));
+ QCOMPARE(line.cursorToX(1), line.cursorToX(3));
+ QCOMPARE(line.cursorToX(2), line.cursorToX(3));
}
void tst_QTextLayout::justifyTrailingSpaces()
diff --git a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
index c57123af61..03e557d8dd 100644
--- a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
@@ -113,11 +113,11 @@ void tst_QTextList::autoNumbering()
for (int i = 0; i < 27; ++i)
cursor.insertBlock();
- QVERIFY(list->count() == 28);
+ QCOMPARE(list->count(), 28);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 27);
- QVERIFY(cursor.currentList()->itemText(cursor.block()) == "ab.");
+ QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 27);
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("ab."));
}
void tst_QTextList::autoNumberingPrefixAndSuffix()
@@ -132,11 +132,11 @@ void tst_QTextList::autoNumberingPrefixAndSuffix()
for (int i = 0; i < 27; ++i)
cursor.insertBlock();
- QVERIFY(list->count() == 28);
+ QCOMPARE(list->count(), 28);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 27);
- QVERIFY(cursor.currentList()->itemText(cursor.block()) == "-ab)");
+ QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 27);
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("-ab)"));
}
void tst_QTextList::autoNumberingPrefixAndSuffixRTL()
@@ -154,9 +154,9 @@ void tst_QTextList::autoNumberingPrefixAndSuffixRTL()
cursor.insertBlock();
- QVERIFY(list->count() == 2);
+ QCOMPARE(list->count(), 2);
- QVERIFY(cursor.currentList()->itemText(cursor.block()) == "*B-");
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("*B-"));
}
void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport()
@@ -174,7 +174,7 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport()
for (int i = 0; i < 27; ++i)
cursor.insertBlock();
- QVERIFY(list->count() == 28);
+ QCOMPARE(list->count(), 28);
QString htmlExport = doc->toHtml();
QTextDocument importDoc;
@@ -185,9 +185,9 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport()
importCursor.movePosition(QTextCursor::NextBlock);
QVERIFY(importCursor.currentList());
- QVERIFY(importCursor.currentList()->itemNumber(importCursor.block()) == 27);
- QVERIFY(importCursor.currentList()->itemText(importCursor.block()) == "\"ab#");
- QVERIFY(importCursor.currentList()->format().indent() == 10);
+ QCOMPARE(importCursor.currentList()->itemNumber(importCursor.block()), 27);
+ QCOMPARE(importCursor.currentList()->itemText(importCursor.block()), QLatin1String("\"ab#"));
+ QCOMPARE(importCursor.currentList()->format().indent(), 10);
}
void tst_QTextList::autoNumberingRTL()
@@ -203,9 +203,9 @@ void tst_QTextList::autoNumberingRTL()
cursor.insertBlock();
- QVERIFY(list->count() == 2);
+ QCOMPARE(list->count(), 2);
- QVERIFY(cursor.currentList()->itemText(cursor.block()) == ".B");
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String(".B"));
}
void tst_QTextList::romanNumbering()
@@ -218,11 +218,11 @@ void tst_QTextList::romanNumbering()
for (int i = 0; i < 4998; ++i)
cursor.insertBlock();
- QVERIFY(list->count() == 4999);
+ QCOMPARE(list->count(), 4999);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 4998);
- QVERIFY(cursor.currentList()->itemText(cursor.block()) == "MMMMCMXCIX.");
+ QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 4998);
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("MMMMCMXCIX."));
}
void tst_QTextList::romanNumberingLimit()
@@ -235,11 +235,11 @@ void tst_QTextList::romanNumberingLimit()
for (int i = 0; i < 4999; ++i)
cursor.insertBlock();
- QVERIFY(list->count() == 5000);
+ QCOMPARE(list->count(), 5000);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 4999);
- QVERIFY(cursor.currentList()->itemText(cursor.block()) == "?.");
+ QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 4999);
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("?."));
}
void tst_QTextList::formatChange()
@@ -257,12 +257,12 @@ void tst_QTextList::formatChange()
QVERIFY(list && list->count() == 2);
QTextBlockFormat bfmt = cursor.blockFormat();
-// QVERIFY(bfmt.object() == list);
+// QCOMPARE(bfmt.object(), list);
bfmt.setObjectIndex(-1);
cursor.setBlockFormat(bfmt);
- QVERIFY(firstList->count() == 1);
+ QCOMPARE(firstList->count(), 1);
}
void tst_QTextList::cursorNavigation()
@@ -282,7 +282,7 @@ void tst_QTextList::cursorNavigation()
QVERIFY(cursor.currentList());
cursor.movePosition(QTextCursor::PreviousBlock);
QVERIFY(cursor.currentList());
- QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 0);
+ QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 0);
}
void tst_QTextList::partialRemoval()
diff --git a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
index ae8948a61f..cd43849729 100644
--- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
+++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
@@ -157,7 +157,7 @@ void tst_QTextPieceTable::insertion3()
table->insert(pos, str, charFormatIndex);
compare.insert(pos, str);
}
- QVERIFY(table->plainText() == compare);
+ QCOMPARE(table->plainText(), compare);
}
void tst_QTextPieceTable::insertion4()
@@ -176,7 +176,7 @@ void tst_QTextPieceTable::insertion4()
// exit(12);
// }
}
- QVERIFY(table->plainText() == compare);
+ QCOMPARE(table->plainText(), compare);
}
void tst_QTextPieceTable::insertion5()
@@ -196,10 +196,10 @@ void tst_QTextPieceTable::insertion5()
}
compare.insert(pos, str);
}
- QVERIFY(table->plainText() == compare);
+ QCOMPARE(table->plainText(), compare);
for (QTextBlock it = table->blocksBegin(); it != table->blocksEnd(); it = it.next()) {
QTextDocumentPrivate::FragmentIterator fit = table->find(it.position());
- QVERIFY(fit.position() == it.position());
+ QCOMPARE(fit.position(), it.position());
}
}
@@ -260,7 +260,7 @@ void tst_QTextPieceTable::removal3()
// exit(12);
// }
}
- QVERIFY(table->plainText() == compare);
+ QCOMPARE(table->plainText(), compare);
}
void tst_QTextPieceTable::removal4()
@@ -294,7 +294,7 @@ void tst_QTextPieceTable::removal4()
// exit(12);
// }
}
- QVERIFY(table->plainText() == compare);
+ QCOMPARE(table->plainText(), compare);
}
void tst_QTextPieceTable::undoRedo1()
@@ -392,7 +392,7 @@ void tst_QTextPieceTable::undoRedo6()
QTextBlockFormat bfmt;
bfmt.setAlignment(Qt::AlignHCenter);
cursor.setBlockFormat(bfmt);
- QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter);
+ QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter);
QTextCursor range = cursor;
range.clearSelection();
@@ -404,11 +404,11 @@ void tst_QTextPieceTable::undoRedo6()
range.mergeCharFormat(modifier);
cursor.movePosition(QTextCursor::Start);
- QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter);
+ QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter);
doc.undo();
- QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter);
+ QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter);
}
void tst_QTextPieceTable::undoRedo7()
@@ -497,13 +497,13 @@ void tst_QTextPieceTable::undoRedo11()
}
l += remove ? -1 : 2;
}
- QVERIFY(table->plainText() == compare);
+ QCOMPARE(table->plainText(), compare);
for (int i = 0; i < loops; ++i)
table->undo();
- QVERIFY(table->plainText() == QString(""));
+ QCOMPARE(table->plainText(), QString(""));
for (int i = 0; i < loops; ++i)
table->redo();
- QVERIFY(table->plainText() == compare);
+ QCOMPARE(table->plainText(), compare);
}
@@ -693,9 +693,9 @@ void tst_QTextPieceTable::setBlockFormat()
QTextBlock b = table->blocksFind(1);
table->setBlockFormat(b, b, newbfmt);
- QVERIFY(table->blocksFind(0).blockFormat() == bfmt);
- QVERIFY(table->blocksFind(1).blockFormat() == newbfmt);
- QVERIFY(table->blocksFind(2).blockFormat() == bfmt);
+ QCOMPARE(table->blocksFind(0).blockFormat(), bfmt);
+ QCOMPARE(table->blocksFind(1).blockFormat(), newbfmt);
+ QCOMPARE(table->blocksFind(2).blockFormat(), bfmt);
}
@@ -705,19 +705,19 @@ void tst_QTextPieceTable::blockInsertion()
fmt.setTopMargin(100);
int idx = table->formatCollection()->indexForFormat(fmt);
int charFormat = table->formatCollection()->indexForFormat(QTextCharFormat());
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
table->insertBlock(0, idx, charFormat);
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(1).blockFormat() == fmt);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).blockFormat(), fmt);
table->undo();
- QVERIFY(table->blockMap().length() == 1);
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
+ QCOMPARE(table->blockMap().length(), 1);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
table->redo();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(1).blockFormat() == fmt);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).blockFormat(), fmt);
}
void tst_QTextPieceTable::blockInsertion2()
@@ -755,37 +755,37 @@ void tst_QTextPieceTable::blockRemoval1()
table->insertBlock(9, idx2, charFormatIndex);
table->insert(10, "0123", charFormatIndex);
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->beginEditBlock();
table->remove(5, 5);
table->endEditBlock();
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(4).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 5);
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(4).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 5);
table->undo();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->redo();
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(4).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 5);
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(4).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 5);
}
void tst_QTextPieceTable::blockRemoval2()
@@ -803,35 +803,35 @@ void tst_QTextPieceTable::blockRemoval2()
table->insertBlock(9, idx2, charFormatIndex);
table->insert(10, "0123", charFormatIndex);
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->remove(4, 1);
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(6).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 0);
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(6).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 0);
table->undo();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->redo();
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(6).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 0);
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(6).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 0);
}
void tst_QTextPieceTable::blockRemoval3()
@@ -849,38 +849,38 @@ void tst_QTextPieceTable::blockRemoval3()
table->insertBlock(9, idx2, charFormatIndex);
table->insert(10, "0123", charFormatIndex);
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->beginEditBlock();
table->remove(3, 4);
table->endEditBlock();
- QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 0);
+ QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 0);
table->undo();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->redo();
- QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 0);
+ QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 0);
}
void tst_QTextPieceTable::blockRemoval4()
@@ -899,35 +899,35 @@ void tst_QTextPieceTable::blockRemoval4()
table->insertBlock(9, idx2, charFormatIndex);
table->insert(10, "0123", charFormatIndex);
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->remove(3, 7);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 0);
- QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 0);
+ QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat());
table->undo();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->redo();
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 0);
- QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 0);
+ QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat());
#endif
}
@@ -946,38 +946,38 @@ void tst_QTextPieceTable::blockRemoval5()
table->insertBlock(9, idx2, charFormatIndex);
table->insert(10, "0123", charFormatIndex);
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->beginEditBlock();
table->remove(3, 8);
table->endEditBlock();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 0);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 0);
table->undo();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == fmt1);
- QVERIFY(table->blocksFind(10).blockFormat() == fmt2);
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(6).position() == 5);
- QVERIFY(table->blocksFind(11).position() == 10);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), fmt1);
+ QCOMPARE(table->blocksFind(10).blockFormat(), fmt2);
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(6).position(), 5);
+ QCOMPARE(table->blocksFind(11).position(), 10);
table->redo();
- QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
- QVERIFY(table->blocksFind(1).position() == 0);
- QVERIFY(table->blocksFind(5).position() == 0);
+ QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat());
+ QCOMPARE(table->blocksFind(1).position(), 0);
+ QCOMPARE(table->blocksFind(5).position(), 0);
}
@@ -996,66 +996,66 @@ void tst_QTextPieceTable::checkFrames1()
QPointer<QTextFrame> frame = table->insertFrame(1, 3, ffmt);
QTextFrame *root = table->rootFrame();
- QVERIFY(root == frame->parentFrame());
+ QCOMPARE(root, frame->parentFrame());
QVERIFY(root);
- QVERIFY(root->parentFrame() == 0);
+ QVERIFY(!root->parentFrame());
- QVERIFY(root->childFrames().count() == 1);
+ QCOMPARE(root->childFrames().count(), 1);
QVERIFY(frame->format() == ffmt);
- QVERIFY(frame->firstPosition() == 2);
- QVERIFY(frame->lastPosition() == 4);
+ QCOMPARE(frame->firstPosition(), 2);
+ QCOMPARE(frame->lastPosition(), 4);
QPointer<QTextFrame> frame2 = table->insertFrame(2, 3, ffmt);
- QVERIFY(root->childFrames().count() == 1);
- QVERIFY(root->childFrames().at(0) == frame);
- QVERIFY(frame->childFrames().count() == 1);
- QVERIFY(frame2->childFrames().count() == 0);
- QVERIFY(frame2->parentFrame() == frame);
- QVERIFY(frame2->firstPosition() == 3);
- QVERIFY(frame2->lastPosition() == 4);
+ QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().at(0), frame.data());
+ QCOMPARE(frame->childFrames().count(), 1);
+ QCOMPARE(frame2->childFrames().count(), 0);
+ QCOMPARE(frame2->parentFrame(), frame.data());
+ QCOMPARE(frame2->firstPosition(), 3);
+ QCOMPARE(frame2->lastPosition(), 4);
QVERIFY(frame->format() == ffmt);
- QVERIFY(frame->firstPosition() == 2);
- QVERIFY(frame->lastPosition() == 6);
+ QCOMPARE(frame->firstPosition(), 2);
+ QCOMPARE(frame->lastPosition(), 6);
table->removeFrame(frame);
- QVERIFY(root->childFrames().count() == 1);
- QVERIFY(root->childFrames().at(0) == frame2);
+ QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().at(0), frame2.data());
QVERIFY(!frame);
- QVERIFY(frame2->childFrames().count() == 0);
- QVERIFY(frame2->parentFrame() == root);
- QVERIFY(frame2->firstPosition() == 2);
- QVERIFY(frame2->lastPosition() == 3);
+ QCOMPARE(frame2->childFrames().count(), 0);
+ QCOMPARE(frame2->parentFrame(), root);
+ QCOMPARE(frame2->firstPosition(), 2);
+ QCOMPARE(frame2->lastPosition(), 3);
table->undo();
frame = table->frameAt(2);
- QVERIFY(root->childFrames().count() == 1);
- QVERIFY(root->childFrames().at(0) == frame);
- QVERIFY(frame->childFrames().count() == 1);
- QVERIFY(frame->childFrames().at(0) == frame2);
- QVERIFY(frame2->childFrames().count() == 0);
- QVERIFY(frame2->parentFrame() == frame);
- QVERIFY(frame2->firstPosition() == 3);
- QVERIFY(frame2->lastPosition() == 4);
+ QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().at(0), frame.data());
+ QCOMPARE(frame->childFrames().count(), 1);
+ QCOMPARE(frame->childFrames().at(0), frame2.data());
+ QCOMPARE(frame2->childFrames().count(), 0);
+ QCOMPARE(frame2->parentFrame(), frame.data());
+ QCOMPARE(frame2->firstPosition(), 3);
+ QCOMPARE(frame2->lastPosition(), 4);
- QVERIFY(frame->firstPosition() == 2);
- QVERIFY(frame->lastPosition() == 6);
+ QCOMPARE(frame->firstPosition(), 2);
+ QCOMPARE(frame->lastPosition(), 6);
table->undo();
- QVERIFY(root->childFrames().count() == 1);
- QVERIFY(root->childFrames().at(0) == frame);
- QVERIFY(frame->childFrames().count() == 0);
+ QCOMPARE(root->childFrames().count(), 1);
+ QCOMPARE(root->childFrames().at(0), frame.data());
+ QCOMPARE(frame->childFrames().count(), 0);
QVERIFY(!frame2);
- QVERIFY(frame->firstPosition() == 2);
- QVERIFY(frame->lastPosition() == 4);
+ QCOMPARE(frame->firstPosition(), 2);
+ QCOMPARE(frame->lastPosition(), 4);
}
void tst_QTextPieceTable::removeFrameDirect()
@@ -1065,7 +1065,7 @@ void tst_QTextPieceTable::removeFrameDirect()
QTextFrame *frame = table->insertFrame(1, 5, ffmt);
- QVERIFY(frame->parentFrame() == table->rootFrame());
+ QCOMPARE(frame->parentFrame(), table->rootFrame());
const int start = frame->firstPosition() - 1;
const int end = frame->lastPosition();
diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
index c8d3122e6d..1c099acc56 100644
--- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
@@ -146,87 +146,87 @@ void tst_QTextTable::variousTableModifications()
QTextTableFormat tableFmt;
QTextTable *tab = cursor.insertTable(2, 2, tableFmt);
- QVERIFY(doc->toPlainText().length() == 5);
- QVERIFY(tab == cursor.currentTable());
- QVERIFY(tab->columns() == 2);
- QVERIFY(tab->rows() == 2);
+ QCOMPARE(doc->toPlainText().length(), 5);
+ QCOMPARE(tab, cursor.currentTable());
+ QCOMPARE(tab->columns(), 2);
+ QCOMPARE(tab->rows(), 2);
- QVERIFY(cursor.position() == 1);
+ QCOMPARE(cursor.position(), 1);
QTextCharFormat fmt = cursor.charFormat();
- QVERIFY(fmt.objectIndex() == -1);
+ QCOMPARE(fmt.objectIndex(), -1);
QTextTableCell cell = tab->cellAt(cursor);
QVERIFY(cell.isValid());
- QVERIFY(cell.row() == 0);
- QVERIFY(cell.column() == 0);
+ QCOMPARE(cell.row(), 0);
+ QCOMPARE(cell.column(), 0);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 2);
+ QCOMPARE(cursor.position(), 2);
fmt = cursor.charFormat();
- QVERIFY(fmt.objectIndex() == -1);
+ QCOMPARE(fmt.objectIndex(), -1);
cell = tab->cellAt(cursor);
QVERIFY(cell.isValid());
- QVERIFY(cell.row() == 0);
- QVERIFY(cell.column() == 1);
+ QCOMPARE(cell.row(), 0);
+ QCOMPARE(cell.column(), 1);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 3);
+ QCOMPARE(cursor.position(), 3);
fmt = cursor.charFormat();
- QVERIFY(fmt.objectIndex() == -1);
+ QCOMPARE(fmt.objectIndex(), -1);
cell = tab->cellAt(cursor);
QVERIFY(cell.isValid());
- QVERIFY(cell.row() == 1);
- QVERIFY(cell.column() == 0);
+ QCOMPARE(cell.row(), 1);
+ QCOMPARE(cell.column(), 0);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 4);
+ QCOMPARE(cursor.position(), 4);
fmt = cursor.charFormat();
- QVERIFY(fmt.objectIndex() == -1);
+ QCOMPARE(fmt.objectIndex(), -1);
cell = tab->cellAt(cursor);
QVERIFY(cell.isValid());
- QVERIFY(cell.row() == 1);
- QVERIFY(cell.column() == 1);
+ QCOMPARE(cell.row(), 1);
+ QCOMPARE(cell.column(), 1);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 5);
+ QCOMPARE(cursor.position(), 5);
fmt = cursor.charFormat();
- QVERIFY(fmt.objectIndex() == -1);
+ QCOMPARE(fmt.objectIndex(), -1);
cell = tab->cellAt(cursor);
QVERIFY(!cell.isValid());
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 5);
+ QCOMPARE(cursor.position(), 5);
// check we can't delete the cells with the cursor
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 1);
+ QCOMPARE(cursor.position(), 1);
cursor.deleteChar();
- QVERIFY(doc->toPlainText().length() == 5);
+ QCOMPARE(doc->toPlainText().length(), 5);
cursor.movePosition(QTextCursor::NextBlock);
- QVERIFY(cursor.position() == 2);
+ QCOMPARE(cursor.position(), 2);
cursor.deleteChar();
- QVERIFY(doc->toPlainText().length() == 5);
+ QCOMPARE(doc->toPlainText().length(), 5);
cursor.deletePreviousChar();
- QVERIFY(cursor.position() == 2);
- QVERIFY(doc->toPlainText().length() == 5);
+ QCOMPARE(cursor.position(), 2);
+ QCOMPARE(doc->toPlainText().length(), 5);
QTextTable *table = cursor.currentTable();
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 2);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 2);
table->insertRows(2, 1);
- QVERIFY(table->rows() == 3);
- QVERIFY(table->columns() == 2);
- QVERIFY(doc->toPlainText().length() == 7);
+ QCOMPARE(table->rows(), 3);
+ QCOMPARE(table->columns(), 2);
+ QCOMPARE(doc->toPlainText().length(), 7);
table->insertColumns(2, 2);
- QVERIFY(table->rows() == 3);
- QVERIFY(table->columns() == 4);
- QVERIFY(doc->toPlainText().length() == 13);
+ QCOMPARE(table->rows(), 3);
+ QCOMPARE(table->columns(), 4);
+ QCOMPARE(doc->toPlainText().length(), 13);
table->resize(4, 5);
- QVERIFY(table->rows() == 4);
- QVERIFY(table->columns() == 5);
- QVERIFY(doc->toPlainText().length() == 21);
+ QCOMPARE(table->rows(), 4);
+ QCOMPARE(table->columns(), 5);
+ QCOMPARE(doc->toPlainText().length(), 21);
}
void tst_QTextTable::tableShrinking()
@@ -234,25 +234,25 @@ void tst_QTextTable::tableShrinking()
QTextTableFormat tableFmt;
cursor.insertTable(3, 4, tableFmt);
- QVERIFY(doc->toPlainText().length() == 13);
+ QCOMPARE(doc->toPlainText().length(), 13);
QTextTable *table = cursor.currentTable();
- QVERIFY(table->rows() == 3);
- QVERIFY(table->columns() == 4);
+ QCOMPARE(table->rows(), 3);
+ QCOMPARE(table->columns(), 4);
table->removeRows(1, 1);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 4);
- QVERIFY(doc->toPlainText().length() == 9);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 4);
+ QCOMPARE(doc->toPlainText().length(), 9);
table->removeColumns(1, 2);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 2);
- QVERIFY(doc->toPlainText().length() == 5);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 2);
+ QCOMPARE(doc->toPlainText().length(), 5);
table->resize(1, 1);
- QVERIFY(table->rows() == 1);
- QVERIFY(table->columns() == 1);
- QVERIFY(doc->toPlainText().length() == 2);
+ QCOMPARE(table->rows(), 1);
+ QCOMPARE(table->columns(), 1);
+ QCOMPARE(doc->toPlainText().length(), 2);
}
void tst_QTextTable::spans()
@@ -264,12 +264,12 @@ void tst_QTextTable::spans()
QTextTable *table = cursor.currentTable();
QVERIFY(table->cellAt(0, 0) != table->cellAt(0, 1));
table->mergeCells(0, 0, 1, 2);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 2);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 2);
QVERIFY(table->cellAt(0, 0) == table->cellAt(0, 1));
table->mergeCells(0, 0, 2, 2);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 2);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 2);
}
void tst_QTextTable::variousModifications2()
@@ -277,45 +277,45 @@ void tst_QTextTable::variousModifications2()
QTextTableFormat tableFmt;
cursor.insertTable(2, 5, tableFmt);
- QVERIFY(doc->toPlainText().length() == 11);
+ QCOMPARE(doc->toPlainText().length(), 11);
QTextTable *table = cursor.currentTable();
- QVERIFY(cursor.position() == 1);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 5);
+ QCOMPARE(cursor.position(), 1);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 5);
table->insertColumns(0, 1);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 6);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 6);
table->insertColumns(6, 1);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 7);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 7);
table->insertRows(0, 1);
- QVERIFY(table->rows() == 3);
- QVERIFY(table->columns() == 7);
+ QCOMPARE(table->rows(), 3);
+ QCOMPARE(table->columns(), 7);
table->insertRows(3, 1);
- QVERIFY(table->rows() == 4);
- QVERIFY(table->columns() == 7);
+ QCOMPARE(table->rows(), 4);
+ QCOMPARE(table->columns(), 7);
table->removeRows(0, 1);
- QVERIFY(table->rows() == 3);
- QVERIFY(table->columns() == 7);
+ QCOMPARE(table->rows(), 3);
+ QCOMPARE(table->columns(), 7);
table->removeRows(2, 1);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 7);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 7);
table->removeColumns(0, 1);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 6);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 6);
table->removeColumns(5, 1);
- QVERIFY(table->rows() == 2);
- QVERIFY(table->columns() == 5);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 5);
tableFmt = table->format();
table->insertColumns(2, 1);
table->setFormat(tableFmt);
table->insertColumns(2, 1);
- QVERIFY(table->columns() == 7);
+ QCOMPARE(table->columns(), 7);
}
void tst_QTextTable::tableManager_undo()
@@ -325,16 +325,16 @@ void tst_QTextTable::tableManager_undo()
QTextTable *table = cursor.insertTable(2, 2, fmt);
QVERIFY(table);
- QVERIFY(table->format().border() == 10);
+ QCOMPARE(table->format().border(), qreal(10));
fmt.setBorder(20);
table->setFormat(fmt);
- QVERIFY(table->format().border() == 20);
+ QCOMPARE(table->format().border(), qreal(20));
doc->undo();
- QVERIFY(table->format().border() == 10);
+ QCOMPARE(table->format().border(), qreal(10));
}
void tst_QTextTable::tableManager_removeCell()
@@ -360,10 +360,10 @@ void tst_QTextTable::rowAt()
QTextCursor cell20Cursor = table->cellAt(2, 0).firstCursorPosition();
QTextCursor cell21Cursor = table->cellAt(2, 1).firstCursorPosition();
QTextCursor cell30Cursor = table->cellAt(3, 0).firstCursorPosition();
- QVERIFY(table->cellAt(cell00Cursor).firstCursorPosition() == cell00Cursor);
- QVERIFY(table->cellAt(cell10Cursor).firstCursorPosition() == cell10Cursor);
- QVERIFY(table->cellAt(cell20Cursor).firstCursorPosition() == cell20Cursor);
- QVERIFY(table->cellAt(cell30Cursor).firstCursorPosition() == cell30Cursor);
+ QCOMPARE(table->cellAt(cell00Cursor).firstCursorPosition(), cell00Cursor);
+ QCOMPARE(table->cellAt(cell10Cursor).firstCursorPosition(), cell10Cursor);
+ QCOMPARE(table->cellAt(cell20Cursor).firstCursorPosition(), cell20Cursor);
+ QCOMPARE(table->cellAt(cell30Cursor).firstCursorPosition(), cell30Cursor);
table->mergeCells(1, 0, 2, 1);
@@ -433,16 +433,16 @@ void tst_QTextTable::insertRows()
QVERIFY(cursor == table->cellAt(0, 0).firstCursorPosition());
table->insertRows(0, 1);
- QVERIFY(table->rows() == 3);
+ QCOMPARE(table->rows(), 3);
table->insertRows(1, 1);
- QVERIFY(table->rows() == 4);
+ QCOMPARE(table->rows(), 4);
table->insertRows(-1, 1);
- QVERIFY(table->rows() == 5);
+ QCOMPARE(table->rows(), 5);
table->insertRows(5, 2);
- QVERIFY(table->rows() == 7);
+ QCOMPARE(table->rows(), 7);
}
@@ -552,9 +552,9 @@ void tst_QTextTable::mergeCells()
QTextBlock block = table->cellAt(0, 0).firstCursorPosition().block();
- QVERIFY(block.text() == "Blah Foo");
- QVERIFY(block.next().text() == "Hah");
- QVERIFY(block.next().next().text() == "Bar");
+ QCOMPARE(block.text(), QLatin1String("Blah Foo"));
+ QCOMPARE(block.next().text(), QLatin1String("Hah"));
+ QCOMPARE(block.next().next().text(), QLatin1String("Bar"));
table = create4x4Table();
@@ -580,7 +580,7 @@ void tst_QTextTable::mergeCells()
if (table) {
cursor = table->cellAt(0, 0).firstCursorPosition();
- QVERIFY(cursor.block().text() == "Test");
+ QCOMPARE(cursor.block().text(), QLatin1String("Test"));
}
table = create2x2Table();
@@ -750,7 +750,7 @@ void tst_QTextTable::setCellFormat()
fmt.setTableCellColumnSpan(25);
fmt.setTableCellRowSpan(42);
cell.setFormat(fmt);
- QVERIFY(cell.format().background().color() == QColor(Qt::blue));
+ QCOMPARE(cell.format().background().color(), QColor(Qt::blue));
QCOMPARE(cell.format().tableCellColumnSpan(), 1);
QCOMPARE(cell.format().tableCellRowSpan(), 1);
}
@@ -1086,6 +1086,8 @@ public:
{
if (PdmDevicePixelRatio == metric)
return 1;
+ if (PdmDevicePixelRatioScaled == metric)
+ return 1 * QPaintDevice::devicePixelRatioFScale();
if (PdmDpiY == metric)
return 96;
if (PdmDpiX == metric)
diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/gui/text/qzip/tst_qzip.cpp
index 90e93881b9..8381c93bc2 100644
--- a/tests/auto/gui/text/qzip/tst_qzip.cpp
+++ b/tests/auto/gui/text/qzip/tst_qzip.cpp
@@ -39,9 +39,6 @@
class tst_QZip : public QObject
{
Q_OBJECT
-public slots:
- void init();
- void cleanup();
private slots:
void basicUnpack();
@@ -50,18 +47,10 @@ private slots:
void createArchive();
};
-void tst_QZip::init()
-{
-}
-
-void tst_QZip::cleanup()
-{
-}
-
void tst_QZip::basicUnpack()
{
QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly);
- QList<QZipReader::FileInfo> files = zip.fileInfoList();
+ QVector<QZipReader::FileInfo> files = zip.fileInfoList();
QCOMPARE(files.count(), 2);
QZipReader::FileInfo fi = files.at(0);
@@ -97,7 +86,7 @@ void tst_QZip::basicUnpack()
void tst_QZip::symlinks()
{
QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly);
- QList<QZipReader::FileInfo> files = zip.fileInfoList();
+ QVector<QZipReader::FileInfo> files = zip.fileInfoList();
QCOMPARE(files.count(), 2);
QZipReader::FileInfo fi = files.at(0);
@@ -120,7 +109,7 @@ void tst_QZip::symlinks()
void tst_QZip::readTest()
{
QZipReader zip("foobar.zip", QIODevice::ReadOnly); // non existing file.
- QList<QZipReader::FileInfo> files = zip.fileInfoList();
+ QVector<QZipReader::FileInfo> files = zip.fileInfoList();
QCOMPARE(files.count(), 0);
QByteArray b = zip.fileData("foobar");
QCOMPARE(b.size(), 0);
@@ -139,7 +128,7 @@ void tst_QZip::createArchive()
QBuffer buffer2(&zipFile);
QZipReader zip2(&buffer2);
- QList<QZipReader::FileInfo> files = zip2.fileInfoList();
+ QVector<QZipReader::FileInfo> files = zip2.fileInfoList();
QCOMPARE(files.count(), 1);
QZipReader::FileInfo file = files.at(0);
QCOMPARE(file.filePath, QString("My Filename"));
diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
index c8964eb02c..db4b15530c 100644
--- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
+++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
@@ -35,6 +35,7 @@
#include <QtTest/QtTest>
#include <qdebug.h>
#include <qdesktopservices.h>
+#include <qregularexpression.h>
class tst_qdesktopservices : public QObject
{
@@ -74,7 +75,9 @@ void tst_qdesktopservices::openUrl()
QCOMPARE(QDesktopServices::openUrl(QUrl()), false);
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// this test is only valid on windows on other systems it might mean open a new document in the application handling .file
- QTest::ignoreMessage(QtWarningMsg, "ShellExecute 'file://invalid.file' failed (error 3).");
+ const QRegularExpression messagePattern("ShellExecute 'file://invalid\\.file' failed \\(error \\d+\\)\\.");
+ QVERIFY(messagePattern.isValid());
+ QTest::ignoreMessage(QtWarningMsg, messagePattern);
QCOMPARE(QDesktopServices::openUrl(QUrl("file://invalid.file")), false);
#endif
}
diff --git a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
index c2833d9e67..78ab769137 100644
--- a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
+++ b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
@@ -256,41 +256,41 @@ void tst_QDoubleValidator::notifySignals()
dv.setTop(0.8);
QCOMPARE(topSpy.count(), 1);
QCOMPARE(changedSpy.count(), 1);
- QVERIFY(dv.top() == 0.8);
+ QCOMPARE(dv.top(), 0.8);
dv.setBottom(0.2);
QCOMPARE(bottomSpy.count(), 1);
QCOMPARE(changedSpy.count(), 2);
- QVERIFY(dv.bottom() == 0.2);
+ QCOMPARE(dv.bottom(), 0.2);
dv.setRange(0.2, 0.7);
QCOMPARE(topSpy.count(), 2);
QCOMPARE(bottomSpy.count(), 1);
QCOMPARE(decSpy.count(), 1);
QCOMPARE(changedSpy.count(), 3);
- QVERIFY(dv.bottom() == 0.2);
- QVERIFY(dv.top() == 0.7);
- QVERIFY(dv.decimals() == 0.);
+ QCOMPARE(dv.bottom(), 0.2);
+ QCOMPARE(dv.top(), 0.7);
+ QCOMPARE(dv.decimals(), 0);
dv.setRange(0.3, 0.7);
QCOMPARE(topSpy.count(), 2);
QCOMPARE(bottomSpy.count(), 2);
QCOMPARE(changedSpy.count(), 4);
- QVERIFY(dv.bottom() == 0.3);
- QVERIFY(dv.top() == 0.7);
- QVERIFY(dv.decimals() == 0.);
+ QCOMPARE(dv.bottom(), 0.3);
+ QCOMPARE(dv.top(), 0.7);
+ QCOMPARE(dv.decimals(), 0);
dv.setRange(0.4, 0.6);
QCOMPARE(topSpy.count(), 3);
QCOMPARE(bottomSpy.count(), 3);
QCOMPARE(changedSpy.count(), 5);
- QVERIFY(dv.bottom() == 0.4);
- QVERIFY(dv.top() == 0.6);
- QVERIFY(dv.decimals() == 0.);
+ QCOMPARE(dv.bottom(), 0.4);
+ QCOMPARE(dv.top(), 0.6);
+ QCOMPARE(dv.decimals(), 0);
dv.setDecimals(10);
QCOMPARE(decSpy.count(), 2);
QCOMPARE(changedSpy.count(), 6);
- QVERIFY(dv.decimals() == 10.);
+ QCOMPARE(dv.decimals(), 10);
dv.setRange(0.4, 0.6, 100);
@@ -298,14 +298,14 @@ void tst_QDoubleValidator::notifySignals()
QCOMPARE(bottomSpy.count(), 3);
QCOMPARE(decSpy.count(), 3);
QCOMPARE(changedSpy.count(), 7);
- QVERIFY(dv.bottom() == 0.4);
- QVERIFY(dv.top() == 0.6);
- QVERIFY(dv.decimals() == 100.);
+ 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);
- QVERIFY(dv.notation() == QDoubleValidator::StandardNotation);
+ QCOMPARE(dv.notation(), QDoubleValidator::StandardNotation);
dv.setRange(dv.bottom(), dv.top(), dv.decimals());
QCOMPARE(topSpy.count(), 3);
diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
index 43f7b58439..a683d903df 100644
--- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
+++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
@@ -239,32 +239,32 @@ void tst_QIntValidator::notifySignals()
iv.setTop(9);
QCOMPARE(topSpy.count(), 1);
QCOMPARE(changedSpy.count(), 1);
- QVERIFY(iv.top() == 9);
+ QCOMPARE(iv.top(), 9);
iv.setBottom(1);
QCOMPARE(bottomSpy.count(), 1);
QCOMPARE(changedSpy.count(), 2);
- QVERIFY(iv.bottom() == 1);
+ QCOMPARE(iv.bottom(), 1);
iv.setRange(1, 8);
QCOMPARE(topSpy.count(), 2);
QCOMPARE(bottomSpy.count(), 1);
QCOMPARE(changedSpy.count(), 3);
- QVERIFY(iv.top() == 8);
- QVERIFY(iv.bottom() == 1);
+ QCOMPARE(iv.top(), 8);
+ QCOMPARE(iv.bottom(), 1);
iv.setRange(2, 8);
QCOMPARE(topSpy.count(), 2);
QCOMPARE(bottomSpy.count(), 2);
QCOMPARE(changedSpy.count(), 4);
- QVERIFY(iv.top() == 8);
- QVERIFY(iv.bottom() == 2);
+ QCOMPARE(iv.top(), 8);
+ QCOMPARE(iv.bottom(), 2);
iv.setRange(3, 7);
QCOMPARE(topSpy.count(), 3);
QCOMPARE(bottomSpy.count(), 3);
QCOMPARE(changedSpy.count(), 5);
- QVERIFY(iv.top() == 7);
- QVERIFY(iv.bottom() == 3);
+ QCOMPARE(iv.top(), 7);
+ QCOMPARE(iv.bottom(), 3);
iv.setRange(3, 7);
QCOMPARE(topSpy.count(), 3);
diff --git a/tests/auto/network/access/qabstractnetworkcache/BLACKLIST b/tests/auto/network/access/qabstractnetworkcache/BLACKLIST
new file mode 100644
index 0000000000..3bd3350e4b
--- /dev/null
+++ b/tests/auto/network/access/qabstractnetworkcache/BLACKLIST
@@ -0,0 +1,9 @@
+[cacheControl]
+windows
+osx
+[expires]
+osx
+[etag]
+osx
+[lastModified]
+osx
diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
index 4cbdef2bbe..fd48ec3253 100644
--- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
+++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
@@ -294,6 +294,7 @@ void tst_QAbstractNetworkCache::runTest()
QNetworkAccessManager manager;
NetworkDiskCache *diskCache = new NetworkDiskCache(&manager);
+ QVERIFY2(diskCache->tempDir.isValid(), qPrintable(diskCache->tempDir.errorString()));
manager.setCache(diskCache);
QCOMPARE(diskCache->gotData, false);
@@ -344,6 +345,7 @@ void tst_QAbstractNetworkCache::checkSynchronous()
QNetworkAccessManager manager;
NetworkDiskCache *diskCache = new NetworkDiskCache(&manager);
+ QVERIFY2(diskCache->tempDir.isValid(), qPrintable(diskCache->tempDir.errorString()));
manager.setCache(diskCache);
QCOMPARE(diskCache->gotData, false);
@@ -392,6 +394,7 @@ void tst_QAbstractNetworkCache::deleteCache()
{
QNetworkAccessManager manager;
NetworkDiskCache *diskCache = new NetworkDiskCache(&manager);
+ QVERIFY2(diskCache->tempDir.isValid(), qPrintable(diskCache->tempDir.errorString()));
manager.setCache(diskCache);
QString url = "httpcachetest_cachecontrol.cgi?max-age=1000";
diff --git a/tests/auto/network/access/qftp/BLACKLIST b/tests/auto/network/access/qftp/BLACKLIST
new file mode 100644
index 0000000000..a67c22265c
--- /dev/null
+++ b/tests/auto/network/access/qftp/BLACKLIST
@@ -0,0 +1,11 @@
+# QTBUG-15111
+
+[activeMode:WithoutProxy]
+opensuse-13.1 64bit
+redhatenterpriselinuxworkstation-6.6
+osx-10.10
+
+[activeMode:WithoutProxyWithSession]
+opensuse-13.1 64bit
+redhatenterpriselinuxworkstation-6.6
+osx-10.10
diff --git a/tests/auto/network/access/qftp/qftp.pro b/tests/auto/network/access/qftp/qftp.pro
index 850e1a9417..4294f27e74 100644
--- a/tests/auto/network/access/qftp/qftp.pro
+++ b/tests/auto/network/access/qftp/qftp.pro
@@ -11,4 +11,3 @@ wince {
DEPLOYMENT += addFiles
}
-CONFIG+=insignificant_test # QTBUG-15111: uses live qt-test-server, inherently unstable
diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp
index 7ea1859938..795548ccc8 100644
--- a/tests/auto/network/access/qftp/tst_qftp.cpp
+++ b/tests/auto/network/access/qftp/tst_qftp.cpp
@@ -390,8 +390,7 @@ void tst_QFtp::connectToUnresponsiveHost()
a lot of other stuff in QFtp, so we just expect this test to fail on Windows.
*/
QEXPECT_FAIL("", "timeout not working due to strange Windows socket behaviour (see source file of this test for explanation)", Abort);
-#else
- QEXPECT_FAIL("", "QTBUG-20687", Abort);
+
#endif
QVERIFY2(! QTestEventLoop::instance().timeout(), "Network timeout longer than expected (should have been 60 seconds)");
diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index 5d072af6d5..0d188a8fec 100644
--- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -36,6 +36,7 @@
#include "private/qhttpnetworkconnection_p.h"
#include "private/qnoncontiguousbytedevice_p.h"
#include <QAuthenticator>
+#include <QTcpServer>
#include "../../../network-settings.h"
@@ -106,6 +107,8 @@ private Q_SLOTS:
void getAndThenDeleteObject();
void getAndThenDeleteObject_data();
+
+ void overlappingCloseAndWrite();
};
tst_QHttpNetworkConnection::tst_QHttpNetworkConnection()
@@ -1112,6 +1115,57 @@ void tst_QHttpNetworkConnection::getAndThenDeleteObject()
}
}
+class TestTcpServer : public QTcpServer
+{
+ Q_OBJECT
+public:
+ TestTcpServer() : errorCodeReports(0)
+ {
+ connect(this, &QTcpServer::newConnection, this, &TestTcpServer::onNewConnection);
+ QVERIFY(listen(QHostAddress::LocalHost));
+ }
+
+ int errorCodeReports;
+
+public slots:
+ void onNewConnection()
+ {
+ QTcpSocket *socket = nextPendingConnection();
+ if (!socket)
+ return;
+ // close socket instantly!
+ connect(socket, &QTcpSocket::readyRead, socket, &QTcpSocket::close);
+ }
+
+ void onReply(QNetworkReply::NetworkError code)
+ {
+ QCOMPARE(code, QNetworkReply::RemoteHostClosedError);
+ ++errorCodeReports;
+ }
+};
+
+void tst_QHttpNetworkConnection::overlappingCloseAndWrite()
+{
+ // server accepts connections, but closes the socket instantly
+ TestTcpServer server;
+ QNetworkAccessManager accessManager;
+
+ // ten requests are scheduled. All should result in an RemoteHostClosed...
+ QUrl url;
+ url.setScheme(QStringLiteral("http"));
+ url.setHost(server.serverAddress().toString());
+ url.setPort(server.serverPort());
+ for (int i = 0; i < 10; ++i) {
+ QNetworkRequest request(url);
+ QNetworkReply *reply = accessManager.get(request);
+ // Not using Qt5 connection syntax here because of overly baroque syntax to discern between
+ // different error() methods.
+ QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
+ &server, SLOT(onReply(QNetworkReply::NetworkError)));
+ }
+
+ QTRY_COMPARE(server.errorCodeReports, 10);
+}
QTEST_MAIN(tst_QHttpNetworkConnection)
diff --git a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
index 1d04921c9a..be3e839725 100644
--- a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -83,7 +83,7 @@ void tst_QNetworkCookie::getterSetter()
QNetworkCookie cookie;
QNetworkCookie otherCookie;
- QVERIFY(cookie == otherCookie);
+ QCOMPARE(cookie, otherCookie);
QCOMPARE(cookie, otherCookie);
QVERIFY(!(cookie != otherCookie));
@@ -133,7 +133,7 @@ void tst_QNetworkCookie::getterSetter()
cookie.setSecure(false);
QVERIFY(!cookie.isSecure());
- QVERIFY(cookie == otherCookie);
+ QCOMPARE(cookie, otherCookie);
}
void tst_QNetworkCookie::parseSingleCookie_data()
diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index 708e7ebca8..1685838e9e 100644
--- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -563,7 +563,7 @@ void tst_QNetworkDiskCache::oldCacheVersionFile()
{
QTemporaryFile file(cache.cacheDirectory() + "/XXXXXX.d");
file.setAutoRemove(false);
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QDataStream out(&file);
out << qint32(0xe8);
out << qint32(2);
diff --git a/tests/auto/network/access/qnetworkreply/element.xml b/tests/auto/network/access/qnetworkreply/element.xml
new file mode 100644
index 0000000000..071ffae057
--- /dev/null
+++ b/tests/auto/network/access/qnetworkreply/element.xml
@@ -0,0 +1 @@
+<root attr="value" attr2="value2"><person /><fruit /></root>
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 4ed175ff7f..fbeeec2ec4 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -129,6 +129,14 @@ class tst_QNetworkReply: public QObject
return s;
};
+ static QString tempRedirectReplyStr() {
+ QString s = "HTTP/1.1 307 Temporary Redirect\r\n"
+ "Content-Type: text/plain\r\n"
+ "location: %1\r\n"
+ "\r\n";
+ return s;
+ };
+
QEventLoop *loop;
enum RunSimpleRequestReturn { Timeout = 0, Success, Failure };
int returnCode;
@@ -426,6 +434,8 @@ private Q_SLOTS:
void qtbug28035browserDoesNotLoadQtProjectOrgCorrectly();
+ void qtbug45581WrongReplyStatusCode();
+
void synchronousRequest_data();
void synchronousRequest();
#ifndef QT_NO_SSL
@@ -464,6 +474,10 @@ private Q_SLOTS:
void putWithRateLimiting();
+ void ioHttpSingleRedirect();
+ void ioHttpChangeMaxRedirects();
+ void ioHttpRedirectErrors_data();
+ void ioHttpRedirectErrors();
#ifndef QT_NO_SSL
void putWithServerClosingConnectionImmediately();
#endif
@@ -605,10 +619,16 @@ protected:
virtual void reply() {
Q_ASSERT(!client.isNull());
// we need to emulate the bytesWrittenSlot call if the data is empty.
- if (dataToTransmit.size() == 0)
+ if (dataToTransmit.size() == 0) {
QMetaObject::invokeMethod(this, "bytesWrittenSlot", Qt::QueuedConnection);
- else
+ } else {
client->write(dataToTransmit);
+ // FIXME: For SSL connections, if we don't flush the socket, the
+ // client never receives the data and since we're doing a disconnect
+ // immediately afterwards, it causes a RemoteHostClosedError for the
+ // client
+ client->flush();
+ }
}
private:
void connectSocketSignals()
@@ -1659,14 +1679,14 @@ void tst_QNetworkReply::getFromFile()
// create the file:
QTemporaryFile file(QDir::currentPath() + "/temp-XXXXXX");
file.setAutoRemove(true);
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QNetworkRequest request(QUrl::fromLocalFile(file.fileName()));
QNetworkReplyPtr reply;
static const char fileData[] = "This is some data that is in the file.\r\n";
QByteArray data = QByteArray::fromRawData(fileData, sizeof fileData - 1);
- QVERIFY(file.write(data) == data.size());
+ QCOMPARE(file.write(data), data.size());
file.flush();
QCOMPARE(file.size(), qint64(data.size()));
@@ -2914,9 +2934,9 @@ void tst_QNetworkReply::connectToIPv6Address()
//qDebug() << server.receivedData;
QByteArray hostinfo = "\r\nHost: " + hostfield + ":" + QByteArray::number(server.serverPort()) + "\r\n";
QVERIFY(server.receivedData.contains(hostinfo));
- QVERIFY(content == dataToSend);
+ QCOMPARE(content, dataToSend);
QCOMPARE(reply->url(), request.url());
- QVERIFY(reply->error() == error);
+ QCOMPARE(reply->error(), error);
}
void tst_QNetworkReply::sendCustomRequestToHttp_data()
@@ -3045,10 +3065,10 @@ void tst_QNetworkReply::ioGetFromFile()
{
QTemporaryFile file(QDir::currentPath() + "/temp-XXXXXX");
file.setAutoRemove(true);
- QVERIFY(file.open());
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QFETCH(QByteArray, data);
- QVERIFY(file.write(data) == data.size());
+ QCOMPARE(file.write(data), data.size());
file.flush();
QCOMPARE(file.size(), qint64(data.size()));
@@ -3118,8 +3138,8 @@ void tst_QNetworkReply::ioGetFromFtpWithReuse()
DataReader reader2(reply2);
QSignalSpy spy(reply1.data(), SIGNAL(finished()));
- QVERIFY(waitForFinish(reply1) == Success);
- QVERIFY(waitForFinish(reply2) == Success);
+ QCOMPARE(waitForFinish(reply1), int(Success));
+ QCOMPARE(waitForFinish(reply2), int(Success));
QCOMPARE(reply1->url(), request.url());
QCOMPARE(reply2->url(), request.url());
@@ -3169,8 +3189,8 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseParallel()
DataReader reader2(reply2);
QSignalSpy spy(reply1.data(), SIGNAL(finished()));
- QVERIFY(waitForFinish(reply2) == Success);
- QVERIFY(waitForFinish(reply1) == Success);
+ QCOMPARE(waitForFinish(reply2), int(Success));
+ QCOMPARE(waitForFinish(reply1), int(Success));
QCOMPARE(reply1->url(), request.url());
QCOMPARE(reply2->url(), request.url());
@@ -3272,8 +3292,8 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
- QVERIFY(waitForFinish(reply2) == Success);
- QVERIFY(waitForFinish(reply1) == Success);
+ QCOMPARE(waitForFinish(reply2), int(Success));
+ QCOMPARE(waitForFinish(reply1), int(Success));
manager.disconnect(SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@@ -3402,8 +3422,8 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
- QVERIFY(waitForFinish(reply2) == Success);
- QVERIFY(waitForFinish(reply1) == Success);
+ QCOMPARE(waitForFinish(reply2), int(Success));
+ QCOMPARE(waitForFinish(reply1), int(Success));
manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@@ -3525,7 +3545,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Failure);
+ QCOMPARE(waitForFinish(reply), int(Failure));
manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@@ -3613,7 +3633,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError()
QSignalSpy sslspy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
connect(reply, SIGNAL(metaDataChanged()), SLOT(storeSslConfiguration()));
- QVERIFY(waitForFinish(reply) == Failure);
+ QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError);
QCOMPARE(sslspy.count(), 0);
@@ -3671,7 +3691,7 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer()
QNetworkReplyPtr reply(manager.get(request));
QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
- QVERIFY(waitForFinish(reply) == Failure);
+ QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->url(), request.url());
QCOMPARE(spy.count(), 1);
@@ -4722,7 +4742,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Failure);
+ QCOMPARE(waitForFinish(reply), int(Failure));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@@ -5092,7 +5112,7 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress()
QVERIFY(!QTestEventLoop::instance().timeout());
// final check: only 1 uploadProgress has been emitted
- QVERIFY(spy.length() == 1);
+ QCOMPARE(spy.length(), 1);
QList<QVariant> args = spy.last();
QVERIFY(!args.isEmpty());
QCOMPARE(args.at(0).toLongLong(), buffer.size());
@@ -5333,10 +5353,10 @@ void tst_QNetworkReply::chaining()
{
QTemporaryFile sourceFile(QDir::currentPath() + "/temp-XXXXXX");
sourceFile.setAutoRemove(true);
- QVERIFY(sourceFile.open());
+ QVERIFY2(sourceFile.open(), qPrintable(sourceFile.errorString()));
QFETCH(QByteArray, data);
- QVERIFY(sourceFile.write(data) == data.size());
+ QCOMPARE(sourceFile.write(data), data.size());
sourceFile.flush();
QCOMPARE(sourceFile.size(), qint64(data.size()));
@@ -5348,7 +5368,7 @@ void tst_QNetworkReply::chaining()
request.setUrl(url);
QNetworkReplyPtr putReply(manager.put(request, getReply.data()));
- QVERIFY(waitForFinish(putReply) == Success);
+ QCOMPARE(waitForFinish(putReply), int(Success));
QCOMPARE(getReply->url(), QUrl::fromLocalFile(sourceFile.fileName()));
QCOMPARE(getReply->error(), QNetworkReply::NoError);
@@ -5755,7 +5775,7 @@ void tst_QNetworkReply::proxyChange()
// verify that the replies succeeded
QCOMPARE(reply1->error(), QNetworkReply::NoError);
QCOMPARE(reply1->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
- QVERIFY(reply1->size() == 1);
+ QCOMPARE(reply1->size(), 1);
QCOMPARE(reply2->error(), QNetworkReply::NoError);
QCOMPARE(reply2->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
@@ -5772,7 +5792,7 @@ void tst_QNetworkReply::proxyChange()
manager.setProxy(dummyProxy);
QNetworkReplyPtr reply3(manager.get(req));
- QVERIFY(waitForFinish(reply3) == Failure);
+ QCOMPARE(waitForFinish(reply3), int(Failure));
QVERIFY(int(reply3->error()) > 0);
}
@@ -5808,7 +5828,7 @@ void tst_QNetworkReply::authorizationError()
QSignalSpy errorSpy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
QSignalSpy finishedSpy(reply.data(), SIGNAL(finished()));
// now run the request:
- QVERIFY(waitForFinish(reply) == Failure);
+ QCOMPARE(waitForFinish(reply), int(Failure));
QFETCH(int, errorSignalCount);
QCOMPARE(errorSpy.count(), errorSignalCount);
@@ -5983,7 +6003,7 @@ public slots:
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QVERIFY(!reply->error());
- QVERIFY(reply->bytesAvailable() == 27906);
+ QCOMPARE(reply->bytesAvailable(), 27906);
if (requestsFinishedCount == 60) {
QTestEventLoop::instance().exitLoop();
@@ -6153,6 +6173,10 @@ void tst_QNetworkReply::sslSessionSharing_data()
void tst_QNetworkReply::sslSessionSharing()
{
+#ifdef QT_SECURETRANSPORT
+ QSKIP("Not implemented with SecureTransport");
+#endif
+
QString urlString("https://" + QtNetworkSettings::serverName());
QList<QNetworkReplyPtr> replies;
@@ -6217,6 +6241,10 @@ void tst_QNetworkReply::sslSessionSharingFromPersistentSession_data()
void tst_QNetworkReply::sslSessionSharingFromPersistentSession()
{
+#ifdef QT_SECURETRANSPORT
+ QSKIP("Not implemented with SecureTransport");
+#endif
+
QString urlString("https://" + QtNetworkSettings::serverName());
// warm up SSL session cache to get a working session
@@ -6501,7 +6529,7 @@ public:
void finishedSlot() {
// We should have already received all readyRead
QVERIFY(!bytesAvailableList.isEmpty());
- QVERIFY(bytesAvailableList.last() == uploadSize);
+ QCOMPARE(bytesAvailableList.last(), uploadSize);
}
};
@@ -6584,7 +6612,7 @@ void tst_QNetworkReply::ioGetFromHttpWithoutContentLength()
QCOMPARE(reply->url(), request.url());
QVERIFY(reply->isFinished());
- QVERIFY(reply->error() == QNetworkReply::NoError);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
}
// Is handled somewhere else too, introduced this special test to have it more accessible
@@ -6651,7 +6679,7 @@ void tst_QNetworkReply::compressedHttpReplyBrokenGzip()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Failure);
+ QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->error(), QNetworkReply::ProtocolFailure);
}
@@ -6664,7 +6692,7 @@ void tst_QNetworkReply::getFromUnreachableIp()
QNetworkRequest request(QUrl("http://255.255.255.255/42/23/narf/narf/narf"));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Failure);
+ QCOMPARE(waitForFinish(reply), int(Failure));
QVERIFY(reply->error() != QNetworkReply::NoError);
}
@@ -7166,6 +7194,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
QByteArray postData = "ACT=100";
QTemporaryDir tempDir(QDir::tempPath() + "/tmp_cache_28035");
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
tempDir.setAutoRemove(true);
QNetworkDiskCache *diskCache = new QNetworkDiskCache();
@@ -7255,6 +7284,34 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
QCOMPARE(reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool(), true);
}
+void tst_QNetworkReply::qtbug45581WrongReplyStatusCode()
+{
+ const QUrl url("file:" + testDataDir + "/element.xml");
+ QNetworkRequest request(url);
+
+ QNetworkReplyPtr reply;
+ QSignalSpy finishedSpy(&manager, SIGNAL(finished(QNetworkReply*)));
+ QSignalSpy sslErrorsSpy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
+ RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply, 0));
+ QVERIFY(reply->isFinished());
+
+ const QByteArray expectedContent =
+ "<root attr=\"value\" attr2=\"value2\">"
+ "<person /><fruit /></root>\n";
+
+ QCOMPARE(reply->readAll(), expectedContent);
+
+ QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(sslErrorsSpy.count(), 0);
+
+ QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), expectedContent.size());
+
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(), QLatin1String("OK"));
+
+ reply->deleteLater();
+}
+
void tst_QNetworkReply::synchronousRequest_data()
{
QTest::addColumn<QUrl>("url");
@@ -7425,7 +7482,7 @@ void tst_QNetworkReply::httpAbort()
QNetworkRequest request3("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt");
QNetworkReplyPtr reply3(manager.get(request3));
- QVERIFY(waitForFinish(reply3) == Success);
+ QCOMPARE(waitForFinish(reply3), int(Success));
QVERIFY(reply3->isFinished());
reply3->abort();
@@ -7980,7 +8037,142 @@ void tst_QNetworkReply::putWithRateLimiting()
QCOMPARE(uploadedData, data);
}
+void tst_QNetworkReply::ioHttpSingleRedirect()
+{
+ QUrl localhost = QUrl("http://localhost");
+ QByteArray http200Reply = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n";
+
+ // Setup server to which the second server will redirect to
+ MiniHttpServer server2(http200Reply);
+
+ QUrl redirectUrl = QUrl(localhost);
+ redirectUrl.setPort(server2.serverPort());
+
+ QByteArray tempRedirectReply =
+ tempRedirectReplyStr().arg(QString(redirectUrl.toEncoded())).toLatin1();
+
+
+ // Setup redirect server
+ MiniHttpServer server(tempRedirectReply);
+
+ localhost.setPort(server.serverPort());
+ QNetworkRequest request(localhost);
+ request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
+
+ QNetworkReplyPtr reply(manager.get(request));
+ QSignalSpy redSpy(reply.data(), SIGNAL(redirected(QUrl)));
+ QSignalSpy finSpy(reply.data(), SIGNAL(finished()));
+
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
+
+ // Redirected and finished should be emitted exactly once
+ QCOMPARE(redSpy.count(), 1);
+ QCOMPARE(finSpy.count(), 1);
+
+ // Original URL should not be changed after redirect
+ QCOMPARE(request.url(), localhost);
+ // Verify Redirect url
+ QList<QVariant> args = redSpy.takeFirst();
+ QCOMPARE(args.at(0).toUrl(), redirectUrl);
+
+ // Reply url is set to the redirect url
+ QCOMPARE(reply->url(), redirectUrl);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+}
+
+void tst_QNetworkReply::ioHttpChangeMaxRedirects()
+{
+ QUrl localhost = QUrl("http://localhost");
+
+ QByteArray http200Reply = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n";
+
+ MiniHttpServer server1("");
+ MiniHttpServer server2("");
+ MiniHttpServer server3(http200Reply);
+
+ QUrl server2Url(localhost);
+ server2Url.setPort(server2.serverPort());
+ server1.setDataToTransmit(tempRedirectReplyStr().arg(
+ QString(server2Url.toEncoded())).toLatin1());
+
+ QUrl server3Url(localhost);
+ server3Url.setPort(server3.serverPort());
+ server2.setDataToTransmit(tempRedirectReplyStr().arg(
+ QString(server3Url.toEncoded())).toLatin1());
+
+ localhost.setPort(server1.serverPort());
+ QNetworkRequest request(localhost);
+ request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
+
+ // Set Max redirects to 1. This will cause TooManyRedirectsError
+ request.setMaximumRedirectsAllowed(1);
+
+ QNetworkReplyPtr reply(manager.get(request));
+ QSignalSpy redSpy(reply.data(), SIGNAL(redirected(QUrl)));
+ QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
+
+ QCOMPARE(waitForFinish(reply), int(Failure));
+
+ QCOMPARE(redSpy.count(), request.maximumRedirectsAllowed());
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(reply->error(), QNetworkReply::TooManyRedirectsError);
+
+ // Increase max redirects to allow successful completion
+ request.setMaximumRedirectsAllowed(3);
+
+ QNetworkReplyPtr reply2(manager.get(request));
+ QSignalSpy redSpy2(reply2.data(), SIGNAL(redirected(QUrl)));
+
+ QVERIFY2(waitForFinish(reply2) == Success, msgWaitForFinished(reply2));
+
+ QCOMPARE(redSpy2.count(), 2);
+ QCOMPARE(reply2->url(), server3Url);
+ QCOMPARE(reply2->error(), QNetworkReply::NoError);
+}
+
+void tst_QNetworkReply::ioHttpRedirectErrors_data()
+{
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<QString>("dataToSend");
+ QTest::addColumn<QNetworkReply::NetworkError>("error");
+
+ QString tempRedirectReply = QString("HTTP/1.1 307 Temporary Redirect\r\n"
+ "Content-Type: text/plain\r\n"
+ "location: http://localhost:%1\r\n\r\n");
+
+ QTest::newRow("too-many-redirects") << "http://localhost" << tempRedirectReply << QNetworkReply::TooManyRedirectsError;
+ QTest::newRow("insecure-redirect") << "https://localhost" << tempRedirectReply << QNetworkReply::InsecureRedirectError;
+ QTest::newRow("unknown-redirect") << "http://localhost"<< tempRedirectReply.replace("http", "bad_protocol") << QNetworkReply::ProtocolUnknownError;
+}
+
+void tst_QNetworkReply::ioHttpRedirectErrors()
+{
+ QFETCH(QString, url);
+ QFETCH(QString, dataToSend);
+ QFETCH(QNetworkReply::NetworkError, error);
+
+ QUrl localhost(url);
+ MiniHttpServer server("", localhost.scheme() == "https");
+
+ localhost.setPort(server.serverPort());
+
+ QByteArray d2s = dataToSend.arg(
+ QString::number(server.serverPort())).toLatin1();
+ server.setDataToTransmit(d2s);
+
+ QNetworkRequest request(localhost);
+ request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
+ QNetworkReplyPtr reply(manager.get(request));
+ if (localhost.scheme() == "https")
+ reply.data()->ignoreSslErrors();
+ QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
+
+ QCOMPARE(waitForFinish(reply), int(Failure));
+
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(reply->error(), error);
+}
#ifndef QT_NO_SSL
class PutWithServerClosingConnectionImmediatelyHandler: public QObject
diff --git a/tests/auto/network/access/spdy/BLACKLIST b/tests/auto/network/access/spdy/BLACKLIST
new file mode 100644
index 0000000000..b13eae1000
--- /dev/null
+++ b/tests/auto/network/access/spdy/BLACKLIST
@@ -0,0 +1,4 @@
+[download]
+linux
+[upload]
+linux
diff --git a/tests/auto/network/access/spdy/spdy.pro b/tests/auto/network/access/spdy/spdy.pro
index 6bfc6d84e0..23efa85b47 100644
--- a/tests/auto/network/access/spdy/spdy.pro
+++ b/tests/auto/network/access/spdy/spdy.pro
@@ -5,3 +5,5 @@ SOURCES += tst_spdy.cpp
QT = core core-private network network-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+win32:CONFIG += insignificant_test # QTBUG-47128
diff --git a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
index 7dfc02463e..09ccff4968 100644
--- a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
+++ b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
@@ -68,7 +68,7 @@ void tst_QNetworkConfiguration::invalidPoint()
QVERIFY(pt.name().isEmpty());
QVERIFY(!pt.isValid());
- QVERIFY(pt.type() == QNetworkConfiguration::Invalid);
+ QCOMPARE(pt.type(), QNetworkConfiguration::Invalid);
QVERIFY(!(pt.state() & QNetworkConfiguration::Defined));
QVERIFY(!(pt.state() & QNetworkConfiguration::Discovered));
QVERIFY(!(pt.state() & QNetworkConfiguration::Active));
@@ -77,7 +77,7 @@ void tst_QNetworkConfiguration::invalidPoint()
QNetworkConfiguration pt2(pt);
QVERIFY(pt2.name().isEmpty());
QVERIFY(!pt2.isValid());
- QVERIFY(pt2.type() == QNetworkConfiguration::Invalid);
+ QCOMPARE(pt2.type(), QNetworkConfiguration::Invalid);
QVERIFY(!(pt2.state() & QNetworkConfiguration::Defined));
QVERIFY(!(pt2.state() & QNetworkConfiguration::Discovered));
QVERIFY(!(pt2.state() & QNetworkConfiguration::Active));
@@ -91,27 +91,27 @@ void tst_QNetworkConfiguration::comparison()
//compare invalid connection points
QNetworkConfiguration pt1;
QVERIFY(!pt1.isValid());
- QVERIFY(pt1.type() == QNetworkConfiguration::Invalid);
+ QCOMPARE(pt1.type(), QNetworkConfiguration::Invalid);
QNetworkConfiguration pt2(pt1);
QVERIFY(pt1==pt2);
QVERIFY(!(pt1!=pt2));
- QVERIFY(pt1.name() == pt2.name());
- QVERIFY(pt1.isValid() == pt2.isValid());
- QVERIFY(pt1.type() == pt2.type());
- QVERIFY(pt1.state() == pt2.state());
- QVERIFY(pt1.purpose() == pt2.purpose());
+ QCOMPARE(pt1.name(), pt2.name());
+ QCOMPARE(pt1.isValid(), pt2.isValid());
+ QCOMPARE(pt1.type(), pt2.type());
+ QCOMPARE(pt1.state(), pt2.state());
+ QCOMPARE(pt1.purpose(), pt2.purpose());
QNetworkConfiguration pt3;
pt3 = pt1;
QVERIFY(pt1==pt3);
QVERIFY(!(pt1!=pt3));
- QVERIFY(pt1.name() == pt3.name());
- QVERIFY(pt1.isValid() == pt3.isValid());
- QVERIFY(pt1.type() == pt3.type());
- QVERIFY(pt1.state() == pt3.state());
- QVERIFY(pt1.purpose() == pt3.purpose());
+ QCOMPARE(pt1.name(), pt3.name());
+ QCOMPARE(pt1.isValid(), pt3.isValid());
+ QCOMPARE(pt1.type(), pt3.type());
+ QCOMPARE(pt1.state(), pt3.state());
+ QCOMPARE(pt1.purpose(), pt3.purpose());
//test case must run on machine that has valid connection points
QNetworkConfigurationManager manager;
@@ -131,11 +131,11 @@ void tst_QNetworkConfiguration::comparison()
pt3 = defaultConfig;
QVERIFY(defaultConfig==pt3);
QVERIFY(!(defaultConfig!=pt3));
- QVERIFY(defaultConfig.name() == pt3.name());
- QVERIFY(defaultConfig.isValid() == pt3.isValid());
- QVERIFY(defaultConfig.type() == pt3.type());
- QVERIFY(defaultConfig.state() == pt3.state());
- QVERIFY(defaultConfig.purpose() == pt3.purpose());
+ QCOMPARE(defaultConfig.name(), pt3.name());
+ QCOMPARE(defaultConfig.isValid(), pt3.isValid());
+ QCOMPARE(defaultConfig.type(), pt3.type());
+ QCOMPARE(defaultConfig.state(), pt3.state());
+ QCOMPARE(defaultConfig.purpose(), pt3.purpose());
}
void tst_QNetworkConfiguration::children()
@@ -178,7 +178,7 @@ void tst_QNetworkConfiguration::isRoamingAvailable()
if ( c.children().count() <= 1 )
QVERIFY(!c.isRoamingAvailable());
foreach(QNetworkConfiguration child, c.children()) {
- QVERIFY(QNetworkConfiguration::InternetAccessPoint == child.type());
+ QCOMPARE(QNetworkConfiguration::InternetAccessPoint, child.type());
QCOMPARE(child.children().count(), 0);
}
} else {
diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
index afe1fc274e..94c4d903b2 100644
--- a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
+++ b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
@@ -168,7 +168,7 @@ void tst_QNetworkConfigurationManager::defaultConfiguration()
QVERIFY(!defaultConfig.isRoamingAvailable());
QCOMPARE(defaultConfig.state(), QNetworkConfiguration::Discovered);
QNetworkConfiguration copy = manager.configurationFromIdentifier(defaultConfig.identifier());
- QVERIFY(copy == defaultConfig);
+ QCOMPARE(copy, defaultConfig);
}
}
@@ -190,7 +190,7 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier()
QNetworkConfiguration direct = manager.configurationFromIdentifier(c.identifier());
QVERIFY(direct.isValid());
- QVERIFY(direct == c);
+ QCOMPARE(direct, c);
}
//assume that there is no item with identifier 'FooBar'
diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
index 2fd80b3e71..cd510ddfa8 100644
--- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
@@ -187,19 +187,19 @@ void tst_QNetworkSession::invalidSession()
// 1. Verify that session created with invalid configuration remains in invalid state
QNetworkSession session(QNetworkConfiguration(), 0);
QVERIFY(!session.isOpen());
- QVERIFY(session.state() == QNetworkSession::Invalid);
- QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
+ QCOMPARE(session.state(), QNetworkSession::Invalid);
+ QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError);
// 2. Verify that opening session with invalid configuration both 1) emits invalidconfigurationerror and 2) sets session's state as invalid.
QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError)));
session.open();
session.waitForOpened(1000); // Should bail out right away
- QVERIFY(errorSpy.count() == 1);
+ QCOMPARE(errorSpy.count(), 1);
QNetworkSession::SessionError error =
qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0));
- QVERIFY(error == QNetworkSession::InvalidConfigurationError);
- QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
- QVERIFY(session.state() == QNetworkSession::Invalid);
+ QCOMPARE(error, QNetworkSession::InvalidConfigurationError);
+ QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError);
+ QCOMPARE(session.state(), QNetworkSession::Invalid);
#ifdef QNETWORKSESSION_MANUAL_TESTS
@@ -210,7 +210,7 @@ void tst_QNetworkSession::invalidSession()
qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name();
QTest::qWait(60000);
QVERIFY(!invalidatedConfig.isValid());
- QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid);
+ QCOMPARE(invalidatedSession.state(), QNetworkSession::Invalid);
qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name();
QTest::qWait(60000);
}
@@ -235,11 +235,11 @@ void tst_QNetworkSession::invalidSession()
QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage
QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration
sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0));
- QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError);
+ QCOMPARE(sessionError, QNetworkSession::InvalidConfigurationError);
qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name();
QTest::qWait(60000);
updateConfigurations();
- QVERIFY(definedConfig.state() == QNetworkConfiguration::Discovered);
+ QCOMPARE(definedConfig.state(), QNetworkConfiguration::Discovered);
}
#endif
}
@@ -260,7 +260,7 @@ void tst_QNetworkSession::sessionProperties()
{
QFETCH(QNetworkConfiguration, configuration);
QNetworkSession session(configuration);
- QVERIFY(session.configuration() == configuration);
+ QCOMPARE(session.configuration(), configuration);
QStringList validBearerNames = QStringList() << QLatin1String("Unknown")
<< QLatin1String("Ethernet")
<< QLatin1String("WLAN")
@@ -303,10 +303,10 @@ void tst_QNetworkSession::sessionProperties()
} else {
switch (configuration.state()) {
case QNetworkConfiguration::Undefined:
- QVERIFY(session.state() == QNetworkSession::NotAvailable);
+ QCOMPARE(session.state(), QNetworkSession::NotAvailable);
break;
case QNetworkConfiguration::Defined:
- QVERIFY(session.state() == QNetworkSession::NotAvailable);
+ QCOMPARE(session.state(), QNetworkSession::NotAvailable);
break;
case QNetworkConfiguration::Discovered:
QVERIFY(session.state() == QNetworkSession::Connecting ||
@@ -372,12 +372,12 @@ void tst_QNetworkSession::userChoiceSession()
{
QFETCH(QNetworkConfiguration, configuration);
- QVERIFY(configuration.type() == QNetworkConfiguration::UserChoice);
+ QCOMPARE(configuration.type(), QNetworkConfiguration::UserChoice);
QNetworkSession session(configuration);
// Check that configuration was really set
- QVERIFY(session.configuration() == configuration);
+ QCOMPARE(session.configuration(), configuration);
QVERIFY(!session.isOpen());
@@ -431,7 +431,7 @@ void tst_QNetworkSession::userChoiceSession()
if (expectStateChange)
QTRY_VERIFY_WITH_TIMEOUT(!stateChangedSpy.isEmpty(), TestTimeOut);
- QVERIFY(session.state() == QNetworkSession::Connected);
+ QCOMPARE(session.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
#endif
@@ -462,16 +462,16 @@ void tst_QNetworkSession::userChoiceSession()
manager.configurationFromIdentifier(activeIdentifier);
QVERIFY(activeConfiguration.isValid());
- QVERIFY(activeConfiguration.type() == QNetworkConfiguration::InternetAccessPoint);
+ QCOMPARE(activeConfiguration.type(), QNetworkConfiguration::InternetAccessPoint);
//resetting ActiveConfiguration is ignored (read only property)
session.setSessionProperty("ActiveConfiguration", testIdentifier);
QVERIFY(session.sessionProperty("ActiveConfiguration").toString() != testIdentifier);
if (userChoiceConfiguration.type() == QNetworkConfiguration::InternetAccessPoint) {
- QVERIFY(userChoiceConfiguration == activeConfiguration);
+ QCOMPARE(userChoiceConfiguration, activeConfiguration);
} else {
- QVERIFY(userChoiceConfiguration.type() == QNetworkConfiguration::ServiceNetwork);
+ QCOMPARE(userChoiceConfiguration.type(), QNetworkConfiguration::ServiceNetwork);
QVERIFY(userChoiceConfiguration.children().contains(activeConfiguration));
}
} else {
@@ -500,18 +500,21 @@ void tst_QNetworkSession::sessionOpenCloseStop()
{
QFETCH(QNetworkConfiguration, configuration);
QFETCH(bool, forceSessionStop);
+#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
+ QSKIP("Deadlocks on Linux due to QTBUG-45655");
+#endif
QNetworkSession session(configuration);
// Test initial state of the session.
{
- QVERIFY(session.configuration() == configuration);
+ QCOMPARE(session.configuration(), configuration);
QVERIFY(!session.isOpen());
// session may be invalid if configuration is removed between when
// sessionOpenCloseStop_data() is called and here.
QVERIFY((configuration.isValid() && (session.state() != QNetworkSession::Invalid)) ||
(!configuration.isValid() && (session.state() == QNetworkSession::Invalid)));
- QVERIFY(session.error() == QNetworkSession::UnknownSessionError);
+ QCOMPARE(session.error(), QNetworkSession::UnknownSessionError);
}
// The remaining tests require the session to be not NotAvailable.
@@ -541,7 +544,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::SessionError error =
qvariant_cast<QNetworkSession::SessionError>(errorSpy.first().at(0));
- QVERIFY(session.state() == previousState);
+ QCOMPARE(session.state(), previousState);
if (error == QNetworkSession::OperationNotSupportedError) {
// The session needed to bring up the interface,
@@ -571,13 +574,13 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::State state =
qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(0).at(0));
- QVERIFY(state == QNetworkSession::Connecting);
+ QCOMPARE(state, QNetworkSession::Connecting);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(1).at(0));
- QVERIFY(state == QNetworkSession::Connected);
+ QCOMPARE(state, QNetworkSession::Connected);
}
- QVERIFY(session.state() == QNetworkSession::Connected);
+ QCOMPARE(session.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
#endif
@@ -600,10 +603,10 @@ void tst_QNetworkSession::sessionOpenCloseStop()
// Test opening a second session.
{
- QVERIFY(session2.configuration() == configuration);
+ QCOMPARE(session2.configuration(), configuration);
QVERIFY(!session2.isOpen());
- QVERIFY(session2.state() == QNetworkSession::Connected);
- QVERIFY(session.error() == QNetworkSession::UnknownSessionError);
+ QCOMPARE(session2.state(), QNetworkSession::Connected);
+ QCOMPARE(session.error(), QNetworkSession::UnknownSessionError);
session2.open();
@@ -611,10 +614,10 @@ void tst_QNetworkSession::sessionOpenCloseStop()
if (errorSpy2.isEmpty()) {
QVERIFY(session2.isOpen());
- QVERIFY(session2.state() == QNetworkSession::Connected);
+ QCOMPARE(session2.state(), QNetworkSession::Connected);
}
QVERIFY(session.isOpen());
- QVERIFY(session.state() == QNetworkSession::Connected);
+ QCOMPARE(session.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
if (errorSpy2.isEmpty()) {
@@ -648,8 +651,8 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::SessionError error2 =
qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0));
- QVERIFY(error == QNetworkSession::SessionAbortedError);
- QVERIFY(error2 == QNetworkSession::SessionAbortedError);
+ QCOMPARE(error, QNetworkSession::SessionAbortedError);
+ QCOMPARE(error2, QNetworkSession::SessionAbortedError);
QCOMPARE(errorSpy.count(), 1);
QCOMPARE(errorSpy2.count(), 1);
@@ -668,8 +671,8 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QTRY_VERIFY_WITH_TIMEOUT(stateChangedSpy2.count() >= 1 || !errorSpy2.isEmpty(), TestTimeOut);
if (!errorSpy2.isEmpty()) {
- QVERIFY(session2.state() == previousState);
- QVERIFY(session.state() == previousState);
+ QCOMPARE(session2.state(), previousState);
+ QCOMPARE(session.state(), previousState);
QNetworkSession::SessionError error =
qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0));
@@ -697,22 +700,22 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::State state;
if (stateChangedSpy2.count() == 4) {
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0));
- QVERIFY(state == QNetworkSession::Connecting);
+ QCOMPARE(state, QNetworkSession::Connecting);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0));
- QVERIFY(state == QNetworkSession::Connected);
+ QCOMPARE(state, QNetworkSession::Connected);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(2).at(0));
- QVERIFY(state == QNetworkSession::Closing);
+ QCOMPARE(state, QNetworkSession::Closing);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(3).at(0));
- QVERIFY(state == QNetworkSession::Disconnected);
+ QCOMPARE(state, QNetworkSession::Disconnected);
} else if (stateChangedSpy2.count() == 2) {
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0));
- QVERIFY(state == QNetworkSession::Closing);
+ QCOMPARE(state, QNetworkSession::Closing);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0));
- QVERIFY(state == QNetworkSession::Disconnected);
+ QCOMPARE(state, QNetworkSession::Disconnected);
} else {
QFAIL("Unexpected amount of state changes when roaming.");
}
@@ -748,7 +751,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
if (stateChangedSpy.count() > 1) {
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0));
- QVERIFY(state == QNetworkSession::Roaming);
+ QCOMPARE(state, QNetworkSession::Roaming);
}
roamedSuccessfully = true;
}
@@ -776,9 +779,9 @@ void tst_QNetworkSession::sessionOpenCloseStop()
if (stateChangedSpy2.count() == 2) {
QNetworkSession::State state =
qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0));
- QVERIFY(state == QNetworkSession::Closing);
+ QCOMPARE(state, QNetworkSession::Closing);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0));
- QVERIFY(state == QNetworkSession::Disconnected);
+ QCOMPARE(state, QNetworkSession::Disconnected);
} else {
QVERIFY(stateChangedSpy2.count() >= 1);
@@ -791,7 +794,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::State state =
qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(stateChangedSpy2.count() - 1).at(0));
- QVERIFY(state == QNetworkSession::Disconnected);
+ QCOMPARE(state, QNetworkSession::Disconnected);
}
}
@@ -818,14 +821,14 @@ void tst_QNetworkSession::sessionOpenCloseStop()
session2.close();
QTRY_VERIFY_WITH_TIMEOUT(!sessionClosedSpy2.isEmpty(), TestTimeOut);
- QVERIFY(stateChangedSpy2.count() == stateChangedCountBeforeClose);
+ QCOMPARE(stateChangedSpy2.count(), stateChangedCountBeforeClose);
QVERIFY(sessionClosedSpy.isEmpty());
QVERIFY(session.isOpen());
QVERIFY(!session2.isOpen());
- QVERIFY(session.state() == QNetworkSession::Connected);
- QVERIFY(session2.state() == QNetworkSession::Connected);
+ QCOMPARE(session.state(), QNetworkSession::Connected);
+ QCOMPARE(session2.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress());
@@ -1233,7 +1236,7 @@ void tst_QNetworkSession::sessionAutoClose()
QNetworkSession session(configuration);
- QVERIFY(session.configuration() == configuration);
+ QCOMPARE(session.configuration(), configuration);
QVariant autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout"));
@@ -1259,7 +1262,7 @@ void tst_QNetworkSession::sessionAutoClose()
QVERIFY(!session.isOpen());
- QVERIFY(session.configuration() == configuration);
+ QCOMPARE(session.configuration(), configuration);
autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout"));
diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
index f6b7dfa3af..026a2a2722 100644
--- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
+++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
@@ -82,7 +82,7 @@ void tst_QAuthenticator::basicAuth()
QAuthenticator auth;
auth.detach();
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth);
- QVERIFY(priv->phase == QAuthenticatorPrivate::Start);
+ QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
QList<QPair<QByteArray, QByteArray> > headers;
headers << qMakePair<QByteArray, QByteArray>(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8());
@@ -94,7 +94,7 @@ void tst_QAuthenticator::basicAuth()
auth.setUser(user);
auth.setPassword(password);
- QVERIFY(priv->phase == QAuthenticatorPrivate::Start);
+ QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
QCOMPARE(priv->calculateResponse("GET", "/").constData(), QByteArray("Basic " + expectedReply).constData());
}
@@ -125,7 +125,7 @@ void tst_QAuthenticator::ntlmAuth()
auth.detach();
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth);
- QVERIFY(priv->phase == QAuthenticatorPrivate::Start);
+ QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
QList<QPair<QByteArray, QByteArray> > headers;
diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
index ef24cbf3c8..8069865d93 100644
--- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
+++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
@@ -83,22 +83,12 @@ private slots:
void isInSubnet();
void isLoopback_data();
void isLoopback();
+ void isMulticast_data();
+ void isMulticast();
void convertv4v6_data();
void convertv4v6();
};
-QT_BEGIN_NAMESPACE
-namespace QTest {
- template<>
- char *toString(const QHostAddress &addr)
- {
- if (addr.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol)
- return qstrdup("<invalid>");
- return qstrdup(addr.toString().toLatin1());
- }
-}
-QT_END_NAMESPACE
-
tst_QHostAddress::tst_QHostAddress()
{
}
@@ -234,7 +224,7 @@ void tst_QHostAddress::setAddress_QString()
QFETCH(int, protocol);
QHostAddress hostAddr;
- QVERIFY(hostAddr.setAddress(address) == ok);
+ QCOMPARE(hostAddr.setAddress(address), ok);
if (ok)
QTEST(hostAddr.toString(), "resAddr");
@@ -316,7 +306,7 @@ void tst_QHostAddress::compare_data()
QTest::newRow("6") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::LocalHostIPv6) << false;
QTest::newRow("7") << QHostAddress() << QHostAddress(QHostAddress::LocalHostIPv6) << false;
- Q_IPV6ADDR localhostv4mapped = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1 };
+ Q_IPV6ADDR localhostv4mapped = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1 } };
QTest::newRow("v4-v4mapped") << QHostAddress(QHostAddress::LocalHost) << QHostAddress("::ffff:127.0.0.1") << false;
QTest::newRow("v4-v4mapped-2") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(localhostv4mapped) << false;
}
@@ -330,7 +320,7 @@ void tst_QHostAddress::compare()
QCOMPARE(first == second, result);
QCOMPARE(second == first, result);
if (result == true)
- QVERIFY(qHash(first) == qHash(second));
+ QCOMPARE(qHash(first), qHash(second));
}
void tst_QHostAddress::assignment()
@@ -399,11 +389,11 @@ void tst_QHostAddress::streaming()
QByteArray ba;
QDataStream ds1(&ba, QIODevice::WriteOnly);
ds1 << address;
- QVERIFY(ds1.status() == QDataStream::Ok);
+ QCOMPARE(ds1.status(), QDataStream::Ok);
QDataStream ds2(&ba, QIODevice::ReadOnly);
QHostAddress address2;
ds2 >> address2;
- QVERIFY(ds2.status() == QDataStream::Ok);
+ QCOMPARE(ds2.status(), QDataStream::Ok);
QCOMPARE(address, address2);
}
@@ -631,6 +621,9 @@ void tst_QHostAddress::isLoopback_data()
QTest::addColumn<QHostAddress>("address");
QTest::addColumn<bool>("result");
+ QTest::newRow("default") << QHostAddress() << false;
+ QTest::newRow("invalid") << QHostAddress("&&&") << false;
+
QTest::newRow("ipv6_loop") << QHostAddress(QHostAddress::LocalHostIPv6) << true;
QTest::newRow("::1") << QHostAddress("::1") << true;
@@ -639,7 +632,6 @@ void tst_QHostAddress::isLoopback_data()
QTest::newRow("127.0.0.2") << QHostAddress("127.0.0.2") << true;
QTest::newRow("127.3.2.1") << QHostAddress("127.3.2.1") << true;
- QTest::newRow("default") << QHostAddress() << false;
QTest::newRow("1.2.3.4") << QHostAddress("1.2.3.4") << false;
QTest::newRow("10.0.0.4") << QHostAddress("10.0.0.4") << false;
QTest::newRow("192.168.3.4") << QHostAddress("192.168.3.4") << false;
@@ -650,10 +642,12 @@ void tst_QHostAddress::isLoopback_data()
QTest::newRow("AnyIPv6") << QHostAddress(QHostAddress::AnyIPv6) << false;
QTest::newRow("Broadcast") << QHostAddress(QHostAddress::Broadcast) << false;
QTest::newRow("Null") << QHostAddress(QHostAddress::Null) << false;
+ QTest::newRow("ipv6-all-ffff") << QHostAddress("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") << false;
QTest::newRow("::ffff:127.0.0.1") << QHostAddress("::ffff:127.0.0.1") << true;
QTest::newRow("::ffff:127.0.0.2") << QHostAddress("::ffff:127.0.0.2") << true;
QTest::newRow("::ffff:127.3.2.1") << QHostAddress("::ffff:127.3.2.1") << true;
+
}
void tst_QHostAddress::isLoopback()
@@ -664,6 +658,50 @@ void tst_QHostAddress::isLoopback()
QCOMPARE(address.isLoopback(), result);
}
+void tst_QHostAddress::isMulticast_data()
+{
+ QTest::addColumn<QHostAddress>("address");
+ QTest::addColumn<bool>("result");
+
+ QTest::newRow("default") << QHostAddress() << false;
+ QTest::newRow("invalid") << QHostAddress("&&&") << false;
+
+ QTest::newRow("ipv6_loop") << QHostAddress(QHostAddress::LocalHostIPv6) << false;
+ QTest::newRow("::1") << QHostAddress("::1") << false;
+ QTest::newRow("ipv4_loop") << QHostAddress(QHostAddress::LocalHost) << false;
+ QTest::newRow("127.0.0.1") << QHostAddress("127.0.0.1") << false;
+ QTest::newRow("::") << QHostAddress("::") << false;
+ QTest::newRow("Any") << QHostAddress(QHostAddress::Any) << false;
+ QTest::newRow("AnyIPv4") << QHostAddress(QHostAddress::AnyIPv4) << false;
+ QTest::newRow("AnyIPv6") << QHostAddress(QHostAddress::AnyIPv6) << false;
+ QTest::newRow("Broadcast") << QHostAddress(QHostAddress::Broadcast) << false;
+ QTest::newRow("Null") << QHostAddress(QHostAddress::Null) << false;
+
+ QTest::newRow("223.255.255.255") << QHostAddress("223.255.255.255") << false;
+ QTest::newRow("224.0.0.0") << QHostAddress("224.0.0.0") << true;
+ QTest::newRow("239.255.255.255") << QHostAddress("239.255.255.255") << true;
+ QTest::newRow("240.0.0.0") << QHostAddress("240.0.0.0") << false;
+
+ QTest::newRow("::ffff:223.255.255.255") << QHostAddress("::ffff:223.255.255.255") << false;
+ QTest::newRow("::ffff:224.0.0.0") << QHostAddress("::ffff:224.0.0.0") << true;
+ QTest::newRow("::ffff:239.255.255.255") << QHostAddress("::ffff:239.255.255.255") << true;
+ QTest::newRow("::ffff:240.0.0.0") << QHostAddress("::ffff:240.0.0.0") << false;
+
+ QTest::newRow("fc00::") << QHostAddress("fc00::") << false;
+ QTest::newRow("fe80::") << QHostAddress("fe80::") << false;
+ QTest::newRow("fec0::") << QHostAddress("fec0::") << false;
+ QTest::newRow("ff00::") << QHostAddress("ff00::") << true;
+ QTest::newRow("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") << QHostAddress("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") << true;
+}
+
+void tst_QHostAddress::isMulticast()
+{
+ QFETCH(QHostAddress, address);
+ QFETCH(bool, result);
+
+ QCOMPARE(address.isMulticast(), result);
+}
+
void tst_QHostAddress::convertv4v6_data()
{
QTest::addColumn<QHostAddress>("source");
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index 599e475beb..5f0addba98 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -561,13 +561,13 @@ void tst_QHostInfo::cache()
QHostInfo result = qt_qhostinfo_lookup("localhost", this, SLOT(resultsReady(QHostInfo)), &valid, &id);
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(valid == false);
+ QVERIFY(!valid);
QVERIFY(result.addresses().isEmpty());
// loopkup second time, result should come directly
valid = false;
result = qt_qhostinfo_lookup("localhost", this, SLOT(resultsReady(QHostInfo)), &valid, &id);
- QVERIFY(valid == true);
+ QVERIFY(valid);
QVERIFY(!result.addresses().isEmpty());
// clear the cache
@@ -578,7 +578,7 @@ void tst_QHostInfo::cache()
result = qt_qhostinfo_lookup("localhost", this, SLOT(resultsReady(QHostInfo)), &valid, &id);
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(valid == false);
+ QVERIFY(!valid);
QVERIFY(result.addresses().isEmpty());
// the slot should have been called 2 times.
diff --git a/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp b/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp
index d88b2e222c..cca670e13a 100644
--- a/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp
+++ b/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp
@@ -76,7 +76,7 @@ void tst_QNetworkAddressEntry::getSetCheck()
entry = entry2;
QCOMPARE(entry, entry2);
- QVERIFY(entry == entry);
+ QCOMPARE(entry, entry);
QVERIFY(!(entry != entry2));
}
diff --git a/tests/auto/network/kernel/qnetworkinterface/BLACKLIST b/tests/auto/network/kernel/qnetworkinterface/BLACKLIST
new file mode 100644
index 0000000000..23bb688d9a
--- /dev/null
+++ b/tests/auto/network/kernel/qnetworkinterface/BLACKLIST
@@ -0,0 +1,2 @@
+[localAddress]
+linux
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index b3ffe74b67..f7798bbb70 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -58,6 +58,7 @@ private slots:
void loopbackIPv4();
void loopbackIPv6();
void localAddress();
+ void interfaceFromXXX_data();
void interfaceFromXXX();
void copyInvalidInterface();
@@ -188,35 +189,42 @@ void tst_QNetworkInterface::localAddress()
QVERIFY(all.contains(local));
}
-void tst_QNetworkInterface::interfaceFromXXX()
+void tst_QNetworkInterface::interfaceFromXXX_data()
{
+ QTest::addColumn<QNetworkInterface>("iface");
+
QList<QNetworkInterface> allInterfaces = QNetworkInterface::allInterfaces();
+ foreach (QNetworkInterface iface, allInterfaces)
+ QTest::newRow(iface.name().toLocal8Bit()) << iface;
+}
+
+void tst_QNetworkInterface::interfaceFromXXX()
+{
+ QFETCH(QNetworkInterface, iface);
- foreach (QNetworkInterface iface, allInterfaces) {
- QVERIFY(QNetworkInterface::interfaceFromName(iface.name()).isValid());
- foreach (QNetworkAddressEntry entry, iface.addressEntries()) {
- QVERIFY(!entry.ip().isNull());
+ QVERIFY(QNetworkInterface::interfaceFromName(iface.name()).isValid());
+ foreach (QNetworkAddressEntry entry, iface.addressEntries()) {
+ QVERIFY(!entry.ip().isNull());
- if (!entry.netmask().isNull()) {
- QCOMPARE(entry.netmask().protocol(), entry.ip().protocol());
+ if (!entry.netmask().isNull()) {
+ QCOMPARE(entry.netmask().protocol(), entry.ip().protocol());
- // if the netmask is known, the broadcast is known
- // but only for IPv4 (there is no such thing as broadcast in IPv6)
- if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
- QVERIFY(!entry.broadcast().isNull());
+ // if the netmask is known, the broadcast is known
+ // but only for IPv4 (there is no such thing as broadcast in IPv6)
+ if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
+ QVERIFY(!entry.broadcast().isNull());
- // verify that the broadcast address is correct
- quint32 ip = entry.ip().toIPv4Address();
- quint32 mask = entry.netmask().toIPv4Address();
- quint32 bcast = entry.broadcast().toIPv4Address();
+ // verify that the broadcast address is correct
+ quint32 ip = entry.ip().toIPv4Address();
+ quint32 mask = entry.netmask().toIPv4Address();
+ quint32 bcast = entry.broadcast().toIPv4Address();
- QCOMPARE(bcast, ip | ~mask);
- }
+ QCOMPARE(bcast, ip | ~mask);
}
-
- if (!entry.broadcast().isNull())
- QCOMPARE(entry.broadcast().protocol(), entry.ip().protocol());
}
+
+ if (!entry.broadcast().isNull())
+ QCOMPARE(entry.broadcast().protocol(), entry.ip().protocol());
}
}
diff --git a/tests/auto/network/socket/platformsocketengine/BLACKLIST b/tests/auto/network/socket/platformsocketengine/BLACKLIST
new file mode 100644
index 0000000000..8e1a55995e
--- /dev/null
+++ b/tests/auto/network/socket/platformsocketengine/BLACKLIST
@@ -0,0 +1 @@
+windows
diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
index 9bd89cdf4f..71125f463a 100644
--- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
+++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
@@ -130,18 +130,18 @@ void tst_PlatformSocketEngine::construction()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.isValid());
- QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol);
- QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol);
+ QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
QVERIFY(socketDevice.socketDescriptor() != -1);
- QVERIFY(socketDevice.localAddress() == QHostAddress());
- QVERIFY(socketDevice.localPort() == 0);
- QVERIFY(socketDevice.peerAddress() == QHostAddress());
- QVERIFY(socketDevice.peerPort() == 0);
- QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
+ QCOMPARE(socketDevice.localAddress(), QHostAddress());
+ QCOMPARE(socketDevice.localPort(), quint16(0));
+ QCOMPARE(socketDevice.peerAddress(), QHostAddress());
+ QCOMPARE(socketDevice.peerPort(), quint16(0));
+ QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
- QVERIFY(socketDevice.bytesAvailable() == -1);
+ QCOMPARE(socketDevice.bytesAvailable(), -1);
QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
@@ -154,16 +154,16 @@ void tst_PlatformSocketEngine::simpleConnectToIMAP()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
const bool isConnected = socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143);
if (!isConnected) {
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
}
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -200,8 +200,8 @@ void tst_PlatformSocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
- QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//---------------------------------------------------------------------------
@@ -213,13 +213,13 @@ void tst_PlatformSocketEngine::udpLoopbackTest()
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
QVERIFY(udpSocket.isValid());
QVERIFY(udpSocket.socketDescriptor() != -1);
- QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol);
- QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket);
- QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol);
+ QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket);
+ QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState);
// Bind #1 to localhost
QVERIFY(udpSocket.bind(QHostAddress("127.0.0.1"), 0));
- QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
+ QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
quint16 port = udpSocket.localPort();
QVERIFY(port != 0);
@@ -229,7 +229,7 @@ void tst_PlatformSocketEngine::udpLoopbackTest()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(QHostAddress("127.0.0.1"), port));
- QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
// Write a message to #1
QByteArray message1 = "hei der";
@@ -243,13 +243,13 @@ void tst_PlatformSocketEngine::udpLoopbackTest()
QVERIFY(available > 0);
QByteArray answer;
answer.resize(available);
- QHostAddress senderAddress;
- quint16 senderPort = 0;
- QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(),
- &senderAddress,
- &senderPort) == message1.size());
- QVERIFY(senderAddress == QHostAddress("127.0.0.1"));
- QVERIFY(senderPort != 0);
+ QIpPacketHeader header;
+ QCOMPARE(udpSocket.readDatagram(answer.data(), answer.size(),
+ &header, QAbstractSocketEngine::WantDatagramSender),
+ qint64(message1.size()));
+ QVERIFY(header.senderAddress == QHostAddress("127.0.0.1"));
+ QCOMPARE(header.senderAddress, QHostAddress("127.0.0.1"));
+ QVERIFY(header.senderPort != 0);
}
//---------------------------------------------------------------------------
@@ -261,13 +261,13 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
bool init = udpSocket.initialize(QAbstractSocket::UdpSocket, QAbstractSocket::IPv6Protocol);
if (!init) {
- QVERIFY(udpSocket.error() == QAbstractSocket::UnsupportedSocketOperationError);
+ QCOMPARE(udpSocket.error(), QAbstractSocket::UnsupportedSocketOperationError);
} else {
- QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv6Protocol);
+ QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv6Protocol);
// Bind #1 to localhost
QVERIFY(udpSocket.bind(QHostAddress("::1"), 0));
- QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
+ QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
quint16 port = udpSocket.localPort();
QVERIFY(port != 0);
@@ -277,7 +277,7 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(QHostAddress("::1"), port));
- QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
// Write a message to #1
QByteArray message1 = "hei der";
@@ -291,13 +291,13 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
QVERIFY(available > 0);
QByteArray answer;
answer.resize(available);
- QHostAddress senderAddress;
- quint16 senderPort = 0;
- QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(),
- &senderAddress,
- &senderPort) == message1.size());
- QVERIFY(senderAddress == QHostAddress("::1"));
- QVERIFY(senderPort != 0);
+ QIpPacketHeader header;
+ QCOMPARE(udpSocket.readDatagram(answer.data(), answer.size(),
+ &header, QAbstractSocketEngine::WantDatagramSender),
+ qint64(message1.size()));
+ QVERIFY(header.senderAddress == QHostAddress("::1"));
+ QCOMPARE(header.senderAddress, QHostAddress("::1"));
+ QVERIFY(header.senderPort != 0);
}
}
@@ -314,7 +314,7 @@ void tst_PlatformSocketEngine::broadcastTest()
// Bind to any port on all interfaces
QVERIFY(broadcastSocket.bind(QHostAddress::Any, 0));
- QVERIFY(broadcastSocket.state() == QAbstractSocket::BoundState);
+ QCOMPARE(broadcastSocket.state(), QAbstractSocket::BoundState);
quint16 port = broadcastSocket.localPort();
QVERIFY(port > 0);
@@ -323,9 +323,9 @@ void tst_PlatformSocketEngine::broadcastTest()
= "MOOT wtf is a MOOT? talk english not your sutpiD ENGLISH.";
qint64 written = broadcastSocket.writeDatagram(trollMessage.data(),
trollMessage.size(),
- QHostAddress::Broadcast,
- port);
+ QIpPacketHeader(QHostAddress::Broadcast, port));
+ QVERIFY2(written != -1, qt_error_string().toLocal8Bit());
QCOMPARE((int)written, trollMessage.size());
// Wait until we receive it ourselves
@@ -354,20 +354,20 @@ void tst_PlatformSocketEngine::serverTest()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
- QVERIFY(server.state() == QAbstractSocket::BoundState);
+ QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
- QVERIFY(server.state() == QAbstractSocket::ListeningState);
+ QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
- QVERIFY(client.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
- QVERIFY(client.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
// The server accepts the connection
@@ -378,7 +378,7 @@ void tst_PlatformSocketEngine::serverTest()
// socket descriptor from accept(). It's pre-connected.
PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
- QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
// The server socket sends a greeting to the clietn
QByteArray greeting = "Greetings!";
@@ -407,13 +407,13 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance()
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
QVERIFY(udpSocket.isValid());
QVERIFY(udpSocket.socketDescriptor() != -1);
- QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol);
- QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket);
- QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol);
+ QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket);
+ QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState);
// Bind #1 to localhost
QVERIFY(udpSocket.bind(QHostAddress("127.0.0.1"), 0));
- QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
+ QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
quint16 port = udpSocket.localPort();
QVERIFY(port != 0);
@@ -423,7 +423,7 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(QHostAddress("127.0.0.1"), port));
- QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
const int messageSize = 8192;
QByteArray message1(messageSize, '@');
@@ -459,12 +459,12 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
- QVERIFY(server.state() == QAbstractSocket::BoundState);
+ QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
- QVERIFY(server.state() == QAbstractSocket::ListeningState);
+ QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
PLATFORMSOCKETENGINE client;
@@ -472,9 +472,9 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
// Connect to our server
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
- QVERIFY(client.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
- QVERIFY(client.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
// The server accepts the connection
@@ -485,7 +485,7 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
// socket descriptor from accept(). It's pre-connected.
PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
- QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
const int messageSize = 1024 * 256;
QByteArray message1(messageSize, '@');
@@ -562,7 +562,7 @@ void tst_PlatformSocketEngine::bind()
PLATFORMSOCKETENGINE binder;
QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder.bind(QHostAddress::AnyIPv4, 82));
- QVERIFY(binder.error() == QAbstractSocket::SocketAccessError);
+ QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError);
#endif
PLATFORMSOCKETENGINE binder2;
@@ -572,7 +572,7 @@ void tst_PlatformSocketEngine::bind()
PLATFORMSOCKETENGINE binder3;
QVERIFY(binder3.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder3.bind(QHostAddress::AnyIPv4, 31180));
- QVERIFY(binder3.error() == QAbstractSocket::AddressInUseError);
+ QCOMPARE(binder3.error(), QAbstractSocket::AddressInUseError);
if (QtNetworkSettings::hasIPv6()) {
PLATFORMSOCKETENGINE binder4;
@@ -582,7 +582,7 @@ void tst_PlatformSocketEngine::bind()
PLATFORMSOCKETENGINE binder5;
QVERIFY(binder5.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv6Protocol));
QVERIFY(!binder5.bind(QHostAddress::AnyIPv6, 31180));
- QVERIFY(binder5.error() == QAbstractSocket::AddressInUseError);
+ QCOMPARE(binder5.error(), QAbstractSocket::AddressInUseError);
}
PLATFORMSOCKETENGINE binder6;
@@ -599,11 +599,11 @@ void tst_PlatformSocketEngine::networkError()
const bool isConnected = client.connectToHost(QtNetworkSettings::serverIP(), 143);
if (!isConnected) {
- QVERIFY(client.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
- QVERIFY(client.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
- QVERIFY(client.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
// An unexpected network error!
#ifdef Q_OS_WINRT
@@ -636,7 +636,7 @@ void tst_PlatformSocketEngine::invalidSend()
QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::writeDatagram() was"
" called by a socket other than QAbstractSocket::UdpSocket");
- QCOMPARE(socket.writeDatagram("hei", 3, QHostAddress::LocalHost, 143),
+ QCOMPARE(socket.writeDatagram("hei", 3, QIpPacketHeader(QHostAddress::LocalHost, 143)),
(qlonglong) -1);
}
@@ -650,19 +650,19 @@ void tst_PlatformSocketEngine::receiveUrgentData()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
- QVERIFY(server.state() == QAbstractSocket::BoundState);
+ QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
QVERIFY(server.listen());
- QVERIFY(server.state() == QAbstractSocket::ListeningState);
+ QCOMPARE(server.state(), QAbstractSocket::ListeningState);
PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
- QVERIFY(client.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
- QVERIFY(client.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
int socketDescriptor = server.accept();
@@ -670,7 +670,7 @@ void tst_PlatformSocketEngine::receiveUrgentData()
PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
- QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
char msg;
int available;
diff --git a/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp b/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp
index 76c36831bd..1c79b6c016 100644
--- a/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp
+++ b/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp
@@ -37,11 +37,6 @@
#include <qcoreapplication.h>
#include <qdebug.h>
#include <qabstractsocket.h>
-#include <qtcpserver.h>
-#include <qtcpsocket.h>
-#ifndef QT_NO_SSL
-#include <qsslsocket.h>
-#endif
class tst_QAbstractSocket : public QObject
{
@@ -52,9 +47,7 @@ public:
virtual ~tst_QAbstractSocket();
private slots:
- void initTestCase();
void getSetCheck();
- void serverDisconnectWithBuffered();
};
tst_QAbstractSocket::tst_QAbstractSocket()
@@ -73,11 +66,6 @@ public:
void setPeerPort(quint16 port) { QAbstractSocket::setPeerPort(port); }
};
-void tst_QAbstractSocket::initTestCase()
-{
- qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
-}
-
// Testing get/set functions
void tst_QAbstractSocket::getSetCheck()
{
@@ -106,46 +94,5 @@ void tst_QAbstractSocket::getSetCheck()
QCOMPARE(quint16(0xffff), obj1.peerPort());
}
-// Test buffered socket being properly closed on remote disconnect
-void tst_QAbstractSocket::serverDisconnectWithBuffered()
-{
- QTcpServer tcpServer;
-#ifndef QT_NO_SSL
- QSslSocket testSocket;
-#else
- QTcpSocket testSocket;
-#endif
-
- QVERIFY(tcpServer.listen(QHostAddress::LocalHost));
- testSocket.connectToHost(tcpServer.serverAddress(), tcpServer.serverPort());
- // Accept connection on server side
- QVERIFY(tcpServer.waitForNewConnection(5000));
- QTcpSocket *newConnection = tcpServer.nextPendingConnection();
- // Send one char and drop link
- QVERIFY(newConnection != NULL);
- QVERIFY(newConnection->putChar(0));
- QVERIFY(newConnection->flush());
- delete newConnection;
-
- QVERIFY(testSocket.waitForConnected(5000)); // ready for write
- QVERIFY(testSocket.state() == QAbstractSocket::ConnectedState);
-
- QSignalSpy spyStateChanged(&testSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
- QSignalSpy spyDisconnected(&testSocket, SIGNAL(disconnected()));
-
- QVERIFY(testSocket.waitForReadyRead(5000)); // have one char already in internal buffer
- char buf[128];
- QCOMPARE(testSocket.read(buf, sizeof(buf)), Q_INT64_C(1));
- if (testSocket.state() != QAbstractSocket::UnconnectedState) {
- QVERIFY(testSocket.waitForDisconnected(5000));
- QVERIFY(testSocket.state() == QAbstractSocket::UnconnectedState);
- }
- // Test signal emitting
- QVERIFY(spyDisconnected.count() == 1);
- QVERIFY(spyStateChanged.count() > 0);
- QVERIFY(qvariant_cast<QAbstractSocket::SocketState>(spyStateChanged.last().first())
- == QAbstractSocket::UnconnectedState);
-}
-
QTEST_MAIN(tst_QAbstractSocket)
#include "tst_qabstractsocket.moc"
diff --git a/tests/auto/network/socket/qhttpsocketengine/BLACKLIST b/tests/auto/network/socket/qhttpsocketengine/BLACKLIST
new file mode 100644
index 0000000000..8e1a55995e
--- /dev/null
+++ b/tests/auto/network/socket/qhttpsocketengine/BLACKLIST
@@ -0,0 +1 @@
+windows
diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
index 10e8c95fc0..179cdb76bc 100644
--- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
+++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
@@ -164,18 +164,18 @@ void tst_QHttpSocketEngine::construction()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.isValid());
- QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol);
- QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol);
+ QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
// QVERIFY(socketDevice.socketDescriptor() != -1);
- QVERIFY(socketDevice.localAddress() == QHostAddress());
- QVERIFY(socketDevice.localPort() == 0);
- QVERIFY(socketDevice.peerAddress() == QHostAddress());
- QVERIFY(socketDevice.peerPort() == 0);
- QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
+ QCOMPARE(socketDevice.localAddress(), QHostAddress());
+ QCOMPARE(socketDevice.localPort(), quint16(0));
+ QCOMPARE(socketDevice.peerAddress(), QHostAddress());
+ QCOMPARE(socketDevice.peerPort(), quint16(0));
+ QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
- QVERIFY(socketDevice.bytesAvailable() == 0);
+ QCOMPARE(socketDevice.bytesAvailable(), 0);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
@@ -299,15 +299,15 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
QVERIFY(!socketDevice.localAddress().isNull());
QVERIFY(socketDevice.localPort() > 0);
@@ -345,8 +345,8 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.waitForRead());
char c;
QCOMPARE(socketDevice.read(&c, sizeof(c)), (qint64) -1);
- QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//---------------------------------------------------------------------------
@@ -360,14 +360,14 @@ void tst_QHttpSocketEngine::simpleErrorsAndStates()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverName()), 8088));
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
if (socketDevice.waitForWrite(30000)) {
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState ||
socketDevice.state() == QAbstractSocket::UnconnectedState);
} else {
- QVERIFY(socketDevice.error() == QAbstractSocket::SocketTimeoutError);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::SocketTimeoutError);
}
}
@@ -381,12 +381,12 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
- QVERIFY(server.state() == QAbstractSocket::BoundState);
+ QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
- QVERIFY(server.state() == QAbstractSocket::ListeningState);
+ QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
QHttpSocketEngine client;
@@ -408,7 +408,7 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance()
// socket descriptor from accept(). It's pre-connected.
QSocketLayer serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
- QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
const int messageSize = 1024 * 256;
QByteArray message1(messageSize, '@');
@@ -544,7 +544,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
- QVERIFY(tcpSocketNonBlocking_totalWritten == 8);
+ QCOMPARE(tcpSocketNonBlocking_totalWritten, 8);
QTestEventLoop::instance().enterLoop(30);
@@ -569,7 +569,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
- QVERIFY(tcpSocketNonBlocking_totalWritten == 10);
+ QCOMPARE(tcpSocketNonBlocking_totalWritten, 10);
// Wait for greeting
QTestEventLoop::instance().enterLoop(30);
@@ -637,7 +637,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
QFAIL("Network operation timed out");
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
- QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("Host: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
@@ -659,7 +659,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
QVERIFY(bytesAvailable >= 10000000);
- QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s",
bytesAvailable / (1024.0 * 1024.0),
@@ -689,15 +689,15 @@ void tst_QHttpSocketEngine::passwordAuth()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128, "qsockstest", "password"));
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -733,8 +733,8 @@ void tst_QHttpSocketEngine::passwordAuth()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
- QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//----------------------------------------------------------------------------------
diff --git a/tests/auto/network/socket/qlocalsocket/BLACKLIST b/tests/auto/network/socket/qlocalsocket/BLACKLIST
new file mode 100644
index 0000000000..11ddef30a5
--- /dev/null
+++ b/tests/auto/network/socket/qlocalsocket/BLACKLIST
@@ -0,0 +1,2 @@
+[processConnection:1 client]
+windows
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 4881d86937..847e065aa8 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -246,8 +246,8 @@ void tst_QLocalSocket::socket_basic()
QCOMPARE(socket.serverName(), QString());
QCOMPARE(socket.fullServerName(), QString());
socket.abort();
- QVERIFY(socket.bytesAvailable() == 0);
- QVERIFY(socket.bytesToWrite() == 0);
+ QCOMPARE(socket.bytesAvailable(), 0);
+ QCOMPARE(socket.bytesToWrite(), 0);
QCOMPARE(socket.canReadLine(), false);
socket.close();
socket.disconnectFromServer();
@@ -255,7 +255,7 @@ void tst_QLocalSocket::socket_basic()
QVERIFY(!socket.errorString().isEmpty());
QCOMPARE(socket.flush(), false);
QCOMPARE(socket.isValid(), false);
- QVERIFY(socket.readBufferSize() == 0);
+ QCOMPARE(socket.readBufferSize(), 0);
socket.setReadBufferSize(0);
//QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
QCOMPARE(socket.state(), QLocalSocket::UnconnectedState);
@@ -375,13 +375,13 @@ void tst_QLocalSocket::listenAndConnect()
QVERIFY(!socket->errorString().isEmpty());
QVERIFY(socket->error() != QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::UnconnectedState);
- //QVERIFY(socket->socketDescriptor() == -1);
+ //QCOMPARE(socket->socketDescriptor(), -1);
QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]),
QLocalSocket::ServerNotFoundError);
}
- QVERIFY(socket->bytesAvailable() == 0);
- QVERIFY(socket->bytesToWrite() == 0);
+ QCOMPARE(socket->bytesAvailable(), 0);
+ QCOMPARE(socket->bytesToWrite(), 0);
QCOMPARE(socket->canReadLine(), false);
QCOMPARE(socket->flush(), false);
QCOMPARE(socket->isValid(), canListen);
@@ -432,7 +432,7 @@ void tst_QLocalSocket::listenAndConnect()
} else {
QVERIFY(server.serverName().isEmpty());
QVERIFY(server.fullServerName().isEmpty());
- QVERIFY(server.nextPendingConnection() == (QLocalSocket*)0);
+ QCOMPARE(server.nextPendingConnection(), (QLocalSocket*)0);
QCOMPARE(spyNewConnection.count(), 0);
QCOMPARE(server.hits.count(), 0);
QVERIFY(!server.errorString().isEmpty());
@@ -616,7 +616,7 @@ void tst_QLocalSocket::readBufferOverflow()
QVERIFY(client.waitForReadyRead());
QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
// no more bytes available
- QVERIFY(client.bytesAvailable() == 0);
+ QCOMPARE(client.bytesAvailable(), 0);
}
// QLocalSocket/Server can take a name or path, check that it works as expected
@@ -912,7 +912,7 @@ void tst_QLocalSocket::waitForDisconnectByServer()
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
serverSocket->close();
- QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState);
+ QCOMPARE(serverSocket->state(), QLocalSocket::UnconnectedState);
QVERIFY(socket.waitForDisconnected(3000));
QCOMPARE(spy.count(), 1);
}
@@ -1197,11 +1197,12 @@ void tst_QLocalSocket::verifyListenWithDescriptor()
QVERIFY2(server.listen(listenSocket), "failed to start create QLocalServer with local socket");
#ifdef Q_OS_LINUX
+ const QChar at(QLatin1Char('@'));
if (!bound) {
- QVERIFY(server.serverName().at(0) == QLatin1Char('@'));
- QVERIFY(server.fullServerName().at(0) == QLatin1Char('@'));
+ QCOMPARE(server.serverName().at(0), at);
+ QCOMPARE(server.fullServerName().at(0), at);
} else if (abstract) {
- QVERIFY2(server.fullServerName().at(0) == QLatin1Char('@'), "abstract sockets should start with a '@'");
+ QVERIFY2(server.fullServerName().at(0) == at, "abstract sockets should start with a '@'");
} else {
QCOMPARE(server.fullServerName(), path);
if (path.contains(QLatin1String("/"))) {
diff --git a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
index bf4afa8c45..2a32a326d0 100644
--- a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
+++ b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
@@ -2,3 +2,5 @@
*
[passwordAuth]
*
+[serverTest]
+windows
diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
index 0ae9887773..8da656aab7 100644
--- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
+++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
@@ -193,18 +193,18 @@ void tst_QSocks5SocketEngine::construction()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.isValid());
- QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol);
- QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol);
+ QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
// QVERIFY(socketDevice.socketDescriptor() != -1);
- QVERIFY(socketDevice.localAddress() == QHostAddress());
- QVERIFY(socketDevice.localPort() == 0);
- QVERIFY(socketDevice.peerAddress() == QHostAddress());
- QVERIFY(socketDevice.peerPort() == 0);
- QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
+ QCOMPARE(socketDevice.localAddress(), QHostAddress());
+ QCOMPARE(socketDevice.localPort(), quint16(0));
+ QCOMPARE(socketDevice.peerAddress(), QHostAddress());
+ QCOMPARE(socketDevice.peerPort(), quint16(0));
+ QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
- QVERIFY(socketDevice.bytesAvailable() == 0);
+ QCOMPARE(socketDevice.bytesAvailable(), 0);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
@@ -334,15 +334,15 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -377,8 +377,8 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
- QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//---------------------------------------------------------------------------
@@ -392,14 +392,14 @@ void tst_QSocks5SocketEngine::simpleErrorsAndStates()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
QVERIFY(!socketDevice.connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first(), 8088));
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
if (socketDevice.waitForWrite(15000)) {
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState ||
socketDevice.state() == QAbstractSocket::ConnectedState);
} else {
- QVERIFY(socketDevice.error() == QAbstractSocket::SocketTimeoutError);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::SocketTimeoutError);
}
}
@@ -413,12 +413,12 @@ void tst_QSocks5SocketEngine::tcpLoopbackPerformance()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
- QVERIFY(server.state() == QAbstractSocket::BoundState);
+ QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
- QVERIFY(server.state() == QAbstractSocket::ListeningState);
+ QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
QSocks5SocketEngine client;
@@ -440,7 +440,7 @@ void tst_QSocks5SocketEngine::tcpLoopbackPerformance()
// socket descriptor from accept(). It's pre-connected.
QSocketLayer serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
- QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
const int messageSize = 1024 * 256;
QByteArray message1(messageSize, '@');
@@ -482,11 +482,11 @@ void tst_QSocks5SocketEngine::serverTest()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
- QVERIFY(server.state() == QAbstractSocket::BoundState);
+ QCOMPARE(server.state(), QAbstractSocket::BoundState);
// Listen for incoming connections
QVERIFY(server.listen());
- QVERIFY(server.state() == QAbstractSocket::ListeningState);
+ QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
QSocks5SocketEngine client;
@@ -501,7 +501,7 @@ void tst_QSocks5SocketEngine::serverTest()
if (!client.connectToHost(server.localAddress(), server.localPort())) {
QVERIFY(client.waitForWrite());
// QTest::wait(100); // ### timing problem on win32
- QVERIFY(client.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
//QTest::wait(100);
}
@@ -516,14 +516,14 @@ void tst_QSocks5SocketEngine::serverTest()
QSocks5SocketEngine serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
- QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
- QVERIFY(serverSocket.localAddress() == client.peerAddress());
- QVERIFY(serverSocket.localPort() == client.peerPort());
+ QCOMPARE(serverSocket.localAddress(), client.peerAddress());
+ QCOMPARE(serverSocket.localPort(), client.peerPort());
// this seems depends on the socks server implementation, especially
// when connecting /to/ the socks server /through/ the same socks server
- //QVERIFY(serverSocket.peerAddress() == client.localAddress());
- //QVERIFY(serverSocket.peerPort() == client.localPort());
+ //QCOMPARE(serverSocket.peerAddress(), client.localAddress());
+ //QCOMPARE(serverSocket.peerPort(), client.localPort());
// The server socket sends a greeting to the client
QByteArray greeting = "Greetings!";
@@ -557,16 +557,16 @@ void tst_QSocks5SocketEngine::udpTest()
udpSocket.setProxy(proxy);
- QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol);
- QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket);
- QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol);
+ QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket);
+ QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState);
// Bind #1
bool bindSuccessful = udpSocket.bind(QHostAddress("0.0.0.0"), 0);
if (!bindSuccessful)
QEXPECT_FAIL("", "QTBUG-23380 / QTBUG-35490: Fails on some Ubuntu 11.10 x64 configurations and on new network test server", Abort);
QVERIFY(bindSuccessful);
- QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
+ QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
QVERIFY(udpSocket.localPort() != 0);
// Initialize device #2
@@ -577,7 +577,7 @@ void tst_QSocks5SocketEngine::udpTest()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(udpSocket.localAddress(), udpSocket.localPort()));
- QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
// Write a message to #1
QByteArray message1 = "hei der";
@@ -591,13 +591,13 @@ void tst_QSocks5SocketEngine::udpTest()
QVERIFY(available > 0);
QByteArray answer;
answer.resize(available);
- QHostAddress senderAddress;
- quint16 senderPort = 0;
- QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(),
- &senderAddress,
- &senderPort) == message1.size());
- QVERIFY(senderAddress == udpSocket2.localAddress());
- QVERIFY(senderPort == udpSocket2.localPort());
+ QIpPacketHeader header;
+ QCOMPARE(udpSocket.readDatagram(answer.data(), answer.size(),
+ &header, QAbstractSocketEngine::WantDatagramSender),
+ qint64(message1.size()));
+ QVERIFY(header.senderAddress == udpSocket2.localAddress());
+ QCOMPARE(header.senderAddress, udpSocket2.localAddress());
+ QCOMPARE(header.senderPort, udpSocket2.localPort());
}
void tst_QSocks5SocketEngine::tcpSocketBlockingTest()
@@ -705,7 +705,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
- QVERIFY(tcpSocketNonBlocking_totalWritten == 8);
+ QCOMPARE(tcpSocketNonBlocking_totalWritten, 8);
QTestEventLoop::instance().enterLoop(30);
@@ -729,7 +729,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
- QVERIFY(tcpSocketNonBlocking_totalWritten == 10);
+ QCOMPARE(tcpSocketNonBlocking_totalWritten, 10);
// Wait for greeting
QTestEventLoop::instance().enterLoop(30);
@@ -797,7 +797,7 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QFAIL("Network operation timed out");
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
- QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
@@ -819,7 +819,7 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QCOMPARE(bytesAvailable, qint64(10000000));
- QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
/*qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s",
bytesAvailable / (1024.0 * 1024.0),
@@ -852,19 +852,19 @@ void tst_QSocks5SocketEngine::passwordAuth()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password"));
// Connect to imap.trolltech.com's IP
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
if (!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)) {
qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData());
}
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -899,8 +899,8 @@ void tst_QSocks5SocketEngine::passwordAuth()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
- QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//----------------------------------------------------------------------------------
@@ -918,21 +918,21 @@ void tst_QSocks5SocketEngine::passwordAuth2()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081));
socketDevice.setReceiver(this);
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
while (socketDevice.state() == QAbstractSocket::ConnectingState) {
QVERIFY(socketDevice.waitForWrite());
socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143);
}
if (socketDevice.state() != QAbstractSocket::ConnectedState)
qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData());
- QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
- QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
+ QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@@ -967,8 +967,8 @@ void tst_QSocks5SocketEngine::passwordAuth2()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
- QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
- QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
+ QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
void tst_QSocks5SocketEngine::fragmentation_data()
@@ -1017,7 +1017,7 @@ void tst_QSocks5SocketEngine::fragmentation()
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(socket.localAddress() == QHostAddress("1.2.3.4") || socket.localAddress() == QHostAddress("0123:4567:89ab:cdef:0123:4567:89ab:cdef"));
- QVERIFY(socket.localPort() == 0x0506);
+ QCOMPARE(socket.localPort(), quint16(0x0506));
}
void tst_QSocks5SocketEngine::incomplete_data()
diff --git a/tests/auto/network/socket/qtcpserver/BLACKLIST b/tests/auto/network/socket/qtcpserver/BLACKLIST
new file mode 100644
index 0000000000..f8b61808cc
--- /dev/null
+++ b/tests/auto/network/socket/qtcpserver/BLACKLIST
@@ -0,0 +1,13 @@
+windows
+[linkLocal]
+linux
+[listenWhileListening:WithSocks5Proxy]
+linux
+windows
+[ipv6Server:WithoutProxy]
+windows
+osx
+[clientServerLoop:WithSocks5Proxy]
+linux
+[crashTests:WithSocks5Proxy]
+linux
diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
index e0a6e3699d..5df5432cdd 100644
--- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
@@ -265,11 +265,11 @@ void tst_QTcpServer::ipv6Server()
//### need to enter the event loop for the server to get the connection ?? ( windows)
QTcpServer server;
if (!server.listen(QHostAddress::LocalHostIPv6, 8944)) {
- QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError);
+ QCOMPARE(server.serverError(), QAbstractSocket::UnsupportedSocketOperationError);
return;
}
- QVERIFY(server.serverPort() == 8944);
+ QCOMPARE(server.serverPort(), quint16(8944));
QVERIFY(server.serverAddress() == QHostAddress::LocalHostIPv6);
QTcpSocket client;
@@ -835,17 +835,17 @@ void tst_QTcpServer::qtbug14268_peek()
client.write("abc\n");
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(helper.lastDataPeeked == QByteArray("6162630a"));
+ QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a"));
client.write("def\n");
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a"));
+ QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a6465660a"));
client.write("ghi\n");
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a6768690a"));
+ QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a6465660a6768690a"));
}
void tst_QTcpServer::serverAddress_data()
diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro
index 3e64b87b53..325abcaab8 100644
--- a/tests/auto/network/socket/qtcpsocket/test/test.pro
+++ b/tests/auto/network/socket/qtcpsocket/test/test.pro
@@ -21,3 +21,5 @@ win32 {
} else {
DESTDIR = ../
}
+
+win32: CONFIG += insignificant_test # Hangs in release builds
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 0ba9b6a58c..abbc560414 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -200,6 +200,7 @@ private slots:
void setSocketOption();
void clientSendDataOnDelayedDisconnect();
+ void serverDisconnectWithBuffered();
protected slots:
void nonBlockingIMAP_hostFound();
@@ -241,7 +242,6 @@ private:
mutable int proxyAuthCalled;
- int numConnections;
static int loopLevel;
SocketPair *earlyConstructedSockets;
@@ -483,9 +483,9 @@ void tst_QTcpSocket::constructing()
QCOMPARE(socket->readLine(), QByteArray());
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
QCOMPARE((int) socket->localPort(), 0);
- QVERIFY(socket->localAddress() == QHostAddress());
+ QCOMPARE(socket->localAddress(), QHostAddress());
QCOMPARE((int) socket->peerPort(), 0);
- QVERIFY(socket->peerAddress() == QHostAddress());
+ QCOMPARE(socket->peerAddress(), QHostAddress());
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError);
QCOMPARE(socket->errorString(), QString("Unknown error"));
@@ -755,7 +755,7 @@ void tst_QTcpSocket::socketDescriptor()
QVERIFY(socket->state() == QAbstractSocket::HostLookupState ||
socket->state() == QAbstractSocket::ConnectingState);
QVERIFY(socket->waitForConnected(10000));
- QVERIFY(socket->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(socket->state(), QAbstractSocket::ConnectedState);
QVERIFY(socket->socketDescriptor() != -1);
delete socket;
@@ -936,7 +936,7 @@ void tst_QTcpSocket::nonBlockingIMAP()
QFAIL("Timed out");
}
- QVERIFY(nonBlockingIMAP_totalWritten == 8);
+ QCOMPARE(nonBlockingIMAP_totalWritten, 8);
enterLoop(30);
@@ -961,7 +961,7 @@ void tst_QTcpSocket::nonBlockingIMAP()
QFAIL("Timed out");
}
- QVERIFY(nonBlockingIMAP_totalWritten == 10);
+ QCOMPARE(nonBlockingIMAP_totalWritten, 10);
// Wait for greeting
enterLoop(30);
@@ -1086,7 +1086,7 @@ void tst_QTcpSocket::partialRead()
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForConnected(10000));
- QVERIFY(socket->state() == QTcpSocket::ConnectedState);
+ QCOMPARE(socket->state(), QTcpSocket::ConnectedState);
char buf[512];
QByteArray greeting = expectedReplyIMAP();
@@ -1110,7 +1110,7 @@ void tst_QTcpSocket::unget()
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForConnected(10000));
- QVERIFY(socket->state() == QTcpSocket::ConnectedState);
+ QCOMPARE(socket->state(), QTcpSocket::ConnectedState);
char buf[512];
QByteArray greeting = expectedReplyIMAP();
@@ -1168,7 +1168,7 @@ void tst_QTcpSocket::openCloseOpenClose()
QCOMPARE(int(socket->openMode()), int(QIODevice::NotOpen));
QVERIFY(socket->isSequential());
QVERIFY(!socket->isOpen());
- QVERIFY(socket->socketType() == QTcpSocket::TcpSocket);
+ QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket);
char c;
QCOMPARE(socket->getChar(&c), false);
@@ -1177,13 +1177,13 @@ void tst_QTcpSocket::openCloseOpenClose()
QCOMPARE(socket->readLine(), QByteArray());
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
QCOMPARE((int) socket->localPort(), 0);
- QVERIFY(socket->localAddress() == QHostAddress());
+ QCOMPARE(socket->localAddress(), QHostAddress());
QCOMPARE((int) socket->peerPort(), 0);
- QVERIFY(socket->peerAddress() == QHostAddress());
+ QCOMPARE(socket->peerAddress(), QHostAddress());
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError);
QCOMPARE(socket->errorString(), QString("Unknown error"));
- QVERIFY(socket->state() == QTcpSocket::UnconnectedState);
+ QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForConnected(10000));
@@ -1200,7 +1200,7 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect()
for (int i = 0; i < 3; ++i) {
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
- QVERIFY(socket->socketType() == QTcpSocket::TcpSocket);
+ QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket);
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForReadyRead(10000));
@@ -1260,7 +1260,7 @@ void tst_QTcpSocket::disconnectWhileConnecting()
connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot()));
enterLoop(10);
QVERIFY2(!timeout(), "Network timeout");
- QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
if (!closeDirectly) {
QCOMPARE(int(socket->openMode()), int(QIODevice::ReadWrite));
socket->close();
@@ -1272,7 +1272,7 @@ void tst_QTcpSocket::disconnectWhileConnecting()
QTcpSocket *othersocket = server.nextPendingConnection();
if (othersocket->state() != QAbstractSocket::UnconnectedState)
QVERIFY2(othersocket->waitForDisconnected(10000), "Network timeout");
- QVERIFY(othersocket->state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(othersocket->state(), QAbstractSocket::UnconnectedState);
QCOMPARE(othersocket->readAll(), data);
delete socket;
@@ -1375,7 +1375,7 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop()
}
QVERIFY2(socket->waitForDisconnected(10000), "Network timeout");
- QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
if (!closeDirectly) {
QCOMPARE(int(socket->openMode()), int(QIODevice::ReadWrite));
socket->close();
@@ -1414,10 +1414,10 @@ void tst_QTcpSocket::disconnectWhileLookingUp()
QFETCH(bool, doClose);
if (doClose) {
socket->close();
- QVERIFY(socket->openMode() == QIODevice::NotOpen);
+ QCOMPARE(socket->openMode(), QIODevice::NotOpen);
} else {
socket->disconnectFromHost();
- QVERIFY(socket->openMode() == QIODevice::ReadWrite);
+ QCOMPARE(socket->openMode(), QIODevice::ReadWrite);
QVERIFY(socket->waitForDisconnected(5000));
}
@@ -1428,12 +1428,12 @@ void tst_QTcpSocket::disconnectWhileLookingUp()
// recheck
if (doClose) {
- QVERIFY(socket->openMode() == QIODevice::NotOpen);
+ QCOMPARE(socket->openMode(), QIODevice::NotOpen);
} else {
- QVERIFY(socket->openMode() == QIODevice::ReadWrite);
+ QCOMPARE(socket->openMode(), QIODevice::ReadWrite);
}
- QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
}
//----------------------------------------------------------------------------------
@@ -1457,7 +1457,7 @@ void tst_QTcpSocket::downloadBigFile()
}
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
- QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
@@ -1830,7 +1830,6 @@ private slots:
}
#endif // !QT_NO_NETWORKPROXY
private:
- int exitCode;
QTcpSocket *socket;
QByteArray socketData;
};
@@ -2686,12 +2685,12 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
socket->connectToHost(QtNetworkSettings::serverName(), 443);
QVERIFY(socket->waitForConnected(5*1000));
- QVERIFY(socket->error() == QAbstractSocket::UnknownSocketError);
+ QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError);
// We connected to the HTTPS port. Wait two seconds to receive data. We will receive
// nothing because we would need to start the SSL handshake
QVERIFY(!socket->waitForReadyRead(2*1000));
- QVERIFY(socket->error() == QAbstractSocket::SocketTimeoutError);
+ QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError);
// Now write some crap to make the server disconnect us. 4 lines are enough.
socket->write("a\r\nb\r\nc\r\nd\r\n");
@@ -2701,7 +2700,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
// should get a better error since the server disconnected us
QVERIFY(!socket->waitForReadyRead(2*1000));
// It must NOT be the SocketTimeoutError that had been set before
- QVERIFY(socket->error() == QAbstractSocket::RemoteHostClosedError);
+ QCOMPARE(socket->error(), QAbstractSocket::RemoteHostClosedError);
}
#ifndef QT_NO_NETWORKPROXY
@@ -2895,25 +2894,25 @@ void tst_QTcpSocket::qtbug14268_peek()
QTcpSocket *outgoing = socketPair.endPoints[0];
QTcpSocket *incoming = socketPair.endPoints[1];
- QVERIFY(incoming->state() == QTcpSocket::ConnectedState);
- QVERIFY(outgoing->state() == QTcpSocket::ConnectedState);
+ QCOMPARE(incoming->state(), QTcpSocket::ConnectedState);
+ QCOMPARE(outgoing->state(), QTcpSocket::ConnectedState);
outgoing->write("abc\n");
QVERIFY(outgoing->waitForBytesWritten(2000));
QVERIFY(incoming->waitForReadyRead(2000));
- QVERIFY(incoming->peek(128*1024) == QByteArray("abc\n"));
+ QCOMPARE(incoming->peek(128*1024), QByteArray("abc\n"));
outgoing->write("def\n");
QVERIFY(outgoing->waitForBytesWritten(2000));
QVERIFY(incoming->waitForReadyRead(2000));
- QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\n"));
+ QCOMPARE(incoming->peek(128*1024), QByteArray("abc\ndef\n"));
outgoing->write("ghi\n");
QVERIFY(outgoing->waitForBytesWritten(2000));
QVERIFY(incoming->waitForReadyRead(2000));
- QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\nghi\n"));
+ QCOMPARE(incoming->peek(128*1024), QByteArray("abc\ndef\nghi\n"));
- QVERIFY(incoming->read(128*1024) == QByteArray("abc\ndef\nghi\n"));
+ QCOMPARE(incoming->read(128*1024), QByteArray("abc\ndef\nghi\n"));
}
void tst_QTcpSocket::setSocketOption()
@@ -2927,8 +2926,8 @@ void tst_QTcpSocket::setSocketOption()
QTcpSocket *outgoing = socketPair.endPoints[0];
QTcpSocket *incoming = socketPair.endPoints[1];
- QVERIFY(incoming->state() == QTcpSocket::ConnectedState);
- QVERIFY(outgoing->state() == QTcpSocket::ConnectedState);
+ QCOMPARE(incoming->state(), QTcpSocket::ConnectedState);
+ QCOMPARE(outgoing->state(), QTcpSocket::ConnectedState);
outgoing->setSocketOption(QAbstractSocket::LowDelayOption, true);
QVariant v = outgoing->socketOption(QAbstractSocket::LowDelayOption);
@@ -2984,5 +2983,50 @@ void tst_QTcpSocket::clientSendDataOnDelayedDisconnect()
delete socket;
}
+// Test buffered socket being properly closed on remote disconnect
+void tst_QTcpSocket::serverDisconnectWithBuffered()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
+
+ QTcpServer tcpServer;
+ QTcpSocket *socket = newSocket();
+
+ QVERIFY(tcpServer.listen(QHostAddress::LocalHost));
+ socket->connectToHost(tcpServer.serverAddress(), tcpServer.serverPort());
+ // Accept connection on server side
+ QVERIFY(tcpServer.waitForNewConnection(5000));
+ QTcpSocket *newConnection = tcpServer.nextPendingConnection();
+ // Send one char and drop link
+ QVERIFY(newConnection != NULL);
+ QVERIFY(newConnection->putChar(0));
+ QVERIFY(newConnection->flush());
+ delete newConnection;
+
+ QVERIFY(socket->waitForConnected(5000)); // ready for write
+ QCOMPARE(socket->state(), QAbstractSocket::ConnectedState);
+
+ QSignalSpy spyStateChanged(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
+ QSignalSpy spyDisconnected(socket, SIGNAL(disconnected()));
+
+ QVERIFY(socket->waitForReadyRead(5000)); // have one char already in internal buffer
+ char buf[128];
+ QCOMPARE(socket->read(buf, sizeof(buf)), Q_INT64_C(1));
+ if (socket->state() != QAbstractSocket::UnconnectedState) {
+ QVERIFY(socket->waitForDisconnected(5000));
+ QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
+ }
+ // Test signal emitting
+ QCOMPARE(spyDisconnected.count(), 1);
+ QVERIFY(spyStateChanged.count() > 0);
+ QVERIFY(qvariant_cast<QAbstractSocket::SocketState>(spyStateChanged.last().first())
+ == QAbstractSocket::UnconnectedState);
+
+ delete socket;
+}
+
QTEST_MAIN(tst_QTcpSocket)
#include "tst_qtcpsocket.moc"
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index 6f96e6d6f5..0ee3255502 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -56,7 +56,6 @@
#endif
Q_DECLARE_METATYPE(QHostAddress)
-Q_DECLARE_METATYPE(QNetworkInterface)
QT_FORWARD_DECLARE_CLASS(QUdpSocket)
@@ -228,7 +227,7 @@ void tst_QUdpSocket::constructing()
QVERIFY(socket.isSequential());
QVERIFY(!socket.isOpen());
- QVERIFY(socket.socketType() == QUdpSocket::UdpSocket);
+ QCOMPARE(socket.socketType(), QUdpSocket::UdpSocket);
QCOMPARE((int) socket.bytesAvailable(), 0);
QCOMPARE(socket.canReadLine(), false);
QCOMPARE(socket.readLine(), QByteArray());
@@ -754,7 +753,7 @@ void tst_QUdpSocket::writeDatagram()
QCOMPARE(client.error(), QUdpSocket::DatagramTooLargeError);
break;
}
- QVERIFY(bytesspy.count() == 1);
+ QCOMPARE(bytesspy.count(), 1);
QCOMPARE(*static_cast<const qint64 *>(bytesspy.at(0).at(0).constData()),
qint64(i * 1024));
QCOMPARE(errorspy.count(), 0);
diff --git a/tests/auto/network/ssl/qsslcertificate/BLACKLIST b/tests/auto/network/ssl/qsslcertificate/BLACKLIST
new file mode 100644
index 0000000000..2e376fa2a9
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/BLACKLIST
@@ -0,0 +1,3 @@
+# OpenSSL version is too new. Rich will fix :)
+[subjectAndIssuerAttributes]
+osx
diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
index 748c240f3d..4c288fffaf 100644
--- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
@@ -775,7 +775,7 @@ void tst_QSslCertificate::certInfo()
QVERIFY(cert.expiryDate() < QDateTime::currentDateTime()); // cert has expired
QSslCertificate copy = cert;
- QVERIFY(cert == copy);
+ QCOMPARE(cert, copy);
QVERIFY(!(cert != copy));
QCOMPARE(cert, QSslCertificate(pem, QSsl::Pem));
@@ -833,6 +833,9 @@ void tst_QSslCertificate::task256066toPem()
void tst_QSslCertificate::nulInCN()
{
+#ifdef QT_SECURETRANSPORT
+ QSKIP("Generic QSslCertificatePrivate fails this test");
+#endif
QList<QSslCertificate> certList =
QSslCertificate::fromPath(testDataDir + "/more-certificates/badguy-nul-cn.crt");
QCOMPARE(certList.size(), 1);
@@ -849,6 +852,9 @@ void tst_QSslCertificate::nulInCN()
void tst_QSslCertificate::nulInSan()
{
+#ifdef QT_SECURETRANSPORT
+ QSKIP("Generic QSslCertificatePrivate fails this test");
+#endif
QList<QSslCertificate> certList =
QSslCertificate::fromPath(testDataDir + "/more-certificates/badguy-nul-san.crt");
QCOMPARE(certList.size(), 1);
@@ -976,6 +982,9 @@ void tst_QSslCertificate::subjectAndIssuerAttributes()
void tst_QSslCertificate::verify()
{
+#ifdef QT_SECURETRANSPORT
+ QSKIP("Not implemented in SecureTransport");
+#endif
QList<QSslError> errors;
QList<QSslCertificate> toVerify;
@@ -1069,7 +1078,7 @@ void tst_QSslCertificate::extensions()
QSslCertificate cert = certList[0];
QList<QSslCertificateExtension> extensions = cert.extensions();
- QVERIFY(extensions.count() == 9);
+ QCOMPARE(extensions.count(), 9);
int unknown_idx = -1;
int authority_info_idx = -1;
@@ -1101,8 +1110,8 @@ void tst_QSslCertificate::extensions()
// Unknown
QSslCertificateExtension unknown = extensions[unknown_idx];
- QVERIFY(unknown.oid() == QStringLiteral("1.3.6.1.5.5.7.1.12"));
- QVERIFY(unknown.name() == QStringLiteral("1.3.6.1.5.5.7.1.12"));
+ QCOMPARE(unknown.oid(), QStringLiteral("1.3.6.1.5.5.7.1.12"));
+ QCOMPARE(unknown.name(), QStringLiteral("1.3.6.1.5.5.7.1.12"));
QVERIFY(!unknown.isCritical());
QVERIFY(!unknown.isSupported());
@@ -1114,8 +1123,8 @@ void tst_QSslCertificate::extensions()
// Authority Info Access
QSslCertificateExtension aia = extensions[authority_info_idx];
- QVERIFY(aia.oid() == QStringLiteral("1.3.6.1.5.5.7.1.1"));
- QVERIFY(aia.name() == QStringLiteral("authorityInfoAccess"));
+ QCOMPARE(aia.oid(), QStringLiteral("1.3.6.1.5.5.7.1.1"));
+ QCOMPARE(aia.name(), QStringLiteral("authorityInfoAccess"));
QVERIFY(!aia.isCritical());
QVERIFY(aia.isSupported());
@@ -1124,32 +1133,32 @@ void tst_QSslCertificate::extensions()
QString ocsp = aiaValue[QStringLiteral("OCSP")].toString();
QString caIssuers = aiaValue[QStringLiteral("caIssuers")].toString();
- QVERIFY(ocsp == QStringLiteral("http://EVIntl-ocsp.verisign.com"));
- QVERIFY(caIssuers == QStringLiteral("http://EVIntl-aia.verisign.com/EVIntl2006.cer"));
+ QCOMPARE(ocsp, QStringLiteral("http://EVIntl-ocsp.verisign.com"));
+ QCOMPARE(caIssuers, QStringLiteral("http://EVIntl-aia.verisign.com/EVIntl2006.cer"));
// Basic constraints
QSslCertificateExtension basic = extensions[basic_constraints_idx];
- QVERIFY(basic.oid() == QStringLiteral("2.5.29.19"));
- QVERIFY(basic.name() == QStringLiteral("basicConstraints"));
+ QCOMPARE(basic.oid(), QStringLiteral("2.5.29.19"));
+ QCOMPARE(basic.name(), QStringLiteral("basicConstraints"));
QVERIFY(!basic.isCritical());
QVERIFY(basic.isSupported());
QVariantMap basicValue = basic.value().toMap();
QCOMPARE(basicValue.keys(), QList<QString>() << QStringLiteral("ca"));
- QVERIFY(basicValue[QStringLiteral("ca")].toBool() == false);
+ QVERIFY(!basicValue[QStringLiteral("ca")].toBool());
// Subject key identifier
QSslCertificateExtension subjectKey = extensions[subject_key_idx];
- QVERIFY(subjectKey.oid() == QStringLiteral("2.5.29.14"));
- QVERIFY(subjectKey.name() == QStringLiteral("subjectKeyIdentifier"));
+ QCOMPARE(subjectKey.oid(), QStringLiteral("2.5.29.14"));
+ QCOMPARE(subjectKey.name(), QStringLiteral("subjectKeyIdentifier"));
QVERIFY(!subjectKey.isCritical());
QVERIFY(subjectKey.isSupported());
- QVERIFY(subjectKey.value().toString() == QStringLiteral("5F:90:23:CD:24:CA:52:C9:36:29:F0:7E:9D:B1:FE:08:E0:EE:69:F0"));
+ QCOMPARE(subjectKey.value().toString(), QStringLiteral("5F:90:23:CD:24:CA:52:C9:36:29:F0:7E:9D:B1:FE:08:E0:EE:69:F0"));
// Authority key identifier
QSslCertificateExtension authKey = extensions[auth_key_idx];
- QVERIFY(authKey.oid() == QStringLiteral("2.5.29.35"));
- QVERIFY(authKey.name() == QStringLiteral("authorityKeyIdentifier"));
+ QCOMPARE(authKey.oid(), QStringLiteral("2.5.29.35"));
+ QCOMPARE(authKey.name(), QStringLiteral("authorityKeyIdentifier"));
QVERIFY(!authKey.isCritical());
QVERIFY(authKey.isSupported());
@@ -1167,7 +1176,7 @@ void tst_QSslCertificate::extensionsCritical()
QSslCertificate cert = certList[0];
QList<QSslCertificateExtension> extensions = cert.extensions();
- QVERIFY(extensions.count() == 9);
+ QCOMPARE(extensions.count(), 9);
int basic_constraints_idx = -1;
int key_usage_idx = -1;
@@ -1186,19 +1195,19 @@ void tst_QSslCertificate::extensionsCritical()
// Basic constraints
QSslCertificateExtension basic = extensions[basic_constraints_idx];
- QVERIFY(basic.oid() == QStringLiteral("2.5.29.19"));
- QVERIFY(basic.name() == QStringLiteral("basicConstraints"));
+ QCOMPARE(basic.oid(), QStringLiteral("2.5.29.19"));
+ QCOMPARE(basic.name(), QStringLiteral("basicConstraints"));
QVERIFY(basic.isCritical());
QVERIFY(basic.isSupported());
QVariantMap basicValue = basic.value().toMap();
QCOMPARE(basicValue.keys(), QList<QString>() << QStringLiteral("ca"));
- QVERIFY(basicValue[QStringLiteral("ca")].toBool() == false);
+ QVERIFY(!basicValue[QStringLiteral("ca")].toBool());
// Key Usage
QSslCertificateExtension keyUsage = extensions[key_usage_idx];
- QVERIFY(keyUsage.oid() == QStringLiteral("2.5.29.15"));
- QVERIFY(keyUsage.name() == QStringLiteral("keyUsage"));
+ QCOMPARE(keyUsage.oid(), QStringLiteral("2.5.29.15"));
+ QCOMPARE(keyUsage.name(), QStringLiteral("keyUsage"));
QVERIFY(keyUsage.isCritical());
QVERIFY(!keyUsage.isSupported());
}
@@ -1257,21 +1266,21 @@ void tst_QSslCertificate::threadSafeConstMethods()
t2.start();
QVERIFY(t1.wait(5000));
QVERIFY(t2.wait(5000));
- QVERIFY(t1.cert == t2.cert);
- QVERIFY(t1.effectiveDate == t2.effectiveDate);
- QVERIFY(t1.expiryDate == t2.expiryDate);
+ QCOMPARE(t1.cert, t2.cert);
+ QCOMPARE(t1.effectiveDate, t2.effectiveDate);
+ QCOMPARE(t1.expiryDate, t2.expiryDate);
//QVERIFY(t1.extensions == t2.extensions); // no equality operator, so not tested
- QVERIFY(t1.isBlacklisted == t2.isBlacklisted);
- QVERIFY(t1.issuerInfo == t2.issuerInfo);
- QVERIFY(t1.issuerInfoAttributes == t2.issuerInfoAttributes);
- QVERIFY(t1.publicKey == t2.publicKey);
- QVERIFY(t1.serialNumber == t2.serialNumber);
- QVERIFY(t1.subjectInfo == t2.subjectInfo);
- QVERIFY(t1.subjectInfoAttributes == t2.subjectInfoAttributes);
- QVERIFY(t1.toDer == t2.toDer);
- QVERIFY(t1.toPem == t2.toPem);
- QVERIFY(t1.toText == t2.toText);
- QVERIFY(t1.version == t2.version);
+ QCOMPARE(t1.isBlacklisted, t2.isBlacklisted);
+ QCOMPARE(t1.issuerInfo, t2.issuerInfo);
+ QCOMPARE(t1.issuerInfoAttributes, t2.issuerInfoAttributes);
+ QCOMPARE(t1.publicKey, t2.publicKey);
+ QCOMPARE(t1.serialNumber, t2.serialNumber);
+ QCOMPARE(t1.subjectInfo, t2.subjectInfo);
+ QCOMPARE(t1.subjectInfoAttributes, t2.subjectInfoAttributes);
+ QCOMPARE(t1.toDer, t2.toDer);
+ QCOMPARE(t1.toPem, t2.toPem);
+ QCOMPARE(t1.toText, t2.toText);
+ QCOMPARE(t1.version, t2.version);
}
diff --git a/tests/auto/network/ssl/qsslkey/BLACKLIST b/tests/auto/network/ssl/qsslkey/BLACKLIST
new file mode 100644
index 0000000000..a08e1f35eb
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/BLACKLIST
@@ -0,0 +1 @@
+linux
diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
index d570037015..a7957d3288 100644
--- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
+++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
@@ -39,7 +39,7 @@
#include <QtNetwork/qhostaddress.h>
#include <QtNetwork/qnetworkproxy.h>
-#if !defined(QT_NO_SSL) && defined(QT_NO_OPENSSL) && defined(QT_BUILD_INTERNAL)
+#if !defined(QT_NO_SSL) && defined(QT_BUILD_INTERNAL)
#include "private/qsslkey_p.h"
#define TEST_CRYPTO
#endif
diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST
index 17b606e2be..4146a352e9 100644
--- a/tests/auto/network/ssl/qsslsocket/BLACKLIST
+++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST
@@ -1,2 +1,3 @@
+windows
[waitForConnectedEncryptedReadyRead:WithSocks5ProxyAuth]
*
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index b95b72a41e..c7d655af3d 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -170,6 +170,9 @@ private slots:
void protocol();
void protocolServerSide_data();
void protocolServerSide();
+#ifndef QT_NO_OPENSSL
+ void serverCipherPreferences();
+#endif // QT_NO_OPENSSL
void setCaCertificates();
void setLocalCertificate();
void localCertificateChain();
@@ -817,7 +820,7 @@ void tst_QSslSocket::peerCertificateChain()
this->socket = socket.data();
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
- QVERIFY(caCertificates.count() == 1);
+ QCOMPARE(caCertificates.count(), 1);
socket->addCaCertificates(caCertificates);
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)),
@@ -863,7 +866,7 @@ void tst_QSslSocket::peerCertificateChain()
QSKIP("Skipping flaky test - See QTBUG-29941");
QCOMPARE(socket->peerCertificateChain().first(), socket->peerCertificate());
- QVERIFY(socket->peerCertificateChain() == certChain);
+ QCOMPARE(socket->peerCertificateChain(), certChain);
socket->disconnectFromHost();
QVERIFY(socket->waitForDisconnected());
@@ -1063,6 +1066,7 @@ public:
const QString &certFile = SRCDIR "certs/fluke.cert",
const QString &interFile = QString())
: socket(0),
+ config(QSslConfiguration::defaultConfiguration()),
ignoreSslErrors(true),
peerVerifyMode(QSslSocket::AutoVerifyPeer),
protocol(QSsl::TlsV1_0),
@@ -1071,6 +1075,7 @@ public:
m_interFile(interFile)
{ }
QSslSocket *socket;
+ QSslConfiguration config;
QString addCaCertificates;
bool ignoreSslErrors;
QSslSocket::PeerVerifyMode peerVerifyMode;
@@ -1084,6 +1089,7 @@ protected:
void incomingConnection(qintptr socketDescriptor)
{
socket = new QSslSocket(this);
+ socket->setSslConfiguration(config);
socket->setPeerVerifyMode(peerVerifyMode);
socket->setProtocol(protocol);
if (ignoreSslErrors)
@@ -1254,6 +1260,78 @@ void tst_QSslSocket::protocolServerSide()
QCOMPARE(client->isEncrypted(), works);
}
+#ifndef QT_NO_OPENSSL
+
+void tst_QSslSocket::serverCipherPreferences()
+{
+ if (!QSslSocket::supportsSsl()) {
+ qWarning("SSL not supported, skipping test");
+ return;
+ }
+
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ // First using the default (server preference)
+ {
+ SslServer server;
+ server.ciphers = QString("AES128-SHA:AES256-SHA");
+ QVERIFY(server.listen());
+
+ QEventLoop loop;
+ QTimer::singleShot(5000, &loop, SLOT(quit()));
+
+ QSslSocketPtr client(new QSslSocket);
+ socket = client.data();
+ socket->setCiphers("AES256-SHA:AES128-SHA");
+
+ // upon SSL wrong version error, error will be triggered, not sslErrors
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
+ connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
+ connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
+
+ client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
+
+ loop.exec();
+
+ QVERIFY(client->isEncrypted());
+ QCOMPARE(client->sessionCipher().name(), QString("AES128-SHA"));
+ }
+
+ {
+ // Now using the client preferences
+ SslServer server;
+ QSslConfiguration config = QSslConfiguration::defaultConfiguration();
+ config.setSslOption(QSsl::SslOptionDisableServerCipherPreference, true);
+ server.config = config;
+ server.ciphers = QString("AES128-SHA:AES256-SHA");
+ QVERIFY(server.listen());
+
+ QEventLoop loop;
+ QTimer::singleShot(5000, &loop, SLOT(quit()));
+
+ QSslSocketPtr client(new QSslSocket);
+ socket = client.data();
+ socket->setCiphers("AES256-SHA:AES128-SHA");
+
+ // upon SSL wrong version error, error will be triggered, not sslErrors
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
+ connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
+ connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
+
+ client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
+
+ loop.exec();
+
+ QVERIFY(client->isEncrypted());
+ QCOMPARE(client->sessionCipher().name(), QString("AES256-SHA"));
+ }
+}
+
+#endif // QT_NO_OPENSSL
+
+
void tst_QSslSocket::setCaCertificates()
{
if (!QSslSocket::supportsSsl())
@@ -1655,7 +1733,7 @@ void tst_QSslSocket::spontaneousWrite()
QSslSocket *sender = server.socket;
QVERIFY(sender);
- QVERIFY(sender->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(sender->state(), QAbstractSocket::ConnectedState);
receiver->setObjectName("receiver");
sender->setObjectName("sender");
receiver->ignoreSslErrors();
@@ -1700,7 +1778,7 @@ void tst_QSslSocket::setReadBufferSize()
QSslSocket *sender = server.socket;
QVERIFY(sender);
- QVERIFY(sender->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(sender->state(), QAbstractSocket::ConnectedState);
receiver->setObjectName("receiver");
sender->setObjectName("sender");
receiver->ignoreSslErrors();
@@ -2254,7 +2332,7 @@ void tst_QSslSocket::readFromClosedSocket()
socket->close();
QVERIFY(!socket->bytesAvailable());
QVERIFY(!socket->bytesToWrite());
- QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
+ QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
}
void tst_QSslSocket::writeBigChunk()
@@ -2281,7 +2359,7 @@ void tst_QSslSocket::writeBigChunk()
QString errorBefore = socket->errorString();
int ret = socket->write(data.constData(), data.size());
- QVERIFY(data.size() == ret);
+ QCOMPARE(data.size(), ret);
// spin the event loop once so QSslSocket::transmit() gets called
QCoreApplication::processEvents();
@@ -2298,7 +2376,7 @@ void tst_QSslSocket::writeBigChunk()
QByteArray("unexpected error: ").append(qPrintable(errorAfter)));
// check that everything has been written to OpenSSL
- QVERIFY(socket->bytesToWrite() == 0);
+ QCOMPARE(socket->bytesToWrite(), 0);
socket->close();
}
@@ -2322,7 +2400,7 @@ void tst_QSslSocket::blacklistedCertificates()
QSslSocket *sender = server.socket;
QVERIFY(sender);
- QVERIFY(sender->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(sender->state(), QAbstractSocket::ConnectedState);
receiver->setObjectName("receiver");
sender->setObjectName("sender");
receiver->startClientEncryption();
@@ -2354,28 +2432,28 @@ void tst_QSslSocket::sslOptions()
#ifdef SSL_OP_NO_COMPRESSION
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSslConfigurationPrivate::defaultSslOptions),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION|SSL_OP_CIPHER_SERVER_PREFERENCE));
#else
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSslConfigurationPrivate::defaultSslOptions),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_CIPHER_SERVER_PREFERENCE));
#endif
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableEmptyFragments
|QSsl::SslOptionDisableLegacyRenegotiation),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_CIPHER_SERVER_PREFERENCE));
#ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableEmptyFragments),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION|SSL_OP_CIPHER_SERVER_PREFERENCE)));
#endif
#ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableLegacyRenegotiation),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_CIPHER_SERVER_PREFERENCE) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS));
#endif
#ifdef SSL_OP_NO_TICKET
@@ -2383,7 +2461,7 @@ void tst_QSslSocket::sslOptions()
QSsl::SslOptionDisableEmptyFragments
|QSsl::SslOptionDisableLegacyRenegotiation
|QSsl::SslOptionDisableSessionTickets),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_CIPHER_SERVER_PREFERENCE)));
#endif
#ifdef SSL_OP_NO_TICKET
@@ -2393,7 +2471,7 @@ void tst_QSslSocket::sslOptions()
|QSsl::SslOptionDisableLegacyRenegotiation
|QSsl::SslOptionDisableSessionTickets
|QSsl::SslOptionDisableCompression),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION|SSL_OP_CIPHER_SERVER_PREFERENCE)));
#endif
#endif
}
@@ -2648,9 +2726,9 @@ void tst_QSslSocket::qtbug18498_peek2()
while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
char c;
- QVERIFY(client->peek(&c,1) == 1);
+ QCOMPARE(client->peek(&c,1), 1);
QCOMPARE(c, 'H');
- QVERIFY(client->read(&c,1) == 1);
+ QCOMPARE(client->read(&c,1), 1);
QCOMPARE(c, 'H');
QByteArray b = client->peek(2);
QCOMPARE(b, QByteArray("EL"));
@@ -2686,7 +2764,7 @@ void tst_QSslSocket::qtbug18498_peek2()
// ### Qt5 use QTRY_VERIFY
while (server->bytesAvailable() < 10 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
- QVERIFY(server->peek(&c,1) == 1);
+ QCOMPARE(server->peek(&c,1), 1);
QCOMPARE(c, 'S');
b = server->peek(3);
QCOMPARE(b, QByteArray("STA"));
@@ -2722,9 +2800,9 @@ void tst_QSslSocket::qtbug18498_peek2()
while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
QVERIFY(server->mode() == QSslSocket::SslServerMode && client->mode() == QSslSocket::SslClientMode);
- QVERIFY(client->peek(&c,1) == 1);
+ QCOMPARE(client->peek(&c,1), 1);
QCOMPARE(c, 'h');
- QVERIFY(client->read(&c,1) == 1);
+ QCOMPARE(client->read(&c,1), 1);
QCOMPARE(c, 'h');
b = client->peek(2);
QCOMPARE(b, QByteArray("el"));
@@ -2734,7 +2812,7 @@ void tst_QSslSocket::qtbug18498_peek2()
stopwatch.start();
while (server->bytesAvailable() < 9 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
- QVERIFY(server->peek(&c,1) == 1);
+ QCOMPARE(server->peek(&c,1), 1);
QCOMPARE(c, 'g');
QCOMPARE(server->readAll(), QByteArray("goodbye\r\n"));
client->disconnectFromHost();
@@ -2768,7 +2846,7 @@ void tst_QSslSocket::dhServer()
client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
loop.exec();
- QVERIFY(client->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client->state(), QAbstractSocket::ConnectedState);
}
void tst_QSslSocket::ecdhServer()
@@ -2798,7 +2876,7 @@ void tst_QSslSocket::ecdhServer()
client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
loop.exec();
- QVERIFY(client->state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(client->state(), QAbstractSocket::ConnectedState);
}
void tst_QSslSocket::verifyClientCertificate_data()
diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/BLACKLIST b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/BLACKLIST
new file mode 100644
index 0000000000..c9b628d79b
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/BLACKLIST
@@ -0,0 +1,2 @@
+[onDemandRootCertLoadingMemberMethods]
+linux
diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/BLACKLIST b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/BLACKLIST
new file mode 100644
index 0000000000..52bd2bc86d
--- /dev/null
+++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/BLACKLIST
@@ -0,0 +1,2 @@
+[onDemandRootCertLoadingStaticMethods:WithSocks5ProxyAuth]
+windows
diff --git a/tests/auto/opengl/qgl/BLACKLIST b/tests/auto/opengl/qgl/BLACKLIST
new file mode 100644
index 0000000000..fa7c829b30
--- /dev/null
+++ b/tests/auto/opengl/qgl/BLACKLIST
@@ -0,0 +1,16 @@
+[glWidgetRendering]
+windows
+[glFBORendering]
+windows
+[multipleFBOInterleavedRendering]
+windows
+[glPBufferRendering]
+windows
+[replaceClipping]
+windows
+[clipTest]
+windows
+[graphicsViewClipping]
+windows
+[glFBOUseInGLWidget]
+windows
diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp
index 9bd82559b7..7970725355 100644
--- a/tests/auto/opengl/qgl/tst_qgl.cpp
+++ b/tests/auto/opengl/qgl/tst_qgl.cpp
@@ -459,113 +459,113 @@ void tst_QGL::getSetCheck()
QGLFormat format1;
QGLFormat format2;
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setDoubleBuffer(false);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setDoubleBuffer(false);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setDepthBufferSize(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setDepthBufferSize(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setAccumBufferSize(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setAccumBufferSize(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setRedBufferSize(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setRedBufferSize(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setGreenBufferSize(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setGreenBufferSize(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setBlueBufferSize(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setBlueBufferSize(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setAlphaBufferSize(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setAlphaBufferSize(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setStencilBufferSize(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setStencilBufferSize(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setSamples(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setSamples(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setSwapInterval(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setSwapInterval(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setPlane(8);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setPlane(8);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setVersion(3, 2);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setVersion(3, 2);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setProfile(QGLFormat::CoreProfile);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setProfile(QGLFormat::CoreProfile);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
format1.setOption(QGL::NoDeprecatedFunctions);
QVERIFY(!(format1 == format2));
QVERIFY(format1 != format2);
format2.setOption(QGL::NoDeprecatedFunctions);
- QVERIFY(format1 == format2);
+ QCOMPARE(format1, format2);
QVERIFY(!(format1 != format2));
// Copy constructor and assignment for QGLFormat.
QGLFormat format3(format1);
QGLFormat format4;
- QVERIFY(format1 == format3);
+ QCOMPARE(format1, format3);
QVERIFY(format1 != format4);
format4 = format1;
- QVERIFY(format1 == format4);
+ QCOMPARE(format1, format4);
// Check that modifying a copy doesn't affect the original.
format3.setRedBufferSize(16);
@@ -584,15 +584,15 @@ void tst_QGL::getSetCheck()
QCOMPARE(format5.plane(), 3);
// The default format should be the same as QGLFormat().
- QVERIFY(QGLFormat::defaultFormat() == QGLFormat());
+ QCOMPARE(QGLFormat::defaultFormat(), QGLFormat());
// Modify the default format and check that it was changed.
QGLFormat::setDefaultFormat(format1);
- QVERIFY(QGLFormat::defaultFormat() == format1);
+ QCOMPARE(QGLFormat::defaultFormat(), format1);
// Restore the default format.
QGLFormat::setDefaultFormat(QGLFormat());
- QVERIFY(QGLFormat::defaultFormat() == QGLFormat());
+ QCOMPARE(QGLFormat::defaultFormat(), QGLFormat());
// Check the default overlay format's expected values.
QGLFormat overlay(QGLFormat::defaultOverlayFormat());
@@ -618,11 +618,11 @@ void tst_QGL::getSetCheck()
// Modify the default overlay format and check that it was changed.
QGLFormat::setDefaultOverlayFormat(format1);
- QVERIFY(QGLFormat::defaultOverlayFormat() == format1);
+ QCOMPARE(QGLFormat::defaultOverlayFormat(), format1);
// Restore the default overlay format.
QGLFormat::setDefaultOverlayFormat(overlay);
- QVERIFY(QGLFormat::defaultOverlayFormat() == overlay);
+ QCOMPARE(QGLFormat::defaultOverlayFormat(), overlay);
MyGLContext obj2(obj1);
// bool QGLContext::windowCreated()
@@ -1512,9 +1512,9 @@ void tst_QGL::colormap()
QGLColormap cmap1;
QVERIFY(cmap1.isEmpty());
QCOMPARE(cmap1.size(), 0);
- QVERIFY(cmap1.entryRgb(0) == 0);
- QVERIFY(cmap1.entryRgb(-1) == 0);
- QVERIFY(cmap1.entryRgb(100) == 0);
+ QCOMPARE(cmap1.entryRgb(0), QRgb(0));
+ QCOMPARE(cmap1.entryRgb(-1), QRgb(0));
+ QCOMPARE(cmap1.entryRgb(100), QRgb(0));
QVERIFY(!cmap1.entryColor(0).isValid());
QVERIFY(!cmap1.entryColor(-1).isValid());
QVERIFY(!cmap1.entryColor(100).isValid());
@@ -1529,7 +1529,7 @@ void tst_QGL::colormap()
// not to detect when it is empty!
QVERIFY(cmap1.isEmpty());
QCOMPARE(cmap1.size(), 256);
- QVERIFY(cmap1.entryRgb(0) == 0);
+ QCOMPARE(cmap1.entryRgb(0), QRgb(0));
QVERIFY(cmap1.entryColor(0) == QColor(0, 0, 0, 255));
QVERIFY(cmap1.entryRgb(56) == qRgb(255, 0, 0));
QVERIFY(cmap1.entryColor(56) == QColor(255, 0, 0, 255));
@@ -1611,7 +1611,7 @@ void tst_QGL::colormap()
QVERIFY(cmap4.isEmpty());
QCOMPARE(cmap4.size(), 256);
cmap4.setHandle(Qt::HANDLE(42));
- QVERIFY(cmap4.handle() == Qt::HANDLE(42));
+ QCOMPARE(cmap4.handle(), Qt::HANDLE(42));
QVERIFY(!cmap4.isEmpty());
QCOMPARE(cmap4.size(), 256);
}
@@ -1629,7 +1629,7 @@ void tst_QGL::fboFormat()
// Check the initial conditions.
QGLFramebufferObjectFormat format1;
QCOMPARE(format1.samples(), 0);
- QVERIFY(format1.attachment() == QGLFramebufferObject::NoAttachment);
+ QCOMPARE(format1.attachment(), QGLFramebufferObject::NoAttachment);
QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_2D));
int expectedFormat =
#ifdef QT_OPENGL_ES_2
@@ -1645,7 +1645,7 @@ void tst_QGL::fboFormat()
format1.setTextureTarget(GL_TEXTURE_3D);
format1.setInternalTextureFormat(GL_RGB16);
QCOMPARE(format1.samples(), 8);
- QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(format1.attachment(), QGLFramebufferObject::CombinedDepthStencil);
QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D));
QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16));
@@ -1653,12 +1653,12 @@ void tst_QGL::fboFormat()
QGLFramebufferObjectFormat format2(format1);
QGLFramebufferObjectFormat format3;
QCOMPARE(format2.samples(), 8);
- QVERIFY(format2.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(format2.attachment(), QGLFramebufferObject::CombinedDepthStencil);
QCOMPARE(int(format2.textureTarget()), int(GL_TEXTURE_3D));
QCOMPARE(int(format2.internalTextureFormat()), int(GL_RGB16));
format3 = format1;
QCOMPARE(format3.samples(), 8);
- QVERIFY(format3.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(format3.attachment(), QGLFramebufferObject::CombinedDepthStencil);
QCOMPARE(int(format3.textureTarget()), int(GL_TEXTURE_3D));
QCOMPARE(int(format3.internalTextureFormat()), int(GL_RGB16));
@@ -1666,7 +1666,7 @@ void tst_QGL::fboFormat()
format2.setSamples(9);
format3.setTextureTarget(GL_TEXTURE_2D);
QCOMPARE(format1.samples(), 8);
- QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(format1.attachment(), QGLFramebufferObject::CombinedDepthStencil);
QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D));
QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16));
@@ -1674,39 +1674,39 @@ void tst_QGL::fboFormat()
QGLFramebufferObjectFormat format1c;
QGLFramebufferObjectFormat format2c;
- QVERIFY(format1c == format2c);
+ QCOMPARE(format1c, format2c);
QVERIFY(!(format1c != format2c));
format1c.setSamples(8);
QVERIFY(!(format1c == format2c));
QVERIFY(format1c != format2c);
format2c.setSamples(8);
- QVERIFY(format1c == format2c);
+ QCOMPARE(format1c, format2c);
QVERIFY(!(format1c != format2c));
format1c.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
QVERIFY(!(format1c == format2c));
QVERIFY(format1c != format2c);
format2c.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
- QVERIFY(format1c == format2c);
+ QCOMPARE(format1c, format2c);
QVERIFY(!(format1c != format2c));
format1c.setTextureTarget(GL_TEXTURE_3D);
QVERIFY(!(format1c == format2c));
QVERIFY(format1c != format2c);
format2c.setTextureTarget(GL_TEXTURE_3D);
- QVERIFY(format1c == format2c);
+ QCOMPARE(format1c, format2c);
QVERIFY(!(format1c != format2c));
format1c.setInternalTextureFormat(GL_RGB16);
QVERIFY(!(format1c == format2c));
QVERIFY(format1c != format2c);
format2c.setInternalTextureFormat(GL_RGB16);
- QVERIFY(format1c == format2c);
+ QCOMPARE(format1c, format2c);
QVERIFY(!(format1c != format2c));
QGLFramebufferObjectFormat format3c(format1c);
QGLFramebufferObjectFormat format4c;
- QVERIFY(format1c == format3c);
+ QCOMPARE(format1c, format3c);
QVERIFY(!(format1c != format3c));
format3c.setInternalTextureFormat(
#ifdef QT_OPENGL_ES_2
@@ -1719,7 +1719,7 @@ void tst_QGL::fboFormat()
QVERIFY(format1c != format3c);
format4c = format1c;
- QVERIFY(format1c == format4c);
+ QCOMPARE(format1c, format4c);
QVERIFY(!(format1c != format4c));
format4c.setInternalTextureFormat(
#ifdef QT_OPENGL_ES_2
@@ -1947,7 +1947,7 @@ void tst_QGL::destroyFBOAfterContext()
delete glw;
// The handle should now be zero.
- QVERIFY(fbo->handle() == 0);
+ QVERIFY(!fbo->handle());
QVERIFY(!fbo->isValid());
delete fbo;
@@ -1984,14 +1984,14 @@ void tst_QGL::shareRegister()
// Create a guard for the first context.
QOpenGLSharedResourceGuard guard(glw1->context()->contextHandle());
- QVERIFY(guard.id() == 0);
+ QCOMPARE(guard.id(), 0);
guard.setId(3);
- QVERIFY(guard.id() == 3);
+ QCOMPARE(guard.id(), 3);
// Request a tst_QGLResource object for the first context.
tst_QGLResource *res1 = qt_shared_test()->value(glw1->context()->contextHandle());
QVERIFY(res1);
- QVERIFY(qt_shared_test()->value(glw1->context()->contextHandle()) == res1);
+ QCOMPARE(qt_shared_test()->value(glw1->context()->contextHandle()), res1);
// Create another context that shares with the first.
QVERIFY(!glw1->isSharing());
@@ -2005,12 +2005,12 @@ void tst_QGL::shareRegister()
QVERIFY(glw1->context() != glw2->context());
// Check that the first context's resource is also on the second.
- QVERIFY(qt_shared_test()->value(glw1->context()) == res1);
- QVERIFY(qt_shared_test()->value(glw2->context()) == res1);
+ QCOMPARE(qt_shared_test()->value(glw1->context()), res1);
+ QCOMPARE(qt_shared_test()->value(glw2->context()), res1);
// Guard should still be the same.
- QVERIFY(guard.context() == glw1->context());
- QVERIFY(guard.id() == 3);
+ QCOMPARE(guard.context(), glw1->context());
+ QCOMPARE(guard.id(), 3);
// Check the sharing relationships.
QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context()));
@@ -2032,9 +2032,9 @@ void tst_QGL::shareRegister()
// Request a resource to the third context.
tst_QGLResource *res3 = qt_shared_test()->value(glw3->context());
QVERIFY(res3);
- QVERIFY(qt_shared_test()->value(glw1->context()) == res1);
- QVERIFY(qt_shared_test()->value(glw2->context()) == res1);
- QVERIFY(qt_shared_test()->value(glw3->context()) == res3);
+ QCOMPARE(qt_shared_test()->value(glw1->context()), res1);
+ QCOMPARE(qt_shared_test()->value(glw2->context()), res1);
+ QCOMPARE(qt_shared_test()->value(glw3->context()), res3);
// Check the sharing relationships again.
QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context()));
@@ -2053,8 +2053,8 @@ void tst_QGL::shareRegister()
QVERIFY(!QGLContext::areSharing(0, 0));
// Shared guard should still be the same.
- QVERIFY(guard.context() == glw1->context());
- QVERIFY(guard.id() == 3);
+ QCOMPARE(guard.context(), glw1->context());
+ QCOMPARE(guard.id(), 3);
// Delete the first context.
delete glw1;
@@ -2064,14 +2064,14 @@ void tst_QGL::shareRegister()
// The first context's resource should transfer to the second context.
QCOMPARE(tst_QGLResource::deletions, 0);
- QVERIFY(qt_shared_test()->value(glw2->context()) == res1);
- QVERIFY(qt_shared_test()->value(glw3->context()) == res3);
+ QCOMPARE(qt_shared_test()->value(glw2->context()), res1);
+ QCOMPARE(qt_shared_test()->value(glw3->context()), res3);
// Shared guard should now be the second context, with the id the same.
- QVERIFY(guard.context() == glw2->context());
- QVERIFY(guard.id() == 3);
- QVERIFY(guard3.context() == glw3->context());
- QVERIFY(guard3.id() == 5);
+ QCOMPARE(guard.context(), glw2->context());
+ QCOMPARE(guard.id(), 3);
+ QCOMPARE(guard3.context(), glw3->context());
+ QCOMPARE(guard3.id(), 5);
// Clean up and check that the resources are properly deleted.
delete glw2;
@@ -2115,25 +2115,25 @@ void tst_QGL::qglContextDefaultBindTexture()
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
// Make sure the texture IDs returned are valid:
- QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE);
- QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE);
+ QCOMPARE(funcs->glIsTexture(boundImageTextureId), GLboolean(GL_TRUE));
+ QCOMPARE(funcs->glIsTexture(boundPixmapTextureId), GLboolean(GL_TRUE));
// Make sure the textures are still valid after we delete the image/pixmap:
// Also check that although the textures are left intact, the cache entries are removed:
delete boundImage;
boundImage = 0;
- QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE);
+ QCOMPARE(funcs->glIsTexture(boundImageTextureId), GLboolean(GL_TRUE));
QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+1);
delete boundPixmap;
boundPixmap = 0;
- QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE);
+ QCOMPARE(funcs->glIsTexture(boundPixmapTextureId), GLboolean(GL_TRUE));
QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount);
// Finally, make sure QGLContext::deleteTexture deletes the texture IDs:
ctx->deleteTexture(boundImageTextureId);
ctx->deleteTexture(boundPixmapTextureId);
- QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_FALSE);
- QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_FALSE);
+ QCOMPARE(funcs->glIsTexture(boundImageTextureId), GLboolean(GL_FALSE));
+ QCOMPARE(funcs->glIsTexture(boundPixmapTextureId), GLboolean(GL_FALSE));
}
#endif
diff --git a/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp b/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp
index b0409d46d0..f96e3514a7 100644
--- a/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp
+++ b/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp
@@ -86,14 +86,14 @@ void tst_QGLBuffer::testBuffer(QGLBuffer::Type type)
// Create the local object, but not the buffer in the server.
QGLBuffer buffer(type);
- QVERIFY(buffer.usagePattern() == QGLBuffer::StaticDraw);
+ QCOMPARE(buffer.usagePattern(), QGLBuffer::StaticDraw);
buffer.setUsagePattern(QGLBuffer::UsagePattern(usagePattern));
// Check the initial state.
- QVERIFY(buffer.type() == type);
+ QCOMPARE(buffer.type(), type);
QVERIFY(!buffer.isCreated());
- QVERIFY(buffer.bufferId() == 0);
- QVERIFY(buffer.usagePattern() == QGLBuffer::UsagePattern(usagePattern));
+ QCOMPARE(buffer.bufferId(), GLuint(0));
+ QCOMPARE(buffer.usagePattern(), QGLBuffer::UsagePattern(usagePattern));
QCOMPARE(buffer.size(), -1);
// Should not be able to bind it yet because it isn't created.
@@ -253,7 +253,7 @@ void tst_QGLBuffer::bufferSharing()
delete w2;
// The buffer should now be invalid.
- QVERIFY(buffer.bufferId() == 0);
+ QCOMPARE(buffer.bufferId(), GLuint(0));
QVERIFY(!buffer.isCreated());
}
diff --git a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp
index 866cd57381..07fdba4664 100644
--- a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp
+++ b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp
@@ -200,13 +200,13 @@ void tst_QGLFunctions::multitexture()
GLint active = 0;
funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
- QVERIFY(active == GL_TEXTURE1);
+ QCOMPARE(active, GL_TEXTURE1);
funcs.glActiveTexture(GL_TEXTURE0);
active = 0;
funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
- QVERIFY(active == GL_TEXTURE0);
+ QCOMPARE(active, GL_TEXTURE0);
}
// Verify that the glBlendColor() function appears to resolve and work.
diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp
index 8f7dcdb3c5..5ef247483d 100644
--- a/tests/auto/other/compiler/tst_compiler.cpp
+++ b/tests/auto/other/compiler/tst_compiler.cpp
@@ -336,17 +336,17 @@ struct Qxxx {};
void tst_Compiler::detectDataStream()
{
- QVERIFY(QtTestInternal::DataStreamChecker<int>::HasDataStream == true);
- QVERIFY(QtTestInternal::DataStreamChecker<uint>::HasDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<int>::HasDataStream);
+ QVERIFY(QtTestInternal::DataStreamChecker<uint>::HasDataStream);
QVERIFY(QtTestInternal::DataStreamChecker<char *>::HasDataStream == true);
QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasInDataStream == true);
QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasOutDataStream == false);
QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasDataStream == false);
- QVERIFY(QtTestInternal::DataStreamChecker<double>::HasDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<double>::HasDataStream);
- QVERIFY(QtTestInternal::DataStreamChecker<QString>::HasDataStream == true);
- QVERIFY(QtTestInternal::DataStreamChecker<MyString>::HasDataStream == true);
- QVERIFY(QtTestInternal::DataStreamChecker<Qxxx>::HasDataStream == false);
+ QVERIFY(QtTestInternal::DataStreamChecker<QString>::HasDataStream);
+ QVERIFY(QtTestInternal::DataStreamChecker<MyString>::HasDataStream);
+ QVERIFY(!QtTestInternal::DataStreamChecker<Qxxx>::HasDataStream);
QVERIFY(QtTestInternal::getSaveOperator<int>() != 0);
QVERIFY(QtTestInternal::getSaveOperator<uint>() != 0);
@@ -354,7 +354,7 @@ void tst_Compiler::detectDataStream()
QVERIFY(QtTestInternal::getSaveOperator<double>() != 0);
QVERIFY(QtTestInternal::getSaveOperator<QString>() != 0);
QVERIFY(QtTestInternal::getSaveOperator<MyString>() != 0);
- QVERIFY(QtTestInternal::getSaveOperator<Qxxx>() == 0);
+ QVERIFY(!QtTestInternal::getSaveOperator<Qxxx>());
}
#else
void tst_Compiler::detectDataStream()
@@ -637,7 +637,7 @@ void tst_Compiler::cxx11_alignas()
QSKIP("Compiler does not support C++11 feature");
#else
alignas(double) char c;
- QVERIFY(Q_ALIGNOF(c) == Q_ALIGNOF(double));
+ QCOMPARE(Q_ALIGNOF(c), Q_ALIGNOF(double));
#endif
}
diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST
new file mode 100644
index 0000000000..4e8745ca78
--- /dev/null
+++ b/tests/auto/other/gestures/BLACKLIST
@@ -0,0 +1,2 @@
+[customGesture]
+opensuse-13.1
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp
index 43ce6b2d72..2a4f88c627 100644
--- a/tests/auto/other/gestures/tst_gestures.cpp
+++ b/tests/auto/other/gestures/tst_gestures.cpp
@@ -1461,7 +1461,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
QPointer<QGesture> customGestureB;
customGestureB = *(b->gestures.begin());
QVERIFY(!customGestureB.isNull());
- QVERIFY(customGestureA.data() == customGestureB.data());
+ QCOMPARE(customGestureA.data(), customGestureB.data());
QCOMPARE(customGestureB->gestureType(), CustomGesture::GestureType);
a->gestures.clear();
diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp
index 6da3d06ba8..3022114403 100644
--- a/tests/auto/other/lancelot/tst_lancelot.cpp
+++ b/tests/auto/other/lancelot/tst_lancelot.cpp
@@ -259,13 +259,9 @@ void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, const QStr
QTEST_MAIN(tst_Lancelot)
#undef main
-QT_BEGIN_NAMESPACE
-extern Q_DECL_IMPORT QBasicAtomicInt qt_qhash_seed; // from qhash.cpp
-QT_END_NAMESPACE
-
int main(int argc, char *argv[])
{
- qt_qhash_seed.store(0); // Avoid rendering variations caused by QHash randomization
+ qSetGlobalQHashSeed(0); // Avoid rendering variations caused by QHash randomization
QBaselineTest::handleCmdLineArgs(&argc, &argv);
return _realmain(argc, argv);
diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp
index 788993ef35..68d604547d 100644
--- a/tests/auto/other/languagechange/tst_languagechange.cpp
+++ b/tests/auto/other/languagechange/tst_languagechange.cpp
@@ -276,7 +276,7 @@ void tst_languageChange::retranslatability()
tempDirPattern += QStringLiteral("languagechangetestdirXXXXXX");
QTemporaryDir temporaryDir(tempDirPattern);
temporaryDir.setAutoRemove(true);
- QVERIFY(temporaryDir.isValid());
+ QVERIFY2(temporaryDir.isValid(), qPrintable(temporaryDir.errorString()));
const QString finalDir = temporaryDir.path() + QStringLiteral("/finaldir");
const QString fooName = temporaryDir.path() + QStringLiteral("/foo");
QDir dir;
diff --git a/tests/auto/other/macgui/tst_macgui.cpp b/tests/auto/other/macgui/tst_macgui.cpp
index 56035f4be4..ba6ac536f2 100644
--- a/tests/auto/other/macgui/tst_macgui.cpp
+++ b/tests/auto/other/macgui/tst_macgui.cpp
@@ -146,7 +146,7 @@ void tst_MacGui::splashScreenModality()
connect(wn.getWidget(interface), SIGNAL(clicked()), SLOT(exitLoopSlot()));
const int timeout = 4;
QTestEventLoop::instance().enterLoop(timeout);
- QVERIFY(QTestEventLoop::instance().timeout() == false);
+ QVERIFY(!QTestEventLoop::instance().timeout());
}
class PrimaryWindowDialog : public QDialog
@@ -231,7 +231,7 @@ void tst_MacGui::spinBoxArrowButtons()
const QRect lessRect = lessInterface->rect();
const QRect lessLocalRect(colorWidget.mapFromGlobal(lessRect.topLeft()), colorWidget.mapFromGlobal(lessRect.bottomRight()));
const QRect compareRect = lessLocalRect.adjusted(5, 3, -5, -7);
- QVERIFY(noFocus.copy(compareRect) == focus.copy(compareRect));
+ QCOMPARE(noFocus.copy(compareRect), focus.copy(compareRect));
}
QTEST_MAIN(tst_MacGui)
diff --git a/tests/auto/other/macnativeevents/BLACKLIST b/tests/auto/other/macnativeevents/BLACKLIST
index 2820457075..4129868022 100644
--- a/tests/auto/other/macnativeevents/BLACKLIST
+++ b/tests/auto/other/macnativeevents/BLACKLIST
@@ -3,9 +3,22 @@
osx
[testMouseEnter]
osx-10.9
+osx-10.8
[testChildDialogInFrontOfModalParent]
osx
[testChildWindowInFrontOfStaysOnTopParentWindow]
osx
[testModifierCtrlWithDontSwapCtrlAndMeta]
osx
+[testMouseMoveLocation]
+osx
+[testMouseLeftDoubleClick]
+osx
+[stressTestMouseLeftDoubleClick]
+osx
+[testMouseDragInside]
+osx
+[testMouseDragOutside]
+osx
+[testMouseDragToNonClientArea]
+osx
diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
index 5d24655144..d1c5e4a35e 100644
--- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
@@ -457,8 +457,8 @@ void tst_MacNativeEvents::testModifierCtrl()
QWidget w;
w.show();
- QVERIFY(kControlUnicode == QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText)[0]);
- QVERIFY(kCommandUnicode == QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText)[0]);
+ QCOMPARE(ushort(kControlUnicode), QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText).at(0).unicode());
+ QCOMPARE(ushort(kCommandUnicode), QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText).at(0).unicode());
NativeEventList native;
native.append(new QNativeModifierEvent(Qt::ControlModifier));
@@ -490,8 +490,8 @@ void tst_MacNativeEvents::testModifierCtrlWithDontSwapCtrlAndMeta()
QWidget w;
w.show();
- QVERIFY(kCommandUnicode == QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText)[0]);
- QVERIFY(kControlUnicode == QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText)[0]);
+ QCOMPARE(ushort(kCommandUnicode), QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText).at(0).unicode());
+ QCOMPARE(ushort(kControlUnicode), QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText).at(0).unicode());
NativeEventList native;
native.append(new QNativeModifierEvent(Qt::ControlModifier));
diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp
index 72a4a0ad29..c119fdaa4e 100644
--- a/tests/auto/other/modeltest/modeltest.cpp
+++ b/tests/auto/other/modeltest/modeltest.cpp
@@ -569,7 +569,7 @@ void ModelTest::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto
QVERIFY(topLeft.isValid());
QVERIFY(bottomRight.isValid());
QModelIndex commonParent = bottomRight.parent();
- QVERIFY(topLeft.parent() == commonParent);
+ QCOMPARE(topLeft.parent(), commonParent);
QVERIFY(topLeft.row() <= bottomRight.row());
QVERIFY(topLeft.column() <= bottomRight.column());
int rowCount = model->rowCount(commonParent);
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp
index 5612260cca..7ce385121c 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp
@@ -34,6 +34,8 @@
#include <QtTest/QtTest>
#include <QtNetwork/QtNetwork>
#include <QtCore/QDateTime>
+#include <QtCore/QTextStream>
+#include <QtCore/QStandardPaths>
#include <QtCore/private/qiodevice_p.h>
#ifndef QT_NO_BEARERMANAGEMENT
@@ -460,7 +462,7 @@ void tst_NetworkSelfTest::remotePortsOpen()
else
QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit());
}
- QVERIFY(socket.state() == QAbstractSocket::ConnectedState);
+ QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
}
static QList<Chat> ftpChat(const QByteArray &userSuffix = QByteArray())
@@ -960,6 +962,25 @@ void tst_NetworkSelfTest::supportsSsl()
#endif
}
+#ifndef QT_NO_PROCESS
+static const QByteArray msgProcessError(const QProcess &process, const char *what)
+{
+ QString result;
+ QTextStream(&result) << what << ": \"" << process.program() << ' '
+ << process.arguments().join(QLatin1Char(' ')) << "\": " << process.errorString();
+ return result.toLocal8Bit();
+}
+
+static void ensureTermination(QProcess &process)
+{
+ if (process.state() == QProcess::Running) {
+ process.terminate();
+ if (!process.waitForFinished(300))
+ process.kill();
+ }
+}
+#endif // !QT_NO_PROCESS
+
void tst_NetworkSelfTest::smbServer()
{
static const char contents[] = "This is 34 bytes. Do not change...";
@@ -977,19 +998,24 @@ void tst_NetworkSelfTest::smbServer()
QVERIFY(memcmp(buf, contents, strlen(contents)) == 0);
#else
#ifndef QT_NO_PROCESS
+ enum { sambaTimeOutSecs = 5 };
// try to use Samba
- QString progname = "smbclient";
- QProcess smbclient;
- smbclient.start(progname, QIODevice::ReadOnly);
- if (!smbclient.waitForStarted(2000))
+ const QString progname = "smbclient";
+ const QString binary = QStandardPaths::findExecutable(progname);
+ if (binary.isEmpty())
QSKIP("Could not find smbclient (from Samba), cannot continue testing");
- if (!smbclient.waitForFinished(2000) || smbclient.exitStatus() != QProcess::NormalExit)
- QSKIP("smbclient isn't working, cannot continue testing");
- smbclient.close();
// try listing the server
- smbclient.start(progname, QStringList() << "-g" << "-N" << "-L" << QtNetworkSettings::winServerName(), QIODevice::ReadOnly);
- QVERIFY(smbclient.waitForFinished(5000));
+ const QStringList timeOutArguments = QStringList()
+ << "--timeout" << QString::number(sambaTimeOutSecs);
+ QStringList arguments = timeOutArguments;
+ arguments << "-g" << "-N" << "-L" << QtNetworkSettings::winServerName();
+ QProcess smbclient;
+ smbclient.start(binary, arguments, QIODevice::ReadOnly);
+ QVERIFY2(smbclient.waitForStarted(), msgProcessError(smbclient, "Unable to start"));
+ const bool listFinished = smbclient.waitForFinished((1 + sambaTimeOutSecs) * 1000);
+ ensureTermination(smbclient);
+ QVERIFY2(listFinished, msgProcessError(smbclient, "Listing servers timed out"));
if (smbclient.exitStatus() != QProcess::NormalExit)
QSKIP("smbclient crashed");
QVERIFY2(smbclient.exitCode() == 0, "Test server not found");
@@ -1004,9 +1030,13 @@ void tst_NetworkSelfTest::smbServer()
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("PAGER", "/bin/cat"); // just in case
smbclient.setProcessEnvironment(env);
- smbclient.start(progname, QStringList() << "-N" << "-c" << "more test.pri"
- << QString("\\\\%1\\testshare").arg(QtNetworkSettings::winServerName()), QIODevice::ReadOnly);
- QVERIFY(smbclient.waitForFinished(5000));
+ arguments = timeOutArguments;
+ arguments << "-N" << "-c" << "more test.pri"
+ << ("\\\\" + QtNetworkSettings::winServerName() + "\\testshare");
+ smbclient.start(binary, arguments, QIODevice::ReadOnly);
+ const bool fileFinished = smbclient.waitForFinished((1 + sambaTimeOutSecs) * 1000);
+ ensureTermination(smbclient);
+ QVERIFY2(fileFinished, msgProcessError(smbclient, "Timed out"));
if (smbclient.exitStatus() != QProcess::NormalExit)
QSKIP("smbclient crashed");
QVERIFY2(smbclient.exitCode() == 0, "File //qt-test-server/testshare/test.pri not found");
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 4f891fcda0..62c2c0a916 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -162,16 +162,6 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface,
return true;
}
-static inline int indexOfChild(QAccessibleInterface *parentInterface, QWidget *childWidget)
-{
- if (!parentInterface || !childWidget)
- return -1;
- QAccessibleInterface *childInterface(QAccessible::queryAccessibleInterface(childWidget));
- if (!childInterface)
- return -1;
- return parentInterface->indexOfChild(childInterface);
-}
-
#define EXPECT(cond) \
do { \
if (!errorAt && !(cond)) { \
@@ -462,15 +452,15 @@ void tst_QAccessibility::statesStructTest()
QVERIFY(s1.modal == 0);
QAccessible::State s2;
- QVERIFY(s2 == s1);
+ QCOMPARE(s2, s1);
s2.busy = true;
QVERIFY(!(s2 == s1));
s1.busy = true;
- QVERIFY(s2 == s1);
+ QCOMPARE(s2, s1);
s1 = QAccessible::State();
QVERIFY(!(s2 == s1));
s1 = s2;
- QVERIFY(s2 == s1);
+ QCOMPARE(s2, s1);
QVERIFY(s1.busy == 1);
}
@@ -533,9 +523,9 @@ void tst_QAccessibility::navigateHierarchy()
QVERIFY(ifaceW->isValid());
QAccessibleInterface *target = ifaceW->child(14);
- QVERIFY(target == 0);
+ QVERIFY(!target);
target = ifaceW->child(-1);
- QVERIFY(target == 0);
+ QVERIFY(!target);
target = ifaceW->child(0);
QAccessibleInterface *interfaceW1(ifaceW->child(0));
QVERIFY(target);
@@ -551,7 +541,7 @@ void tst_QAccessibility::navigateHierarchy()
QCOMPARE(target->object(), (QObject*)w3);
QAccessibleInterface *child = target->child(1);
- QVERIFY(child == 0);
+ QVERIFY(!child);
child = target->child(0);
QVERIFY(child != 0);
QVERIFY(child->isValid());
@@ -969,7 +959,7 @@ void tst_QAccessibility::mainWindowTest()
QWindow window;
window.setGeometry(80, 80, 40, 40);
window.show();
- QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
// We currently don't have an accessible interface for QWindow
// the active state is either in the QMainWindow or QQuickView
@@ -1313,7 +1303,7 @@ void tst_QAccessibility::tabTest()
QCOMPARE(child1->text(QAccessible::Description), QLatin1String("Cool tool tip"));
QCOMPARE(child1->text(QAccessible::Help), QLatin1String("I don't know"));
- QVERIFY((child1->state().invisible) == false);
+ QVERIFY(!(child1->state().invisible));
tabBar->hide();
QCoreApplication::processEvents();
@@ -1660,7 +1650,7 @@ void tst_QAccessibility::spinBoxTest()
// make sure that the line edit is not there
const int numChildren = interface->childCount();
QCOMPARE(numChildren, 0);
- QVERIFY(interface->child(0) == Q_NULLPTR);
+ QVERIFY(!interface->child(0));
QVERIFY(interface->valueInterface());
QCOMPARE(interface->valueInterface()->currentValue().toInt(), 3);
@@ -1746,6 +1736,13 @@ static bool fuzzyRectCompare(const QRect &a, const QRect &b)
&& qAbs(delta.right()) <= MAX_ACCEPTABLE_DELTA && qAbs(delta.bottom()) <= MAX_ACCEPTABLE_DELTA;
}
+static QByteArray msgRectMismatch(const QRect &a, const QRect &b)
+{
+ QString result;
+ QDebug(&result) << a << "!=" << b;
+ return result.toLocal8Bit();
+}
+
void tst_QAccessibility::textEditTest()
{
for (int pass = 0; pass < 2; ++pass) {
@@ -1791,16 +1788,24 @@ void tst_QAccessibility::textEditTest()
int offset = 10;
QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("d"));
- QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
+ const QRect actual10 = textIface->characterRect(offset);
+ const QRect expected10 = characterRect(edit, offset);
+ QVERIFY2(fuzzyRectCompare(actual10, expected10), msgRectMismatch(actual10, expected10).constData());
offset = 13;
QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("H"));
- QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
+ const QRect actual13 = textIface->characterRect(offset);
+ const QRect expected13 = characterRect(edit, offset);
+ QVERIFY2(fuzzyRectCompare(actual13, expected13), msgRectMismatch(actual13, expected13).constData());
offset = 21;
QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("y"));
- QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
+ const QRect actual21 = textIface->characterRect(offset);
+ const QRect expected21 = characterRect(edit, offset);
+ QVERIFY2(fuzzyRectCompare(actual21, expected21), msgRectMismatch(actual21, expected21).constData());
offset = 32;
QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("I"));
- QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
+ const QRect actual32 = textIface->characterRect(offset);
+ const QRect expected32 = characterRect(edit, offset);
+ QVERIFY2(fuzzyRectCompare(actual32, expected32), msgRectMismatch(actual32, expected32).constData());
QTestAccessibility::clearEvents();
@@ -2481,7 +2486,7 @@ void tst_QAccessibility::groupBoxTest()
QCOMPARE(iface->text(QAccessible::Name), QLatin1String("Test QGroupBox"));
QCOMPARE(iface->text(QAccessible::Description), QLatin1String("This group box will be used to test accessibility"));
QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations = rButtonIface->relations();
- QVERIFY(relations.size() == 1);
+ QCOMPARE(relations.size(), 1);
QPair<QAccessibleInterface*, QAccessible::Relation> relation = relations.first();
QCOMPARE(relation.first->object(), groupBox);
QCOMPARE(relation.second, QAccessible::Label);
@@ -3526,13 +3531,13 @@ void tst_QAccessibility::dockWidgetTest()
QPoint buttonPoint = pb2->mapToGlobal(QPoint(pb2->width()/2, pb2->height()/2));
QAccessibleInterface *childAt = accDock2->childAt(buttonPoint.x(), buttonPoint.y());
QVERIFY(childAt);
- QVERIFY(childAt->object() == pb2);
+ QCOMPARE(childAt->object(), pb2);
QWidget *close1 = qobject_cast<QWidget*>(dock1Close->object());
QPoint close1ButtonPoint = close1->mapToGlobal(QPoint(close1->width()/2, close1->height()/2));
QAccessibleInterface *childAt2 = accDock1->childAt(close1ButtonPoint.x(), close1ButtonPoint.y());
QVERIFY(childAt2);
- QVERIFY(childAt2->object() == close1);
+ QCOMPARE(childAt2->object(), close1);
// custom title bar widget
QDockWidget *dock3 = new QDockWidget(mw);
diff --git a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
index 2ea54ab603..10d950541a 100644
--- a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
+++ b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
@@ -1,8 +1,5 @@
CONFIG += testcase
-# This is temporary to start running the test as part of normal CI.
-CONFIG += insignificant_test # QTBUG-27732
-
include($$QT_SOURCE_TREE/src/platformsupport/accessibility/accessibility.pri)
include($$QT_SOURCE_TREE/src/platformsupport/linuxaccessibility/linuxaccessibility.pri)
diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
index 5f0eed5afe..4885a5f037 100644
--- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
@@ -84,7 +84,15 @@ class tst_QAccessibilityLinux : public QObject
Q_OBJECT
public:
- tst_QAccessibilityLinux() : m_window(0), root(0), rootApplication(0), mainWindow(0) {}
+ tst_QAccessibilityLinux() : m_window(0), root(0), rootApplication(0), mainWindow(0)
+ {
+ qputenv("QT_LINUX_ACCESSIBILITY_ALWAYS_ON", QByteArrayLiteral("1"));
+ dbus = new DBusConnection();
+ }
+ ~tst_QAccessibilityLinux()
+ {
+ delete dbus;
+ }
private slots:
void initTestCase();
@@ -112,7 +120,7 @@ private:
QDBusInterface *rootApplication;
QDBusInterface *mainWindow;
- DBusConnection dbus;
+ DBusConnection *dbus;
};
// helper to find children of a dbus object
@@ -149,7 +157,7 @@ QString tst_QAccessibilityLinux::getParent(QDBusInterface *interface)
// helper to get dbus object
QDBusInterface *tst_QAccessibilityLinux::getInterface(const QString &path, const QString &interfaceName)
{
- return new QDBusInterface(address, path, interfaceName, dbus.connection(), this);
+ return new QDBusInterface(address, path, interfaceName, dbus->connection(), this);
}
void tst_QAccessibilityLinux::initTestCase()
@@ -158,14 +166,22 @@ void tst_QAccessibilityLinux::initTestCase()
qApp->setStyle("fusion");
qApp->setApplicationName("tst_QAccessibilityLinux app");
- // Pretend we are a screen reader
+
+ // trigger launching of at-spi if it isn't running already
QDBusConnection c = QDBusConnection::sessionBus();
OrgA11yStatusInterface *a11yStatus = new OrgA11yStatusInterface(QStringLiteral("org.a11y.Bus"), QStringLiteral("/org/a11y/bus"), c, this);
- a11yStatus->setScreenReaderEnabled(true);
+ // don't care about the result, calling any function on "org.a11y.Bus" will launch the service
+ a11yStatus->isEnabled();
+ for (int i = 0; i < 5; ++i) {
+ if (!dbus->isEnabled())
+ QTest::qWait(100);
+ }
- QTRY_VERIFY(dbus.isEnabled());
- QTRY_VERIFY(dbus.connection().isConnected());
- address = dbus.connection().baseService().toLatin1().data();
+ if (!dbus->isEnabled())
+ QSKIP("Could not connect to AT-SPI, make sure lib atspi2 is installed.");
+ QTRY_VERIFY(dbus->isEnabled());
+ QTRY_VERIFY(dbus->connection().isConnected());
+ address = dbus->connection().baseService().toLatin1().data();
QVERIFY(!address.isEmpty());
m_window = new AccessibleTestWindow();
@@ -185,7 +201,7 @@ void tst_QAccessibilityLinux::cleanupTestCase()
void tst_QAccessibilityLinux::registerDbus()
{
- QVERIFY(dbus.connection().isConnected());
+ QVERIFY(dbus->connection().isConnected());
root = getInterface("/org/a11y/atspi/accessible/root",
"org.a11y.atspi.Accessible");
diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
index a9234b7060..1428a63123 100644
--- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
@@ -173,7 +173,7 @@ void tst_QComplexText::bidiCursor_qtbug2795()
qreal x2 = line2.cursorToX(0) - line2.cursorToX(str.size());
// The cursor should remain at the same position after a digit is appended
- QVERIFY(x1 == x2);
+ QCOMPARE(x1, x2);
}
void tst_QComplexText::bidiCursorMovement_data()
diff --git a/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp
index b161dccb88..acb0d28c6b 100644
--- a/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp
+++ b/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp
@@ -132,7 +132,7 @@ void compareScreenshots(const QString &image1, const QString &image2)
//screenShot.save("scr2.png", "PNG");
//original.save("orig1.png", "PNG");
- QVERIFY(original == screenShot);
+ QCOMPARE(original, screenShot);
}
void takeScreenShot(const QString filename)
diff --git a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
index 598abca43b..f3b865ed92 100644
--- a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
+++ b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
@@ -57,7 +57,6 @@ void tst_QPrintDevice::basics()
if (defaultId.isEmpty()) {
qDebug() << "No default printer found";
} else {
- qDebug() << "Default Printer ID :" << defaultId;
QVERIFY(ps->availablePrintDeviceIds().contains(defaultId));
}
@@ -66,7 +65,9 @@ void tst_QPrintDevice::basics()
// Just exercise the api for now as we don't know what is installed
foreach (const QString id, ps->availablePrintDeviceIds()) {
QPrintDevice printDevice = ps->createPrintDevice(id);
- qDebug() << "Created printer" << id;
+ const char quote = id == defaultId ? '*' : '"';
+ qDebug().noquote().nospace() << "\nCreated printer " << quote << id
+ << quote << ":\n" << printDevice << '\n';
QCOMPARE(printDevice.isValid(), true);
printDevice.id();
printDevice.name();
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index c256d9ba82..318f87467c 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -425,12 +425,12 @@ void tst_QPrinter::outputFormatFromSuffix()
if (QPrinterInfo::availablePrinters().size() == 0)
QSKIP("No printers available.");
QPrinter p;
- QVERIFY(p.outputFormat() == QPrinter::NativeFormat);
+ QCOMPARE(p.outputFormat(), QPrinter::NativeFormat);
p.setOutputFileName("test.pdf");
TempFileCleanup tmpFile("test.pdf");
- QVERIFY(p.outputFormat() == QPrinter::PdfFormat);
+ QCOMPARE(p.outputFormat(), QPrinter::PdfFormat);
p.setOutputFileName(QString());
- QVERIFY(p.outputFormat() == QPrinter::NativeFormat);
+ QCOMPARE(p.outputFormat(), QPrinter::NativeFormat);
}
void tst_QPrinter::testPageMargins_data()
diff --git a/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb b/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb
index f388f192ac..f388f192ac 100755..100644
--- a/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb
+++ b/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb
Binary files differ
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
index c499aed481..fe8a3689b0 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h
@@ -261,8 +261,8 @@ public:
// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org" );
// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3307 );
-// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3308, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 4.1.1
-// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3309, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 5.0.18 Linux
+// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3308, "CLIENT_COMPRESS=1" ); // MySQL 4.1.1
+// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3309, "CLIENT_COMPRESS=1" ); // MySQL 5.0.18 Linux
// addDb( "QMYSQL3", "testdb", "troll", "trond", "silence.qt-project.org" ); // MySQL 5.1.36 Windows
// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql41.qt-project.org" ); // MySQL 4.1.22-2.el4 linux
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 1993f23672..83cf0394f9 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -1569,11 +1569,11 @@ void tst_QSqlDatabase::ibase_numericFields()
QCOMPARE(q.value(2).toString(), QString("%1").arg(num2));
QCOMPARE(QString("%1").arg(q.value(3).toDouble()), QString("%1").arg(num3));
QCOMPARE(QString("%1").arg(q.value(4).toDouble()), QString("%1").arg(num4));
- QVERIFY(q.value(0).type() == QVariant::Int);
- QVERIFY(q.value(1).type() == QVariant::Double);
- QVERIFY(q.value(2).type() == QVariant::Double);
- QVERIFY(q.value(3).type() == QVariant::Double);
- QVERIFY(q.value(4).type() == QVariant::Double);
+ QCOMPARE(q.value(0).type(), QVariant::Int);
+ QCOMPARE(q.value(1).type(), QVariant::Double);
+ QCOMPARE(q.value(2).type(), QVariant::Double);
+ QCOMPARE(q.value(3).type(), QVariant::Double);
+ QCOMPARE(q.value(4).type(), QVariant::Double);
QCOMPARE(q.record().field(1).length(), 2);
QCOMPARE(q.record().field(1).precision(), 1);
@@ -1583,16 +1583,16 @@ void tst_QSqlDatabase::ibase_numericFields()
QCOMPARE(q.record().field(3).precision(), 3);
QCOMPARE(q.record().field(4).length(), 18);
QCOMPARE(q.record().field(4).precision(), 4);
- QVERIFY(q.record().field(0).requiredStatus() == QSqlField::Required);
- QVERIFY(q.record().field(1).requiredStatus() == QSqlField::Optional);
+ QCOMPARE(q.record().field(0).requiredStatus(), QSqlField::Required);
+ QCOMPARE(q.record().field(1).requiredStatus(), QSqlField::Optional);
}
QSqlRecord r = db.record(tableName);
- QVERIFY(r.field(0).type() == QVariant::Int);
- QVERIFY(r.field(1).type() == QVariant::Double);
- QVERIFY(r.field(2).type() == QVariant::Double);
- QVERIFY(r.field(3).type() == QVariant::Double);
- QVERIFY(r.field(4).type() == QVariant::Double);
+ QCOMPARE(r.field(0).type(), QVariant::Int);
+ QCOMPARE(r.field(1).type(), QVariant::Double);
+ QCOMPARE(r.field(2).type(), QVariant::Double);
+ QCOMPARE(r.field(3).type(), QVariant::Double);
+ QCOMPARE(r.field(4).type(), QVariant::Double);
QCOMPARE(r.field(1).length(), 2);
QCOMPARE(r.field(1).precision(), 1);
QCOMPARE(r.field(2).length(), 5);
@@ -1601,8 +1601,8 @@ void tst_QSqlDatabase::ibase_numericFields()
QCOMPARE(r.field(3).precision(), 3);
QCOMPARE(r.field(4).length(), 18);
QCOMPARE(r.field(4).precision(), 4);
- QVERIFY(r.field(0).requiredStatus() == QSqlField::Required);
- QVERIFY(r.field(1).requiredStatus() == QSqlField::Optional);
+ QCOMPARE(r.field(0).requiredStatus(), QSqlField::Required);
+ QCOMPARE(r.field(1).requiredStatus(), QSqlField::Optional);
}
void tst_QSqlDatabase::ibase_fetchBlobs()
@@ -2086,7 +2086,7 @@ void tst_QSqlDatabase::eventNotificationIBase()
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toString() == procedureName);
+ QCOMPARE(arguments.at(0).toString(), procedureName);
QVERIFY_SQL(*driver, unsubscribeFromNotification(procedureName));
q.exec(QString("DROP PROCEDURE %1").arg(procedureName));
}
diff --git a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp
index 7a12f66452..70e09a2b80 100644
--- a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp
+++ b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp
@@ -160,7 +160,7 @@ void tst_QSqlError::operators()
error2.setType(QSqlError::NoError);
error3.setType(QSqlError::UnknownError);
- QVERIFY(error1 == error2);
+ QCOMPARE(error1, error2);
QVERIFY(error1 != error3);
}
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 61586eb841..b98ab68ae9 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -241,6 +241,10 @@ private slots:
void aggregateFunctionTypes_data() { generic_data(); }
void aggregateFunctionTypes();
+
+ void integralTypesMysql_data() { generic_data("QMYSQL"); }
+ void integralTypesMysql();
+
private:
// returns all database connections
void generic_data(const QString &engine=QString());
@@ -3974,5 +3978,65 @@ void tst_QSqlQuery::aggregateFunctionTypes()
}
}
+template<typename T>
+void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QString &type, const bool withPreparedStatement,
+ const T min = std::numeric_limits<T>::min(), const T max = std::numeric_limits<T>::max())
+{
+ QSqlQuery q(db);
+ QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName));
+ QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ")"));
+
+ const int steps = 20;
+ const T increment = max / steps - min / steps;
+
+ // insert some values
+ QVector<T> values;
+ values.resize(steps);
+ T v = min;
+ if (withPreparedStatement) {
+ QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (id) VALUES (?)"));
+ }
+ for (int i = 0; i < values.size(); ++i) {
+ if (withPreparedStatement) {
+ q.bindValue(0, v);
+ QVERIFY_SQL(q, exec());
+ } else {
+ QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + ")"));
+ }
+ values[i] = v;
+ v += increment;
+ }
+
+ // ensure we can read them back properly
+ QVERIFY_SQL(q, exec("SELECT id FROM " + tableName));
+ QVector<T> actualValues;
+ actualValues.reserve(values.size());
+ while (q.next()) {
+ actualValues << q.value(0).value<T>();
+ }
+ QCOMPARE(actualValues, values);
+}
+
+void tst_QSqlQuery::integralTypesMysql()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ for (int i = 0; i < 2; ++i) {
+ const bool withPreparedStatement = (i == 1);
+ runIntegralTypesMysqlTest<char>(db, "tinyIntTest", "TINYINT", withPreparedStatement);
+ runIntegralTypesMysqlTest<unsigned char>(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement);
+ runIntegralTypesMysqlTest<char>(db, "smallIntTest", "SMALLINT", withPreparedStatement);
+ runIntegralTypesMysqlTest<unsigned char>(db, "unsignedSmallIntTest", "SMALLINT UNSIGNED", withPreparedStatement);
+ runIntegralTypesMysqlTest<int>(db, "mediumIntTest", "MEDIUMINT", withPreparedStatement, -(1 << 23), (1 << 23) - 1);
+ runIntegralTypesMysqlTest<unsigned int>(db, "unsignedMediumIntTest", "MEDIUMINT UNSIGNED", withPreparedStatement, 0, (1 << 24) - 1);
+ runIntegralTypesMysqlTest<int>(db, "intTest", "INT", withPreparedStatement);
+ runIntegralTypesMysqlTest<unsigned int>(db, "unsignedIntTest", "INT UNSIGNED", withPreparedStatement);
+ runIntegralTypesMysqlTest<long long>(db, "bigIntTest", "BIGINT", withPreparedStatement);
+ runIntegralTypesMysqlTest<unsigned long long>(db, "unsignedBigIntTest", "BIGINT UNSIGNED", withPreparedStatement);
+ }
+}
+
QTEST_MAIN( tst_QSqlQuery )
#include "tst_qsqlquery.moc"
diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 71ec2b6588..3702631275 100644
--- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -858,7 +858,7 @@ static void testRevert(QSqlRelationalTableModel &model)
/* Now revert the newly inserted rows */
model.revertAll();
- QVERIFY(model.rowCount() == initialRowCount);
+ QCOMPARE(model.rowCount(), initialRowCount);
/* Insert rows again */
QVERIFY(model.insertRows(4, 4));
@@ -1026,7 +1026,7 @@ void tst_QSqlRelationalTableModel::invalidData()
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
//try to set data in non valid index
- QVERIFY(model.setData(model.index(0,10),5) == false);
+ QVERIFY(!model.setData(model.index(0,10),5));
//same test with LeftJoin mode
model.setJoinMode(QSqlRelationalTableModel::LeftJoin);
@@ -1037,7 +1037,7 @@ void tst_QSqlRelationalTableModel::invalidData()
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
//try to set data in non valid index
- QVERIFY(model.setData(model.index(0,10),5) == false);
+ QVERIFY(!model.setData(model.index(0,10),5));
}
void tst_QSqlRelationalTableModel::relationModel()
@@ -1051,20 +1051,20 @@ void tst_QSqlRelationalTableModel::relationModel()
model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
QVERIFY_SQL(model, select());
- QVERIFY(model.relationModel(0) == NULL);
- QVERIFY(model.relationModel(1) == NULL);
+ QVERIFY(!model.relationModel(0));
+ QVERIFY(!model.relationModel(1));
QVERIFY(model.relationModel(2) != NULL);
- QVERIFY(model.relationModel(3) == NULL);
- QVERIFY(model.relationModel(4) == NULL);
+ QVERIFY(!model.relationModel(3));
+ QVERIFY(!model.relationModel(4));
model.setRelation(3, QSqlRelation(reltest4, "id", "name"));
QVERIFY_SQL(model, select());
- QVERIFY(model.relationModel(0) == NULL);
- QVERIFY(model.relationModel(1) == NULL);
+ QVERIFY(!model.relationModel(0));
+ QVERIFY(!model.relationModel(1));
QVERIFY(model.relationModel(2) != NULL);
QVERIFY(model.relationModel(3) != NULL);
- QVERIFY(model.relationModel(4) == NULL);
+ QVERIFY(!model.relationModel(4));
QSqlTableModel *rel_model = model.relationModel(2);
QCOMPARE(rel_model->data(rel_model->index(0,1)).toString(), QString("herr"));
@@ -1073,11 +1073,11 @@ void tst_QSqlRelationalTableModel::relationModel()
model.setJoinMode(QSqlRelationalTableModel::LeftJoin);
QVERIFY_SQL(model, select());
- QVERIFY(model.relationModel(0) == NULL);
- QVERIFY(model.relationModel(1) == NULL);
+ QVERIFY(!model.relationModel(0));
+ QVERIFY(!model.relationModel(1));
QVERIFY(model.relationModel(2) != NULL);
QVERIFY(model.relationModel(3) != NULL);
- QVERIFY(model.relationModel(4) == NULL);
+ QVERIFY(!model.relationModel(4));
QSqlTableModel *rel_model2 = model.relationModel(2);
QCOMPARE(rel_model2->data(rel_model->index(0,1)).toString(), QString("herr"));
@@ -1487,13 +1487,13 @@ void tst_QSqlRelationalTableModel::selectAfterUpdate()
model.setTable(reltest1);
model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
QVERIFY_SQL(model, select());
- QVERIFY(model.relationModel(2)->rowCount() == 2);
+ QCOMPARE(model.relationModel(2)->rowCount(), 2);
{
QSqlQuery q(db);
QVERIFY_SQL(q, exec("insert into " + reltest2 + " values(3, 'mrs')"));
model.relationModel(2)->select();
}
- QVERIFY(model.relationModel(2)->rowCount() == 3);
+ QCOMPARE(model.relationModel(2)->rowCount(), 3);
QVERIFY(model.setData(model.index(0,2), 3));
QVERIFY(model.submitAll());
QCOMPARE(model.data(model.index(0,2)), QVariant("mrs"));
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index 9c351f4657..2ace79973b 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -533,7 +533,7 @@ void tst_QSqlTableModel::setData()
idx = model.index(0, 0);
QVERIFY_SQL(model, setData(idx, QVariant(QVariant::Int)));
val = model.data(idx);
- QVERIFY(val == QVariant(QVariant::Int));
+ QCOMPARE(val, QVariant(QVariant::Int));
QVERIFY(val.isNull());
QVERIFY_SQL(model, isDirty(idx));
QVERIFY_SQL(model, submitAll());
@@ -560,13 +560,13 @@ void tst_QSqlTableModel::setData()
// initial state
idx = model.index(0, 0);
QSqlRecord rec = model.record(0);
- QVERIFY(rec.value(0) == QVariant(QVariant::Int));
+ QCOMPARE(rec.value(0), QVariant(QVariant::Int));
QVERIFY(rec.isNull(0));
QVERIFY(!rec.isGenerated(0));
// unchanged value, but causes column to be included in INSERT
QVERIFY_SQL(model, setData(idx, QVariant(QVariant::Int)));
rec = model.record(0);
- QVERIFY(rec.value(0) == QVariant(QVariant::Int));
+ QCOMPARE(rec.value(0), QVariant(QVariant::Int));
QVERIFY(rec.isNull(0));
QVERIFY(rec.isGenerated(0));
QVERIFY_SQL(model, submitAll());
@@ -1136,8 +1136,8 @@ void tst_QSqlTableModel::removeRows()
QVERIFY_SQL(model, removeRows(0, 1));
QVERIFY_SQL(model, removeRows(1, 1));
QCOMPARE(beforeDeleteSpy.count(), 2);
- QVERIFY(beforeDeleteSpy.at(0).at(0).toInt() == 0);
- QVERIFY(beforeDeleteSpy.at(1).at(0).toInt() == 1);
+ QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(beforeDeleteSpy.at(1).at(0).toInt(), 1);
// deleted rows shown as empty until select
QCOMPARE(model.rowCount(), 3);
QCOMPARE(model.data(model.index(0, 1)).toString(), QString(""));
@@ -1172,11 +1172,11 @@ void tst_QSqlTableModel::removeRows()
QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 0);
QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 0);
QCOMPARE(model.rowCount(), 3);
- QVERIFY(beforeDeleteSpy.count() == 0);
+ QCOMPARE(beforeDeleteSpy.count(), 0);
QVERIFY(model.submitAll());
- QVERIFY(beforeDeleteSpy.count() == 2);
- QVERIFY(beforeDeleteSpy.at(0).at(0).toInt() == 0);
- QVERIFY(beforeDeleteSpy.at(1).at(0).toInt() == 1);
+ QCOMPARE(beforeDeleteSpy.count(), 2);
+ QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(beforeDeleteSpy.at(1).at(0).toInt(), 1);
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("vohi"));
}
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index 6b94dfb529..6446fec510 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -124,6 +124,8 @@ class tst_Cmptest: public QObject
Q_OBJECT
private slots:
+ void compare_unregistered_enums();
+ void compare_registered_enums();
void compare_boolfuncs();
void compare_pointerfuncs();
void compare_tostring();
@@ -138,8 +140,26 @@ private slots:
void compareQImages();
void compareQImages_data();
#endif
+ void verify();
+ void verify2();
+ void tryVerify();
+ void tryVerify2();
};
+enum MyUnregisteredEnum { MyUnregisteredEnumValue1, MyUnregisteredEnumValue2 };
+
+void tst_Cmptest::compare_unregistered_enums()
+{
+ QCOMPARE(MyUnregisteredEnumValue1, MyUnregisteredEnumValue1);
+ QCOMPARE(MyUnregisteredEnumValue1, MyUnregisteredEnumValue2);
+}
+
+void tst_Cmptest::compare_registered_enums()
+{
+ QCOMPARE(Qt::ArrowCursor, Qt::ArrowCursor);
+ QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor);
+}
+
static bool boolfunc() { return true; }
static bool boolfunc2() { return true; }
@@ -371,7 +391,36 @@ void tst_Cmptest::compareQImages()
QCOMPARE(opA, opB);
}
-#endif
+#endif // QT_GUI_LIB
+
+static int opaqueFunc()
+{
+ return 42;
+}
+
+void tst_Cmptest::verify()
+{
+ QVERIFY(opaqueFunc() > 2);
+ QVERIFY(opaqueFunc() < 2);
+}
+
+void tst_Cmptest::verify2()
+{
+ QVERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData());
+ QVERIFY2(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData());
+}
+
+void tst_Cmptest::tryVerify()
+{
+ QTRY_VERIFY(opaqueFunc() > 2);
+ QTRY_VERIFY_WITH_TIMEOUT(opaqueFunc() < 2, 1);
+}
+
+void tst_Cmptest::tryVerify2()
+{
+ QTRY_VERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData());
+ QTRY_VERIFY2_WITH_TIMEOUT(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData(), 1);
+}
QTEST_MAIN(tst_Cmptest)
#include "tst_cmptest.moc"
diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml
index 4a376b5c8b..36929cec6b 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.lightxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml
@@ -5,18 +5,32 @@
</Environment>
<TestFunction name="initTestCase">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="compare_unregistered_enums">
+<Incident type="fail" file="tst_cmptest.cpp" line="154">
+ <Description><![CDATA[Compared values are not the same]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="compare_registered_enums">
+<Incident type="fail" file="tst_cmptest.cpp" line="160">
+ <Description><![CDATA[Compared values are not the same
+ Actual (Qt::ArrowCursor): ArrowCursor
+ Expected (Qt::BusyCursor) : BusyCursor]]></Description>
+</Incident>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_boolfuncs">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_pointerfuncs">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_tostring">
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[int, string]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(int,123)
@@ -25,25 +39,25 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both invalid]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[null hash, invalid]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[string, null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[both non-null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
Expected (expected): QVariant(PhonyClass,<value not representable as string>)]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQStringLists">
<Incident type="pass" file="" line="0">
@@ -52,65 +66,65 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal lists]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[second-last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[prefix]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 2
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[short list second]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 12
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[short list first]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 1
Expected (opB) size: 12]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListInt">
-<Incident type="fail" file="tst_cmptest.cpp" line="320">
+<Incident type="fail" file="tst_cmptest.cpp" line="332">
<Description><![CDATA[Compared lists differ at index 2.
Actual (int1): 3
Expected (int2): 4]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListDouble">
-<Incident type="fail" file="tst_cmptest.cpp" line="327">
+<Incident type="fail" file="tst_cmptest.cpp" line="339">
<Description><![CDATA[Compared lists differ at index 0.
Actual (double1): 1.5
Expected (double2): 1]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQPixmaps">
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 0
@@ -119,29 +133,29 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQImages">
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 0
@@ -150,26 +164,50 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QImages differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[different format]]></DataTag>
<Description><![CDATA[Compared QImages differ in format.
Actual (opA): 6
Expected (opB): 3]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="verify">
+<Incident type="fail" file="tst_cmptest.cpp" line="404">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="verify2">
+<Incident type="fail" file="tst_cmptest.cpp" line="410">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="tryVerify">
+<Incident type="fail" file="tst_cmptest.cpp" line="416">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="tryVerify2">
+<Incident type="fail" file="tst_cmptest.cpp" line="422">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
+</Incident>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="cleanupTestCase">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt
index 9e8c56ed99..70c54704f9 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.txt
+++ b/tests/auto/testlib/selftests/expected_cmptest.txt
@@ -1,91 +1,105 @@
********* Start testing of tst_Cmptest *********
-Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@
+Config: Using QtTest library
PASS : tst_Cmptest::initTestCase()
+FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same
+ Loc: [tst_cmptest.cpp(154)]
+FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same
+ Actual (Qt::ArrowCursor): ArrowCursor
+ Expected (Qt::BusyCursor) : BusyCursor
+ Loc: [tst_cmptest.cpp(160)]
PASS : tst_Cmptest::compare_boolfuncs()
PASS : tst_Cmptest::compare_pointerfuncs()
FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same
Actual (actual) : QVariant(int,123)
Expected (expected): QVariant(QString,hi)
- Loc: [tst_cmptest.cpp(219)]
+ Loc: [tst_cmptest.cpp(231)]
PASS : tst_Cmptest::compare_tostring(both invalid)
FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same
Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()
- Loc: [tst_cmptest.cpp(219)]
+ Loc: [tst_cmptest.cpp(231)]
FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same
Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)
- Loc: [tst_cmptest.cpp(219)]
+ Loc: [tst_cmptest.cpp(231)]
FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
Expected (expected): QVariant(PhonyClass,<value not representable as string>)
- Loc: [tst_cmptest.cpp(219)]
+ Loc: [tst_cmptest.cpp(231)]
PASS : tst_Cmptest::compareQStringLists(empty lists)
PASS : tst_Cmptest::compareQStringLists(equal lists)
FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"
- Loc: [tst_cmptest.cpp(313)]
+ Loc: [tst_cmptest.cpp(325)]
FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"
- Loc: [tst_cmptest.cpp(313)]
+ Loc: [tst_cmptest.cpp(325)]
FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared lists have different sizes.
Actual (opA) size: 2
Expected (opB) size: 1
- Loc: [tst_cmptest.cpp(313)]
+ Loc: [tst_cmptest.cpp(325)]
FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared lists have different sizes.
Actual (opA) size: 12
Expected (opB) size: 1
- Loc: [tst_cmptest.cpp(313)]
+ Loc: [tst_cmptest.cpp(325)]
FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared lists have different sizes.
Actual (opA) size: 1
Expected (opB) size: 12
- Loc: [tst_cmptest.cpp(313)]
+ Loc: [tst_cmptest.cpp(325)]
FAIL! : tst_Cmptest::compareQListInt() Compared lists differ at index 2.
Actual (int1): 3
Expected (int2): 4
- Loc: [tst_cmptest.cpp(320)]
+ Loc: [tst_cmptest.cpp(332)]
FAIL! : tst_Cmptest::compareQListDouble() Compared lists differ at index 0.
Actual (double1): 1.5
Expected (double2): 1
- Loc: [tst_cmptest.cpp(327)]
+ Loc: [tst_cmptest.cpp(339)]
PASS : tst_Cmptest::compareQPixmaps(both null)
FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(365)]
FAIL! : tst_Cmptest::compareQPixmaps(other null) Compared QPixmaps differ.
Actual (opA).isNull(): 0
Expected (opB).isNull(): 1
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(365)]
PASS : tst_Cmptest::compareQPixmaps(equal)
FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ in size.
Actual (opA): 11x20
Expected (opB): 20x20
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(365)]
FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(365)]
PASS : tst_Cmptest::compareQImages(both null)
FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0
- Loc: [tst_cmptest.cpp(380)]
+ Loc: [tst_cmptest.cpp(392)]
FAIL! : tst_Cmptest::compareQImages(other null) Compared QImages differ.
Actual (opA).isNull(): 0
Expected (opB).isNull(): 1
- Loc: [tst_cmptest.cpp(380)]
+ Loc: [tst_cmptest.cpp(392)]
PASS : tst_Cmptest::compareQImages(equal)
FAIL! : tst_Cmptest::compareQImages(different size) Compared QImages differ in size.
Actual (opA): 11x20
Expected (opB): 20x20
- Loc: [tst_cmptest.cpp(380)]
+ Loc: [tst_cmptest.cpp(392)]
FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ in format.
Actual (opA): 6
Expected (opB): 3
- Loc: [tst_cmptest.cpp(380)]
+ Loc: [tst_cmptest.cpp(392)]
FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same
- Loc: [tst_cmptest.cpp(380)]
+ Loc: [tst_cmptest.cpp(392)]
+FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. ()
+ Loc: [tst_cmptest.cpp(404)]
+FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42)
+ Loc: [tst_cmptest.cpp(410)]
+FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. ()
+ Loc: [tst_cmptest.cpp(416)]
+FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42)
+ Loc: [tst_cmptest.cpp(422)]
PASS : tst_Cmptest::cleanupTestCase()
-Totals: 11 passed, 20 failed, 0 skipped, 0 blacklisted
+Totals: 11 passed, 26 failed, 0 skipped, 0 blacklisted
********* Finished testing of tst_Cmptest *********
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml
index aefb1b5f4c..9437e8e4b7 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xml
@@ -7,18 +7,32 @@
</Environment>
<TestFunction name="initTestCase">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="compare_unregistered_enums">
+<Incident type="fail" file="tst_cmptest.cpp" line="154">
+ <Description><![CDATA[Compared values are not the same]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="compare_registered_enums">
+<Incident type="fail" file="tst_cmptest.cpp" line="160">
+ <Description><![CDATA[Compared values are not the same
+ Actual (Qt::ArrowCursor): ArrowCursor
+ Expected (Qt::BusyCursor) : BusyCursor]]></Description>
+</Incident>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_boolfuncs">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_pointerfuncs">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_tostring">
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[int, string]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(int,123)
@@ -27,25 +41,25 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both invalid]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[null hash, invalid]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[string, null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="219">
+<Incident type="fail" file="tst_cmptest.cpp" line="231">
<DataTag><![CDATA[both non-null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
Expected (expected): QVariant(PhonyClass,<value not representable as string>)]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQStringLists">
<Incident type="pass" file="" line="0">
@@ -54,65 +68,65 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal lists]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[second-last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[prefix]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 2
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[short list second]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 12
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="313">
+<Incident type="fail" file="tst_cmptest.cpp" line="325">
<DataTag><![CDATA[short list first]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 1
Expected (opB) size: 12]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListInt">
-<Incident type="fail" file="tst_cmptest.cpp" line="320">
+<Incident type="fail" file="tst_cmptest.cpp" line="332">
<Description><![CDATA[Compared lists differ at index 2.
Actual (int1): 3
Expected (int2): 4]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListDouble">
-<Incident type="fail" file="tst_cmptest.cpp" line="327">
+<Incident type="fail" file="tst_cmptest.cpp" line="339">
<Description><![CDATA[Compared lists differ at index 0.
Actual (double1): 1.5
Expected (double2): 1]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQPixmaps">
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 0
@@ -121,29 +135,29 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="365">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQImages">
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 0
@@ -152,27 +166,51 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QImages differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[different format]]></DataTag>
<Description><![CDATA[Compared QImages differ in format.
Actual (opA): 6
Expected (opB): 3]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="380">
+<Incident type="fail" file="tst_cmptest.cpp" line="392">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="verify">
+<Incident type="fail" file="tst_cmptest.cpp" line="404">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="verify2">
+<Incident type="fail" file="tst_cmptest.cpp" line="410">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="tryVerify">
+<Incident type="fail" file="tst_cmptest.cpp" line="416">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
+<TestFunction name="tryVerify2">
+<Incident type="fail" file="tst_cmptest.cpp" line="422">
+ <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
+</Incident>
+ <Duration msecs="0"/>
</TestFunction>
<TestFunction name="cleanupTestCase">
<Incident type="pass" file="" line="0" />
-<Duration msecs="0"/>
+ <Duration msecs="0"/>
</TestFunction>
<Duration msecs="0"/>
</TestCase>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
index 7502d3cc54..fa970d4172 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
@@ -1,11 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" failures="20" tests="10" name="tst_Cmptest">
+<testsuite errors="0" failures="26" tests="16" name="tst_Cmptest">
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
<property value="" name="QtBuild"/>
</properties>
<testcase result="pass" name="initTestCase"/>
+ <testcase result="fail" name="compare_unregistered_enums">
+ <failure message="Compared values are not the same" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="compare_registered_enums">
+ <failure message="Compared values are not the same
+ Actual (Qt::ArrowCursor): ArrowCursor
+ Expected (Qt::BusyCursor) : BusyCursor" result="fail"/>
+ </testcase>
<testcase result="pass" name="compare_boolfuncs"/>
<testcase result="pass" name="compare_pointerfuncs"/>
<testcase result="fail" name="compare_tostring">
@@ -76,6 +84,18 @@
Expected (opB): 3" result="fail"/>
<failure tag="different pixels" message="Compared values are not the same" result="fail"/>
</testcase>
+ <testcase result="fail" name="verify">
+ <failure message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. ()" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="verify2">
+ <failure message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. (42)" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="tryVerify">
+ <failure message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. ()" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="tryVerify2">
+ <failure message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. (42)" result="fail"/>
+ </testcase>
<testcase result="pass" name="cleanupTestCase"/>
<system-err/>
</testsuite>
diff --git a/tests/auto/testlib/selftests/expected_crashes_3.txt b/tests/auto/testlib/selftests/expected_crashes_3.txt
index 57c3ddc2ba..0e3f60dd1b 100644
--- a/tests/auto/testlib/selftests/expected_crashes_3.txt
+++ b/tests/auto/testlib/selftests/expected_crashes_3.txt
@@ -2,6 +2,7 @@
Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@
PASS : tst_Crashes::initTestCase()
QFATAL : tst_Crashes::crash() Received signal 11
+ Function time: ms Total time: ms
FAIL! : tst_Crashes::crash() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 1 passed, 1 failed, 0 skipped, 0 blacklisted
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 6536f103ac..63c48fc809 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -316,6 +316,7 @@ tst_Selftests::tst_Selftests()
void tst_Selftests::initTestCase()
{
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
//Detect the location of the sub programs
QString subProgram = QLatin1String("float/float");
#if defined(Q_OS_WIN)
@@ -571,7 +572,9 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
#endif
QProcess proc;
- static const QProcessEnvironment environment = processEnvironment();
+ QProcessEnvironment environment = processEnvironment();
+ if (crashes)
+ environment.insert("QTEST_DISABLE_STACK_DUMP", "1");
proc.setProcessEnvironment(environment);
const QString path = subdir + QLatin1Char('/') + subdir;
proc.start(path, arguments);
@@ -623,11 +626,33 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
for (int n = 0; n < loggers.count(); ++n) {
QString logger = loggers[n];
+ if (n == 0 && subdir == QLatin1String("crashes")) {
+ QByteArray &actual = actualOutputs[0];
+#ifndef Q_OS_WIN
+ // Remove digits of times to match the expected file.
+ const QLatin1String timePattern("Function time:");
+ int timePos = actual.indexOf(timePattern);
+ if (timePos >= 0) {
+ timePos += timePattern.size();
+ const int nextLinePos = actual.indexOf('\n', timePos);
+ for (int c = (nextLinePos != -1 ? nextLinePos : actual.size()) - 1; c >= timePos; --c) {
+ if (actual.at(c) >= '0' && actual.at(c) <= '9')
+ actual.remove(c, 1);
+ }
+ }
+#else // !Q_OS_WIN
+ // Remove stack trace which is output to stdout.
+ const int exceptionLogStart = actual.indexOf("A crash occurred in ");
+ if (exceptionLogStart >= 0)
+ actual.truncate(exceptionLogStart);
+#endif // Q_OS_WIN
+ }
+
QList<QByteArray> res = splitLines(actualOutputs[n]);
const QString expectedFileName = expectedFileNameFromTest(subdir, logger);
QList<QByteArray> exp = expectedResult(expectedFileName);
-#if defined (Q_CC_MSVC) || defined(Q_CC_MINGW)
- // MSVC, MinGW format double numbers differently
+#if (defined (Q_CC_MSVC) && _MSC_VER < 1900)|| defined(Q_CC_MINGW)
+ // MSVC up to MSVC2013, MinGW format double numbers differently
if (n == 0 && subdir == QStringLiteral("float")) {
for (int i = 0; i < exp.size(); ++i) {
exp[i].replace("e-07", "e-007");
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 350c6142d2..fa1b68b4f9 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -880,7 +880,7 @@ void tst_Moc::preprocessorConditionals()
QVERIFY(mobj->indexOfSignal("signalInIf1()") != -1);
QVERIFY(mobj->indexOfSignal("signalInIf2()") != -1);
QVERIFY(mobj->indexOfSignal("signalInIf3()") != -1);
- QVERIFY(mobj->indexOfSignal("doNotExist()") == -1);
+ QCOMPARE(mobj->indexOfSignal("doNotExist()"), -1);
}
void tst_Moc::blackslashNewlines()
@@ -888,7 +888,7 @@ void tst_Moc::blackslashNewlines()
BackslashNewlines tst;
const QMetaObject *mobj = tst.metaObject();
QVERIFY(mobj->indexOfSlot("works()") != -1);
- QVERIFY(mobj->indexOfSlot("buggy()") == -1);
+ QCOMPARE(mobj->indexOfSlot("buggy()"), -1);
}
void tst_Moc::slotWithSillyConst()
@@ -928,8 +928,8 @@ void tst_Moc::testExtraDataForEnum()
const QMetaObject * const *objects = mobjUser->d.relatedMetaObjects;
QVERIFY(objects);
- QVERIFY(objects[0] == mobjSource);
- QVERIFY(objects[1] == 0);
+ QCOMPARE(objects[0], mobjSource);
+ QVERIFY(!objects[1]);
}
void tst_Moc::namespaceTypeProperty()
@@ -982,7 +982,7 @@ void tst_Moc::namespacedFlags()
const QVariant v = bar.property("flags");
QVERIFY(v.isValid());
QVERIFY(baz.setProperty("flags", v));
- QVERIFY(baz.flags() == bar.flags());
+ QCOMPARE(baz.flags(), bar.flags());
QList<Foo::Bar::Flags> l;
l << baz.flags();
@@ -1104,7 +1104,7 @@ void tst_Moc::winNewline()
if (data.at(i) == QLatin1Char('\r')) {
QVERIFY(i < data.count() - 1);
++i;
- QVERIFY(data.at(i) == '\n');
+ QCOMPARE(data.at(i), '\n');
} else {
QVERIFY(data.at(i) != '\n');
}
@@ -1255,14 +1255,14 @@ void tst_Moc::invokable()
{
const QMetaObject &mobj = InvokableBeforeReturnType::staticMetaObject;
QCOMPARE(mobj.methodCount(), 6);
- QVERIFY(mobj.method(5).methodSignature() == QByteArray("foo()"));
+ QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()"));
}
{
const QMetaObject &mobj = InvokableBeforeInline::staticMetaObject;
QCOMPARE(mobj.methodCount(), 7);
- QVERIFY(mobj.method(5).methodSignature() == QByteArray("foo()"));
- QVERIFY(mobj.method(6).methodSignature() == QByteArray("bar()"));
+ QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()"));
+ QCOMPARE(mobj.method(6).methodSignature(), QByteArray("bar()"));
}
}
@@ -1271,22 +1271,22 @@ void tst_Moc::singleFunctionKeywordSignalAndSlot()
{
const QMetaObject &mobj = SingleFunctionKeywordBeforeReturnType::staticMetaObject;
QCOMPARE(mobj.methodCount(), 7);
- QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()"));
- QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()"));
+ QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()"));
+ QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()"));
}
{
const QMetaObject &mobj = SingleFunctionKeywordBeforeInline::staticMetaObject;
QCOMPARE(mobj.methodCount(), 7);
- QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()"));
- QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()"));
+ QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()"));
+ QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()"));
}
{
const QMetaObject &mobj = SingleFunctionKeywordAfterInline::staticMetaObject;
QCOMPARE(mobj.methodCount(), 7);
- QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()"));
- QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()"));
+ QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()"));
+ QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()"));
}
}
@@ -1740,34 +1740,34 @@ template <class T>
void tst_Moc::revisions_T()
{
int idx = T::staticMetaObject.indexOfProperty("prop1");
- QVERIFY(T::staticMetaObject.property(idx).revision() == 0);
+ QCOMPARE(T::staticMetaObject.property(idx).revision(), 0);
idx = T::staticMetaObject.indexOfProperty("prop2");
- QVERIFY(T::staticMetaObject.property(idx).revision() == 2);
+ QCOMPARE(T::staticMetaObject.property(idx).revision(), 2);
idx = T::staticMetaObject.indexOfMethod("method1()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 0);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 0);
idx = T::staticMetaObject.indexOfMethod("method2()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 4);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 4);
idx = T::staticMetaObject.indexOfSlot("slot1()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 0);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 0);
idx = T::staticMetaObject.indexOfSlot("slot2()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 3);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 3);
idx = T::staticMetaObject.indexOfSlot("slot3()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 6);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 6);
idx = T::staticMetaObject.indexOfSlot("slot4()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 6);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 6);
idx = T::staticMetaObject.indexOfSignal("signal1()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 0);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 0);
idx = T::staticMetaObject.indexOfSignal("signal2()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 5);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 5);
idx = T::staticMetaObject.indexOfSignal("signal3()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 7);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 7);
idx = T::staticMetaObject.indexOfSignal("signal4()");
- QVERIFY(T::staticMetaObject.method(idx).revision() == 7);
+ QCOMPARE(T::staticMetaObject.method(idx).revision(), 7);
idx = T::staticMetaObject.indexOfEnumerator("TestEnum");
QCOMPARE(T::staticMetaObject.enumerator(idx).keyCount(), 2);
@@ -1947,7 +1947,7 @@ public:
void tst_Moc::privateClass()
{
- QVERIFY(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()") == 0);
+ QCOMPARE(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()"), 0);
QVERIFY(PrivateClass::staticMetaObject.indexOfSignal("someSignal()") > 0);
}
@@ -3068,7 +3068,7 @@ void tst_Moc::parseDefines()
int index = mo->indexOfSlot("stringMethod()");
QVERIFY(index != -1);
- QVERIFY(mo->method(index).returnType() == QMetaType::QString);
+ QCOMPARE(mo->method(index).returnType(), int(QMetaType::QString));
index = mo->indexOfSlot("combined1()");
QVERIFY(index != -1);
@@ -3127,7 +3127,7 @@ void tst_Moc::parseDefines()
QVERIFY(!qstrcmp(mci.value(), "TestValue"));
}
}
- QVERIFY(count == 3);
+ QCOMPARE(count, 3);
index = mo->indexOfSlot("PD_DEFINE_ITSELF_SUFFIX(int)");
QVERIFY(index != -1);
@@ -3253,7 +3253,7 @@ void tst_Moc::relatedMetaObjectsWithinNamespaces()
const QMetaObject *testMo = &QTBUG_2151::B::staticMetaObject;
QVERIFY(testMo->d.relatedMetaObjects);
- QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo);
+ QCOMPARE(testMo->d.relatedMetaObjects[0], relatedMo);
}
void tst_Moc::relatedMetaObjectsInGadget()
@@ -3262,7 +3262,7 @@ void tst_Moc::relatedMetaObjectsInGadget()
const QMetaObject *testMo = &QTBUG_35657::B::staticMetaObject;
QVERIFY(testMo->d.relatedMetaObjects);
- QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo);
+ QCOMPARE(testMo->d.relatedMetaObjects[0], relatedMo);
}
void tst_Moc::relatedMetaObjectsNameConflict_data()
diff --git a/tests/auto/tools/qmake/qmake.pro b/tests/auto/tools/qmake/qmake.pro
index 5ed3073e20..d0817247db 100644
--- a/tests/auto/tools/qmake/qmake.pro
+++ b/tests/auto/tools/qmake/qmake.pro
@@ -8,5 +8,11 @@ SOURCES += tst_qmake.cpp testcompiler.cpp
QT = core testlib
cross_compile: DEFINES += QMAKE_CROSS_COMPILED
+debug_and_release {
+ CONFIG(debug, debug|release): \
+ DEFINES += DEBUG_BUILD
+ else: \
+ DEFINES += RELEASE_BUILD
+}
TESTDATA += testdata/*
diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp b/tests/auto/tools/qmake/testdata/resources/main.cpp
index 2d86b46875..78f9814396 100644
--- a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp
+++ b/tests/auto/tools/qmake/testdata/resources/main.cpp
@@ -30,17 +30,13 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QApplication>
-#include <stdio.h>
-int main(int argc, char *argv[])
+
+
+#include <qguiapplication.h>
+
+int main( int argc, char **argv )
{
- QApplication app(argc, argv);
- if (argc > 1)
- fprintf(stderr, "%s", argv[1]);
- else
- fprintf(stderr, "Failed");
- fflush(stderr);
- return 0;
+ QGuiApplication a( argc, argv );
+ return a.exec();
}
-
diff --git a/tests/auto/tools/qmake/testdata/resources/resources.pro b/tests/auto/tools/qmake/testdata/resources/resources.pro
new file mode 100644
index 0000000000..f024fe5617
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/resources/resources.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+SOURCES = main.cpp
+
+pro_file.files = resources.pro
+pro_file.prefix = /prefix
+
+subdir.files = subdir/file.txt
+subdir.base = subdir
+
+RESOURCES = test.qrc main.cpp pro_file subdir
diff --git a/tests/auto/tools/qmake/testdata/resources/subdir/file.txt b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt
diff --git a/tests/auto/tools/qmake/testdata/resources/test.qrc b/tests/auto/tools/qmake/testdata/resources/test.qrc
new file mode 100644
index 0000000000..decde3dd24
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/resources/test.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>test.qrc</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index da5314c83b..ac94d1a2b9 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -39,6 +39,14 @@
#include <QStandardPaths>
#include <QDir>
+#if defined(DEBUG_BUILD)
+# define DIR_INFIX "debug/"
+#elif defined(RELEASE_BUILD)
+# define DIR_INFIX "release/"
+#else
+# define DIR_INFIX ""
+#endif
+
class tst_qmake : public QObject
{
Q_OBJECT
@@ -77,6 +85,7 @@ private slots:
void substitutes();
void project();
void proFileCache();
+ void resources();
private:
TestCompiler test_compiler;
@@ -490,5 +499,38 @@ void tst_qmake::proFileCache()
QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" ));
}
+void tst_qmake::resources()
+{
+ QString workDir = base_path + "/testdata/resources";
+ QVERIFY(test_compiler.qmake(workDir, "resources"));
+
+ {
+ QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_pro_file.qrc");
+ QVERIFY(qrcFile.exists());
+ QVERIFY(qrcFile.open(QFile::ReadOnly));
+ QByteArray qrcXml = qrcFile.readAll();
+ QVERIFY(qrcXml.contains("alias=\"resources.pro\""));
+ QVERIFY(qrcXml.contains("prefix=\"/prefix\""));
+ }
+
+ {
+ QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_subdir.qrc");
+ QVERIFY(qrcFile.exists());
+ QVERIFY(qrcFile.open(QFile::ReadOnly));
+ QByteArray qrcXml = qrcFile.readAll();
+ QVERIFY(qrcXml.contains("alias=\"file.txt\""));
+ }
+
+ {
+ QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_qmake_immediate.qrc");
+ QVERIFY(qrcFile.exists());
+ QVERIFY(qrcFile.open(QFile::ReadOnly));
+ QByteArray qrcXml = qrcFile.readAll();
+ QVERIFY(qrcXml.contains("alias=\"main.cpp\""));
+ }
+
+ QVERIFY(test_compiler.make(workDir));
+}
+
QTEST_MAIN(tst_qmake)
#include "tst_qmake.moc"
diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp
index eac80bed7a..42c8e3e7b9 100644
--- a/tests/auto/tools/uic/tst_uic.cpp
+++ b/tests/auto/tools/uic/tst_uic.cpp
@@ -86,6 +86,7 @@ static QByteArray msgProcessStartFailed(const QString &command, const QString &w
void tst_uic::initTestCase()
{
+ QVERIFY2(m_generated.isValid(), qPrintable(m_generated.errorString()));
QVERIFY(m_versionRegexp.isValid());
m_baseline = QFINDTESTDATA("baseline");
QVERIFY2(!m_baseline.isEmpty(), "Could not find 'baseline'.");
diff --git a/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro b/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro
index 22f6bab497..c379e67ec5 100644
--- a/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro
+++ b/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro
@@ -4,5 +4,4 @@ TARGET = tst_qcolordialog
QT += widgets testlib
SOURCES += tst_qcolordialog.cpp
-
-
+linux*: CONFIG += insignificant_test # Crashes on different Linux distros
diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
index 59227a6168..c5e31a4bd4 100644
--- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
+++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
@@ -98,7 +98,7 @@ void tst_QColorDialog::testNativeActiveModalWidget()
TestNativeDialog d;
QTimer::singleShot(1000, &d, SLOT(hide()));
d.exec();
- QVERIFY(&d == d.m_activeModalWidget);
+ QCOMPARE(&d, d.m_activeModalWidget);
}
void tst_QColorDialog::native_activeModalWidget()
diff --git a/tests/auto/widgets/dialogs/qdialog/BLACKLIST b/tests/auto/widgets/dialogs/qdialog/BLACKLIST
new file mode 100644
index 0000000000..3da7337784
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qdialog/BLACKLIST
@@ -0,0 +1,2 @@
+[snapToDefaultButton]
+osx
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index e62ce3ceb5..2982d80477 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -557,7 +557,7 @@ void tst_QDialog::snapToDefaultButton()
#ifdef QT_NO_CURSOR
QSKIP("Test relies on there being a cursor");
#else
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: Wayland does not support setting the cursor position.");
QPoint topLeftPos = QApplication::desktop()->availableGeometry().topLeft();
diff --git a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro
index 3a96827352..2a11a29420 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro
+++ b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro
@@ -21,3 +21,5 @@ wince* {
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
+
+linux*: CONFIG += insignificant_test # Crashes on different Linux distros
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index ffc000a418..bc3c5e73f0 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -483,11 +483,11 @@ void tst_QFiledialog::completer()
if (startPath.isEmpty()) {
tempDir.reset(new QTemporaryDir);
- QVERIFY(tempDir->isValid());
+ QVERIFY2(tempDir->isValid(), qPrintable(tempDir->errorString()));
startPath = tempDir->path();
for (int i = 0; i < 10; ++i) {
TemporaryFilePtr file(new QTemporaryFile(startPath + QStringLiteral("/rXXXXXX")));
- QVERIFY(file->open());
+ QVERIFY2(file->open(), qPrintable(file->errorString()));
files.append(file);
}
}
@@ -677,7 +677,7 @@ void tst_QFiledialog::filters()
// effects
QList<QComboBox*> views = fd.findChildren<QComboBox*>("fileTypeCombo");
- QVERIFY(views.count() == 1);
+ QCOMPARE(views.count(), 1);
QCOMPARE(views.at(0)->isVisible(), false);
QStringList filters;
@@ -889,7 +889,7 @@ void tst_QFiledialog::selectFile()
QScopedPointer<QTemporaryFile> tempFile;
if (file == QLatin1String("temp")) {
tempFile.reset(new QTemporaryFile(QDir::tempPath() + QStringLiteral("/aXXXXXX")));
- QVERIFY(tempFile->open());
+ QVERIFY2(tempFile->open(), qPrintable(tempFile->errorString()));
file = tempFile->fileName();
}
@@ -927,7 +927,7 @@ void tst_QFiledialog::selectFileWrongCaseSaveAs()
void tst_QFiledialog::selectFiles()
{
QTemporaryDir tempDir;
- QVERIFY(tempDir.isValid());
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
const QString tempPath = tempDir.path();
{
QNonNativeFileDialog fd;
@@ -1296,7 +1296,7 @@ void tst_QFiledialog::clearLineEdit()
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
- QVERIFY(lineEdit->text() == "foo");
+ QCOMPARE(lineEdit->text(), QLatin1String("foo"));
fd.setDirectory(QDir::home());
QListView* list = fd.findChild<QListView*>("listView");
@@ -1393,12 +1393,12 @@ void tst_QFiledialog::trailingDotsAndSpaces()
QTest::keyClick(lineEdit, Qt::Key_Space);
QTest::keyClick(lineEdit, Qt::Key_Period);
QTest::qWait(1000);
- QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex()));
+ QCOMPARE(currentChildrenCount, list->model()->rowCount(list->rootIndex()));
lineEdit->clear();
QTest::keyClick(lineEdit, Qt::Key_Period);
QTest::keyClick(lineEdit, Qt::Key_Space);
QTest::qWait(1000);
- QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex()));
+ QCOMPARE(currentChildrenCount, list->model()->rowCount(list->rootIndex()));
}
#ifdef Q_OS_UNIX
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index ed34c67aad..d48c718d4d 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -57,6 +57,8 @@
#include "../../../../../src/widgets/dialogs/qfilesystemmodel_p.h"
#include "../../../../../src/widgets/dialogs/qfiledialog_p.h"
+#include <qpa/qplatformdialoghelper.h>
+
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#include "../../../network-settings.h"
#endif
@@ -79,6 +81,12 @@ public:
}
};
+static QByteArray msgDoesNotExist(const QString &name)
+{
+ return (QLatin1Char('"') + QDir::toNativeSeparators(name)
+ + QLatin1String("\" does not exist.")).toLocal8Bit();
+}
+
class tst_QFileDialog2 : public QObject
{
Q_OBJECT
@@ -134,6 +142,8 @@ private slots:
void QTBUG6558_showDirsOnly();
void QTBUG4842_selectFilterWithHideNameFilterDetails();
void dontShowCompleterOnRoot();
+ void nameFilterParsing_data();
+ void nameFilterParsing();
private:
void cleanupSettingsFile();
@@ -167,7 +177,7 @@ void tst_QFileDialog2::cleanupSettingsFile()
void tst_QFileDialog2::initTestCase()
{
- QVERIFY(tempDir.isValid());
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
QStandardPaths::setTestModeEnabled(true);
cleanupSettingsFile();
}
@@ -239,13 +249,13 @@ void tst_QFileDialog2::deleteDirAndFiles()
QTemporaryFile *t;
t = new QTemporaryFile(tempPath + "/foo/aXXXXXX");
t->setAutoRemove(false);
- t->open();
+ QVERIFY2(t->open(), qPrintable(t->errorString()));
t->close();
delete t;
t = new QTemporaryFile(tempPath + "/foo/B/yXXXXXX");
t->setAutoRemove(false);
- t->open();
+ QVERIFY2(t->open(), qPrintable(t->errorString()));
t->close();
delete t;
FriendlyQFileDialog fd;
@@ -303,7 +313,7 @@ void tst_QFileDialog2::unc()
#else
QString dir(QDir::currentPath());
#endif
- QVERIFY(QFile::exists(dir));
+ QVERIFY2(QFile::exists(dir), msgDoesNotExist(dir).constData());
QNonNativeFileDialog fd(0, QString(), dir);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
@@ -459,7 +469,7 @@ void tst_QFileDialog2::task180459_lastDirectory_data()
void tst_QFileDialog2::task180459_lastDirectory()
{
- if (qApp->platformName().toLower() == QStringLiteral("cocoa"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive))
QSKIP("Insignificant on OSX"); //QTBUG-39183
//first visit the temp directory and close the dialog
QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", tempDir.path());
@@ -845,7 +855,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
current.mkdir("f");
current.mkdir("g");
QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX");
- tempFile->open();
+ QVERIFY2(tempFile->open(), qPrintable(tempFile->errorString()));
current.cdUp();
QNonNativeFileDialog fd;
@@ -1104,6 +1114,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes()
QString tempPath = tempDir.path();
QTemporaryFile *t;
t = new QTemporaryFile;
+ QVERIFY2(t->open(), qPrintable(t->errorString()));
t->open();
QNonNativeFileDialog fd(0, "TestFileDialog");
@@ -1205,7 +1216,7 @@ void tst_QFileDialog2::QTBUG4419_lineEditSelectAll()
{
QString tempPath = tempDir.path();
QTemporaryFile temporaryFile(tempPath + "/tst_qfiledialog2_lineEditSelectAll.XXXXXX");
- QVERIFY(temporaryFile.open());
+ QVERIFY2(temporaryFile.open(), qPrintable(temporaryFile.errorString()));
QNonNativeFileDialog fd(0, "TestFileDialog", temporaryFile.fileName());
fd.setDirectory(tempPath);
@@ -1353,5 +1364,24 @@ void tst_QFileDialog2::dontShowCompleterOnRoot()
QTRY_VERIFY(lineEdit->completer()->popup()->isHidden());
}
+void tst_QFileDialog2::nameFilterParsing_data()
+{
+ QTest::addColumn<QString>("filterString");
+ QTest::addColumn<QStringList>("filters");
+
+ // QTBUG-47923: Do not trip over "*,v".
+ QTest::newRow("text") << "plain text document (*.txt *.asc *,v *.doc)"
+ << (QStringList() << "*.txt" << "*.asc" << "*,v" << "*.doc");
+ QTest::newRow("html") << "HTML document (*.html *.htm)"
+ << (QStringList() << "*.html" << "*.htm");
+}
+
+void tst_QFileDialog2::nameFilterParsing()
+{
+ QFETCH(QString, filterString);
+ QFETCH(QStringList, filters);
+ QCOMPARE(QPlatformFileDialogHelper::cleanFilterList(filterString), filters);
+}
+
QTEST_MAIN(tst_QFileDialog2)
#include "tst_qfiledialog2.moc"
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 03f0d25375..209048a853 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -167,13 +167,13 @@ void tst_QFileSystemModel::cleanup()
QVERIFY(dir.rmdir(list.at(i)));
}
list = dir.entryList(QDir::AllEntries | QDir::System | QDir::Hidden | QDir::NoDotAndDotDot);
- QVERIFY(list.count() == 0);
+ QCOMPARE(list.count(), 0);
}
}
void tst_QFileSystemModel::initTestCase()
{
- QVERIFY(m_tempDir.isValid());
+ QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString()));
flatDirTestPath = m_tempDir.path();
}
@@ -318,7 +318,7 @@ void tst_QFileSystemModel::readOnly()
{
QCOMPARE(model->isReadOnly(), true);
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
- file.open();
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
@@ -523,8 +523,14 @@ void tst_QFileSystemModel::rowsInserted()
QVERIFY(createFiles(tmp, QStringList(".hidden_file"), 5 + count));
- if (count != 0) QTRY_VERIFY(spy0.count() >= 1); else QTRY_VERIFY(spy0.count() == 0);
- if (count != 0) QTRY_VERIFY(spy1.count() >= 1); else QTRY_VERIFY(spy1.count() == 0);
+ if (count != 0)
+ QTRY_VERIFY(spy0.count() >= 1);
+ else
+ QTRY_COMPARE(spy0.count(), 0);
+ if (count != 0)
+ QTRY_VERIFY(spy1.count() >= 1);
+ else
+ QTRY_COMPARE(spy1.count(), 0);
}
void tst_QFileSystemModel::rowsRemoved_data()
@@ -563,8 +569,8 @@ void tst_QFileSystemModel::rowsRemoved()
}
} else {
if (i == 10 || spy0.count() == 0) {
- QVERIFY(spy0.count() == 0);
- QVERIFY(spy1.count() == 0);
+ QCOMPARE(spy0.count(), 0);
+ QCOMPARE(spy1.count(), 0);
}
}
QStringList lst;
@@ -583,8 +589,8 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + '/' + QString(".c")));
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy0.count() >= 1); else QVERIFY(spy0.count() == 0);
- if (count != 0) QVERIFY(spy1.count() >= 1); else QVERIFY(spy1.count() == 0);
+ if (count != 0) QVERIFY(spy0.count() >= 1); else QCOMPARE(spy0.count(), 0);
+ if (count != 0) QVERIFY(spy1.count() >= 1); else QCOMPARE(spy1.count(), 0);
}
void tst_QFileSystemModel::dataChanged_data()
@@ -614,7 +620,7 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy.count() >= 1); else QVERIFY(spy.count() == 0);
+ if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
*/
}
@@ -813,7 +819,7 @@ void tst_QFileSystemModel::setData()
void tst_QFileSystemModel::sortPersistentIndex()
{
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
- file.open();
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
diff --git a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
new file mode 100644
index 0000000000..31fbc428c9
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
@@ -0,0 +1,4 @@
+[task256466_wrongStyle]
+opensuse-13.1
+[setFont]
+ubuntu-14.04
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm
index 6e4ad29190..0d29f5b7a2 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm
@@ -36,7 +36,7 @@
void click_cocoa_button()
{
- QMacCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSArray *windows = [NSApp windows];
for (NSWindow *window in windows) {
// This is NOT how one should do RTTI, but since I don't want to leak the class too much...
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index cb816a7e85..97cfec8171 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -216,7 +216,7 @@ void tst_QMessageBox::button()
// remove the cancel, should not exist anymore
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- QVERIFY(msgBox.button(QMessageBox::Cancel) == 0);
+ QVERIFY(!msgBox.button(QMessageBox::Cancel));
QVERIFY(msgBox.button(QMessageBox::Yes) != 0);
// should not crash
@@ -228,10 +228,10 @@ void tst_QMessageBox::button()
void tst_QMessageBox::defaultButton()
{
QMessageBox msgBox;
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
msgBox.addButton(QMessageBox::Ok);
msgBox.addButton(QMessageBox::Cancel);
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
QPushButton pushButton;
msgBox.setDefaultButton(&pushButton);
QVERIFY(msgBox.defaultButton() == 0); // we have not added it yet
@@ -250,27 +250,27 @@ void tst_QMessageBox::defaultButton()
exec(&msgBox, Qt::Key_Enter);
QCOMPARE(msgBox.clickedButton(), okButton);
msgBox.setDefaultButton(QMessageBox::Yes); // its not in there!
- QVERIFY(msgBox.defaultButton() == okButton);
+ QCOMPARE(msgBox.defaultButton(), okButton);
msgBox.removeButton(okButton);
delete okButton;
okButton = 0;
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
msgBox.setDefaultButton(QMessageBox::Ok);
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
}
void tst_QMessageBox::escapeButton()
{
QMessageBox msgBox;
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
msgBox.addButton(QMessageBox::Ok);
exec(&msgBox);
QVERIFY(msgBox.clickedButton() == msgBox.button(QMessageBox::Ok)); // auto detected (one button only)
msgBox.addButton(QMessageBox::Cancel);
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
QPushButton invalidButton;
msgBox.setEscapeButton(&invalidButton);
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
QAbstractButton *retryButton = msgBox.addButton(QMessageBox::Retry);
exec(&msgBox);
@@ -293,13 +293,13 @@ void tst_QMessageBox::escapeButton()
exec(&msgBox, Qt::Key_Escape);
QCOMPARE(msgBox.clickedButton(), okButton);
msgBox.setEscapeButton(QMessageBox::Yes); // its not in there!
- QVERIFY(msgBox.escapeButton() == okButton);
+ QCOMPARE(msgBox.escapeButton(), okButton);
msgBox.removeButton(okButton);
delete okButton;
okButton = 0;
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
msgBox.setEscapeButton(QMessageBox::Ok);
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
QMessageBox msgBox2;
msgBox2.addButton(QMessageBox::Yes);
@@ -527,13 +527,13 @@ void tst_QMessageBox::testSymbols()
QCOMPARE(mb1.text(), text);
icon = mb1.icon();
- QVERIFY(icon == QMessageBox::NoIcon);
+ QCOMPARE(icon, QMessageBox::NoIcon);
mb1.setIcon(QMessageBox::Question);
- QVERIFY(mb1.icon() == QMessageBox::Question);
+ QCOMPARE(mb1.icon(), QMessageBox::Question);
QPixmap iconPixmap = mb1.iconPixmap();
mb1.setIconPixmap(iconPixmap);
- QVERIFY(mb1.icon() == QMessageBox::NoIcon);
+ QCOMPARE(mb1.icon(), QMessageBox::NoIcon);
QCOMPARE(mb1.buttonText(QMessageBox::Ok), QLatin1String("OK"));
QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString());
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST b/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST
new file mode 100644
index 0000000000..a2670e8f36
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST
@@ -0,0 +1,2 @@
+[autoShow:50_to_100_fast_0_compat]
+osx
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index 21c15edff2..b2bdbac79a 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -400,7 +400,7 @@ void tst_QWizard::setButton()
// revert to default button
wizard.setButton(QWizard::NextButton, 0);
- QVERIFY(toolButton == 0);
+ QVERIFY(toolButton.isNull());
QVERIFY(qobject_cast<QPushButton *>(wizard.button(QWizard::NextButton)));
QVERIFY(wizard.button(QWizard::NextButton)->text().contains("Next"));
}
@@ -408,16 +408,16 @@ void tst_QWizard::setButton()
void tst_QWizard::setTitleFormatEtc()
{
QWizard wizard;
- QVERIFY(wizard.titleFormat() == Qt::AutoText);
- QVERIFY(wizard.subTitleFormat() == Qt::AutoText);
+ QCOMPARE(wizard.titleFormat(), Qt::AutoText);
+ QCOMPARE(wizard.subTitleFormat(), Qt::AutoText);
wizard.setTitleFormat(Qt::RichText);
- QVERIFY(wizard.titleFormat() == Qt::RichText);
- QVERIFY(wizard.subTitleFormat() == Qt::AutoText);
+ QCOMPARE(wizard.titleFormat(), Qt::RichText);
+ QCOMPARE(wizard.subTitleFormat(), Qt::AutoText);
wizard.setSubTitleFormat(Qt::PlainText);
- QVERIFY(wizard.titleFormat() == Qt::RichText);
- QVERIFY(wizard.subTitleFormat() == Qt::PlainText);
+ QCOMPARE(wizard.titleFormat(), Qt::RichText);
+ QCOMPARE(wizard.subTitleFormat(), Qt::PlainText);
}
void tst_QWizard::setPixmap()
@@ -439,7 +439,7 @@ void tst_QWizard::setPixmap()
QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull());
#ifdef Q_OS_OSX
- QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
+ QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
#else
QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull());
#endif
@@ -448,7 +448,7 @@ void tst_QWizard::setPixmap()
QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull());
#ifdef Q_OS_OSX
- QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
+ QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
#else
QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull());
#endif
@@ -459,20 +459,20 @@ void tst_QWizard::setPixmap()
page->setPixmap(QWizard::LogoPixmap, p5);
- QVERIFY(wizard.pixmap(QWizard::BannerPixmap).size() == p1.size());
- QVERIFY(wizard.pixmap(QWizard::LogoPixmap).size() == p2.size());
- QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).size() == p3.size());
- QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).size() == p4.size());
+ QCOMPARE(wizard.pixmap(QWizard::BannerPixmap).size(), p1.size());
+ QCOMPARE(wizard.pixmap(QWizard::LogoPixmap).size(), p2.size());
+ QCOMPARE(wizard.pixmap(QWizard::WatermarkPixmap).size(), p3.size());
+ QCOMPARE(wizard.pixmap(QWizard::BackgroundPixmap).size(), p4.size());
- QVERIFY(page->pixmap(QWizard::BannerPixmap).size() == p1.size());
- QVERIFY(page->pixmap(QWizard::LogoPixmap).size() == p5.size());
- QVERIFY(page->pixmap(QWizard::WatermarkPixmap).size() == p3.size());
- QVERIFY(page->pixmap(QWizard::BackgroundPixmap).size() == p4.size());
+ QCOMPARE(page->pixmap(QWizard::BannerPixmap).size(), p1.size());
+ QCOMPARE(page->pixmap(QWizard::LogoPixmap).size(), p5.size());
+ QCOMPARE(page->pixmap(QWizard::WatermarkPixmap).size(), p3.size());
+ QCOMPARE(page->pixmap(QWizard::BackgroundPixmap).size(), p4.size());
- QVERIFY(page2->pixmap(QWizard::BannerPixmap).size() == p1.size());
- QVERIFY(page2->pixmap(QWizard::LogoPixmap).size() == p2.size());
- QVERIFY(page2->pixmap(QWizard::WatermarkPixmap).size() == p3.size());
- QVERIFY(page2->pixmap(QWizard::BackgroundPixmap).size() == p4.size());
+ QCOMPARE(page2->pixmap(QWizard::BannerPixmap).size(), p1.size());
+ QCOMPARE(page2->pixmap(QWizard::LogoPixmap).size(), p2.size());
+ QCOMPARE(page2->pixmap(QWizard::WatermarkPixmap).size(), p3.size());
+ QCOMPARE(page2->pixmap(QWizard::BackgroundPixmap).size(), p4.size());
}
class MyPage1 : public QWizardPage
@@ -571,7 +571,7 @@ void tst_QWizard::addPage()
}
for (int i = 0; i < N; ++i) {
- QVERIFY(pages[i] == wizard.page(i));
+ QCOMPARE(pages[i], wizard.page(i));
}
QVERIFY(!wizard.page(-1));
QVERIFY(!wizard.page(N));
@@ -667,7 +667,7 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.page(-2), page);
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == page);
+ QCOMPARE(wizard.currentPage(), page);
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
@@ -679,14 +679,14 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.page(2), page);
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
wizard.restart();
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
@@ -698,28 +698,28 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.page(-3), page);
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
wizard.restart();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -3);
- QVERIFY(wizard.currentPage() == wizard.page(-3));
+ QCOMPARE(wizard.currentPage(), wizard.page(-3));
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
wizard.next();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -3 << -2);
wizard.next();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 2);
CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0);
@@ -727,7 +727,7 @@ void tst_QWizard::setPage()
wizard.next();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), 2);
- QVERIFY(wizard.currentPage() == wizard.page(2));
+ QCOMPARE(wizard.currentPage(), wizard.page(2));
QCOMPARE(wizard.nextId(), -1);
CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0 << 2);
}
@@ -735,14 +735,14 @@ void tst_QWizard::setPage()
wizard.back();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 2);
CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0);
wizard.back();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -3 << -2);
@@ -750,7 +750,7 @@ void tst_QWizard::setPage()
wizard.back();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -3);
- QVERIFY(wizard.currentPage() == wizard.page(-3));
+ QCOMPARE(wizard.currentPage(), wizard.page(-3));
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
}
@@ -759,7 +759,7 @@ void tst_QWizard::setPage()
wizard.restart();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -3);
- QVERIFY(wizard.currentPage() == wizard.page(-3));
+ QCOMPARE(wizard.currentPage(), wizard.page(-3));
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
}
@@ -808,31 +808,31 @@ void tst_QWizard::setStartId()
wizard.restart();
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
wizard.next();
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 1);
wizard.setStartId(INT_MIN);
QCOMPARE(wizard.startId(), INT_MIN);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 1);
wizard.next();
QCOMPARE(wizard.startId(), INT_MIN);
QCOMPARE(wizard.currentId(), 1);
- QVERIFY(wizard.currentPage() == wizard.page(1));
+ QCOMPARE(wizard.currentPage(), wizard.page(1));
QCOMPARE(wizard.nextId(), INT_MAX);
wizard.next();
QCOMPARE(wizard.startId(), INT_MIN);
QCOMPARE(wizard.currentId(), INT_MAX);
- QVERIFY(wizard.currentPage() == wizard.page(INT_MAX));
+ QCOMPARE(wizard.currentPage(), wizard.page(INT_MAX));
QCOMPARE(wizard.nextId(), -1);
CHECK_VISITED(wizard, QList<int>() << -2 << 0 << 1 << INT_MAX);
}
@@ -1143,12 +1143,12 @@ void tst_QWizard::setOption_ExtendedWatermarkPixmap()
}
if (wizard1.wizardStyle() == QWizard::MacStyle) {
- QVERIFY(i1[0] == i1[1]);
- QVERIFY(i2[0] == i2[1]);
- QVERIFY(i1[0] == i2[0]);
+ QCOMPARE(i1[0], i1[1]);
+ QCOMPARE(i2[0], i2[1]);
+ QCOMPARE(i1[0], i2[0]);
} else {
QVERIFY(i1[0] != i1[1]);
- QVERIFY(i2[0] == i2[1]);
+ QCOMPARE(i2[0], i2[1]);
QVERIFY(i1[0] != i2[0]);
QVERIFY(i1[1] != i2[1]);
}
@@ -2425,19 +2425,19 @@ void tst_QWizard::sideWidget()
QWizard wizard;
wizard.setSideWidget(0);
- QVERIFY(wizard.sideWidget() == 0);
+ QVERIFY(!wizard.sideWidget());
QScopedPointer<QWidget> w1(new QWidget(&wizard));
wizard.setSideWidget(w1.data());
QCOMPARE(wizard.sideWidget(), w1.data());
QWidget *w2 = new QWidget(&wizard);
wizard.setSideWidget(w2);
- QVERIFY(wizard.sideWidget() == w2);
+ QCOMPARE(wizard.sideWidget(), w2);
QVERIFY(w1->parent() != 0);
QCOMPARE(w1->window(), static_cast<QWidget *>(&wizard));
QCOMPARE(w2->window(), static_cast<QWidget *>(&wizard));
w1->setParent(0);
wizard.setSideWidget(0);
- QVERIFY(wizard.sideWidget() == 0);
+ QVERIFY(!wizard.sideWidget());
}
void tst_QWizard::objectNames_data()
@@ -2558,7 +2558,7 @@ void tst_QWizard::task183550_stretchFactor()
page2->disableVerticalExpansion();
wizard.next();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page2));
- QVERIFY(page2->treeWidgetHeight() == page2->treeWidgetSizeHintHeight());
+ QCOMPARE(page2->treeWidgetHeight(), page2->treeWidgetSizeHintHeight());
wizard.back();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page1));
@@ -2576,7 +2576,7 @@ void tst_QWizard::task183550_stretchFactor()
page2->disableVerticalExpansion();
wizard.next();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page2));
- QVERIFY(page2->treeWidgetHeight() == page2->treeWidgetSizeHintHeight());
+ QCOMPARE(page2->treeWidgetHeight(), page2->treeWidgetSizeHintHeight());
}
void tst_QWizard::task161658_alignments()
diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
index 4d7f55f37d..c7d1dd0aa1 100644
--- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -520,7 +520,7 @@ public:
void draw(QPainter *painter)
{
- QVERIFY(sourcePixmap(Qt::LogicalCoordinates).handle() == pixmap.handle());
+ QCOMPARE(sourcePixmap(Qt::LogicalCoordinates).handle(), pixmap.handle());
QVERIFY((painter->worldTransform().type() <= QTransform::TxTranslate) == (sourcePixmap(Qt::DeviceCoordinates).handle() == pixmap.handle()));
++repaints;
@@ -595,7 +595,7 @@ void tst_QGraphicsEffect::deviceCoordinateTranslateCaching()
item->translate(10, 0);
- QTRY_VERIFY(item->numRepaints == numRepaints);
+ QTRY_COMPARE(item->numRepaints, numRepaints);
}
void tst_QGraphicsEffect::inheritOpacity()
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
new file mode 100644
index 0000000000..7f55c2dae0
--- /dev/null
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
@@ -0,0 +1,2 @@
+[panGesture:Two finger]
+xcb
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index ca01b27bee..f71308cdaf 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -133,7 +133,6 @@ static bool checkReverseDirection(QGraphicsWidget *widget)
layout->getContentsMargins(&left, &top, &right, &bottom);
widget->setLayoutDirection(Qt::LeftToRight);
QApplication::processEvents();
- const QRectF layoutGeometry = layout->geometry();
QMap<QGraphicsLayoutItem *, QRectF> geometries;
for (int i = 0; i < layout->count(); ++i) {
QGraphicsLayoutItem *item = layout->itemAt(i);
@@ -141,7 +140,7 @@ static bool checkReverseDirection(QGraphicsWidget *widget)
}
widget->setLayoutDirection(Qt::RightToLeft);
QApplication::processEvents();
- layoutGeometry.adjusted(+right, +top, -left, -bottom);
+ const QRectF layoutGeometry = layout->geometry().adjusted(+right, +top, -left, -bottom);
for (int i = 0; i < layout->count(); ++i) {
QGraphicsLayoutItem *item = layout->itemAt(i);
const QRectF rightToLeftGeometry = item->geometry();
@@ -653,7 +652,7 @@ void tst_QGraphicsAnchorLayout::snake()
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
- QVERIFY(layoutHasConflict(l) == false);
+ QVERIFY(!layoutHasConflict(l));
// Test QSizePolicy::ExpandFlag, it shouldn't change the extreme
// points of the layout...
@@ -2041,9 +2040,9 @@ void tst_QGraphicsAnchorLayout::graphicsAnchorHandling()
QGraphicsAnchor *invalidAnchor = l->anchor(a, Qt::AnchorTop, l, Qt::AnchorBottom);
// Ensure none of these anchors are accessible.
- QVERIFY(layoutAnchor == 0);
- QVERIFY(itemAnchor == 0);
- QVERIFY(invalidAnchor == 0);
+ QVERIFY(!layoutAnchor);
+ QVERIFY(!itemAnchor);
+ QVERIFY(!invalidAnchor);
// Hook the anchors to a QObject
QObject object;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index a2108dd494..a58f295575 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -715,7 +715,7 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases()
widget1->setGeometry(QRectF(0,0,100,100));
QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98));
- QVERIFY(childWidget->parentLayoutItem() == layout1);
+ QCOMPARE(childWidget->parentLayoutItem(), layout1);
QGraphicsWidget *widget2 = new QGraphicsWidget;
TheAnchorLayout *layout2 = new TheAnchorLayout();
widget2->setLayout(layout2);
@@ -739,10 +739,10 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases()
widget2->setGeometry(QRectF(0,0,100,100));
QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98));
- QVERIFY(childWidget->parentLayoutItem() == layout2);
+ QCOMPARE(childWidget->parentLayoutItem(), layout2);
QCOMPARE(widget4->geometry(), QRectF(1,1,98,98));
- QVERIFY(widget4->parentLayoutItem() == layout2);
- QVERIFY(widget4->parentItem() == widget2);
+ QCOMPARE(widget4->parentLayoutItem(), layout2);
+ QCOMPARE(widget4->parentItem(), widget2);
delete widget4;
delete widget3;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 0dd1161dcf..835aeaa4df 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -4274,7 +4274,7 @@ void tst_QGraphicsItem::cursor()
void tst_QGraphicsItem::textControlGetterSetter()
{
QGraphicsTextItem *item = new QGraphicsTextItem;
- QVERIFY(item->textControl()->parent() == item);
+ QCOMPARE(item->textControl()->parent(), item);
QPointer<QWidgetTextControl> control = item->textControl();
delete item;
QVERIFY(!control);
@@ -4285,7 +4285,7 @@ void tst_QGraphicsItem::textControlGetterSetter()
control = new QWidgetTextControl;
item->setTextControl(control);
- QVERIFY(item->textControl() == control);
+ QCOMPARE(item->textControl(), control);
QVERIFY(!control->parent());
QVERIFY(!oldControl);
@@ -5141,19 +5141,19 @@ void tst_QGraphicsItem::paint()
//nominal case, update call paint
tester2.update();
qApp->processEvents();
- QTRY_VERIFY(tester2.painted == 2);
+ QTRY_COMPARE(tester2.painted, 2);
//we remove the item from the scene, number of updates is still the same
tester2.update();
scene2.removeItem(&tester2);
qApp->processEvents();
- QTRY_VERIFY(tester2.painted == 2);
+ QTRY_COMPARE(tester2.painted, 2);
//We re-add the item, the number of paint should increase
scene2.addItem(&tester2);
tester2.update();
qApp->processEvents();
- QTRY_VERIFY(tester2.painted == 3);
+ QTRY_COMPARE(tester2.painted, 3);
}
class HarakiriItem : public QGraphicsRectItem
@@ -5878,7 +5878,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
scene.addItem(parent);
- QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+ QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls);
int oldParentBoundingRectCalls = parent->boundingRectCalls;
int oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
@@ -5886,10 +5886,10 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
// First test that both items are searched if no optimization flags are set
QGraphicsItem* item = scene.itemAt(25,5);
- QVERIFY(item == childOutsideShape);
+ QCOMPARE(item, childOutsideShape);
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls);
- QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+ QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls);
oldParentBoundingRectCalls = parent->boundingRectCalls;
oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
@@ -5897,10 +5897,10 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
// Repeat the test to make sure that no caching/indexing is in effect
item = scene.itemAt(25,5);
- QVERIFY(item == childOutsideShape);
+ QCOMPARE(item, childOutsideShape);
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls);
- QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+ QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls);
oldParentBoundingRectCalls = parent->boundingRectCalls;
oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
@@ -5912,7 +5912,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
QVERIFY(!(item));
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
- QVERIFY(childOutsideShape->boundingRectCalls == oldChildBoundingRectCalls);
+ QCOMPARE(childOutsideShape->boundingRectCalls, oldChildBoundingRectCalls);
QVERIFY(parent->boundingRectCalls > childOutsideShape->boundingRectCalls);
}
@@ -11205,21 +11205,21 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent()
child2->setVisible(false);
child2->setParentItem(child);
- QTRY_VERIFY(view.repaints == 1);
+ QTRY_COMPARE(view.repaints, 1);
// test case #2
view.reset();
child3->setOpacity(0.0);
child3->setParentItem(child);
- QTRY_VERIFY(view.repaints == 1);
+ QTRY_COMPARE(view.repaints, 1);
// test case #3
view.reset();
child4->setParentItem(child);
child4->setVisible(false);
- QTRY_VERIFY(view.repaints == 1);
+ QTRY_COMPARE(view.repaints, 1);
}
void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate()
@@ -11469,9 +11469,9 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation()
QGraphicsSceneDragDropEvent event(QEvent::GraphicsSceneDragMove);
event.setScenePos(item->boundingRect().center());
QApplication::sendEvent(&scene, &event);
- QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == item);
+ QCOMPARE(QGraphicsScenePrivate::get(&scene)->dragDropItem, item);
delete item;
- QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0);
+ QVERIFY(!QGraphicsScenePrivate::get(&scene)->dragDropItem);
}
void tst_QGraphicsItem::QTBUG_12112_focusItem()
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index bd104539ac..a2740edc54 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -948,7 +948,7 @@ void tst_QGraphicsLayout::ownership()
destructedSet.clear();
window->setLayout(0);
- QVERIFY(destructedSet.count() == 0);
+ QCOMPARE(destructedSet.count(), 0);
delete window;
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 6a8b690560..8bebd4eddd 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -1230,8 +1230,8 @@ void tst_QGraphicsLinearLayout::testStretch()
layout->addStretch(2);
layout->addItem(w2);
QCOMPARE(layout->count(), 2);
- QVERIFY(layout->itemAt(0) == w1);
- QVERIFY(layout->itemAt(1) == w2);
+ QCOMPARE(layout->itemAt(0), w1);
+ QCOMPARE(layout->itemAt(1), w2);
layout->activate();
//view->setSceneRect(-50, -50, 800, 800);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
index 84c39bbb98..0f9e8c101e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
@@ -102,7 +102,7 @@ void tst_QGraphicsObject::pos()
QCOMPARE(xSpy.count(), 1);
QCOMPARE(ySpy.count(), 1);
- QVERIFY(object.pos() == QPointF(10,10));
+ QCOMPARE(object.pos(), QPointF(10,10));
object.setPos(10, 10);
QCOMPARE(xSpy.count(), 1);
@@ -111,12 +111,12 @@ void tst_QGraphicsObject::pos()
object.setProperty("pos", QPointF(0, 0));
QCOMPARE(xSpy.count(), 2);
QCOMPARE(ySpy.count(), 2);
- QVERIFY(object.property("pos") == QPointF(0,0));
+ QCOMPARE(object.property("pos").toPointF(), QPointF(0,0));
object.setProperty("pos", QPointF(10, 0));
QCOMPARE(xSpy.count(), 3);
QCOMPARE(ySpy.count(), 2);
- QVERIFY(object.property("pos") == QPointF(10,0));
+ QCOMPARE(object.property("pos").toPointF(), QPointF(10,0));
object.setProperty("pos", QPointF(10, 10));
QCOMPARE(xSpy.count(), 3);
@@ -135,7 +135,7 @@ void tst_QGraphicsObject::x()
QCOMPARE(ySpy.count(), 0);
QVERIFY(object.pos() == QPointF(10, 0));
- QVERIFY(object.x() == 10);
+ QCOMPARE(object.x(), qreal(10));
object.setX(10);
QCOMPARE(xSpy.count(), 1);
@@ -144,7 +144,7 @@ void tst_QGraphicsObject::x()
object.setProperty("x", 0);
QCOMPARE(xSpy.count(), 2);
QCOMPARE(ySpy.count(), 0);
- QVERIFY(object.property("x") == 0);
+ QCOMPARE(object.property("x").toDouble(), double(0));
}
void tst_QGraphicsObject::y()
@@ -158,7 +158,7 @@ void tst_QGraphicsObject::y()
QCOMPARE(ySpy.count(), 1);
QVERIFY(object.pos() == QPointF(0, 10));
- QVERIFY(object.y() == 10);
+ QCOMPARE(object.y(), qreal(10));
object.setY(10);
QCOMPARE(xSpy.count(), 0);
@@ -167,79 +167,79 @@ void tst_QGraphicsObject::y()
object.setProperty("y", 0);
QCOMPARE(xSpy.count(), 0);
QCOMPARE(ySpy.count(), 2);
- QVERIFY(object.property("y") == 0);
+ QCOMPARE(object.property("y").toDouble(), qreal(0));
}
void tst_QGraphicsObject::z()
{
MyGraphicsObject object;
QSignalSpy zSpy(&object, SIGNAL(zChanged()));
- QVERIFY(object.zValue() == 0);
+ QCOMPARE(object.zValue(), qreal(0));
object.setZValue(10);
QCOMPARE(zSpy.count(), 1);
- QVERIFY(object.zValue() == 10);
+ QCOMPARE(object.zValue(), qreal(10));
object.setZValue(10);
QCOMPARE(zSpy.count(), 1);
object.setProperty("z", 0);
QCOMPARE(zSpy.count(), 2);
- QVERIFY(object.property("z") == 0);
+ QCOMPARE(object.property("z").toDouble(), double(0));
}
void tst_QGraphicsObject::opacity()
{
MyGraphicsObject object;
QSignalSpy spy(&object, SIGNAL(opacityChanged()));
- QVERIFY(object.opacity() == 1.);
+ QCOMPARE(object.opacity(), 1.);
object.setOpacity(0);
QCOMPARE(spy.count(), 1);
- QVERIFY(object.opacity() == 0.);
+ QCOMPARE(object.opacity(), 0.);
object.setOpacity(0);
QCOMPARE(spy.count(), 1);
object.setProperty("opacity", .5);
QCOMPARE(spy.count(), 2);
- QVERIFY(object.property("opacity") == .5);
+ QCOMPARE(object.property("opacity").toDouble(), .5);
}
void tst_QGraphicsObject::enabled()
{
MyGraphicsObject object;
QSignalSpy spy(&object, SIGNAL(enabledChanged()));
- QVERIFY(object.isEnabled() == true);
+ QVERIFY(object.isEnabled());
object.setEnabled(false);
QCOMPARE(spy.count(), 1);
- QVERIFY(object.isEnabled() == false);
+ QVERIFY(!object.isEnabled());
object.setEnabled(false);
QCOMPARE(spy.count(), 1);
object.setProperty("enabled", true);
QCOMPARE(spy.count(), 2);
- QVERIFY(object.property("enabled") == true);
+ QVERIFY(object.property("enabled").toBool());
}
void tst_QGraphicsObject::visible()
{
MyGraphicsObject object;
QSignalSpy spy(&object, SIGNAL(visibleChanged()));
- QVERIFY(object.isVisible() == true);
+ QVERIFY(object.isVisible());
object.setVisible(false);
QCOMPARE(spy.count(), 1);
- QVERIFY(object.isVisible() == false);
+ QVERIFY(!object.isVisible());
object.setVisible(false);
QCOMPARE(spy.count(), 1);
object.setProperty("visible", true);
QCOMPARE(spy.count(), 2);
- QVERIFY(object.property("visible") == true);
+ QVERIFY(object.property("visible").toBool());
}
class DeleteTester : public QGraphicsObject
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index cd40c5541c..8760dc176c 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -97,8 +97,8 @@ private slots:
void paint_2();
void setWidget_data();
void setWidget();
- void eventFilter_data();
- void eventFilter();
+ void testEventFilter_data();
+ void testEventFilter();
void focusInEvent_data();
void focusInEvent();
void focusInEventNoWidget();
@@ -179,6 +179,7 @@ private slots:
void mapToGlobal();
void mapToGlobalWithoutScene();
void QTBUG_43780_visibility();
+ void forwardTouchEvent();
};
// Subclass that exposes the protected functions.
@@ -314,7 +315,7 @@ void tst_QGraphicsProxyWidget::qgraphicsproxywidget()
SubQGraphicsProxyWidget proxy;
proxy.paint(0, 0, 0);
proxy.setWidget(0);
- QVERIFY(proxy.type() == QGraphicsProxyWidget::Type);
+ QCOMPARE(proxy.type(), int(QGraphicsProxyWidget::Type));
QVERIFY(!proxy.widget());
QEvent event(QEvent::None);
proxy.call_eventFilter(0, &event);
@@ -533,7 +534,7 @@ void tst_QGraphicsProxyWidget::setWidget()
}
Q_DECLARE_METATYPE(QEvent::Type)
-void tst_QGraphicsProxyWidget::eventFilter_data()
+void tst_QGraphicsProxyWidget::testEventFilter_data()
{
QTest::addColumn<QEvent::Type>("eventType");
QTest::addColumn<bool>("fromObject"); // big grin evil
@@ -552,7 +553,7 @@ void tst_QGraphicsProxyWidget::eventFilter_data()
}
// protected bool eventFilter(QObject* object, QEvent* event)
-void tst_QGraphicsProxyWidget::eventFilter()
+void tst_QGraphicsProxyWidget::testEventFilter()
{
QFETCH(QEvent::Type, eventType);
QFETCH(bool, fromObject);
@@ -1223,6 +1224,7 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.resize(500, 500);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -1231,7 +1233,6 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
QPushButton *widget = new QPushButton;
QSignalSpy spy(widget, SIGNAL(clicked()));
widget->resize(50, 50);
- view.resize(100, 100);
if (hasWidget) {
proxy->setWidget(widget);
proxy->show();
@@ -3017,36 +3018,36 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
layout->addWidget(rightDial);
window.setLayout(layout);
- QVERIFY(window.graphicsProxyWidget() == 0);
- QVERIFY(checkbox->graphicsProxyWidget() == 0);
+ QVERIFY(!window.graphicsProxyWidget());
+ QVERIFY(!checkbox->graphicsProxyWidget());
QGraphicsProxyWidget *windowProxy = scene.addWidget(&window);
QGraphicsView view(&scene);
view.show();
view.resize(500,500);
- QVERIFY(window.graphicsProxyWidget() == windowProxy);
- QVERIFY(box->graphicsProxyWidget() == 0);
- QVERIFY(checkbox->graphicsProxyWidget() == 0);
+ QCOMPARE(window.graphicsProxyWidget(), windowProxy);
+ QVERIFY(!box->graphicsProxyWidget());
+ QVERIFY(!checkbox->graphicsProxyWidget());
QPointer<QGraphicsProxyWidget> checkboxProxy = windowProxy->createProxyForChildWidget(checkbox);
QGraphicsProxyWidget *boxProxy = box->graphicsProxyWidget();
QVERIFY(boxProxy);
- QVERIFY(checkbox->graphicsProxyWidget() == checkboxProxy);
- QVERIFY(checkboxProxy->parentItem() == boxProxy);
- QVERIFY(boxProxy->parentItem() == windowProxy);
+ QCOMPARE(checkbox->graphicsProxyWidget(), checkboxProxy.data());
+ QCOMPARE(checkboxProxy->parentItem(), boxProxy);
+ QCOMPARE(boxProxy->parentItem(), windowProxy);
QVERIFY(checkboxProxy->mapToScene(QPointF()) == checkbox->mapTo(&window, QPoint()));
- QVERIFY(checkboxProxy->size() == checkbox->size());
- QVERIFY(boxProxy->size() == box->size());
+ QCOMPARE(checkboxProxy->size().toSize(), checkbox->size());
+ QCOMPARE(boxProxy->size().toSize(), box->size());
window.resize(500,500);
- QVERIFY(windowProxy->size() == QSize(500,500));
+ QCOMPARE(windowProxy->size().toSize(), QSize(500,500));
QVERIFY(checkboxProxy->mapToScene(QPointF()) == checkbox->mapTo(&window, QPoint()));
- QVERIFY(checkboxProxy->size() == checkbox->size());
- QVERIFY(boxProxy->size() == box->size());
+ QCOMPARE(checkboxProxy->size().toSize(), checkbox->size());
+ QCOMPARE(boxProxy->size().toSize(), box->size());
QTest::qWait(10);
@@ -3064,9 +3065,9 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
boxProxy->setWidget(0);
- QVERIFY(checkbox->graphicsProxyWidget() == 0);
- QVERIFY(box->graphicsProxyWidget() == 0);
- QVERIFY(checkboxProxy == 0);
+ QVERIFY(!checkbox->graphicsProxyWidget());
+ QVERIFY(!box->graphicsProxyWidget());
+ QVERIFY(checkboxProxy.isNull());
delete boxProxy;
}
@@ -3760,5 +3761,73 @@ void tst_QGraphicsProxyWidget::QTBUG_43780_visibility()
QVERIFY(comboPopup->isVisible());
}
+class TouchWidget : public QWidget
+{
+public:
+ TouchWidget(QWidget *parent = 0) : QWidget(parent) {}
+
+ bool event(QEvent *event)
+ {
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ event->accept();
+ return true;
+ break;
+ default:
+ break;
+ }
+
+ return QWidget::event(event);
+ }
+};
+
+// QTBUG_45737
+void tst_QGraphicsProxyWidget::forwardTouchEvent()
+{
+ QGraphicsScene *scene = new QGraphicsScene;
+
+ TouchWidget *widget = new TouchWidget;
+
+ widget->setAttribute(Qt::WA_AcceptTouchEvents);
+
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget;
+
+ proxy->setAcceptTouchEvents(true);
+ proxy->setWidget(widget);
+
+ scene->addItem(proxy);
+
+ QGraphicsView *view = new QGraphicsView(scene);
+
+ view->show();
+
+ EventSpy eventSpy(widget);
+
+ QTouchDevice *device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+
+ QCOMPARE(eventSpy.counts[QEvent::TouchBegin], 0);
+ QCOMPARE(eventSpy.counts[QEvent::TouchUpdate], 0);
+ QCOMPARE(eventSpy.counts[QEvent::TouchEnd], 0);
+
+ QTest::touchEvent(view, device).press(0, QPoint(10, 10), view);
+ QTest::touchEvent(view, device).move(0, QPoint(15, 15), view);
+ QTest::touchEvent(view, device).move(0, QPoint(16, 16), view);
+ QTest::touchEvent(view, device).release(0, QPoint(15, 15), view);
+
+ QApplication::processEvents();
+
+ QCOMPARE(eventSpy.counts[QEvent::TouchBegin], 1);
+ QCOMPARE(eventSpy.counts[QEvent::TouchUpdate], 2);
+ QCOMPARE(eventSpy.counts[QEvent::TouchEnd], 1);
+
+ delete view;
+ delete proxy;
+ delete scene;
+}
+
QTEST_MAIN(tst_QGraphicsProxyWidget)
#include "tst_qgraphicsproxywidget.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 7bd0393760..ae71b0412f 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -1282,33 +1282,16 @@ void tst_QGraphicsScene::removeItem()
view.show();
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- QTest::mouseMove(view.viewport(), QPoint(-1, -1));
- {
- QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton, 0, 0);
- QApplication::sendEvent(view.viewport(), &moveEvent);
- }
- qApp->processEvents(); // update
- qApp->processEvents(); // draw
- QVERIFY(!hoverItem->isHovered);
+ QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton);
+ QTRY_VERIFY(!hoverItem->isHovered);
- {
- QTest::qWait(250);
- QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton);
- QTest::qWait(10);
- QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos()), Qt::NoButton, 0, 0);
- QApplication::sendEvent(view.viewport(), &moveEvent);
- }
- qApp->processEvents(); // update
- qApp->processEvents(); // draw
- QVERIFY(hoverItem->isHovered);
+ QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton);
+ QTRY_VERIFY(hoverItem->isHovered);
scene.removeItem(hoverItem);
hoverItem->setAcceptsHoverEvents(false);
scene.addItem(hoverItem);
- qApp->processEvents(); // <- delayed update is called
- qApp->processEvents(); // <- scene schedules pending update
- qApp->processEvents(); // <- pending update is sent to view
- QVERIFY(!hoverItem->isHovered);
+ QTRY_VERIFY(!hoverItem->isHovered);
}
void tst_QGraphicsScene::focusItem()
@@ -3509,6 +3492,8 @@ void tst_QGraphicsScene::task160653_selectionChanged()
QSignalSpy spy(&scene, SIGNAL(selectionChanged()));
QGraphicsView view(&scene);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::mouseClick(
view.viewport(), Qt::LeftButton, 0, view.mapFromScene(scene.items().first()->scenePos()));
QCOMPARE(spy.count(), 1);
@@ -4742,9 +4727,9 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
- QVERIFY(viewRepaints == smallChild->repaints);
- QVERIFY(viewRepaints == smallerGrandChild->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
+ QCOMPARE(viewRepaints, smallChild->repaints);
+ QCOMPARE(viewRepaints, smallerGrandChild->repaints);
// Setting a minimum render size should cause a repaint
scene.setMinimumRenderSize(0.5);
@@ -4753,9 +4738,9 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
- QVERIFY(viewRepaints == smallChild->repaints);
- QVERIFY(viewRepaints == smallerGrandChild->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
+ QCOMPARE(viewRepaints, smallChild->repaints);
+ QCOMPARE(viewRepaints, smallerGrandChild->repaints);
// Scaling should cause a repaint of big items only.
view.scale(0.1, 0.1);
@@ -4764,8 +4749,8 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
- QVERIFY(viewRepaints == smallChild->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
+ QCOMPARE(viewRepaints, smallChild->repaints);
QVERIFY(smallChild->repaints > smallerGrandChild->repaints);
// Scaling further should cause even fewer items to be repainted
@@ -4775,7 +4760,7 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
QVERIFY(bigParent->repaints > smallChild->repaints);
QVERIFY(smallChild->repaints > smallerGrandChild->repaints);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
index be7a7e398b..3cba8bad7e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
@@ -1,4 +1,18 @@
[task255529_transformationAnchorMouseAndViewportMargins]
-ubuntu-14.04
+xcb
[cursor]
-ubuntu-14.04
+xcb
+[cursor2]
+xcb
+[rubberBandExtendSelection]
+xcb
+[rotated_rubberBand]
+xcb
+[sendEvent]
+xcb
+[forwardMousePress]
+xcb
+[hoverLeave]
+xcb
+[resizeAnchor]
+xcb
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index d1d4c1ab86..98473fb5cc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -145,7 +145,7 @@ class tst_QGraphicsView : public QObject
public:
tst_QGraphicsView()
- : platformName(qApp->platformName().toLower())
+ : platformName(QGuiApplication::platformName().toLower())
{ }
private slots:
void initTestCase();
@@ -255,7 +255,6 @@ private slots:
void task186827_deleteReplayedItem();
void task207546_focusCrash();
void task210599_unsetDragWhileDragging();
- void task236394_sendShortcutOverrideEvent();
void task239729_noViewUpdate_data();
void task239729_noViewUpdate();
void task239047_fitInViewSmallViewport();
@@ -3369,14 +3368,6 @@ void tst_QGraphicsView::task210599_unsetDragWhileDragging()
QCOMPARE(basePos, view.mapFromScene(0, 0));
}
-void tst_QGraphicsView::task236394_sendShortcutOverrideEvent()
-{
- QGraphicsView view;
- view.show();
- QKeyEvent event(QEvent::ShortcutOverride, Qt::Key_A, 0, QString("A"));
- QApplication::sendEvent(&view, &event);
-}
-
class ChangedListener : public QObject
{
Q_OBJECT
@@ -3525,7 +3516,7 @@ void tst_QGraphicsView::embeddedViews()
v2->QWidget::render(&actual);
QTransform b = item->transform;
- QVERIFY(a == b);
+ QCOMPARE(a, b);
delete v1;
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 9b92c34fb5..ec2203e615 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -182,14 +182,6 @@ private slots:
void QTBUG_45867_send_itemChildAddedChange_to_parent();
};
-
-static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0)
-{
- QTest::mouseMove(widget, point);
- QMouseEvent event(QEvent::MouseMove, point, button, buttons, 0);
- QApplication::sendEvent(widget, &event);
-}
-
// Subclass that exposes the protected functions.
class SubQGraphicsWidget : public QGraphicsWidget {
public:
@@ -197,7 +189,7 @@ public:
: QGraphicsWidget(parent, windowFlags), eventCount(0)
{ }
- void initStyleOption(QStyleOption *option)
+ void initStyleOption(QStyleOption *option) const
{ QGraphicsWidget::initStyleOption(option); }
void call_changeEvent(QEvent* event)
@@ -1110,8 +1102,8 @@ void tst_QGraphicsWidget::initStyleOption()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.resize(300, 300);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
view.setAlignment(Qt::AlignTop | Qt::AlignLeft);
@@ -1133,10 +1125,8 @@ void tst_QGraphicsWidget::initStyleOption()
}
QFETCH(bool, underMouse);
if (underMouse) {
- view.resize(300, 300);
- view.show();
- QVERIFY(QTest::qWaitForWindowActive(&view));
- sendMouseMove(view.viewport(), view.mapFromScene(widget->mapToScene(widget->boundingRect().center())));
+ QCursor::setPos(view.viewport()->mapToGlobal(view.mapFromScene(widget->mapToScene(widget->boundingRect().center()))));
+ QTest::qWait(100);
}
QFETCH(QPalette, palette);
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index eed38752d9..fac3f5857b 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -1036,7 +1036,7 @@ void tst_QAbstractItemView::dragAndDropOnChild()
++successes;
}
- QVERIFY(successes == 0);
+ QCOMPARE(successes, 0);
}
#endif // 0
@@ -1214,7 +1214,7 @@ void tst_QAbstractItemView::setCurrentIndex()
view->setModel(model);
view->setCurrentIndex(model->index(0,0));
- QVERIFY(view->currentIndex() == model->index(0,0));
+ QCOMPARE(view->currentIndex(), model->index(0,0));
view->setCurrentIndex(model->index(1,0));
QVERIFY(view->currentIndex() == model->index(result ? 1 : 0,0));
}
diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
index f5e6facaad..6645da727c 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
@@ -292,7 +292,7 @@ void tst_QColumnView::grips()
for (int i = 0 ; i < list.count(); ++i) {
if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i))) {
if (view->isVisible())
- QVERIFY(view->cornerWidget() == 0);
+ QVERIFY(!view->cornerWidget());
}
}
}
@@ -587,7 +587,7 @@ void tst_QColumnView::selectAll()
QVERIFY(view.selectionModel()->selectedIndexes().count() > 0);
view.setCurrentIndex(QModelIndex());
- QVERIFY(view.selectionModel()->selectedIndexes().count() == 0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
}
void tst_QColumnView::clicked()
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 21e4b82366..7e73c19539 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -403,7 +403,7 @@ void tst_QHeaderView::init()
view = new QHeaderView(Qt::Vertical,topLevel);
// Some initial value tests before a model is added
QCOMPARE(view->length(), 0);
- QVERIFY(view->sizeHint() == QSize(0,0));
+ QCOMPARE(view->sizeHint(), QSize(0,0));
QCOMPARE(view->sectionSizeHint(0), -1);
/*
@@ -925,9 +925,9 @@ void tst_QHeaderView::moveSection()
QFETCH(QList<int>, logical);
QFETCH(int, count);
- QVERIFY(from.count() == to.count());
- QVERIFY(from.count() == moved.count());
- QVERIFY(view->count() == logical.count());
+ QCOMPARE(from.count(), to.count());
+ QCOMPARE(from.count(), moved.count());
+ QCOMPARE(view->count(), logical.count());
QSignalSpy spy1(view, SIGNAL(sectionMoved(int,int,int)));
QCOMPARE(view->sectionsMoved(), false);
@@ -1370,15 +1370,15 @@ void tst_QHeaderView::unhideSection()
QCOMPARE(view->sectionsHidden(), false);
view->setSectionHidden(0, true);
QCOMPARE(view->sectionsHidden(), true);
- QVERIFY(view->sectionSize(0) == 0);
+ QCOMPARE(view->sectionSize(0), 0);
view->setSectionResizeMode(QHeaderView::Interactive);
view->setSectionHidden(0, false);
QVERIFY(view->sectionSize(0) > 0);
view->setSectionHidden(0, true);
- QVERIFY(view->sectionSize(0) == 0);
+ QCOMPARE(view->sectionSize(0), 0);
view->setSectionHidden(0, true);
- QVERIFY(view->sectionSize(0) == 0);
+ QCOMPARE(view->sectionSize(0), 0);
view->setSectionResizeMode(QHeaderView::Stretch);
view->setSectionHidden(0, false);
QVERIFY(view->sectionSize(0) > 0);
@@ -1645,7 +1645,7 @@ void tst_QHeaderView::saveRestore()
QByteArray s2 = h2.saveState();
- QVERIFY(s1 == s2);
+ QCOMPARE(s1, s2);
QVERIFY(!h2.restoreState(QByteArrayLiteral("Garbage")));
// QTBUG-40462
@@ -1659,7 +1659,7 @@ void tst_QHeaderView::saveRestore()
int sectionItemsLengthTotal = 0;
for (int i = 0; i < h2.count(); ++i)
sectionItemsLengthTotal += h2.sectionSize(i);
- QVERIFY(sectionItemsLengthTotal == h2.length());
+ QCOMPARE(sectionItemsLengthTotal, h2.length());
// Buggy setting where sum(sectionItems) != length. Check false is returned and this corrupted
// state isn't restored
@@ -1676,8 +1676,8 @@ void tst_QHeaderView::saveRestore()
// Check setting is correctly recognized as corrupted
QVERIFY(!h2.restoreState(settings_buggy_length));
// Check nothing has been actually restored
- QVERIFY(h2.length() == old_length);
- QVERIFY(h2.saveState() == old_state);
+ QCOMPARE(h2.length(), old_length);
+ QCOMPARE(h2.saveState(), old_state);
}
void tst_QHeaderView::defaultSectionSizeTest()
@@ -1699,7 +1699,7 @@ void tst_QHeaderView::defaultSectionSizeTest()
// no hidden Sections
hv->resizeSection(1, 0);
hv->setDefaultSectionSize(defaultSize);
- QVERIFY(hv->sectionSize(1) == defaultSize);
+ QCOMPARE(hv->sectionSize(1), defaultSize);
// with hidden sections
hv->resizeSection(1, 0);
@@ -2277,7 +2277,7 @@ void tst_QHeaderView::QTBUG14242_hideSectionAutoSize()
for (int u = 0; u < hv->count(); ++u)
calced_length += hv->sectionSize(u);
- QVERIFY(calced_length == afterlength);
+ QCOMPARE(calced_length, afterlength);
}
void tst_QHeaderView::ensureNoIndexAtLength()
@@ -2286,9 +2286,9 @@ void tst_QHeaderView::ensureNoIndexAtLength()
QStandardItemModel amodel(4, 4);
qtv.setModel(&amodel);
QHeaderView *hv = qtv.verticalHeader();
- QVERIFY(hv->visualIndexAt(hv->length()) == -1);
+ QCOMPARE(hv->visualIndexAt(hv->length()), -1);
hv->resizeSection(hv->count() - 1, 0);
- QVERIFY(hv->visualIndexAt(hv->length()) == -1);
+ QCOMPARE(hv->visualIndexAt(hv->length()), -1);
}
void tst_QHeaderView::offsetConsistent()
@@ -2307,7 +2307,7 @@ void tst_QHeaderView::offsetConsistent()
hv->hideSection(sectionToHide);
hv->setOffsetToSectionPosition(150);
int offset2 = hv->offset();
- QVERIFY(offset1 == offset2);
+ QCOMPARE(offset1, offset2);
// Ensure that hidden indexes (still) is considered.
hv->resizeSection(sectionToHide, hv->sectionSize(200) * 2);
hv->setOffsetToSectionPosition(800);
@@ -2600,8 +2600,8 @@ void tst_QHeaderView::logicalIndexAtTest()
//qDebug() << "logicalIndexAtTest" << check1 << check2;
const int precalced_check1 = 106327;
const int precalced_check2 = 29856418;
- QVERIFY(precalced_check1 == check1);
- QVERIFY(precalced_check2 == check2);
+ QCOMPARE(precalced_check1, check1);
+ QCOMPARE(precalced_check2, check2);
const int precalced_results[] = { 1145298384, -1710423344, -650981936, 372919464, -1544372176, -426463328, 12124 };
calculateAndCheck(__LINE__, precalced_results);
@@ -2628,8 +2628,8 @@ void tst_QHeaderView::visualIndexAtTest()
//qDebug() << "visualIndexAtTest" << check1 << check2;
const int precalced_check1 = 72665;
const int precalced_check2 = 14015890;
- QVERIFY(precalced_check1 == check1);
- QVERIFY(precalced_check2 == check2);
+ QCOMPARE(precalced_check1, check1);
+ QCOMPARE(precalced_check2, check2);
const int precalced_results[] = { 1145298384, -1710423344, -1457520212, 169223959, 557466160, -324939600, 5453 };
calculateAndCheck(__LINE__, precalced_results);
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 439eeff005..25f27cb0c7 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -804,9 +804,9 @@ void tst_QItemDelegate::dateTimeEditor()
dateTimeEditor->setTime(time.addSecs(600));
widget.clearFocus();
- QVERIFY(item1->data(Qt::EditRole).userType() == QMetaType::QTime);
- QVERIFY(item2->data(Qt::EditRole).userType() == QMetaType::QDate);
- QVERIFY(item3->data(Qt::EditRole).userType() == QMetaType::QDateTime);
+ QCOMPARE(item1->data(Qt::EditRole).userType(), int(QMetaType::QTime));
+ QCOMPARE(item2->data(Qt::EditRole).userType(), int(QMetaType::QDate));
+ QCOMPARE(item3->data(Qt::EditRole).userType(), int(QMetaType::QDateTime));
}
// A delegate where we can either enforce a certain widget or use the standard widget.
@@ -901,9 +901,9 @@ void tst_QItemDelegate::dateAndTimeEditorTest2()
s.setData(i1, datetime2);
editor = w.fastEdit(i1);
timeEdit = qobject_cast<QTimeEdit*>(editor);
- QVERIFY(timeEdit == 0);
+ QVERIFY(!timeEdit);
dateEdit = qobject_cast<QDateEdit*>(editor);
- QVERIFY(dateEdit == 0);
+ QVERIFY(!dateEdit);
dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
QVERIFY(dateTimeEdit);
QCOMPARE(dateTimeEdit->dateTime(), datetime2);
@@ -1154,7 +1154,7 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("unchecked, tristate, release")
<< (int)(Qt::Unchecked)
- << (int)(defaultFlags | Qt::ItemIsTristate)
+ << (int)(defaultFlags | Qt::ItemIsAutoTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1163,7 +1163,7 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("partially checked, tristate, release")
<< (int)(Qt::PartiallyChecked)
- << (int)(defaultFlags | Qt::ItemIsTristate)
+ << (int)(defaultFlags | Qt::ItemIsAutoTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1172,7 +1172,7 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("checked, tristate, release")
<< (int)(Qt::Checked)
- << (int)(defaultFlags | Qt::ItemIsTristate)
+ << (int)(defaultFlags | Qt::ItemIsAutoTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
index 3a6f1f933d..8fd86ea467 100644
--- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
+++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
@@ -483,6 +483,7 @@ void tst_QItemView::spider()
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
view->show();
+ QVERIFY(QTest::qWaitForWindowActive(view));
#if defined(Q_OS_WINCE)
srandom(0);
#else
@@ -551,7 +552,7 @@ void tst_QItemView::visualRect()
QFETCH(bool, displays);
if (!displays){
- QVERIFY(view->visualRect(topIndex) == QRect());
+ QCOMPARE(view->visualRect(topIndex), QRect());
return;
}
@@ -559,15 +560,15 @@ void tst_QItemView::visualRect()
view->show();
QVERIFY(view->visualRect(topIndex) != QRect());
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).center()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomLeft()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomRight()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topLeft()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topRight()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).center()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).bottomLeft()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).bottomRight()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).topLeft()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).topRight()));
testViews->hideIndexes(view);
QModelIndex hiddenIndex = treeModel->index(1, 0);
- QVERIFY(view->visualRect(hiddenIndex) == QRect());
+ QCOMPARE(view->visualRect(hiddenIndex), QRect());
}
void tst_QItemView::walkScreen(QAbstractItemView *view)
@@ -615,7 +616,7 @@ void walkIndex(QModelIndex index, QAbstractItemView *view)
if (view->indexAt(point) != index) {
qDebug() << "index" << index << "visualRect" << visualRect << point << view->indexAt(point);
}
- QVERIFY(view->indexAt(point) == index);
+ QCOMPARE(view->indexAt(point), index);
}
}
diff --git a/tests/auto/widgets/itemviews/qlistview/qlistview.pro b/tests/auto/widgets/itemviews/qlistview/qlistview.pro
index 0623fc8ede..509303b62e 100644
--- a/tests/auto/widgets/itemviews/qlistview/qlistview.pro
+++ b/tests/auto/widgets/itemviews/qlistview/qlistview.pro
@@ -3,3 +3,4 @@ TARGET = tst_qlistview
QT += widgets gui-private widgets-private core-private testlib
SOURCES += tst_qlistview.cpp
win32:!wince:!winrt: LIBS += -luser32
+linux*: CONFIG += insignificant_test # Crashes
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 1b21096b44..d94a3c8bca 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -38,6 +38,7 @@
#include <qapplication.h>
#include <qlistview.h>
#include <private/qlistview_p.h>
+#include <private/qcoreapplication_p.h>
#include <qlistwidget.h>
#include <qitemdelegate.h>
#include <qstandarditemmodel.h>
@@ -150,6 +151,7 @@ private slots:
void testViewOptions();
void taskQTBUG_39902_mutualScrollBars_data();
void taskQTBUG_39902_mutualScrollBars();
+ void horizontalScrollingByVerticalWheelEvents();
};
// Testing get/set functions
@@ -1209,7 +1211,7 @@ void tst_QListView::scrollTo()
list << "Short item";
model.setStringList(list);
lv.setModel(&model);
- lv.setFixedSize(100, 200);
+ lv.setFixedSize(110, 200);
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
@@ -2445,5 +2447,52 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars()
QTRY_VERIFY(view->verticalScrollBar()->isVisible());
}
+void tst_QListView::horizontalScrollingByVerticalWheelEvents()
+{
+ QListView lv;
+ lv.setWrapping(true);
+
+ TestDelegate *delegate = new TestDelegate(&lv);
+ delegate->m_sizeHint = QSize(100, 100);
+ lv.setItemDelegate(delegate);
+
+ QtTestModel model;
+ model.colCount = 1;
+ model.rCount = 100;
+
+ lv.setModel(&model);
+
+ lv.resize(300, 300);
+ lv.show();
+ QTest::qWaitForWindowExposed(&lv);
+
+ QPoint globalPos = lv.geometry().center();
+ QPoint pos = lv.viewport()->geometry().center();
+
+ QWheelEvent wheelDownEvent(pos, globalPos, QPoint(0, 0), QPoint(0, -120), -120, Qt::Vertical, 0, 0);
+ QWheelEvent wheelUpEvent(pos, globalPos, QPoint(0, 0), QPoint(0, 120), 120, Qt::Vertical, 0, 0);
+ QWheelEvent wheelLeftDownEvent(pos, globalPos, QPoint(0, 0), QPoint(120, -120), -120, Qt::Vertical, 0, 0);
+
+ int hValue = lv.horizontalScrollBar()->value();
+ QApplication::sendEvent(lv.viewport(), &wheelDownEvent);
+ QVERIFY(lv.horizontalScrollBar()->value() > hValue);
+
+ QApplication::sendEvent(lv.viewport(), &wheelUpEvent);
+ QCOMPARE(lv.horizontalScrollBar()->value(), hValue);
+
+ QApplication::sendEvent(lv.viewport(), &wheelLeftDownEvent);
+ QCOMPARE(lv.horizontalScrollBar()->value(), hValue);
+
+ // ensure that vertical wheel events are not converted when vertical
+ // scroll bar is not visible but vertical scrolling is possible
+ lv.setWrapping(false);
+ lv.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ QApplication::processEvents();
+
+ int vValue = lv.verticalScrollBar()->value();
+ QApplication::sendEvent(lv.viewport(), &wheelDownEvent);
+ QVERIFY(lv.verticalScrollBar()->value() > vValue);
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index dcbdbe824a..ecf72613da 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -427,9 +427,9 @@ void tst_QListWidget::currentItem()
// actual test
QModelIndex currentIndex = testWidget->selectionModel()->currentIndex();
if (currentIndex.isValid())
- QVERIFY(testWidget->currentItem() == testWidget->item(currentIndex.row()));
+ QCOMPARE(testWidget->currentItem(), testWidget->item(currentIndex.row()));
else
- QVERIFY(testWidget->currentItem() == (QListWidgetItem*)0);
+ QCOMPARE(testWidget->currentItem(), (QListWidgetItem*)0);
}
void tst_QListWidget::currentRow()
@@ -742,7 +742,7 @@ void tst_QListWidget::selectedItems()
QFETCH(IntList, selectedRows);
QFETCH(IntList, expectedRows);
- QVERIFY(testWidget->count() == 0);
+ QCOMPARE(testWidget->count(), 0);
//insert items
for (int i=0; i<itemCount; ++i)
@@ -1159,7 +1159,7 @@ void tst_QListWidget::setData()
QFETCH(int, expectedSignalCount);
qRegisterMetaType<QListWidgetItem *>("QListWidgetItem*");
- QVERIFY(roles.count() == values.count());
+ QCOMPARE(roles.count(), values.count());
for (int manipulateModel=0; manipulateModel<2; ++manipulateModel) {
testWidget->clear();
@@ -1711,7 +1711,7 @@ void tst_QListWidget::mimeData()
QVERIFY(data->hasFormat(format));
QVERIFY(data2->hasFormat(format));
- QVERIFY(data->data(format) == data2->data(format));
+ QCOMPARE(data->data(format), data2->data(format));
delete data;
delete data2;
diff --git a/tests/auto/widgets/itemviews/qtableview/BLACKLIST b/tests/auto/widgets/itemviews/qtableview/BLACKLIST
index fc231a4e30..329010a86e 100644
--- a/tests/auto/widgets/itemviews/qtableview/BLACKLIST
+++ b/tests/auto/widgets/itemviews/qtableview/BLACKLIST
@@ -1,2 +1,4 @@
[moveCursorBiggerJump]
osx
+[resizeColumnsToContents]
+ubuntu-14.04
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 75f77f8107..e5abd6bc46 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -2249,11 +2249,11 @@ void tst_QTableView::resizeColumnsToContents_data()
QTest::addColumn<int>("rowHeight");
QTest::addColumn<int>("columnWidth");
- QTest::newRow("10x10 grid shown 40x40")
- << 10 << 10 << false << 40 << 40 << 40 << 40;
+ QTest::newRow("10x10 grid not shown 60x60")
+ << 10 << 10 << false << 60 << 60 << 60 << 60;
- QTest::newRow("10x10 grid not shown 40x40")
- << 10 << 10 << true << 40 << 40 << 41 << 41;
+ QTest::newRow("10x10 grid shown 60x60")
+ << 10 << 10 << true << 60 << 60 << 61 << 61;
}
void tst_QTableView::resizeColumnsToContents()
@@ -4051,9 +4051,9 @@ void tst_QTableView::mouseWheel()
QWheelEvent verticalEvent(pos, delta, 0, 0, Qt::Vertical);
QWheelEvent horizontalEvent(pos, delta, 0, 0, Qt::Horizontal);
QApplication::sendEvent(view.viewport(), &horizontalEvent);
- QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 10);
+ QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 15);
QApplication::sendEvent(view.viewport(), &verticalEvent);
- QVERIFY(qAbs(view.verticalScrollBar()->value() - verticalPosition) < 10);
+ QVERIFY(qAbs(view.verticalScrollBar()->value() - verticalPosition) < 15);
}
#endif // !QT_NO_WHEELEVENT
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 36bc23910c..ea31fd19dd 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -94,6 +94,7 @@ private slots:
void task262056_sortDuplicate();
void itemWithHeaderItems();
void mimeData();
+ void selectedRowAfterSorting();
private:
QTableWidget *testWidget;
@@ -196,9 +197,9 @@ void tst_QTableWidget::clearContents()
{
QTableWidgetItem *item = new QTableWidgetItem("test");
testWidget->setHorizontalHeaderItem(0, item);
- QVERIFY(testWidget->horizontalHeaderItem(0) == item);
+ QCOMPARE(testWidget->horizontalHeaderItem(0), item);
testWidget->clearContents();
- QVERIFY(testWidget->horizontalHeaderItem(0) == item);
+ QCOMPARE(testWidget->horizontalHeaderItem(0), item);
}
void tst_QTableWidget::clear()
@@ -1559,11 +1560,29 @@ void tst_QTableWidget::mimeData()
QVERIFY(data->hasFormat(format));
QVERIFY(data2->hasFormat(format));
- QVERIFY(data->data(format) == data2->data(format));
+ QCOMPARE(data->data(format), data2->data(format));
delete data;
delete data2;
}
+void tst_QTableWidget::selectedRowAfterSorting()
+{
+ TestTableWidget table(3,3);
+ table.setSelectionBehavior(QAbstractItemView::SelectRows);
+ for (int r = 0; r < 3; r++)
+ for (int c = 0; c < 3; c++)
+ table.setItem(r,c,new QTableWidgetItem(QStringLiteral("0")));
+ QHeaderView *localHorizontalHeader = table.horizontalHeader();
+ localHorizontalHeader->setSortIndicator(1,Qt::DescendingOrder);
+ table.setProperty("sortingEnabled",true);
+ table.selectRow(1);
+ table.item(1,1)->setText("9");
+ QCOMPARE(table.selectedItems().count(),3);
+ foreach (QTableWidgetItem *item, table.selectedItems()) {
+ QCOMPARE(item->row(),0);
+ }
+}
+
QTEST_MAIN(tst_QTableWidget)
#include "tst_qtablewidget.moc"
diff --git a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
index 3abd58e73d..e8406dab7b 100644
--- a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
+++ b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
@@ -4,3 +4,5 @@ QT += widgets testlib
QT += widgets-private gui-private core-private
SOURCES += tst_qtreeview.cpp
HEADERS += ../../../../shared/fakedirmodel.h
+
+win32: CONFIG += insignificant_test
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 340637513c..6d5f5a1c60 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -253,7 +253,6 @@ private slots:
void taskQTBUG_25333_adjustViewOptionsForIndex();
void taskQTBUG_18539_emitLayoutChanged();
void taskQTBUG_8176_emitOnExpandAll();
- void taskQTBUG_34717_collapseAtBottom();
void taskQTBUG_37813_crash();
void taskQTBUG_45697_crash();
void testInitialFocus();
@@ -2365,7 +2364,7 @@ void tst_QTreeView::selectionOrderTest()
void tst_QTreeView::selection()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This causes a crash triggered by setVisible(false)");
QTreeView treeView;
@@ -3657,7 +3656,7 @@ void tst_QTreeView::task202039_closePersistentEditor()
QVERIFY(view.indexWidget(current));
view.closePersistentEditor(current);
- QVERIFY(view.indexWidget(current) == 0);
+ QVERIFY(!view.indexWidget(current));
//here was the bug: closing the persistent editor would not reset the state
//and it was impossible to go into editinon again
@@ -4283,35 +4282,6 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll()
QCOMPARE(spy2.size(), 1); // item2 is collapsed
}
-// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end
-// of an expanded tree, then collapse all)
-// The test passes simply if it doesn't crash.
-void tst_QTreeView::taskQTBUG_34717_collapseAtBottom()
-{
- QTreeWidget treeWidget;
- treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents);
- treeWidget.setColumnCount(2);
- QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root");
- for (int i = 0; i < 200; ++i) {
- QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item")));
- new QTreeWidgetItem(item, QStringList() << "Child" << "1");
- new QTreeWidgetItem(item, QStringList() << "Child" << "2");
- new QTreeWidgetItem(item, QStringList() << "Child" << "3");
- }
- treeWidget.show();
- treeWidget.expandAll();
- treeWidget.scrollToBottom();
- treeWidget.collapseAll();
-
- treeWidget.setAnimated(true);
- treeWidget.expandAll();
- treeWidget.scrollToBottom();
- mainItem->setExpanded(false);
-
- PublicView *pview = (PublicView*) &treeWidget;
- QVERIFY(pview->sizeHintForColumn(1) >= 0);
-}
-
void tst_QTreeView::testInitialFocus()
{
QTreeWidget treeWidget;
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index 5c881369a0..117c53a2bb 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -161,6 +161,7 @@ private slots:
void taskQTBUG2844_visualItemRect();
void setChildIndicatorPolicy();
+ void taskQTBUG_34717_collapseAtBottom();
void task20345_sortChildren();
void getMimeDataWithInvalidItem();
@@ -1037,7 +1038,7 @@ void tst_QTreeWidget::checkState()
QCOMPARE(firstChild->checkState(0), Qt::Checked);
QCOMPARE(seccondChild->checkState(0), Qt::Unchecked);
- item->setFlags(item->flags()|Qt::ItemIsTristate);
+ item->setFlags(item->flags()|Qt::ItemIsAutoTristate);
QCOMPARE(item->checkState(0), Qt::PartiallyChecked);
QCOMPARE(firstChild->checkState(0), Qt::Checked);
QCOMPARE(seccondChild->checkState(0), Qt::Unchecked);
@@ -1586,7 +1587,7 @@ void tst_QTreeWidget::scrollToItem()
testWidget->setHeaderLabels(QStringList() << "foo");
testWidget->scrollToItem(search);
- QVERIFY(search->text(0) == "111");
+ QCOMPARE(search->text(0), QLatin1String("111"));
bar = search->parent();
QVERIFY(testWidget->isItemExpanded(bar));
@@ -2287,7 +2288,7 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting()
QCOMPARE(parent->childCount(), childText.count());
QVERIFY(parent->isExpanded());
}
- QVERIFY(tree.model()->rowCount() == parentText.count());
+ QCOMPARE(tree.model()->rowCount(), parentText.count());
// verify that the items are still expanded
foreach (QTreeWidgetItem *item, items) {
@@ -2659,7 +2660,7 @@ void tst_QTreeWidget::sortedIndexOfChild()
tw.sortItems(0, (Qt::SortOrder)sortOrder);
tw.expandAll();
- QVERIFY(itms.count() == expectedIndexes.count());
+ QCOMPARE(itms.count(), expectedIndexes.count());
for (int j = 0; j < expectedIndexes.count(); ++j)
QCOMPARE(top->indexOfChild(itms.at(j)), expectedIndexes.at(j));
}
@@ -3155,11 +3156,11 @@ void tst_QTreeWidget::setSelectionModel()
void tst_QTreeWidget::task217309()
{
QTreeWidgetItem item;
- item.setFlags(item.flags() | Qt::ItemIsTristate);
+ item.setFlags(item.flags() | Qt::ItemIsAutoTristate);
QTreeWidgetItem subitem1;
- subitem1.setFlags(subitem1.flags() | Qt::ItemIsTristate);
+ subitem1.setFlags(subitem1.flags() | Qt::ItemIsAutoTristate);
QTreeWidgetItem subitem2;
- subitem2.setFlags(subitem2.flags() | Qt::ItemIsTristate);
+ subitem2.setFlags(subitem2.flags() | Qt::ItemIsAutoTristate);
item.addChild(&subitem1);
item.addChild(&subitem2);
subitem1.setCheckState(0, Qt::Checked);
@@ -3180,7 +3181,7 @@ void tst_QTreeWidget::nonEditableTristate()
QTreeWidget *tree = new QTreeWidget;
QTreeWidgetItem *item = new QTreeWidgetItem();
tree->insertTopLevelItem(0, item);
- item->setFlags(item->flags() | Qt::ItemIsTristate);
+ item->setFlags(item->flags() | Qt::ItemIsAutoTristate);
item->setCheckState(0, Qt::Unchecked);
QTreeWidgetItem *subitem1 = new QTreeWidgetItem(item);
subitem1->setCheckState(0, Qt::Unchecked);
@@ -3235,7 +3236,7 @@ void tst_QTreeWidget::setCurrentItemExpandsParent()
QTreeWidgetItem *i1 = new QTreeWidgetItem(&w, QStringList() << "parent");
QTreeWidgetItem *i2 = new QTreeWidgetItem(i1, QStringList() << "child");
QVERIFY(!i2->isExpanded());
- QVERIFY(w.currentItem() == 0);
+ QVERIFY(!w.currentItem());
w.setCurrentItem(i2);
QVERIFY(!i2->isExpanded());
QCOMPARE(w.currentItem(), i2);
@@ -3378,9 +3379,41 @@ void tst_QTreeWidget::setChildIndicatorPolicy()
QTRY_COMPARE(delegate.numPaints, 1);
}
+// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end
+// of an expanded tree, then collapse all)
+// The test passes simply if it doesn't crash.
+void tst_QTreeWidget::taskQTBUG_34717_collapseAtBottom()
+{
+ struct PublicTreeWidget: public QTreeWidget
+ {
+ inline int sizeHintForColumn(int column) const { return QTreeWidget::sizeHintForColumn(column); }
+ };
+ PublicTreeWidget treeWidget;
+ treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+ treeWidget.setColumnCount(2);
+ QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root");
+ for (int i = 0; i < 200; ++i) {
+ QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item")));
+ new QTreeWidgetItem(item, QStringList() << "Child" << "1");
+ new QTreeWidgetItem(item, QStringList() << "Child" << "2");
+ new QTreeWidgetItem(item, QStringList() << "Child" << "3");
+ }
+ treeWidget.show();
+ treeWidget.expandAll();
+ treeWidget.scrollToBottom();
+ treeWidget.collapseAll();
+
+ treeWidget.setAnimated(true);
+ treeWidget.expandAll();
+ treeWidget.scrollToBottom();
+ mainItem->setExpanded(false);
+
+ QVERIFY(treeWidget.sizeHintForColumn(1) >= 0);
+}
+
void tst_QTreeWidget::task20345_sortChildren()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This causes a crash triggered by setVisible(false)");
// This test case is considered successful if it is executed (no crash in sorting)
diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
index 490f87a7ef..c52198fa2c 100644
--- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
@@ -1112,13 +1112,13 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget()
delete item;
item = *it;
if (expecteditemIsNull) {
- QVERIFY(item == 0);
+ QVERIFY(!item);
} else {
QVERIFY(item);
QCOMPARE(item->text(0), expecteditemvalue);
item = *itRemove;
if (expectedUpdatedCurrent.isNull()) {
- QVERIFY(item == 0);
+ QVERIFY(!item);
} else {
QCOMPARE(item->text(0), expectedUpdatedCurrent);
}
diff --git a/tests/auto/widgets/kernel/qaction/BLACKLIST b/tests/auto/widgets/kernel/qaction/BLACKLIST
index f67a3c471e..1ad524fdbf 100644
--- a/tests/auto/widgets/kernel/qaction/BLACKLIST
+++ b/tests/auto/widgets/kernel/qaction/BLACKLIST
@@ -1,2 +1,2 @@
[setStandardKeys]
-ubuntu-14.04
+linux
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 897128d40e..71b55d71ea 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -242,7 +242,7 @@ void tst_QAction::setStandardKeys()
QList<QKeySequence> list;
act.setShortcuts(list);
act.setShortcuts(QKeySequence::Copy);
- QVERIFY(act.shortcut() == act.shortcuts().first());
+ QCOMPARE(act.shortcut(), act.shortcuts().first());
QList<QKeySequence> expected;
const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C"));
diff --git a/tests/auto/widgets/kernel/qactiongroup/BLACKLIST b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
new file mode 100644
index 0000000000..fdc424b6ac
--- /dev/null
+++ b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
@@ -0,0 +1,2 @@
+[QTBUG_14292_filesystem]
+linux
diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
index 8ce9941238..81e5542e91 100644
--- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
@@ -42,6 +42,7 @@ class tst_QActionGroup : public QObject
Q_OBJECT
private slots:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void enabledPropagation();
void visiblePropagation();
void exclusive();
@@ -223,7 +224,7 @@ void tst_QActionGroup::unCheckCurrentAction()
current->setChecked(false);
QVERIFY(!action1.isChecked());
QVERIFY(!action2.isChecked());
- QVERIFY(group.checkedAction() == 0);
+ QVERIFY(!group.checkedAction());
}
diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST
new file mode 100644
index 0000000000..6abb1d9988
--- /dev/null
+++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST
@@ -0,0 +1,4 @@
+[quitOnLastWindowClosed]
+osx-10.10
+[touchEventPropagation]
+xcb
diff --git a/tests/auto/widgets/kernel/qapplication/qapplication.pro b/tests/auto/widgets/kernel/qapplication/qapplication.pro
index 3d167827a3..5154c915cd 100644
--- a/tests/auto/widgets/kernel/qapplication/qapplication.pro
+++ b/tests/auto/widgets/kernel/qapplication/qapplication.pro
@@ -2,6 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = desktopsettingsaware modal
-win32:!wince: SUBDIRS += wincmdline
test.depends += $$SUBDIRS
SUBDIRS += test
diff --git a/tests/auto/widgets/kernel/qapplication/test/BLACKLIST b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
new file mode 100644
index 0000000000..f4a9cb6166
--- /dev/null
+++ b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
@@ -0,0 +1,2 @@
+[quitOnLastWindowClosed]
+osx-10.10
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 84956d0a02..878136b4a0 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -62,6 +62,7 @@
#endif
#include <qpa/qwindowsysteminterface.h>
+#include <private/qhighdpiscaling_p.h>
#include "../../../qtest-config.h"
@@ -162,9 +163,6 @@ private slots:
void setAttribute();
- void windowsCommandLine_data();
- void windowsCommandLine();
-
void touchEventPropagation();
void qtbug_12673();
@@ -1160,7 +1158,7 @@ void tst_QApplication::sendPostedEvents()
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
QPointer<SendPostedEventsTester> p = tester;
(void) app.exec();
- QVERIFY(p == 0);
+ QVERIFY(p.isNull());
}
void tst_QApplication::thread()
@@ -1178,8 +1176,8 @@ void tst_QApplication::thread()
// *before* the QApplication has a thread
QObject object;
QObject child(&object);
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
{
int argc = 0;
@@ -1209,8 +1207,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
// do the test again, making sure that the thread is the same as
// before
@@ -1231,8 +1229,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
QTestEventLoop::instance().enterLoop(1);
}
@@ -1246,8 +1244,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
}
class DeleteLaterWidget : public QWidget
@@ -1561,9 +1559,9 @@ void tst_QApplication::focusChanged()
QCOMPARE(spy.at(0).count(), 2);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == 0);
+ QCOMPARE(now, &le1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QVERIFY(!old);
spy.clear();
QCOMPARE(spy.count(), 0);
@@ -1571,27 +1569,27 @@ void tst_QApplication::focusChanged()
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le1);
+ QCOMPARE(now, &pb1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le1);
spy.clear();
lb1.setFocus();
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &lb1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb1);
+ QCOMPARE(now, &lb1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb1);
spy.clear();
lb1.clearFocus();
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == 0);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &lb1);
+ QVERIFY(!now);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &lb1);
spy.clear();
QWidget parent2;
@@ -1608,9 +1606,9 @@ void tst_QApplication::focusChanged()
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(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == 0);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QVERIFY(!old);
spy.clear();
QTestKeyEvent tab(QTest::Press, Qt::Key_Tab, 0, 0);
@@ -1632,82 +1630,82 @@ void tst_QApplication::focusChanged()
tab.simulate(now);
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
tab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
backtab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
old = &pb2;
} else {
backtab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
click.simulate(old);
if (!(pb2.focusPolicy() & Qt::ClickFocus)) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
click.simulate(old);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
@@ -1722,9 +1720,9 @@ void tst_QApplication::focusChanged()
else
old = qvariant_cast<QWidget*>(spy.at(spy.count()-2).at(0));
now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1));
- QVERIFY(now == &le1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &le1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
@@ -1933,39 +1931,6 @@ void tst_QApplication::setAttribute()
delete w;
}
-void tst_QApplication::windowsCommandLine_data()
-{
-#if defined(Q_OS_WIN)
- QTest::addColumn<QString>("args");
- QTest::addColumn<QString>("expected");
-
- QTest::newRow("hello world")
- << QString("Hello \"World\"")
- << QString("Hello \"World\"");
- QTest::newRow("sql")
- << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME")
- << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME");
-#endif
-}
-
-void tst_QApplication::windowsCommandLine()
-{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
- QFETCH(QString, args);
- QFETCH(QString, expected);
-
- QProcess testProcess;
- const QString path = QStringLiteral("wincmdline/wincmdline");
- testProcess.start(path, QStringList(args));
- QVERIFY2(testProcess.waitForStarted(),
- qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, testProcess.errorString())));
- QVERIFY(testProcess.waitForFinished(10000));
- QByteArray error = testProcess.readAllStandardError();
- QString procError(error);
- QCOMPARE(procError, expected);
-#endif
-}
-
class TouchEventPropagationTestWidget : public QWidget
{
Q_OBJECT
@@ -2038,8 +2003,10 @@ void tst_QApplication::touchEventPropagation()
QVERIFY(QTest::qWaitForWindowExposed(&window));
// QPA always takes screen positions and since we map the TouchPoint back to QPA's structure first,
// we must ensure there is a screen position in the TouchPoint that maps to a local 0, 0.
- pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0)));
- releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0)));
+ const QPoint deviceGlobalPos =
+ QHighDpi::toNativePixels(window.mapToGlobal(QPoint(0, 0)), window.windowHandle()->screen());
+ pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(window.windowHandle(),
0,
@@ -2092,8 +2059,10 @@ void tst_QApplication::touchEventPropagation()
widget.setObjectName("2. widget");
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50)));
- releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50)));
+ const QPoint deviceGlobalPos =
+ QHighDpi::toNativePixels(window.mapToGlobal(QPoint(50, 50)), window.windowHandle()->screen());
+ pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(window.windowHandle(),
0,
diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro b/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro
deleted file mode 100644
index 3e32a6798d..0000000000
--- a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-QT += widgets
-CONFIG -= app_bundle debug_and_release_target
-SOURCES += main.cpp
-DESTDIR = ./
-
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 35a8636f0b..aeaf1e7bf0 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -48,17 +48,8 @@ class tst_QBoxLayout : public QObject
{
Q_OBJECT
-public:
- tst_QBoxLayout();
- virtual ~tst_QBoxLayout();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+ void cleanup();
void insertSpacerItem();
void insertLayout();
void sizeHint();
@@ -120,34 +111,15 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
return QProxyStyle::pixelMetric(metric, option, widget);
}
-
-tst_QBoxLayout::tst_QBoxLayout()
-{
-}
-
-tst_QBoxLayout::~tst_QBoxLayout()
-{
-}
-
-void tst_QBoxLayout::initTestCase()
-{
-}
-
-void tst_QBoxLayout::cleanupTestCase()
-{
-}
-
-void tst_QBoxLayout::init()
-{
-}
-
void tst_QBoxLayout::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QBoxLayout::insertSpacerItem()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -157,44 +129,43 @@ void tst_QBoxLayout::insertSpacerItem()
layout->addSpacerItem(spacer1);
layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar"));
layout->insertSpacerItem(0, spacer2);
- window->setLayout(layout);
+ window.setLayout(layout);
- QVERIFY(layout->itemAt(0) == spacer2);
- QVERIFY(layout->itemAt(2) == spacer1);
+ QCOMPARE(layout->itemAt(0), spacer2);
+ QCOMPARE(layout->itemAt(2), spacer1);
- window->show();
+ window.show();
}
void tst_QBoxLayout::insertLayout()
{
- QWidget *window = new QWidget;
- QVBoxLayout *vbox = new QVBoxLayout(window);
- QVBoxLayout *dummyParentLayout = new QVBoxLayout;
+ QWidget window;
+ QVBoxLayout *vbox = new QVBoxLayout(&window);
+ QScopedPointer<QVBoxLayout> dummyParentLayout(new QVBoxLayout);
QHBoxLayout *subLayout = new QHBoxLayout;
dummyParentLayout->addLayout(subLayout);
- QCOMPARE(subLayout->parent(), dummyParentLayout);
+ QCOMPARE(subLayout->parent(), dummyParentLayout.data());
QCOMPARE(dummyParentLayout->count(), 1);
// add subLayout to another layout
QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent");
vbox->addLayout(subLayout);
QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));
-
- delete dummyParentLayout;
- delete window;
}
void tst_QBoxLayout::sizeHint()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay1 = new QHBoxLayout;
QHBoxLayout *lay2 = new QHBoxLayout;
QLabel *label = new QLabel("widget twooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
lay2->addWidget(label);
lay1->addLayout(lay2);
- window->setLayout(lay1);
- window->show();
+ window.setLayout(lay1);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
label->setText("foooooooo baaaaaaar");
QSize sh = lay1->sizeHint();
QApplication::processEvents();
@@ -207,24 +178,26 @@ void tst_QBoxLayout::sizeHint()
void tst_QBoxLayout::sizeConstraints()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay = new QHBoxLayout;
lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo"));
lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"));
lay->setSizeConstraint(QLayout::SetFixedSize);
- window->setLayout(lay);
- window->show();
- QApplication::processEvents();
- QSize sh = window->sizeHint();
+ window.setLayout(lay);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QSize sh = window.sizeHint();
lay->takeAt(1);
- QVERIFY(sh.width() >= window->sizeHint().width() &&
- sh.height() >= window->sizeHint().height());
+ QVERIFY(sh.width() >= window.sizeHint().width() &&
+ sh.height() >= window.sizeHint().height());
}
void tst_QBoxLayout::setGeometry()
{
QWidget toplevel;
+ toplevel.setWindowTitle(QTest::currentTestFunction());
setFrameless(&toplevel);
QWidget w(&toplevel);
QVBoxLayout *lay = new QVBoxLayout;
@@ -247,33 +220,30 @@ void tst_QBoxLayout::setGeometry()
void tst_QBoxLayout::setStyleShouldChangeSpacing()
{
- QWidget *window = new QWidget;
- QHBoxLayout *hbox = new QHBoxLayout(window);
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
+ QHBoxLayout *hbox = new QHBoxLayout(&window);
QPushButton *pb1 = new QPushButton(tr("The spacing between this"));
QPushButton *pb2 = new QPushButton(tr("and this button should depend on the style of the parent widget"));;
pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect);
pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect);
hbox->addWidget(pb1);
hbox->addWidget(pb2);
- CustomLayoutStyle *style1 = new CustomLayoutStyle;
+ QScopedPointer<CustomLayoutStyle> style1(new CustomLayoutStyle);
style1->hspacing = 6;
- window->setStyle(style1);
- window->show();
+ window.setStyle(style1.data());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
- QTest::qWait(100);
int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 6);
- CustomLayoutStyle *style2 = new CustomLayoutStyle();
+ QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle());
style2->hspacing = 10;
- window->setStyle(style2);
+ window.setStyle(style2.data());
QTest::qWait(100);
spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 10);
-
- delete window;
- delete style1;
- delete style2;
}
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
@@ -287,6 +257,7 @@ void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding));
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setLayout(layout);
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
@@ -325,6 +296,7 @@ void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("347b469225a24a0ef05150a");
QVBoxLayout layout(&widget);
layout.setObjectName("ef9e2b42298e0e6420105bb");
@@ -340,6 +312,7 @@ void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
void tst_QBoxLayout::taskQTBUG_40609_addingLayoutToItself(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("fe44e5cb6c08006597126a");
QVBoxLayout layout(&widget);
layout.setObjectName("cc751dd0f50f62b05a62da");
diff --git a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
index b717c1deb1..e94dfa5754 100644
--- a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
+++ b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
@@ -73,6 +73,7 @@ void tst_QDesktopWidget::init()
void tst_QDesktopWidget::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QDesktopWidget::numScreens()
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 8588df7afa..e1b494c9f1 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -60,17 +60,8 @@ class tst_QFormLayout : public QObject
{
Q_OBJECT
-public:
- tst_QFormLayout();
- ~tst_QFormLayout();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+ void cleanup();
void rowCount();
void buddies();
void getItemPosition();
@@ -132,34 +123,15 @@ private slots:
};
-tst_QFormLayout::tst_QFormLayout()
-{
-}
-
-tst_QFormLayout::~tst_QFormLayout()
-{
-}
-
-void tst_QFormLayout::initTestCase()
-{
-}
-
-void tst_QFormLayout::cleanupTestCase()
-{
-}
-
-void tst_QFormLayout::init()
-{
-}
-
void tst_QFormLayout::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QFormLayout::rowCount()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
fl->addRow(tr("Label 1"), new QLineEdit);
fl->addRow(tr("Label 2"), new QLineEdit);
@@ -174,14 +146,12 @@ void tst_QFormLayout::rowCount()
QCOMPARE(fl->rowCount(), 6);
//TODO: remove items
-
- delete w;
}
void tst_QFormLayout::buddies()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
//normal buddy case
QLineEdit *le = new QLineEdit;
@@ -195,23 +165,21 @@ void tst_QFormLayout::buddies()
QLineEdit *le2 = new QLineEdit;
fl->addRow(0, le2);
QWidget *label2 = fl->labelForField(le2);
- QVERIFY(label2 == 0);
+ QVERIFY(!label2);
//no label
QLineEdit *le3 = new QLineEdit;
fl->addRow(le3);
QWidget *label3 = fl->labelForField(le3);
- QVERIFY(label3 == 0);
+ QVERIFY(!label3);
//TODO: empty label?
-
- delete w;
}
void tst_QFormLayout::getItemPosition()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
QList<QLabel*> labels;
QList<QLineEdit*> fields;
@@ -249,14 +217,12 @@ void tst_QFormLayout::getItemPosition()
QCOMPARE(row, 2);
QCOMPARE(role, QFormLayout::FieldRole);
}
-
- delete w;
}
void tst_QFormLayout::wrapping()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
fl->setRowWrapPolicy(QFormLayout::WrapLongRows);
QLineEdit *le = new QLineEdit;
@@ -264,14 +230,13 @@ void tst_QFormLayout::wrapping()
le->setMinimumWidth(200);
fl->addRow(lbl, le);
- w->setFixedWidth(240);
- w->show();
+ w.setFixedWidth(240);
+ w.setWindowTitle(QTest::currentTestFunction());
+ w.show();
QCOMPARE(le->geometry().y() > lbl->geometry().y(), true);
//TODO: additional tests covering different wrapping cases
-
- delete w;
}
class CustomLayoutStyle : public QProxyStyle
@@ -309,12 +274,12 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
void tst_QFormLayout::spacing()
{
//TODO: confirm spacing behavior
- QWidget *w = new QWidget;
- CustomLayoutStyle *style = new CustomLayoutStyle;
+ QWidget w;
+ QScopedPointer<CustomLayoutStyle> style(new CustomLayoutStyle);
style->hspacing = 5;
style->vspacing = 10;
- w->setStyle(style);
- QFormLayout *fl = new QFormLayout(w);
+ w.setStyle(style.data());
+ QFormLayout *fl = new QFormLayout(&w);
QCOMPARE(style->hspacing, fl->horizontalSpacing());
QCOMPARE(style->vspacing, fl->verticalSpacing());
@@ -351,12 +316,10 @@ void tst_QFormLayout::spacing()
QCheckBox *checkBox = new QCheckBox(tr("Yes"));
fl->setWidget(0, QFormLayout::LabelRole, label);
fl->setWidget(1, QFormLayout::FieldRole, checkBox);
- w->resize(200, 100);
- w->show();
- QVERIFY(QTest::qWaitForWindowExposed(w));
-
- delete w;
- delete style;
+ w.resize(200, 100);
+ w.setWindowTitle(QTest::currentTestFunction());
+ w.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
}
void tst_QFormLayout::contentsRect()
@@ -366,6 +329,7 @@ void tst_QFormLayout::contentsRect()
QFormLayout form;
w.setLayout(&form);
form.addRow("Label", new QPushButton(&w));
+ w.setWindowTitle(QTest::currentTestFunction());
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
int l, t, r, b;
@@ -425,18 +389,18 @@ void tst_QFormLayout::setFormStyle()
#if 0 // QT_NO_STYLE_PLASTIQUE
widget.setStyle(new QPlastiqueStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::ExpandingFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::ExpandingFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
#endif
widget.setStyle(QStyleFactory::create("windows"));
- QVERIFY(layout.labelAlignment() == Qt::AlignLeft);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignLeft);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
/* can't directly create mac style or qtopia style, since
this test is cross platform.. so create dummy styles that
@@ -444,17 +408,17 @@ void tst_QFormLayout::setFormStyle()
*/
widget.setStyle(new DummyMacStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::FieldsStayAtSizeHint);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
widget.setStyle(new DummyQtopiaStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::WrapLongRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::WrapLongRows);
}
void tst_QFormLayout::setFieldGrowthPolicy()
@@ -479,14 +443,14 @@ void tst_QFormLayout::setFieldGrowthPolicy()
layout.activate();
if (i == 0) {
- QVERIFY(fld1.width() == fld2.width());
- QVERIFY(fld2.width() == fld3.width());
+ QCOMPARE(fld1.width(), fld2.width());
+ QCOMPARE(fld2.width(), fld3.width());
} else if (i == 1) {
- QVERIFY(fld1.width() == fld2.width());
+ QCOMPARE(fld1.width(), fld2.width());
QVERIFY(fld2.width() < fld3.width());
} else {
QVERIFY(fld1.width() < fld2.width());
- QVERIFY(fld2.width() == fld3.width());
+ QCOMPARE(fld2.width(), fld3.width());
}
}
}
@@ -505,33 +469,39 @@ void tst_QFormLayout::setFormAlignment()
void tst_QFormLayout::addRow()
{
- QFormLayout layout;
- QWidget w1, w2, w3;
- QHBoxLayout l1, l2, l3;
- QLabel lbl1, lbl2;
-
- QCOMPARE(layout.rowCount(), 0);
-
- layout.addRow(&lbl1, &w1);
- layout.addRow(&lbl2, &l1);
- layout.addRow("Foo:", &w2);
- layout.addRow("Bar:", &l2);
- layout.addRow(&w3);
- layout.addRow(&l3);
-
- QCOMPARE(layout.rowCount(), 6);
-
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:");
- QVERIFY(layout.itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:");
- QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(5, QFormLayout::LabelRole) == 0);
-
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &w1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &l1);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &w2);
- QVERIFY(layout.itemAt(3, QFormLayout::FieldRole)->layout() == &l2);
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QHBoxLayout *l1 = new QHBoxLayout;
+ QHBoxLayout *l2 = new QHBoxLayout;
+ QHBoxLayout *l3 = new QHBoxLayout;
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+
+ QCOMPARE(layout->rowCount(), 0);
+
+ layout->addRow(lbl1, w1);
+ layout->addRow(lbl2, l1);
+ layout->addRow("Foo:", w2);
+ layout->addRow("Bar:", l2);
+ layout->addRow(w3);
+ layout->addRow(l3);
+
+ QCOMPARE(layout->rowCount(), 6);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:");
+ QVERIFY(layout->itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:");
+ QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(5, QFormLayout::LabelRole) == 0);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == w1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == l1);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == w2);
+ QVERIFY(layout->itemAt(3, QFormLayout::FieldRole)->layout() == l2);
// ### should have a third role, FullRowRole?
// QVERIFY(layout.itemAt(4, QFormLayout::FieldRole) == 0);
// QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0);
@@ -539,17 +509,24 @@ void tst_QFormLayout::addRow()
void tst_QFormLayout::insertRow_QWidget_QWidget()
{
- QFormLayout layout;
- QLabel lbl1, lbl2, lbl3, lbl4;
- QLineEdit fld1, fld2, fld3, fld4;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+ QLabel *lbl3 = new QLabel(&topLevel);
+ QLabel *lbl4 = new QLabel(&topLevel);
+ QLineEdit *fld1 = new QLineEdit(&topLevel);
+ QLineEdit *fld2 = new QLineEdit(&topLevel);
+ QLineEdit *fld3 = new QLineEdit(&topLevel);
+ QLineEdit *fld4 = new QLineEdit(&topLevel);
- layout.insertRow(0, &lbl1, &fld1);
- QCOMPARE(layout.rowCount(), 1);
+ layout->insertRow(0, lbl1, fld1);
+ QCOMPARE(layout->rowCount(), 1);
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&lbl1, &row, &role);
+ layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
}
@@ -557,63 +534,68 @@ void tst_QFormLayout::insertRow_QWidget_QWidget()
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&fld1, &row, &role);
+ layout->getWidgetPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
}
// check that negative values append
- layout.insertRow(-2, &lbl2, &fld2);
- QCOMPARE(layout.rowCount(), 2);
+ layout->insertRow(-2, lbl2, fld2);
+ QCOMPARE(layout->rowCount(), 2);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
// check that too large values append
- layout.insertRow(100, &lbl3, &fld3);
- QCOMPARE(layout.rowCount(), 3);
- QCOMPARE(layout.count(), 6);
+ layout->insertRow(100, lbl3, fld3);
+ QCOMPARE(layout->rowCount(), 3);
+ QCOMPARE(layout->count(), 6);
- layout.insertRow(3, (QWidget *)0, (QWidget *)0);
- QCOMPARE(layout.rowCount(), 4);
- QCOMPARE(layout.count(), 6);
+ layout->insertRow(3, (QWidget *)0, (QWidget *)0);
+ QCOMPARE(layout->rowCount(), 4);
+ QCOMPARE(layout->count(), 6);
- layout.insertRow(4, (QWidget *)0, &fld4);
- QCOMPARE(layout.rowCount(), 5);
- QCOMPARE(layout.count(), 7);
+ layout->insertRow(4, (QWidget *)0, fld4);
+ QCOMPARE(layout->rowCount(), 5);
+ QCOMPARE(layout->count(), 7);
- layout.insertRow(5, &lbl4, (QWidget *)0);
- QCOMPARE(layout.rowCount(), 6);
- QCOMPARE(layout.count(), 8);
-
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3);
- QVERIFY(layout.itemAt(3, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(5, QFormLayout::LabelRole)->widget() == &lbl4);
-
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &fld1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->widget() == &fld2);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &fld3);
- QVERIFY(layout.itemAt(3, QFormLayout::FieldRole) == 0);
- QVERIFY(layout.itemAt(4, QFormLayout::FieldRole)->widget() == &fld4);
- QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0);
+ layout->insertRow(5, lbl4, (QWidget *)0);
+ QCOMPARE(layout->rowCount(), 6);
+ QCOMPARE(layout->count(), 8);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3);
+ QVERIFY(layout->itemAt(3, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(5, QFormLayout::LabelRole)->widget() == lbl4);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == fld1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->widget() == fld2);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == fld3);
+ QVERIFY(layout->itemAt(3, QFormLayout::FieldRole) == 0);
+ QVERIFY(layout->itemAt(4, QFormLayout::FieldRole)->widget() == fld4);
+ QVERIFY(layout->itemAt(5, QFormLayout::FieldRole) == 0);
}
void tst_QFormLayout::insertRow_QWidget_QLayout()
{
- QFormLayout layout;
- QLabel lbl1, lbl2, lbl3, lbl4;
- QHBoxLayout fld1, fld2, fld3, fld4;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+ QLabel *lbl3 = new QLabel(&topLevel);
+ QHBoxLayout *fld1 = new QHBoxLayout;
+ QHBoxLayout *fld2 = new QHBoxLayout;
+ QHBoxLayout *fld3 = new QHBoxLayout;
- layout.insertRow(0, &lbl1, &fld1);
- QCOMPARE(layout.rowCount(), 1);
+ layout->insertRow(0, lbl1, fld1);
+ QCOMPARE(layout->rowCount(), 1);
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&lbl1, &row, &role);
+ layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
}
@@ -621,77 +603,83 @@ void tst_QFormLayout::insertRow_QWidget_QLayout()
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getLayoutPosition(&fld1, &row, &role);
+ layout->getLayoutPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
}
// check that negative values append
- layout.insertRow(-2, &lbl2, &fld2);
- QCOMPARE(layout.rowCount(), 2);
+ layout->insertRow(-2, lbl2, fld2);
+ QCOMPARE(layout->rowCount(), 2);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
// check that too large values append
- layout.insertRow(100, &lbl3, &fld3);
- QCOMPARE(layout.rowCount(), 3);
+ layout->insertRow(100, lbl3, fld3);
+ QCOMPARE(layout->rowCount(), 3);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3);
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->layout() == &fld1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &fld2);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->layout() == &fld3);
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->layout() == fld1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == fld2);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->layout() == fld3);
}
void tst_QFormLayout::insertRow_QString_QWidget()
{
- QFormLayout layout;
- QLineEdit fld1, fld2, fld3;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLineEdit *fld1 = new QLineEdit(&topLevel);
+ QLineEdit *fld2 = new QLineEdit(&topLevel);
+ QLineEdit *fld3 = new QLineEdit(&topLevel);
- layout.insertRow(-5, "&Name:", &fld1);
- QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(-5, "&Name:", fld1);
+ QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0);
- QVERIFY(label1->buddy() == &fld1);
+ QCOMPARE(label1->buddy(), fld1);
- layout.insertRow(0, "&Email:", &fld2);
- QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(0, "&Email:", fld2);
+ QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0);
- QVERIFY(label2->buddy() == &fld2);
+ QCOMPARE(label2->buddy(), fld2);
- layout.insertRow(5, "&Age:", &fld3);
- QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget());
+ layout->insertRow(5, "&Age:", fld3);
+ QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0);
- QVERIFY(label3->buddy() == &fld3);
+ QCOMPARE(label3->buddy(), fld3);
}
void tst_QFormLayout::insertRow_QString_QLayout()
{
- QFormLayout layout;
- QHBoxLayout fld1, fld2, fld3;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QHBoxLayout *fld1 = new QHBoxLayout;
+ QHBoxLayout *fld2 = new QHBoxLayout;
+ QHBoxLayout *fld3 = new QHBoxLayout;
- layout.insertRow(-5, "&Name:", &fld1);
- QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(-5, "&Name:", fld1);
+ QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0);
- QVERIFY(label1->buddy() == 0);
+ QVERIFY(!label1->buddy());
- QCOMPARE(layout.rowCount(), 1);
+ QCOMPARE(layout->rowCount(), 1);
- layout.insertRow(0, "&Email:", &fld2);
- QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(0, "&Email:", fld2);
+ QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0);
- QVERIFY(label2->buddy() == 0);
+ QVERIFY(!label2->buddy());
- QCOMPARE(layout.rowCount(), 2);
+ QCOMPARE(layout->rowCount(), 2);
- layout.insertRow(5, "&Age:", &fld3);
- QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget());
+ layout->insertRow(5, "&Age:", fld3);
+ QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0);
- QVERIFY(label3->buddy() == 0);
+ QVERIFY(!label3->buddy());
- QCOMPARE(layout.rowCount(), 3);
+ QCOMPARE(layout->rowCount(), 3);
}
void tst_QFormLayout::insertRow_QWidget()
@@ -840,39 +828,40 @@ void tst_QFormLayout::setLayout()
void tst_QFormLayout::itemAt()
{
- QFormLayout layout;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
- QWidget w1;
- QWidget w2;
- QWidget w3;
- QWidget w4;
- QWidget w5;
- QHBoxLayout l6;
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QWidget *w4 = new QWidget(&topLevel);
+ QWidget *w5 = new QWidget(&topLevel);
+ QHBoxLayout *l6 = new QHBoxLayout;
- layout.setWidget(5, QFormLayout::LabelRole, &w1);
- layout.setWidget(3, QFormLayout::FieldRole, &w2);
- layout.setWidget(3, QFormLayout::LabelRole, &w3);
- layout.addRow(&w4, &w5);
- layout.addRow("Foo:", &l6);
+ layout->setWidget(5, QFormLayout::LabelRole, w1);
+ layout->setWidget(3, QFormLayout::FieldRole, w2);
+ layout->setWidget(3, QFormLayout::LabelRole, w3);
+ layout->addRow(w4, w5);
+ layout->addRow("Foo:", l6);
- QCOMPARE(layout.count(), 7);
+ QCOMPARE(layout->count(), 7);
QBitArray scoreBoard(7);
for (int i = 0; i < 7; ++i) {
- QLayoutItem *item = layout.itemAt(i);
+ QLayoutItem *item = layout->itemAt(i);
QVERIFY(item != 0);
- if (item->widget() == &w1) {
+ if (item->widget() == w1) {
scoreBoard[0] = true;
- } else if (item->widget() == &w2) {
+ } else if (item->widget() == w2) {
scoreBoard[1] = true;
- } else if (item->widget() == &w3) {
+ } else if (item->widget() == w3) {
scoreBoard[2] = true;
- } else if (item->widget() == &w4) {
+ } else if (item->widget() == w4) {
scoreBoard[3] = true;
- } else if (item->widget() == &w5) {
+ } else if (item->widget() == w5) {
scoreBoard[4] = true;
- } else if (item->layout() == &l6) {
+ } else if (item->layout() == l6) {
scoreBoard[5] = true;
} else if (qobject_cast<QLabel *>(item->widget())) {
scoreBoard[6] = true;
@@ -883,26 +872,27 @@ void tst_QFormLayout::itemAt()
void tst_QFormLayout::takeAt()
{
- QFormLayout layout;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
- QWidget w1;
- QWidget w2;
- QWidget w3;
- QWidget w4;
- QWidget w5;
- QHBoxLayout l6;
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QWidget *w4 = new QWidget(&topLevel);
+ QWidget *w5 = new QWidget(&topLevel);
+ QHBoxLayout *l6 = new QHBoxLayout;
- layout.setWidget(5, QFormLayout::LabelRole, &w1);
- layout.setWidget(3, QFormLayout::FieldRole, &w2);
- layout.setWidget(3, QFormLayout::LabelRole, &w3);
- layout.addRow(&w4, &w5);
- layout.addRow("Foo:", &l6);
+ layout->setWidget(5, QFormLayout::LabelRole, w1);
+ layout->setWidget(3, QFormLayout::FieldRole, w2);
+ layout->setWidget(3, QFormLayout::LabelRole, w3);
+ layout->addRow(w4, w5);
+ layout->addRow("Foo:", l6);
- QCOMPARE(layout.count(), 7);
+ QCOMPARE(layout->count(), 7);
for (int i = 6; i >= 0; --i) {
- layout.takeAt(0);
- QCOMPARE(layout.count(), i);
+ layout->takeAt(0);
+ QCOMPARE(layout->count(), i);
}
}
@@ -917,6 +907,7 @@ void tst_QFormLayout::layoutAlone()
QHBoxLayout hlay;
layout.setLayout(1, QFormLayout::LabelRole, &hlay);
QCOMPARE(layout.count(), 2);
+ w.setWindowTitle(QTest::currentTestFunction());
w.show();
layout.activate();
QTest::qWait(500);
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 7f3c289fb4..1e67c675ef 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -60,18 +60,9 @@ class tst_QGridLayout : public QObject
{
Q_OBJECT
-public:
- tst_QGridLayout();
- virtual ~tst_QGridLayout();
-
-
-public slots:
+private slots:
void initTestCase();
- void cleanupTestCase();
- void init();
void cleanup();
-
-private slots:
void getItemPosition();
void itemAtPosition();
void badDistributionBug();
@@ -97,76 +88,72 @@ private slots:
void taskQTBUG_40609_addingLayoutToItself();
void replaceWidget();
void dontCrashWhenExtendsToEnd();
-
-private:
- QWidget *testWidget;
- QGridLayout *testLayout;
- QWidget *w1;
- QWidget *w2;
- QWidget *w3;
- QSpacerItem *sp;
-
- QGridLayout *m_grid;
- QWidget *m_toplevel;
};
-
-tst_QGridLayout::tst_QGridLayout()
+void tst_QGridLayout::initTestCase()
{
- m_grid = 0;
- m_toplevel = 0;
+#ifdef Q_OS_WINCE //disable magic for WindowsCE
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
}
-tst_QGridLayout::~tst_QGridLayout()
+static inline int visibleTopLevelWidgetCount()
{
- delete m_toplevel;
+ int result= 0;
+ foreach (const QWidget *topLevel, QApplication::topLevelWidgets()) {
+ if (topLevel->isVisible())
+ ++result;
+ }
+ return result;
}
-void tst_QGridLayout::initTestCase()
+void tst_QGridLayout::cleanup()
{
-#ifdef Q_OS_WINCE //disable magic for WindowsCE
- qApp->setAutoMaximizeThreshold(-1);
-#endif
- // Create the test class
- testWidget = new QWidget(0);
+ // Verify that no visible top levels are leaked. Cannot check for
+ // topLevelWidgets().isEmpty() here since the data driven test layoutSpacing()
+ // will appear to "leak" top levels due to it creating widgets in the test data.
+ QCOMPARE(visibleTopLevelWidgetCount(), 0);
+}
- testLayout = new QGridLayout(testWidget);
+class ItemTestWidget : public QWidget {
+public:
+ ItemTestWidget();
+
+ QGridLayout *testLayout;
+ QWidget *w1;
+ QWidget *w2;
+ QWidget *w3;
+ QSpacerItem *sp;
+};
+
+ItemTestWidget::ItemTestWidget()
+ : testLayout(new QGridLayout(this))
+ , w1(new QWidget(this))
+ , w2(new QWidget(this))
+ , w3(new QWidget(this))
+ , sp(new QSpacerItem(4, 4))
+{
+ setObjectName("testWidget");
+ setWindowTitle(QTest::currentTestFunction());
- w1 = new QWidget(testWidget);
w1->setPalette(QPalette(Qt::red));
testLayout->addWidget(w1, 0, 0);
- w2 = new QWidget(testWidget);
testLayout->addWidget(w2, 1, 1, 2, 2);
w2->setPalette(QPalette(Qt::green));
- w3 = new QWidget(testWidget);
testLayout->addWidget(w3, 0, 1, 1, 2);
w3->setPalette(QPalette(Qt::blue));
- sp = new QSpacerItem(4, 4);
testLayout->addItem(sp, 1, 3, 2, 1);
-
- testWidget->resize( 200, 200 );
- testWidget->show();
-}
-
-void tst_QGridLayout::cleanupTestCase()
-{
- delete testWidget;
- testWidget = 0;
-}
-
-void tst_QGridLayout::init()
-{
-}
-
-void tst_QGridLayout::cleanup()
-{
}
void tst_QGridLayout::getItemPosition()
{
+ ItemTestWidget testWidget;
+ testWidget.resize(200, 200);
+ testWidget.show();
+
QLayoutItem *item;
int counter = 0;
@@ -175,28 +162,28 @@ void tst_QGridLayout::getItemPosition()
bool seenW3 = false;
bool seenSpacer = false;
- while ((item = testLayout->itemAt(counter))) {
+ while ((item = testWidget.testLayout->itemAt(counter))) {
QWidget *w = item->widget();
int r,c,rs,cs;
- testLayout->getItemPosition(counter, &r, &c, &rs, &cs);
+ testWidget.testLayout->getItemPosition(counter, &r, &c, &rs, &cs);
// qDebug() << "item" << counter << "has" <<r << c << rs << cs;
- if (w == w1) {
+ if (w == testWidget.w1) {
QVERIFY(!seenW1);
seenW1 = true;
QCOMPARE(r, 0);
QCOMPARE(c, 0);
QCOMPARE(rs, 1);
QCOMPARE(cs, 1);
- } else if (w == w2) {
+ } else if (w == testWidget.w2) {
QVERIFY(!seenW2);
seenW2 = true;
QCOMPARE(r, 1);
QCOMPARE(c, 1);
QCOMPARE(rs, 2);
QCOMPARE(cs, 2);
- } else if (w == w3) {
+ } else if (w == testWidget.w3) {
QVERIFY(!seenW3);
seenW3 = true;
QCOMPARE(r, 0);
@@ -223,16 +210,20 @@ void tst_QGridLayout::getItemPosition()
void tst_QGridLayout::itemAtPosition()
{
+ ItemTestWidget testWidget;
+ testWidget.resize(200, 200);
+ testWidget.show();
+
void *table[4][5] = {
- { w1, w3, w3, 0, 0 },
- { 0, w2, w2, sp, 0 },
- { 0, w2, w2, sp, 0 },
+ { testWidget.w1, testWidget.w3,testWidget.w3, 0, 0 },
+ { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 },
+ { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 },
{ 0, 0, 0, 0, 0 }
};
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 5; ++col) {
- QLayoutItem *item = testLayout->itemAtPosition(row, col);
+ QLayoutItem *item = testWidget.testLayout->itemAtPosition(row, col);
QVERIFY(item == table[row][col]
|| (item && item->widget() == table[row][col]));
}
@@ -860,32 +851,31 @@ void tst_QGridLayout::minMaxSize()
}
}
QApplication::setStyle(style);
- if (!m_grid)
- m_grid = new QGridLayout();
- if (!m_toplevel) {
- m_toplevel = new QWidget();
- setFrameless(m_toplevel);
- }
+ QWidget toplevel;
+ toplevel.setWindowTitle(QLatin1String(QTest::currentTestFunction())
+ + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
+ setFrameless(&toplevel);
+ QGridLayout *grid = new QGridLayout;
if (fixedSize.isValid()) {
- m_toplevel->setFixedSize(fixedSize);
+ toplevel.setFixedSize(fixedSize);
} else {
- m_toplevel->setMinimumSize(QSize(0,0));
- m_toplevel->setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX));
+ toplevel.setMinimumSize(QSize(0,0));
+ toplevel.setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX));
}
// Do a two-pass one using the real testdata, the other pass enables heightForWidth
// on the widget, but the heightForWidth() function just return sizeHint().width()
for (int pass = 0; pass < 2; ++pass) {
- m_toplevel->hide();
+ toplevel.hide();
QApplication::processEvents();
QTest::qWait(20);
// Test if removeItem uninitializes data properly
- while (m_grid->count()) {
- QLayoutItem *item = m_grid->itemAt(0);
- m_grid->removeItem(item);
+ while (grid->count()) {
+ QLayoutItem *item = grid->itemAt(0);
+ grid->removeItem(item);
delete item->widget();
delete item;
}
- m_toplevel->setLayout(m_grid);
+ toplevel.setLayout(grid);
// a layout with a top-level parent widget
QList<QPointer<SizeHinterFrame> > sizehinters;
@@ -899,29 +889,29 @@ void tst_QGridLayout::minMaxSize()
QSizePolicy sp = sh->sizePolicy();
sp.setHorizontalPolicy((QSizePolicy::Policy)sizePolicy);
sh->setSizePolicy(sp);
- sh->setParent(m_toplevel);
+ sh->setParent(&toplevel);
if (si.minSize.isValid())
sh->setMinimumSize(si.minSize);
if (si.maxSize.isValid())
sh->setMaximumSize(si.maxSize);
sizehinters.append(sh);
- m_grid->addWidget(sh, i, j);
+ grid->addWidget(sh, i, j);
}
}
- m_toplevel->show();
- QVERIFY(QTest::qWaitForWindowExposed(m_toplevel));
- m_toplevel->adjustSize();
+ toplevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
+ toplevel.adjustSize();
QTest::qWait(240); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
// If that does not help there is likely a problem with the implicit adjustSize in show()
if (!fixedSize.isValid()) {
// Note that this can fail if the desktop has large fonts on windows.
- QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint());
+ QTRY_COMPARE(toplevel.size(), toplevel.sizeHint());
}
// We are relying on the order here...
for (int pi = 0; pi < sizehinters.count(); ++pi) {
- QPoint pt = sizehinters.at(pi)->mapTo(m_toplevel, QPoint(0, 0));
+ QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0));
QCOMPARE(pt, sizeinfos.at(pi).expectedPos);
}
}
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
index d661c074ac..4d15ac9a93 100644
--- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
+++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
@@ -66,6 +66,7 @@ public:
virtual ~tst_QLayout();
private slots:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void getSetCheck();
void geometry();
void smartMaxSize();
@@ -217,12 +218,12 @@ void tst_QLayout::setLayoutBugs()
}
widget.setLayout(hBoxLayout);
- QVERIFY(widget.layout() == hBoxLayout);
+ QCOMPARE(widget.layout(), hBoxLayout);
QWidget containerWidget(0);
containerWidget.setLayout(widget.layout());
- QVERIFY(widget.layout() == 0);
- QVERIFY(containerWidget.layout() == hBoxLayout);
+ QVERIFY(!widget.layout());
+ QCOMPARE(containerWidget.layout(), hBoxLayout);
}
class MyLayout : public QLayout
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 7b9eaa418f..f206a5fe9a 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -108,6 +108,7 @@ public slots:
public slots:
void initTestCase();
void cleanupTestCase();
+ void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); }
private slots:
void number_data();
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index 6c88f8731b..0f8c9d1c9e 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -44,6 +44,7 @@ class tst_QSizePolicy : public QObject
Q_OBJECT
private Q_SLOTS:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void qtest();
void defaultValues();
void getSetCheck_data() { data(); }
@@ -51,6 +52,8 @@ private Q_SLOTS:
void dataStream();
void horizontalStretch();
void verticalStretch();
+ void qhash_data() { data(); }
+ void qhash();
private:
void data() const;
};
@@ -149,8 +152,6 @@ void tst_QSizePolicy::getSetCheck()
QCOMPARE(sp.expandingDirections(), ed);
}
-#undef FETCH_TEST_DATA
-
static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp,
int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh,
Qt::Orientations orients)
@@ -314,5 +315,21 @@ void tst_QSizePolicy::verticalStretch()
QCOMPARE(sp.verticalStretch(), 255);
}
+void tst_QSizePolicy::qhash()
+{
+ FETCH_TEST_DATA;
+ Q_UNUSED(ed);
+
+ QSizePolicy sp2(hp, vp, ct);
+ sp2.setVerticalStretch(vst);
+ sp2.setHorizontalStretch(hst);
+ if (hfw) sp2.setHeightForWidth(true);
+ if (wfh) sp2.setWidthForHeight(true);
+ QCOMPARE(sp, sp2);
+ QCOMPARE(qHash(sp), qHash(sp2));
+}
+
+#undef FETCH_TEST_DATA
+
QTEST_MAIN(tst_QSizePolicy)
#include "tst_qsizepolicy.moc"
diff --git a/tests/auto/widgets/kernel/qtooltip/BLACKLIST b/tests/auto/widgets/kernel/qtooltip/BLACKLIST
new file mode 100644
index 0000000000..f8d062cc46
--- /dev/null
+++ b/tests/auto/widgets/kernel/qtooltip/BLACKLIST
@@ -0,0 +1,4 @@
+[whatsThis]
+ubuntu-14.04
+[task183679]
+opensuse-13.1
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 591aa9e40f..78ccbe302a 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -12,7 +12,7 @@ osx
ubuntu-14.04
osx
[focusProxyAndInputMethods]
-ubuntu-14.04
+linux
[touchEventSynthesizedMouseEvent]
ubuntu-14.04
[grabMouse]
@@ -28,73 +28,17 @@ osx
[stackUnder]
osx
[raise]
-osx-10.9
+osx
[widgetAt]
osx
[sheetOpacity]
osx
[resizeEvent]
osx
-[setWindowGeometry:100,123 200x200, flags 0]
-osx-10.10
-[windowMoveResize:100,123 200x200, flags 0]
-osx-10.10
-[setWindowGeometry:100,122 200x200, flags 0]
-osx-10.9
-[windowMoveResize:100,122 200x200, flags 0]
-osx-10.9
-[setWindowGeometry:100,100 824x564, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x564, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x516, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x516, flags 0]
-osx-10.10
-[setWindowGeometry:100,73 200x0, flags 0]
-osx-10.10
-[windowMoveResize:100,73 200x0, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x519, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x519, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x518, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x518, flags 0]
-osx-10.10
-[setWindowGeometry:100,72 200x0, flags 0]
-osx-10.9
-[windowMoveResize:100,72 200x0, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x574, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x574, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x578, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x578, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x576, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x576, flags 0]
-osx-10.9
-[setWindowGeometry:100,100 824x521, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x521, flags 0]
-osx-10.10
-[setWindowGeometry:100,122 952x577, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x577, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x580, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x580, flags 0]
-osx-10.9
-[windowMoveResize:130,72 0x0, flags 0]
-osx-10.9
-[windowMoveResize:130,122 0x200, flags 0]
-osx-10.9
+[setWindowGeometry]
+osx
+[windowMoveResize]
+osx
[childEvents]
osx
[renderInvisible]
@@ -114,9 +58,9 @@ osx
[showMinimizedKeepsFocus]
osx-10.10
[moveWindowInShowEvent:1]
-osx-10.9
+osx
[moveWindowInShowEvent:2]
-osx-10.9
+osx
[taskQTBUG_4055_sendSyntheticEnterLeave]
osx
[syntheticEnterLeave]
@@ -128,10 +72,14 @@ osx-10.10
[hideOpaqueChildWhileHidden]
osx
[resizeStaticContentsChildWidget_QTBUG35282]
-osx-10.9
+osx
[lower]
osx
[setClearAndResizeMask]
osx
[setToolTip]
osx-10.9
+[moveInResizeEvent]
+ubuntu-14.04
+[moveChild:right]
+osx
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index a0d94d2dc9..f3f4467b80 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -51,6 +51,7 @@
#include <qdesktopwidget.h>
#include <private/qwidget_p.h>
#include <private/qapplication_p.h>
+#include <private/qhighdpiscaling_p.h>
#include <qcalendarwidget.h>
#include <qmainwindow.h>
#include <qdockwidget.h>
@@ -193,6 +194,19 @@ static QByteArray msgComparisonFailed(T v1, const char *op, T v2)
return s.toLocal8Bit();
}
+// Compare a window position that may go through scaling in the platform plugin with fuzz.
+static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz)
+{
+ return (p1 - p2).manhattanLength() <= fuzz;
+}
+
+static QString msgPointMismatch(const QPoint &p1, const QPoint p2)
+{
+ QString result;
+ QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength();
+ return result;
+}
+
class tst_QWidget : public QObject
{
Q_OBJECT
@@ -613,7 +627,7 @@ void tst_QWidget::getSetCheck()
}
tst_QWidget::tst_QWidget()
- : m_platform(qApp->platformName().toLower())
+ : m_platform(QGuiApplication::platformName().toLower())
, m_windowsAnimationsEnabled(windowsAnimationsEnabled())
{
if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild()
@@ -1905,8 +1919,10 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
+ const int fuzz = int(QHighDpiScaling::factor(widget1.windowHandle()));
QVERIFY(!(widget1.windowState() & Qt::WindowMaximized));
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowMinimized);
@@ -1927,7 +1943,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
QVERIFY(!(widget1.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized)));
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -1948,7 +1965,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(Qt::WindowNoState);
QTest::qWait(100);
VERIFY_STATE(Qt::WindowNoState);
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -1981,7 +1999,8 @@ void tst_QWidget::windowState()
QVERIFY(!(widget1.windowState() & stateMask));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QTRY_COMPARE(widget1.size(), size);
}
@@ -3079,12 +3098,12 @@ void tst_QWidget::saveRestoreGeometry()
const QByteArray four("abca");
const QByteArray garbage("abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc");
- QVERIFY(widget.restoreGeometry(empty) == false);
- QVERIFY(widget.restoreGeometry(one) == false);
- QVERIFY(widget.restoreGeometry(two) == false);
- QVERIFY(widget.restoreGeometry(three) == false);
- QVERIFY(widget.restoreGeometry(four) == false);
- QVERIFY(widget.restoreGeometry(garbage) == false);
+ QVERIFY(!widget.restoreGeometry(empty));
+ QVERIFY(!widget.restoreGeometry(one));
+ QVERIFY(!widget.restoreGeometry(two));
+ QVERIFY(!widget.restoreGeometry(three));
+ QVERIFY(!widget.restoreGeometry(four));
+ QVERIFY(!widget.restoreGeometry(garbage));
QVERIFY(widget.restoreGeometry(savedGeometry));
widget.showNormal();
@@ -3354,7 +3373,7 @@ void tst_QWidget::widgetAt()
#if defined(Q_OS_WINCE)
QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191
#endif
- QTRY_VERIFY(QApplication::widgetAt(testPos) == w1.data());
+ QTRY_COMPARE(QApplication::widgetAt(testPos), w1.data());
QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data());
}
@@ -3401,24 +3420,24 @@ void tst_QWidget::testDeletionInEventHandlers()
QPointer<Widget> w = new Widget;
w->deleteThis = true;
w->close();
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// focusOut (crashes)
//w = new Widget;
//w->show();
//w->setFocus();
- //QVERIFY(qApp->focusWidget() == w);
+ //QCOMPARE(qApp->focusWidget(), w);
//w->deleteThis = true;
//w->clearFocus();
- //QVERIFY(w == 0);
+ //QVERIFY(w.isNull());
// key press
w = new Widget;
w->show();
w->deleteThis = true;
QTest::keyPress(w, Qt::Key_A);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// key release
@@ -3426,7 +3445,7 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::keyRelease(w, Qt::Key_A);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// mouse press
@@ -3434,15 +3453,16 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::mousePress(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// mouse release
w = new Widget;
w->show();
w->deleteThis = true;
- QTest::mouseRelease(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QMouseEvent me(QEvent::MouseButtonRelease, QPoint(1, 1), Qt::LeftButton, Qt::LeftButton, 0);
+ qApp->notify(w, &me);
+ QVERIFY(w.isNull());
delete w;
// mouse double click
@@ -3450,7 +3470,7 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::mouseDClick(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// hide event (crashes)
@@ -3458,13 +3478,13 @@ void tst_QWidget::testDeletionInEventHandlers()
//w->show();
//w->deleteThis = true;
//w->hide();
- //QVERIFY(w == 0);
+ //QVERIFY(w.isNull());
// action event
w = new Widget;
w->deleteThis = true;
w->addAction(new QAction(w));
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// change event
@@ -3472,16 +3492,16 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
w->setMouseTracking(true);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
w = new Widget;
w->setMouseTracking(true);
w->show();
w->deleteThis = true;
- QMouseEvent me(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ me = QMouseEvent(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
QApplication::sendEvent(w, &me);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
}
@@ -3675,6 +3695,8 @@ void tst_QWidget::optimizedResizeMove()
void tst_QWidget::optimizedResize_topLevel()
{
+ if (QHighDpiScaling::isActive())
+ QSKIP("Skip due to rounding errors in the regions.");
StaticWidget topLevel;
topLevel.gotPaintEvent = false;
topLevel.show();
@@ -3909,7 +3931,7 @@ void tst_QWidget::winIdChangeEvent()
QCOMPARE(winIdBefore, winIdAfter);
QCOMPARE(child.winIdChangeEventCount(), 3);
// winId is set to zero during reparenting
- QVERIFY(0 == child.m_winIdList[1]);
+ QCOMPARE(WId(0), child.m_winIdList[1]);
}
{
@@ -3949,7 +3971,7 @@ void tst_QWidget::winIdChangeEvent()
QCOMPARE(winIdBefore, winIdAfter);
QCOMPARE(child.winIdChangeEventCount(), 3);
// winId is set to zero during reparenting
- QVERIFY(0 == child.m_winIdList[1]);
+ QCOMPARE(WId(0), child.m_winIdList[1]);
}
}
@@ -4495,7 +4517,7 @@ void tst_QWidget::qobject_castInDestroyedSlot()
QObject::connect(widget, SIGNAL(destroyed(QObject*)), &checker, SLOT(destroyedSlot(QObject*)));
delete widget;
- QVERIFY(checker.wasQWidget == true);
+ QVERIFY(checker.wasQWidget);
}
// Since X11 WindowManager operations are all async, and we have no way to know if the window
@@ -6007,10 +6029,13 @@ void tst_QWidget::childEvents()
expected =
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::Polish)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6022,13 +6047,9 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -6097,10 +6118,13 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6113,13 +6137,9 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -6190,10 +6210,13 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6206,13 +6229,9 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -8957,7 +8976,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
int numEnterEvents, numMouseMoveEvents;
};
- QCursor::setPos(QPoint(0,0));
+ QCursor::setPos(QPoint(0,0));
SELParent parent;
parent.move(200, 200);
@@ -8965,8 +8984,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
SELChild child(&parent);
child.resize(200, 200);
parent.show();
- QVERIFY(QTest::qWaitForWindowExposed(&parent));
- QTest::qWait(150);
+ QVERIFY(QTest::qWaitForWindowActive(&parent));
QCursor::setPos(child.mapToGlobal(QPoint(100, 100)));
// Make sure the cursor has entered the child.
@@ -9714,8 +9732,9 @@ void tst_QWidget::grabMouse()
QVERIFY(QTest::qWaitForWindowActive(&w));
QStringList expectedLog;
- grabber->grabMouse();
QPoint mousePos = QPoint(w.width() / 2, 10);
+ QTest::mouseMove(w.windowHandle(), mousePos);
+ grabber->grabMouse();
const int step = w.height() / 5;
for ( ; mousePos.y() < w.height() ; mousePos.ry() += step) {
QTest::mouseClick(w.windowHandle(), Qt::LeftButton, 0, mousePos);
@@ -10385,6 +10404,9 @@ public:
void tst_QWidget::keyboardModifiers()
{
KeyboardWidget w;
+ w.resize(300, 300);
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
QTest::mouseClick(&w, Qt::LeftButton, Qt::ControlModifier);
QCOMPARE(w.m_eventCounter, 1);
QCOMPARE(int(w.m_modifiers), int(Qt::ControlModifier));
@@ -10462,7 +10484,7 @@ void tst_QWidget::qmlSetParentHelper()
QWidget child;
QVERIFY(QAbstractDeclarativeData::setWidgetParent);
QAbstractDeclarativeData::setWidgetParent(&child, &parent);
- QVERIFY(child.parentWidget() == &parent);
+ QCOMPARE(child.parentWidget(), &parent);
QAbstractDeclarativeData::setWidgetParent(&child, 0);
QVERIFY(!child.parentWidget());
#else
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 148c2352a5..5188dfbcfa 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -97,6 +97,8 @@ private slots:
void tst_resize_count();
void tst_move_count();
+
+ void tst_eventfilter_on_toplevel();
};
void tst_QWidget_window::initTestCase()
@@ -336,30 +338,30 @@ void tst_QWidget_window::tst_windowFilePath()
void tst_QWidget_window::tst_showWithoutActivating()
{
-#ifndef Q_DEAD_CODE_FROM_QT4_X11
- QSKIP("This test is X11-only.");
-#else
- QWidget w;
- w.show();
- QVERIFY(QTest::qWaitForWindowExposed(&w));
- QApplication::processEvents();
+ QString platformName = QGuiApplication::platformName().toLower();
+ if (platformName == "cocoa")
+ QSKIP("Cocoa: This fails. Figure out why.");
+ else if (platformName != QStringLiteral("xcb")
+ && platformName != QStringLiteral("windows")
+ && platformName != QStringLiteral("ios"))
+ QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios platforms.");
+
+ QWidget w1;
+ w1.setAttribute(Qt::WA_ShowWithoutActivating);
+ w1.show();
+ QVERIFY(!QTest::qWaitForWindowActive(&w1));
- QApplication::clipboard();
- QLineEdit *lineEdit = new QLineEdit;
- lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, true);
- lineEdit->show();
- lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, false);
- lineEdit->raise();
- lineEdit->activateWindow();
-
- Window window;
- int revertto;
- QTRY_COMPARE(lineEdit->winId(),
- (XGetInputFocus(QX11Info::display(), &window, &revertto), window) );
- // Note the use of the , before window because we want the XGetInputFocus to be re-executed
- // in each iteration of the inside loop of the QTRY_COMPARE macro
-
-#endif // Q_DEAD_CODE_FROM_QT4_X11
+ QWidget w2;
+ w2.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w2));
+
+ QWidget w3;
+ w3.setAttribute(Qt::WA_ShowWithoutActivating);
+ w3.show();
+ QVERIFY(!QTest::qWaitForWindowActive(&w3));
+
+ w3.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&w3));
}
void tst_QWidget_window::tst_paintEventOnSecondShow()
@@ -762,5 +764,48 @@ void tst_QWidget_window::tst_move_count()
QTRY_VERIFY(move.moveCount >= 1);
}
+class EventFilter : public QObject
+{
+public:
+ int eventCount;
+
+ EventFilter()
+ : QObject(),
+ eventCount(0)
+ {
+ }
+
+ static QEvent::Type filterEventType()
+ {
+ static int type = QEvent::registerEventType();
+ return static_cast<QEvent::Type>(type);
+ }
+
+protected:
+ bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE
+ {
+ if (e->type() == filterEventType())
+ ++eventCount;
+
+ return QObject::eventFilter(o, e);
+ }
+};
+
+void tst_QWidget_window::tst_eventfilter_on_toplevel()
+{
+ QWidget w;
+ EventFilter filter;
+ w.installEventFilter(&filter);
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+ QVERIFY(w.isWindow());
+ QCOMPARE(filter.eventCount, 0);
+
+ // send an event not handled in a special way by QWidgetWindow::event,
+ // and check that it's received by the event filter
+ QCoreApplication::postEvent(w.windowHandle(), new QEvent(EventFilter::filterEventType()));
+ QTRY_COMPARE(filter.eventCount, 1);
+}
+
QTEST_MAIN(tst_QWidget_window)
#include "tst_qwidget_window.moc"
diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
index df54d22a2f..207ce00dbf 100644
--- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
@@ -55,6 +55,8 @@ class tst_QWidgetAction : public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanup();
void defaultWidget();
void visibilityUpdate();
void customWidget();
@@ -65,6 +67,19 @@ private slots:
void releaseWidgetCrash();
};
+void tst_QWidgetAction::initTestCase()
+{
+ // Disable menu/combo animations to prevent the alpha widgets from getting in the
+ // way in popup(), failing the top level leak check in cleanup().
+ QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
+ QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
+}
+
+void tst_QWidgetAction::cleanup()
+{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
void tst_QWidgetAction::defaultWidget()
{
{
@@ -123,14 +138,14 @@ void tst_QWidgetAction::defaultWidget()
action->setDefaultWidget(combo);
tb1.addAction(action);
- QVERIFY(combo->parent() == &tb1);
+ QCOMPARE(combo->parent(), &tb1);
qApp->processEvents();
qApp->processEvents();
QVERIFY(combo->isVisible());
// not supported, not supposed to work, hence the parent() check
tb2.addAction(action);
- QVERIFY(combo->parent() == &tb1);
+ QCOMPARE(combo->parent(), &tb1);
tb2.removeAction(action);
tb1.removeAction(action);
@@ -141,11 +156,11 @@ void tst_QWidgetAction::defaultWidget()
tb2.addAction(action);
qApp->processEvents(); //the call to hide is delayd by the toolbar layout
qApp->processEvents();
- QVERIFY(combo->parent() == &tb2);
+ QCOMPARE(combo->parent(), &tb2);
QVERIFY(combo->isVisible());
tb1.addAction(action);
- QVERIFY(combo->parent() == &tb2);
+ QCOMPARE(combo->parent(), &tb2);
delete action;
QVERIFY(!combo);
@@ -156,17 +171,17 @@ void tst_QWidgetAction::defaultWidget()
QPointer<QComboBox> combo1 = new QComboBox;
a->setDefaultWidget(combo1);
- QVERIFY(a->defaultWidget() == combo1);
+ QCOMPARE(a->defaultWidget(), combo1.data());
a->setDefaultWidget(combo1);
QVERIFY(combo1);
- QVERIFY(a->defaultWidget() == combo1);
+ QCOMPARE(a->defaultWidget(), combo1.data());
QPointer<QComboBox> combo2 = new QComboBox;
QVERIFY(combo1 != combo2);
a->setDefaultWidget(combo2);
QVERIFY(!combo1);
- QVERIFY(a->defaultWidget() == combo2);
+ QCOMPARE(a->defaultWidget(), combo2.data());
delete a;
QVERIFY(!combo2);
@@ -238,7 +253,7 @@ void tst_QWidgetAction::customWidget()
combos = action->createdWidgets();
QCOMPARE(combos.count(), 2);
- QVERIFY(combos.at(0) == combo1);
+ QCOMPARE(combos.at(0), combo1.data());
QPointer<QComboBox> combo2 = qobject_cast<QComboBox *>(combos.at(1));
QVERIFY(combo2);
@@ -262,7 +277,7 @@ void tst_QWidgetAction::keepOwnership()
{
QToolBar *tb = new QToolBar;
tb->addAction(action);
- QVERIFY(combo->parent() == tb);
+ QCOMPARE(combo->parent(), tb);
delete tb;
}
diff --git a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
index 8b566713f9..690ef30f71 100644
--- a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
+++ b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
@@ -84,13 +84,13 @@ void tst_QWidgetsVariant::constructor_invalid()
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(static_cast<QVariant::Type>(typeId));
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(typeId, /* copy */ 0);
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
}
@@ -208,7 +208,7 @@ void tst_QWidgetsVariant::qvariant_cast_QObject_derived()
CustomQWidget customWidget;
QWidget *widget = &customWidget;
QVariant data = QVariant::fromValue(widget);
- QVERIFY(data.userType() == qMetaTypeId<QWidget*>());
+ QCOMPARE(data.userType(), qMetaTypeId<QWidget*>());
QCOMPARE(data.value<QObject*>(), widget);
QCOMPARE(data.value<QWidget*>(), widget);
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 33427788f6..dfc53c9164 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -212,7 +212,7 @@ void tst_QWindowContainer::testActivation()
// Under KDE (ubuntu 12.10), we experience that doing two activateWindow in a row
// does not work. The second gets ignored by the window manager, even though the
// timestamp in the xcb connection is unique for both.
- if (QGuiApplication::platformName() == "xcb")
+ if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive))
QTest::qWait(100);
window->requestActivate();
@@ -327,7 +327,7 @@ void tst_QWindowContainer::testDockWidget()
QTest::qWait(1000);
dock->setFloating(false);
- QTRY_VERIFY(window->parent() == mainWindow.window()->windowHandle());
+ QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle());
}
QTEST_MAIN(tst_QWindowContainer)
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
index 7aa529d5ee..21369d4520 100644
--- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
+++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
@@ -214,12 +214,12 @@ void tst_QStyle::testProxyStyle()
QProxyStyle *proxyStyle = new QProxyStyle();
QVERIFY(proxyStyle->baseStyle());
QStyle *style = QStyleFactory::create("Windows");
- QVERIFY(style->proxy() == style);
+ QCOMPARE(style->proxy(), style);
proxyStyle->setBaseStyle(style);
- QVERIFY(style->proxy() == proxyStyle);
- QVERIFY(style->parent() == proxyStyle);
- QVERIFY(proxyStyle->baseStyle() == style);
+ QCOMPARE(style->proxy(), proxyStyle);
+ QCOMPARE(style->parent(), proxyStyle);
+ QCOMPARE(proxyStyle->baseStyle(), style);
QVERIFY(testAllFunctions(proxyStyle));
proxyStyle->setBaseStyle(0);
@@ -236,7 +236,7 @@ void tst_QStyle::testProxyStyle()
QLineEdit edit;
edit.setStyle(&customStyle);
QVERIFY(!customStyle.parent());
- QVERIFY(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize) == 13);
+ QCOMPARE(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize), 13);
}
void tst_QStyle::drawItemPixmap()
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST
new file mode 100644
index 0000000000..cf78fb47c2
--- /dev/null
+++ b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST
@@ -0,0 +1,2 @@
+[hoverColors]
+ubuntu-14.04
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 25f7715e3b..a511e91e2c 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -178,45 +178,49 @@ void tst_QStyleSheetStyle::numinstances()
void tst_QStyleSheetStyle::widgetsBeforeAppStyleSheet()
{
QPushButton w1; // widget with no stylesheet
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
qApp->setStyleSheet("* { color: red; }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
w1.setStyleSheet("color: white");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
}
class FriendlySpinBox : public QSpinBox { friend class tst_QStyleSheetStyle; };
void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
qApp->setStyleSheet("* { color: red; font-size: 32pt; }");
QPushButton w1;
FriendlySpinBox spin;
- QVERIFY(COLOR(w1) == QColor("red"));
- QVERIFY(COLOR(spin) == QColor("red"));
- QVERIFY(COLOR(*spin.lineEdit()) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
+ QCOMPARE(COLOR(spin), red);
+ QCOMPARE(COLOR(*spin.lineEdit()), red);
QCOMPARE(FONTSIZE(w1), 32);
QCOMPARE(FONTSIZE(spin), 32);
QCOMPARE(FONTSIZE(*spin.lineEdit()), 32);
w1.setStyleSheet("color: white");
- QVERIFY(COLOR(w1) == QColor("white"));
- QVERIFY(COLOR(spin) == QColor("red"));
- QVERIFY(COLOR(*spin.lineEdit()) == QColor("red"));
+ QCOMPARE(COLOR(w1), white);
+ QCOMPARE(COLOR(spin), red);
+ QCOMPARE(COLOR(*spin.lineEdit()), red);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("red"));
- QVERIFY(COLOR(spin) == QColor("red"));
- QVERIFY(COLOR(*spin.lineEdit()) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
+ QCOMPARE(COLOR(spin), red);
+ QCOMPARE(COLOR(*spin.lineEdit()), red);
w1.setStyleSheet("color: white");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("white"));
- QVERIFY(COLOR(spin) == APPCOLOR(spin));
- QVERIFY(COLOR(*spin.lineEdit()) == APPCOLOR(*spin.lineEdit()));
+ QCOMPARE(COLOR(w1), white);
+ QCOMPARE(COLOR(spin), APPCOLOR(spin));
+ QCOMPARE(COLOR(*spin.lineEdit()), APPCOLOR(*spin.lineEdit()));
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
// QCOMPARE(FONTSIZE(w1), APPFONTSIZE(w1)); //### task 244261
QCOMPARE(FONTSIZE(spin), APPFONTSIZE(spin));
//QCOMPARE(FONTSIZE(*spin.lineEdit()), APPFONTSIZE(*spin.lineEdit())); //### task 244261
@@ -224,121 +228,135 @@ void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet()
void tst_QStyleSheetStyle::applicationStyleSheet()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton w1;
qApp->setStyleSheet("* { color: red; }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
qApp->setStyleSheet("* { color: white; }");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
qApp->setStyleSheet("* { color: red }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
}
void tst_QStyleSheetStyle::windowStyleSheet()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton w1;
qApp->setStyleSheet("");
w1.setStyleSheet("* { color: red; }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
w1.setStyleSheet("* { color: white; }");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
w1.setStyleSheet("* { color: red }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
qApp->setStyleSheet("* { color: green }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("green"));
+ QCOMPARE(COLOR(w1), QColor("green"));
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
}
void tst_QStyleSheetStyle::widgetStyleSheet()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton w1;
QPushButton *pb = new QPushButton(&w1);
QPushButton &w2 = *pb;
qApp->setStyleSheet("");
w1.setStyleSheet("* { color: red }");
- QVERIFY(COLOR(w1) == QColor("red"));
- QVERIFY(COLOR(w2) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
+ QCOMPARE(COLOR(w2), red);
w2.setStyleSheet("* { color: white }");
- QVERIFY(COLOR(w2) == QColor("white"));
+ QCOMPARE(COLOR(w2), white);
w1.setStyleSheet("* { color: blue }");
- QVERIFY(COLOR(w1) == QColor("blue"));
- QVERIFY(COLOR(w2) == QColor("white"));
+ QCOMPARE(COLOR(w1), blue);
+ QCOMPARE(COLOR(w2), white);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
- QVERIFY(COLOR(w2) == QColor("white"));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
+ QCOMPARE(COLOR(w2), white);
w2.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
- QVERIFY(COLOR(w2) == APPCOLOR(w2));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
+ QCOMPARE(COLOR(w2), APPCOLOR(w2));
}
void tst_QStyleSheetStyle::reparentWithNoChildStyleSheet()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton p1, p2;
QPushButton *pb = new QPushButton(&p1);
QPushButton &c1 = *pb; // child with no stylesheet
qApp->setStyleSheet("");
p1.setStyleSheet("* { color: red }");
- QVERIFY(COLOR(c1) == QColor("red"));
+ QCOMPARE(COLOR(c1), red);
c1.setParent(&p2);
- QVERIFY(COLOR(c1) == APPCOLOR(c1));
+ QCOMPARE(COLOR(c1), APPCOLOR(c1));
p2.setStyleSheet("* { color: white }");
- QVERIFY(COLOR(c1) == QColor("white"));
+ QCOMPARE(COLOR(c1), white);
c1.setParent(&p1);
- QVERIFY(COLOR(c1) == QColor("red"));
+ QCOMPARE(COLOR(c1), red);
qApp->setStyleSheet("* { color: blue }");
c1.setParent(0);
- QVERIFY(COLOR(c1) == QColor("blue"));
+ QCOMPARE(COLOR(c1), blue);
delete pb;
}
void tst_QStyleSheetStyle::reparentWithChildStyleSheet()
{
+ const QColor gray("gray");
+ const QColor white(Qt::white);
qApp->setStyleSheet("");
QPushButton p1, p2;
QPushButton *pb = new QPushButton(&p1);
QPushButton &c1 = *pb;
c1.setStyleSheet("background: gray");
- QVERIFY(BACKGROUND(c1) == QColor("gray"));
+ QCOMPARE(BACKGROUND(c1), gray);
c1.setParent(&p2);
- QVERIFY(BACKGROUND(c1) == QColor("gray"));
+ QCOMPARE(BACKGROUND(c1), gray);
qApp->setStyleSheet("* { color: white }");
c1.setParent(&p1);
- QVERIFY(BACKGROUND(c1) == QColor("gray"));
- QVERIFY(COLOR(c1) == QColor("white"));
+ QCOMPARE(BACKGROUND(c1), gray);
+ QCOMPARE(COLOR(c1), white);
}
void tst_QStyleSheetStyle::repolish()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
qApp->setStyleSheet("");
QPushButton p1;
p1.setStyleSheet("color: red; background: white");
- QVERIFY(BACKGROUND(p1) == QColor("white"));
+ QCOMPARE(BACKGROUND(p1), white);
p1.setStyleSheet("background: white");
- QVERIFY(COLOR(p1) == APPCOLOR(p1));
+ QCOMPARE(COLOR(p1), APPCOLOR(p1));
p1.setStyleSheet("color: red");
- QVERIFY(COLOR(p1) == QColor("red"));
- QVERIFY(BACKGROUND(p1) == APPBACKGROUND(p1));
+ QCOMPARE(COLOR(p1), red);
+ QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1));
p1.setStyleSheet("");
- QVERIFY(COLOR(p1) == APPCOLOR(p1));
- QVERIFY(BACKGROUND(p1) == APPBACKGROUND(p1));
+ QCOMPARE(COLOR(p1), APPCOLOR(p1));
+ QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1));
}
void tst_QStyleSheetStyle::widgetStyle()
@@ -492,12 +510,12 @@ void tst_QStyleSheetStyle::appStyle()
QPointer<QStyle> style2 = QStyleFactory::create("Windows");
qApp->setStyle(style1);
// Basic sanity
- QVERIFY(qApp->style() == style1);
+ QCOMPARE(QApplication::style(), style1.data());
qApp->setStyle(style2);
QVERIFY(style1.isNull()); // qApp must have taken ownership and deleted it
// Setting null should not crash
qApp->setStyle(0);
- QVERIFY(qApp->style() == style2);
+ QCOMPARE(QApplication::style(), style2.data());
// Set the stylesheet
qApp->setStyleSheet("whatever");
@@ -505,7 +523,7 @@ void tst_QStyleSheetStyle::appStyle()
QVERIFY(!sss.isNull());
QCOMPARE(sss->metaObject()->className(), "QStyleSheetStyle"); // must be our proxy now
QVERIFY(!style2.isNull()); // this should exist as it is the base of the proxy
- QVERIFY(sss->baseStyle() == style2);
+ QCOMPARE(sss->baseStyle(), style2.data());
style1 = QStyleFactory::create("Windows");
qApp->setStyle(style1);
QVERIFY(style2.isNull()); // should disappear automatically
@@ -514,16 +532,16 @@ void tst_QStyleSheetStyle::appStyle()
// Update the stylesheet and check nothing changes
sss = (QStyleSheetStyle *)qApp->style();
qApp->setStyleSheet("whatever2");
- QVERIFY(qApp->style() == sss);
- QVERIFY(sss->baseStyle() == style1);
+ QCOMPARE(QApplication::style(), sss.data());
+ QCOMPARE(sss->baseStyle(), style1.data());
// Revert the stylesheet
qApp->setStyleSheet("");
QVERIFY(sss.isNull()); // should have disappeared
- QVERIFY(qApp->style() == style1);
+ QCOMPARE(QApplication::style(), style1.data());
qApp->setStyleSheet("");
- QVERIFY(qApp->style() == style1);
+ QCOMPARE(QApplication::style(), style1.data());
}
void tst_QStyleSheetStyle::dynamicProperty()
@@ -589,21 +607,24 @@ namespace ns {
void tst_QStyleSheetStyle::namespaces()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
ns::PushButton1 pb1;
qApp->setStyleSheet("ns--PushButton1 { background: white }");
- QVERIFY(BACKGROUND(pb1) == QColor("white"));
+ QCOMPARE(BACKGROUND(pb1), white);
qApp->setStyleSheet(".ns--PushButton1 { background: red }");
- QVERIFY(BACKGROUND(pb1) == QColor("red"));
+ QCOMPARE(BACKGROUND(pb1), red);
ns::PushButton2 pb2;
qApp->setStyleSheet("ns--PushButton1 { background: blue}");
- QVERIFY(BACKGROUND(pb2) == QColor("blue"));
+ QCOMPARE(BACKGROUND(pb2), blue);
qApp->setStyleSheet("ns--PushButton2 { background: magenta }");
- QVERIFY(BACKGROUND(pb2) == QColor("magenta"));
+ QCOMPARE(BACKGROUND(pb2), QColor(Qt::magenta));
qApp->setStyleSheet(".PushButtonTwo { background: white; }");
- QVERIFY(BACKGROUND(pb2) == QColor("white"));
+ QCOMPARE(BACKGROUND(pb2), white);
qApp->setStyleSheet(".PushButtonDuo { background: red; }");
- QVERIFY(BACKGROUND(pb2) == QColor("red"));
+ QCOMPARE(BACKGROUND(pb2), red);
}
void tst_QStyleSheetStyle::palettePropagation()
@@ -639,8 +660,8 @@ void tst_QStyleSheetStyle::fontPropagation()
int viewFontSize = FONTSIZE(*popup);
cb.setStyleSheet("QComboBox { font-size: 20pt; }");
- QVERIFY(FONTSIZE(cb) == 20);
- QVERIFY(FONTSIZE(*popup) == viewFontSize);
+ QCOMPARE(FONTSIZE(cb), 20);
+ QCOMPARE(FONTSIZE(*popup), viewFontSize);
QGroupBox gb;
QPushButton *push = new QPushButton(&gb);
QPushButton &pb = *push;
@@ -648,25 +669,25 @@ void tst_QStyleSheetStyle::fontPropagation()
int gbFontSize = FONTSIZE(gb);
gb.setStyleSheet("QGroupBox { font-size: 20pt }");
- QVERIFY(FONTSIZE(gb) == 20);
+ QCOMPARE(FONTSIZE(gb), 20);
QVERIFY(FONTSIZE(pb) == buttonFontSize); // font does not propagate
gb.setStyleSheet("QGroupBox * { font-size: 20pt; }");
- QVERIFY(FONTSIZE(gb) == gbFontSize);
- QVERIFY(FONTSIZE(pb) == 20);
+ QCOMPARE(FONTSIZE(gb), gbFontSize);
+ QCOMPARE(FONTSIZE(pb), 20);
QWidget window;
window.setStyleSheet("* { font-size: 10pt }");
pb.setParent(&window);
QCOMPARE(FONTSIZE(pb), 10);
window.setStyleSheet("");
- QVERIFY(FONTSIZE(pb) == buttonFontSize);
+ QCOMPARE(FONTSIZE(pb), buttonFontSize);
QTabWidget tw;
tw.setStyleSheet("QTabWidget { font-size: 20pt; }");
- QVERIFY(FONTSIZE(tw) == 20);
+ QCOMPARE(FONTSIZE(tw), 20);
QWidget *child = tw.findChild<QWidget *>("qt_tabwidget_tabbar");
QVERIFY2(child, "QTabWidget did not contain a widget named \"qt_tabwidget_tabbar\"");
- QVERIFY(FONTSIZE(*child) == 20);
+ QCOMPARE(FONTSIZE(*child), 20);
}
void tst_QStyleSheetStyle::onWidgetDestroyed()
@@ -1009,6 +1030,8 @@ void tst_QStyleSheetStyle::tabAlignement()
void tst_QStyleSheetStyle::attributesList()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
QWidget w;
QPushButton *p1=new QPushButton(&w);
QPushButton *p2=new QPushButton(&w);
@@ -1019,10 +1042,10 @@ void tst_QStyleSheetStyle::attributesList()
p3->setProperty("prop", QStringList() << "foo" << "bar");
w.setStyleSheet(" QPushButton{ background-color:blue; } QPushButton[prop~=red] { background-color:red; }");
- QCOMPARE(BACKGROUND(*p1) , QColor("red"));
- QCOMPARE(BACKGROUND(*p2) , QColor("red"));
- QCOMPARE(BACKGROUND(*p3) , QColor("blue"));
- QCOMPARE(BACKGROUND(*p4) , QColor("blue"));
+ QCOMPARE(BACKGROUND(*p1) , red);
+ QCOMPARE(BACKGROUND(*p2) , red);
+ QCOMPARE(BACKGROUND(*p3) , blue);
+ QCOMPARE(BACKGROUND(*p4) , blue);
}
void tst_QStyleSheetStyle::minmaxSizes()
@@ -1065,6 +1088,7 @@ void tst_QStyleSheetStyle::minmaxSizes()
void tst_QStyleSheetStyle::task206238_twice()
{
+ const QColor red(Qt::red);
QMainWindow w;
QTabWidget* tw = new QTabWidget;
tw->addTab(new QLabel("foo"), "test");
@@ -1073,12 +1097,12 @@ void tst_QStyleSheetStyle::task206238_twice()
centerOnScreen(&w);
w.show();
QTest::qWait(20);
- QCOMPARE(BACKGROUND(w) , QColor("red"));
- QCOMPARE(BACKGROUND(*tw), QColor("red"));
+ QCOMPARE(BACKGROUND(w) , red);
+ QCOMPARE(BACKGROUND(*tw), red);
w.setStyleSheet("background: red;");
QTest::qWait(20);
- QCOMPARE(BACKGROUND(w) , QColor("red"));
- QCOMPARE(BACKGROUND(*tw), QColor("red"));
+ QCOMPARE(BACKGROUND(w) , red);
+ QCOMPARE(BACKGROUND(*tw), red);
}
void tst_QStyleSheetStyle::transparent()
diff --git a/tests/auto/widgets/util/qcompleter/BLACKLIST b/tests/auto/widgets/util/qcompleter/BLACKLIST
index ffbcc94a1f..fdc424b6ac 100644
--- a/tests/auto/widgets/util/qcompleter/BLACKLIST
+++ b/tests/auto/widgets/util/qcompleter/BLACKLIST
@@ -1,2 +1,2 @@
[QTBUG_14292_filesystem]
-ubuntu-14.04
+linux
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index dbfeda8104..e8ac9aa5d2 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -1043,9 +1043,9 @@ void tst_QCompleter::setters()
QAbstractItemModel *oldModel = completer->model();
completer->setModel(dirModel);
QVERIFY(completer->popup()->model() != oldModel);
- QVERIFY(completer->popup()->model() == completer->completionModel());
+ QCOMPARE(completer->popup()->model(), completer->completionModel());
completer->setPopup(new QListView);
- QVERIFY(completer->popup()->model() == completer->completionModel());
+ QCOMPARE(completer->popup()->model(), completer->completionModel());
completer->setModel(new QStringListModel(completer));
QVERIFY(dirModel == 0); // must have been deleted
@@ -1062,7 +1062,7 @@ void tst_QCompleter::modelDeletion()
QStringListModel *listModel = new QStringListModel(list);
completer->setCompletionPrefix("i");
completer->setModel(listModel);
- QVERIFY(completer->completionCount() == 3);
+ QCOMPARE(completer->completionCount(), 3);
QScopedPointer<QListView> view(new QListView);
view->setModel(completer->completionModel());
delete listModel;
@@ -1070,8 +1070,8 @@ void tst_QCompleter::modelDeletion()
view->show();
qApp->processEvents();
view.reset();
- QVERIFY(completer->completionCount() == 0);
- QVERIFY(completer->currentRow() == -1);
+ QCOMPARE(completer->completionCount(), 0);
+ QCOMPARE(completer->currentRow(), -1);
}
void tst_QCompleter::multipleWidgets()
@@ -1098,7 +1098,7 @@ void tst_QCompleter::multipleWidgets()
window.activateWindow();
QApplication::setActiveWindow(&window);
QTest::qWait(50);
- QTRY_VERIFY(qApp->focusWidget() == comboBox);
+ QTRY_COMPARE(QApplication::focusWidget(), comboBox);
comboBox->lineEdit()->setText("it");
QCOMPARE(comboBox->currentText(), QString("it")); // should not complete with setText
QTest::keyPress(comboBox, 'e');
@@ -1111,7 +1111,7 @@ void tst_QCompleter::multipleWidgets()
lineEdit->show();
lineEdit->setFocus();
QTest::qWait(50);
- QTRY_VERIFY(qApp->focusWidget() == lineEdit);
+ QTRY_COMPARE(QApplication::focusWidget(), lineEdit);
lineEdit->setText("it");
QCOMPARE(lineEdit->text(), QString("it")); // should not completer with setText
QCOMPARE(comboBox->currentText(), QString("")); // combo box text must not change!
@@ -1148,13 +1148,13 @@ void tst_QCompleter::focusIn()
lineEdit2->show();
comboBox->setFocus();
- QTRY_VERIFY(completer.widget() == comboBox);
+ QTRY_COMPARE(completer.widget(), comboBox);
lineEdit->setFocus();
- QTRY_VERIFY(completer.widget() == lineEdit);
+ QTRY_COMPARE(completer.widget(), lineEdit);
comboBox->setFocus();
- QTRY_VERIFY(completer.widget() == comboBox);
+ QTRY_COMPARE(completer.widget(), comboBox);
lineEdit2->setFocus();
- QTRY_VERIFY(completer.widget() == comboBox);
+ QTRY_COMPARE(completer.widget(), comboBox);
}
void tst_QCompleter::dynamicSortOrder()
diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
index d2e88a1656..58a655321c 100644
--- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
+++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
@@ -297,7 +297,7 @@ void tst_QScroller::staticScrollers()
QScrollerProperties sp2 = QScroller::scroller(o2)->scrollerProperties();
// default properties should be the same
- QVERIFY(sp1 == sp2);
+ QCOMPARE(sp1, sp2);
QCOMPARE(QScroller::scroller(o1)->scrollerProperties(), sp1);
diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
index 7ea63911ae..05511a17a1 100644
--- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
+++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
@@ -136,7 +136,7 @@ void tst_QSystemTrayIcon::lastWindowClosed()
QTimer::singleShot(2500, &window, SLOT(close()));
QTimer::singleShot(20000, qApp, SLOT(quit())); // in case the test fails
qApp->exec();
- QVERIFY(spy.count() == 1);
+ QCOMPARE(spy.count(), 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 a633ba0cf0..43d6912c6e 100644
--- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
@@ -283,9 +283,9 @@ void tst_QAbstractButton::setAutoRepeat()
QTest::qWait(REPEAT_DELAY);
QVERIFY(testWidget->isDown());
QTest::keyRelease(testWidget, Qt::Key_Space);
- QVERIFY(release_count == press_count);
- QVERIFY(toggle_count == 0);
- QVERIFY(press_count == click_count);
+ QCOMPARE(release_count, press_count);
+ QCOMPARE(toggle_count, uint(0));
+ QCOMPARE(press_count, click_count);
QVERIFY(click_count > 1);
break;
case 4:
diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
index df69063540..5dec6224ca 100644
--- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
@@ -324,13 +324,13 @@ void tst_QButtonGroup::testSignals()
int expectedId = -2;
- QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId);
QCOMPARE(pressedSpy.count(), 1);
QCOMPARE(pressedIdSpy.count(), 1);
- QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId);
QCOMPARE(releasedSpy.count(), 1);
QCOMPARE(releasedIdSpy.count(), 1);
- QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId);
clickedSpy.clear();
clickedIdSpy.clear();
@@ -344,13 +344,13 @@ void tst_QButtonGroup::testSignals()
QCOMPARE(clickedSpy.count(), 1);
QCOMPARE(clickedIdSpy.count(), 1);
- QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23);
QCOMPARE(pressedSpy.count(), 1);
QCOMPARE(pressedIdSpy.count(), 1);
- QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23);
QCOMPARE(releasedSpy.count(), 1);
QCOMPARE(releasedIdSpy.count(), 1);
- QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23);
QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool)));
@@ -427,25 +427,25 @@ void tst_QButtonGroup::checkedButton()
buttons.addButton(&pb1);
buttons.addButton(&pb2, 23);
- QVERIFY(buttons.checkedButton() == 0);
+ QVERIFY(!buttons.checkedButton());
pb1.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb1);
+ QCOMPARE(buttons.checkedButton(), &pb1);
pb2.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb2);
+ QCOMPARE(buttons.checkedButton(), &pb2);
pb2.setChecked(false);
- QVERIFY(buttons.checkedButton() == &pb1);
+ QCOMPARE(buttons.checkedButton(), &pb1);
pb1.setChecked(false);
- QVERIFY(buttons.checkedButton() == 0);
+ QVERIFY(!buttons.checkedButton());
buttons.setExclusive(true);
- QVERIFY(buttons.checkedButton() == 0);
+ QVERIFY(!buttons.checkedButton());
pb1.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb1);
+ QCOMPARE(buttons.checkedButton(), &pb1);
pb2.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb2);
+ QCOMPARE(buttons.checkedButton(), &pb2);
// checked button cannot be unchecked
pb2.setChecked(false);
- QVERIFY(buttons.checkedButton() == &pb2);
+ QCOMPARE(buttons.checkedButton(), &pb2);
}
class task209485_ButtonDeleter : public QObject
@@ -523,9 +523,9 @@ void tst_QButtonGroup::autoIncrementId()
radio1->setChecked(true);
- QVERIFY(buttons->id(radio1) == -2);
- QVERIFY(buttons->id(radio2) == -3);
- QVERIFY(buttons->id(radio3) == -4);
+ QCOMPARE(buttons->id(radio1), -2);
+ QCOMPARE(buttons->id(radio2), -3);
+ QCOMPARE(buttons->id(radio3), -4);
dlg.show();
}
diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
index e76e11fc67..5696382fab 100644
--- a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
+++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
@@ -83,9 +83,7 @@ private:
uint press_count;
uint release_count;
int cur_state;
- uint tmp;
QCheckBox *testWidget;
- uint tmp2;
};
tst_QCheckBox::tst_QCheckBox()
@@ -326,7 +324,7 @@ void tst_QCheckBox::isToggleButton()
void tst_QCheckBox::foregroundRole()
{
- QVERIFY(testWidget->foregroundRole() == QPalette::WindowText);
+ QCOMPARE(testWidget->foregroundRole(), QPalette::WindowText);
}
void tst_QCheckBox::minimumSizeHint()
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 7824172812..09129f0676 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -164,6 +164,7 @@ private slots:
void keyboardSelection();
void setCustomModelAndView();
void updateDelegateOnEditableChange();
+ void respectChangedOwnershipOfItemView();
void task_QTBUG_39088_inputMethodHints();
};
@@ -453,7 +454,7 @@ void tst_QComboBox::setPalette()
for (int i = 0; i < comboChildren.size(); ++i) {
QObject *o = comboChildren.at(i);
if (o->isWidgetType()) {
- QVERIFY(((QWidget*)o)->palette() == pal);
+ QCOMPARE(((QWidget*)o)->palette(), pal);
}
}
@@ -462,12 +463,12 @@ void tst_QComboBox::setPalette()
//Setting it on the lineedit should be separate form the combo
testWidget->lineEdit()->setPalette(pal);
QVERIFY(testWidget->palette() != pal);
- QVERIFY(testWidget->lineEdit()->palette() == pal);
+ QCOMPARE(testWidget->lineEdit()->palette(), pal);
pal.setColor(QPalette::Base, Qt::green);
//Setting it on the combo directly should override lineedit
testWidget->setPalette(pal);
- QVERIFY(testWidget->palette() == pal);
- QVERIFY(testWidget->lineEdit()->palette() == pal);
+ QCOMPARE(testWidget->palette(), pal);
+ QCOMPARE(testWidget->lineEdit()->palette(), pal);
}
void tst_QComboBox::sizeAdjustPolicy()
@@ -478,7 +479,7 @@ void tst_QComboBox::sizeAdjustPolicy()
QComboBox *testWidget = topLevel.comboBox();
// test that adding new items will not change the sizehint for AdjustToContentsOnFirstShow
QVERIFY(!testWidget->count());
- QVERIFY(testWidget->sizeAdjustPolicy() == QComboBox::AdjustToContentsOnFirstShow);
+ QCOMPARE(testWidget->sizeAdjustPolicy(), QComboBox::AdjustToContentsOnFirstShow);
QVERIFY(testWidget->isVisible());
QSize firstShow = testWidget->sizeHint();
testWidget->addItem("normal item");
@@ -751,7 +752,7 @@ void tst_QComboBox::insertPolicy()
// First check that there is the right number of entries, or
// we may unwittingly pass
- QVERIFY((int)result.count() == testWidget->count());
+ QCOMPARE((int)result.count(), testWidget->count());
// No need to compare if there are no strings to compare
if (result.count() > 0) {
@@ -796,7 +797,7 @@ void tst_QComboBox::virtualAutocompletion()
QApplication::sendEvent(testWidget, &kr1);
qApp->processEvents(); // Process events to trigger autocompletion
- QTRY_VERIFY(testWidget->currentIndex() == 1);
+ QTRY_COMPARE(testWidget->currentIndex(), 1);
QKeyEvent kp2(QEvent::KeyPress, Qt::Key_O, 0, "o");
QKeyEvent kr2(QEvent::KeyRelease, Qt::Key_O, 0, "o");
@@ -845,7 +846,7 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
testWidget->clearEditText();
QSignalSpy spyReturn(testWidget, SIGNAL(activated(int)));
testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
- QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseInsensitive);
+ QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseInsensitive);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
qApp->processEvents();
@@ -879,7 +880,7 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
// case sensitive
testWidget->clearEditText();
testWidget->setAutoCompletionCaseSensitivity(Qt::CaseSensitive);
- QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseSensitive);
+ QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseSensitive);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
qApp->processEvents();
QCOMPARE(testWidget->currentText(), QString("aww"));
@@ -1377,7 +1378,7 @@ void tst_QComboBox::textpixmapdata()
QCOMPARE(icon.cacheKey(), icons.at(i).cacheKey());
QPixmap original = icons.at(i).pixmap(1024);
QPixmap pixmap = icon.pixmap(1024);
- QVERIFY(pixmap.toImage() == original.toImage());
+ QCOMPARE(pixmap.toImage(), original.toImage());
}
for (int i = 0; i<text.count(); ++i) {
@@ -1611,7 +1612,7 @@ void tst_QComboBox::setModel()
QCOMPARE(box.currentIndex(), 0);
QVERIFY(box.model() != oldModel);
QVERIFY(box.rootModelIndex() != rootModelIndex);
- QVERIFY(box.rootModelIndex() == QModelIndex());
+ QCOMPARE(box.rootModelIndex(), QModelIndex());
// check that setting the very same model doesn't move the current item
box.setCurrentIndex(1);
@@ -3178,5 +3179,27 @@ void tst_QComboBox::task_QTBUG_39088_inputMethodHints()
QCOMPARE(box.lineEdit()->inputMethodHints(), Qt::ImhNoPredictiveText);
}
+void tst_QComboBox::respectChangedOwnershipOfItemView()
+{
+ QComboBox box1;
+ QComboBox box2;
+ QTableView *v1 = new QTableView;
+ box1.setView(v1);
+
+ QSignalSpy spy1(v1, SIGNAL(destroyed()));
+ box2.setView(v1); // Ownership should now be transferred to box2
+
+
+ QTableView *v2 = new QTableView(&box1);
+ box1.setView(v2); // Here we do not expect v1 to be deleted
+ QApplication::processEvents();
+ QCOMPARE(spy1.count(), 0);
+
+ QSignalSpy spy2(v2, SIGNAL(destroyed()));
+ box1.setView(v1);
+ QCOMPARE(spy2.count(), 1);
+}
+
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
index d8cb7c01ad..a57553097a 100644
--- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
@@ -98,11 +98,11 @@ void tst_QCommandLinkButton::getSetCheck()
QString text("mytext");
QVERIFY(obj1.description().isEmpty());
obj1.setDescription(text);
- QVERIFY(obj1.description() == text);
+ QCOMPARE(obj1.description(), text);
QVERIFY(obj1.text().isEmpty());
obj1.setText(text);
- QVERIFY(obj1.text() == text);
+ QCOMPARE(obj1.text(), text);
QMenu *var1 = new QMenu;
obj1.setMenu(var1);
@@ -236,8 +236,8 @@ void tst_QCommandLinkButton::setAutoRepeat()
QVERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QTest::keyRelease( testWidget, Qt::Key_Space );
- QVERIFY(press_count == release_count);
- QVERIFY(release_count == click_count);
+ QCOMPARE(press_count, release_count);
+ QCOMPARE(release_count, click_count);
QVERIFY(press_count > 1);
// #### shouldn't I check here to see if multiple signals have been fired???
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index c9ae60dd76..d41398046f 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -285,6 +285,7 @@ typedef QList<Qt::Key> KeyList;
void tst_QDateTimeEdit::getSetCheck()
{
QDateTimeEdit obj1;
+ QCOMPARE(obj1.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhPreferNumbers)));
obj1.setDisplayFormat("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z AP");
// Section QDateTimeEdit::currentSection()
// void QDateTimeEdit::setCurrentSection(Section)
@@ -306,6 +307,11 @@ void tst_QDateTimeEdit::getSetCheck()
QCOMPARE(QDateTimeEdit::MonthSection, obj1.currentSection());
obj1.setCurrentSection(QDateTimeEdit::YearSection);
QCOMPARE(QDateTimeEdit::YearSection, obj1.currentSection());
+
+ QDateEdit dateEdit;
+ QCOMPARE(dateEdit.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhPreferNumbers)));
+ QTimeEdit timeEdit;
+ QCOMPARE(timeEdit.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhPreferNumbers)));
}
tst_QDateTimeEdit::tst_QDateTimeEdit()
@@ -2416,7 +2422,7 @@ void tst_QDateTimeEdit::displayedSections()
QFETCH(uint, section);
testWidget->setDisplayFormat(format);
- QVERIFY((QDateTimeEdit::Section)section == testWidget->displayedSections());
+ QCOMPARE(QDateTimeEdit::Sections(section), testWidget->displayedSections());
}
void tst_QDateTimeEdit::currentSection_data()
@@ -2460,7 +2466,7 @@ void tst_QDateTimeEdit::currentSection()
if ((QDateTimeEdit::Section)section == QDateTimeEdit::NoSection)
testWidget->setCurrentSection(QDateTimeEdit::YearSection); // Ensure it's not reset (see above)
testWidget->setCurrentSection((QDateTimeEdit::Section)section);
- QVERIFY((QDateTimeEdit::Section)currentSection == testWidget->currentSection());
+ QCOMPARE((QDateTimeEdit::Section)currentSection, testWidget->currentSection());
}
void tst_QDateTimeEdit::readOnly()
@@ -2825,7 +2831,7 @@ void tst_QDateTimeEdit::calendarPopup()
rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &timeEdit);
QTest::mouseClick(&timeEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2));
QWidget *wid2 = timeEdit.findChild<QWidget *>("qt_datetimedit_calendar");
- QVERIFY(wid2 == 0);
+ QVERIFY(!wid2);
timeEdit.hide();
@@ -2839,7 +2845,7 @@ void tst_QDateTimeEdit::calendarPopup()
rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &dateEdit);
QTest::mouseClick(&dateEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2));
QWidget *wid3 = dateEdit.findChild<QWidget *>("qt_datetimedit_calendar");
- QVERIFY(wid3 == 0);
+ QVERIFY(!wid3);
dateEdit.hide();
}
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
index 38b473e5ae..32412afcd5 100644
--- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
@@ -132,12 +132,12 @@ void tst_QDialogButtonBox::layoutReuse()
QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok);
QPointer<QLayout> layout = box->layout();
box->setCenterButtons(!box->centerButtons());
- QVERIFY(layout == box->layout());
+ QCOMPARE(layout.data(), box->layout());
QEvent event(QEvent::StyleChange);
QApplication::sendEvent(box, &event);
- QVERIFY(layout == box->layout());
+ QCOMPARE(layout.data(), box->layout());
box->setOrientation(box->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal);
- QVERIFY(layout == 0);
+ QVERIFY(layout.isNull());
QVERIFY(layout != box->layout());
delete box;
}
diff --git a/tests/auto/widgets/widgets/qdockwidget/BLACKLIST b/tests/auto/widgets/widgets/qdockwidget/BLACKLIST
new file mode 100644
index 0000000000..60adfb9f4b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdockwidget/BLACKLIST
@@ -0,0 +1,2 @@
+[restoreDockWidget]
+ubuntu-14.04
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 2bbc2e05b7..82832bced1 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -120,7 +120,7 @@ void tst_QDockWidget::widget()
{
{
QDockWidget dw;
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
}
{
@@ -130,32 +130,32 @@ void tst_QDockWidget::widget()
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
dw.setWidget(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
dw.setWidget(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
dw.setWidget(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
}
{
@@ -165,37 +165,37 @@ void tst_QDockWidget::widget()
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
w1->setParent(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
w2->setParent(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
w1->setParent(0);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
w2->setParent(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
delete w1;
delete w2;
}
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
index a75833c89c..00447760ec 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
index d656ac56f0..4c809a2c80 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index 1d995b5eea..789a280e80 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -111,7 +111,6 @@ private:
QLabel *testWidget;
QPointer<Widget> test_box;
QPointer<QLabel> test_label;
- QLineEdit *test_edit;
};
// Testing get/set functions
@@ -196,7 +195,7 @@ void tst_QLabel::setBuddy()
test_box = new Widget;
test_label= new QLabel( test_box );
test_label->setText( "&Test with a buddy" );
- test_edit = new QLineEdit( test_box );
+ QWidget *test_edit = new QLineEdit( test_box );
QVBoxLayout *layout = new QVBoxLayout(test_box);
layout->addWidget(test_label);
layout->addWidget(test_edit);
@@ -322,7 +321,7 @@ void tst_QLabel::eventPropagation()
test_label->setText(text);
test_box->events.clear();
test_label->setTextInteractionFlags(Qt::TextInteractionFlags(textInteractionFlags));
- QVERIFY(int(test_label->focusPolicy()) == focusPolicy);
+ QCOMPARE(int(test_label->focusPolicy()), focusPolicy);
QTest::mousePress(test_label, Qt::LeftButton);
QVERIFY(test_box->events.contains(QEvent::MouseButtonPress) == propagation); // should have propagated!
}
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index e6d63ee4d9..a41d80d7dd 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -1669,7 +1669,7 @@ void tst_QLineEdit::displayText()
testWidget->setEchoMode(mode);
testWidget->setText(insertString);
QCOMPARE(testWidget->displayText(), expectedString);
- QVERIFY(testWidget->echoMode() == mode);
+ QCOMPARE(testWidget->echoMode(), mode);
}
void tst_QLineEdit::passwordEchoOnEdit()
@@ -1839,9 +1839,9 @@ void tst_QLineEdit::maxLength()
// Make sure that the textChanged is not emitted unless the text is actually changed
if (insertString == expectedString) {
- QVERIFY(changed_count == 0);
+ QCOMPARE(changed_count, 0);
} else {
- QVERIFY(changed_count == 1);
+ QCOMPARE(changed_count, 1);
}
}
@@ -1962,7 +1962,7 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo
void tst_QLineEdit::cursorPosition()
{
QLineEdit *testWidget = ensureTestWidget();
- QVERIFY(testWidget->cursorPosition() == 0);
+ QCOMPARE(testWidget->cursorPosition(), 0);
// start with a basic text
QTest::keyClicks(testWidget, "The");
@@ -2208,7 +2208,7 @@ void tst_QLineEdit::selectedText()
testWidget->cursorForward(true, 9);
QVERIFY(testWidget->hasSelectedText());
QCOMPARE(testWidget->selectedText(), QString("Abc defg "));
- QVERIFY(selection_count == 1);
+ QCOMPARE(selection_count, 1);
// reset selection
testWidget->home(false);
@@ -2264,19 +2264,19 @@ void tst_QLineEdit::textChangedAndTextEdited()
QLineEdit *testWidget = ensureTestWidget();
QTest::keyClick(testWidget, Qt::Key_A);
QCOMPARE(changed_count, 1);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, 'b');
QCOMPARE(changed_count, 2);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, 'c');
QCOMPARE(changed_count, 3);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, ' ');
QCOMPARE(changed_count, 4);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, 'd');
QCOMPARE(changed_count, 5);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
changed_count = 0;
edited_count = 0;
@@ -2322,27 +2322,27 @@ void tst_QLineEdit::returnPressed()
QLineEdit *testWidget = ensureTestWidget();
QTest::keyClick(testWidget, Qt::Key_Return);
- QVERIFY(return_count == 1);
+ QCOMPARE(return_count, 1);
return_count = 0;
QTest::keyClick(testWidget, 'A');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, 'b');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, 'c');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, ' ');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, 'd');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
psKeyClick(testWidget, Qt::Key_Home);
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
psKeyClick(testWidget, Qt::Key_End);
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, Qt::Key_Escape);
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, Qt::Key_Return);
- QVERIFY(return_count == 1);
+ QCOMPARE(return_count, 1);
}
// int validator that fixes all !isNumber to '0'
@@ -2498,14 +2498,14 @@ void tst_QLineEdit::setValidator()
QCOMPARE(testWidget->validator(), static_cast<const QValidator*>(&iv1));
testWidget->setValidator(0);
- QVERIFY(testWidget->validator() == 0);
+ QVERIFY(!testWidget->validator());
QIntValidator iv2(0, 99, 0);
testWidget->setValidator(&iv2);
QCOMPARE(testWidget->validator(), static_cast<const QValidator *>(&iv2));
testWidget->setValidator(0);
- QVERIFY(testWidget->validator() == 0);
+ QVERIFY(!testWidget->validator());
}
void tst_QLineEdit::setValidator_QIntValidator_data()
@@ -2747,7 +2747,7 @@ void tst_QLineEdit::setAlignment()
QTEST(testWidget, "left");
#endif
#endif
- QVERIFY(testWidget->alignment() == Qt::AlignLeft);
+ QCOMPARE(testWidget->alignment(), Qt::AlignLeft);
testWidget->setText("hcenter");
testWidget->setAlignment(Qt::AlignHCenter);
@@ -2756,7 +2756,7 @@ void tst_QLineEdit::setAlignment()
QTEST(testWidget, "hcenter");
#endif
#endif
- QVERIFY(testWidget->alignment() == Qt::AlignHCenter);
+ QCOMPARE(testWidget->alignment(), Qt::AlignHCenter);
testWidget->setText("right");
testWidget->setAlignment(Qt::AlignRight);
@@ -2765,16 +2765,16 @@ void tst_QLineEdit::setAlignment()
QTEST(testWidget, "right");
#endif
#endif
- QVERIFY(testWidget->alignment() == Qt::AlignRight);
+ QCOMPARE(testWidget->alignment(), Qt::AlignRight);
testWidget->setAlignment(Qt::AlignTop);
- QVERIFY(testWidget->alignment() == Qt::AlignTop);
+ QCOMPARE(testWidget->alignment(), Qt::AlignTop);
testWidget->setAlignment(Qt::AlignBottom);
- QVERIFY(testWidget->alignment() == Qt::AlignBottom);
+ QCOMPARE(testWidget->alignment(), Qt::AlignBottom);
testWidget->setAlignment(Qt::AlignCenter);
- QVERIFY(testWidget->alignment() == Qt::AlignCenter);
+ QCOMPARE(testWidget->alignment(), Qt::AlignCenter);
}
void tst_QLineEdit::isModified()
@@ -3082,10 +3082,10 @@ void tst_QLineEdit::maxLengthAndInputMask()
QLineEdit *testWidget = ensureTestWidget();
QVERIFY(testWidget->inputMask().isNull());
testWidget->setMaxLength(10);
- QVERIFY(testWidget->maxLength() == 10);
+ QCOMPARE(testWidget->maxLength(), 10);
testWidget->setInputMask(QString::null);
QVERIFY(testWidget->inputMask().isNull());
- QVERIFY(testWidget->maxLength() == 10);
+ QCOMPARE(testWidget->maxLength(), 10);
}
@@ -4453,7 +4453,7 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited()
QSignalSpy spy(&lineEdit, SIGNAL(textEdited(QString)));
lineEdit.setInputMask("AAAA");
lineEdit.setInputMask(QString());
- QVERIFY(spy.count() == 0);
+ QCOMPARE(spy.count(), 0);
}
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 270e5168f7..6282028746 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -149,6 +149,8 @@ private slots:
void toggleUnifiedTitleAndToolBarOnMac();
#endif
void QTBUG21378_animationFinished();
+ void resizeDocks();
+ void resizeDocks_data();
};
@@ -211,15 +213,15 @@ tst_QMainWindow::tst_QMainWindow()
void tst_QMainWindow::constructor()
{
QMainWindow mw;
- QVERIFY(mw.parentWidget() == 0);
+ QVERIFY(!mw.parentWidget());
QVERIFY(mw.isWindow());
QMainWindow mw2(&mw);
- QVERIFY(mw2.parentWidget() == &mw);
+ QCOMPARE(mw2.parentWidget(), &mw);
QVERIFY(mw2.isWindow());
QMainWindow mw3(&mw, Qt::FramelessWindowHint);
- QVERIFY(mw3.parentWidget() == &mw);
+ QCOMPARE(mw3.parentWidget(), &mw);
QVERIFY(mw3.isWindow());
}
@@ -607,7 +609,7 @@ void tst_QMainWindow::menuBar()
QVERIFY(mw.menuBar() != 0);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb1 == 0);
+ QVERIFY(mb1.isNull());
mw.setMenuBar(mb2);
QVERIFY(mw.menuBar() != 0);
@@ -618,7 +620,7 @@ void tst_QMainWindow::menuBar()
QVERIFY(mw.menuBar() != 0);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb2 == 0);
+ QVERIFY(mb2.isNull());
mb1 = new QMenuBar;
mw.setMenuBar(mb1);
@@ -631,7 +633,7 @@ void tst_QMainWindow::menuBar()
QCOMPARE(mw.menuBar(), (QMenuBar *)mb2);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb1 == 0);
+ QVERIFY(mb1.isNull());
mb1 = new QMenuBar;
mw.setMenuBar(mb1);
@@ -639,7 +641,7 @@ void tst_QMainWindow::menuBar()
QCOMPARE(mw.menuBar(), (QMenuBar *)mb1);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb2 == 0);
+ QVERIFY(mb2.isNull());
QPointer<QWidget> topLeftCornerWidget = new QWidget;
mb1->setCornerWidget(topLeftCornerWidget, Qt::TopLeftCorner);
@@ -652,7 +654,7 @@ void tst_QMainWindow::menuBar()
QCOMPARE(mw.menuBar(), (QMenuBar *)mb2);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb1 == 0);
+ QVERIFY(mb1.isNull());
QVERIFY(topLeftCornerWidget);
QCOMPARE(mb2->cornerWidget(Qt::TopLeftCorner), static_cast<QWidget *>(topLeftCornerWidget));
@@ -663,8 +665,8 @@ void tst_QMainWindow::menuBar()
QVERIFY(mw.menuBar() != 0);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb2 == 0);
+ QVERIFY(mb2.isNull());
QVERIFY(!topLeftCornerWidget);
QVERIFY(!topRightCornerWidget);
}
@@ -692,7 +694,7 @@ void tst_QMainWindow::statusBar()
QVERIFY(mw.statusBar() != 0);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb1 == 0);
+ QVERIFY(sb1.isNull());
mw.setStatusBar(sb2);
QVERIFY(mw.statusBar() != 0);
@@ -703,7 +705,7 @@ void tst_QMainWindow::statusBar()
QVERIFY(mw.statusBar() != 0);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb2 == 0);
+ QVERIFY(sb2.isNull());
sb1 = new QStatusBar;
mw.setStatusBar(sb1);
@@ -718,7 +720,7 @@ void tst_QMainWindow::statusBar()
QCOMPARE(sb2->parentWidget(), (QWidget *)&mw);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb1 == 0);
+ QVERIFY(sb1.isNull());
sb1 = new QStatusBar;
mw.setStatusBar(sb1);
@@ -727,7 +729,7 @@ void tst_QMainWindow::statusBar()
QCOMPARE(sb1->parentWidget(), (QWidget *)&mw);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb2 == 0);
+ QVERIFY(sb2.isNull());
sb2 = new QStatusBar;
mw.setStatusBar(sb2);
@@ -736,7 +738,7 @@ void tst_QMainWindow::statusBar()
QCOMPARE(sb2->parentWidget(), (QWidget *)&mw);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb1 == 0);
+ QVERIFY(sb1.isNull());
}
{
@@ -749,7 +751,7 @@ void tst_QMainWindow::statusBar()
QVERIFY(indexOfSb != -1);
delete sb;
indexOfSb = l->indexOf(sb);
- QVERIFY(indexOfSb == -1);
+ QCOMPARE(indexOfSb, -1);
}
}
@@ -791,7 +793,7 @@ void tst_QMainWindow::centralWidget()
{
{
QMainWindow mw;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
}
{
@@ -799,7 +801,7 @@ void tst_QMainWindow::centralWidget()
QPointer<QWidget> w1 = new QWidget;
QPointer<QWidget> w2 = new QWidget;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
mw.setCentralWidget(w1);
QVERIFY(mw.centralWidget() != 0);
@@ -812,12 +814,12 @@ void tst_QMainWindow::centralWidget()
QCOMPARE(w2->parentWidget(), (QWidget *)&mw);
mw.setCentralWidget(0);
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
//we now call deleteLater on the previous central widgets
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(w1 == 0);
- QVERIFY(w2 == 0);
+ QVERIFY(w1.isNull());
+ QVERIFY(w2.isNull());
}
{
@@ -831,7 +833,7 @@ void tst_QMainWindow::centralWidget()
QPointer<QWidget> w1 = new QWidget;
QPointer<QWidget> w2 = new QWidget;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
mw.setCentralWidget(w1);
QVERIFY(mw.centralWidget() != 0);
@@ -844,12 +846,12 @@ void tst_QMainWindow::centralWidget()
QCOMPARE(w2->parentWidget(), (QWidget *)&mw);
mw.setCentralWidget(0);
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
//we now call deleteLater on the previous central widgets
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(w1 == 0);
- QVERIFY(w2 == 0);
+ QVERIFY(w1.isNull());
+ QVERIFY(w2.isNull());
}
}
@@ -860,25 +862,25 @@ void tst_QMainWindow::takeCentralWidget() {
QPointer<QWidget> w1 = new QWidget;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
mw.setCentralWidget(w1);
QWidget *oldCentralWidget = mw.takeCentralWidget();
- QVERIFY(oldCentralWidget == w1.data());
+ QCOMPARE(oldCentralWidget, w1.data());
// ensure that takeCentralWidget doesn't end up calling deleteLater
// on the central widget
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
QVERIFY(!w1.isNull());
- QVERIFY(w1->parent() == 0);
+ QVERIFY(!w1->parent());
mw.setCentralWidget(w1);
// ensure that the deleteLater called by setCentralWidget
// gets executed
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mw.centralWidget() == w1.data());
+ QCOMPARE(mw.centralWidget(), w1.data());
QPointer<QWidget> w2 = new QWidget;
@@ -887,10 +889,10 @@ void tst_QMainWindow::takeCentralWidget() {
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QVERIFY(w1.isNull());
- QVERIFY(mw.centralWidget() == w2.data());
+ QCOMPARE(mw.centralWidget(), w2.data());
QWidget *hopefullyW2 = mw.takeCentralWidget();
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
// ensure that takeCentralWidget doesn't end up calling deleteLater
// on the central widget
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
@@ -1928,9 +1930,9 @@ void tst_QMainWindow::toggleUnifiedTitleAndToolBarOnMac()
mw.show();
QRect frameGeometry = mw.frameGeometry();
mw.setUnifiedTitleAndToolBarOnMac(false);
- QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft());
+ QCOMPARE(frameGeometry.topLeft(), mw.frameGeometry().topLeft());
mw.setUnifiedTitleAndToolBarOnMac(true);
- QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft());
+ QCOMPARE(frameGeometry.topLeft(), mw.frameGeometry().topLeft());
}
#endif
@@ -1950,5 +1952,96 @@ void tst_QMainWindow::QTBUG21378_animationFinished()
delete mwClickTimer;
QVERIFY(true);
}
+
+Q_DECLARE_METATYPE(Qt::Orientation)
+
+void tst_QMainWindow::resizeDocks_data()
+{
+ QTest::addColumn<Qt::Orientation>("orientation");
+ QTest::addColumn<QStringList>("docks");
+ QTest::addColumn<QList<int> >("sizes");
+
+ QTest::newRow("1") << Qt::Horizontal
+ << (QStringList() << "blue" << "orange" << "green" << "gray")
+ << (QList<int>() << 190 << 190 << 320 << 160);
+
+ QTest::newRow("2") << Qt::Vertical
+ << (QStringList() << "yellow" << "orange")
+ << (QList<int>() << 147 << 133 );
+
+
+ QTest::newRow("3") << Qt::Horizontal
+ << (QStringList() << "blue" << "yellow")
+ << (QList<int>() << 190 << 600);
+}
+
+void tst_QMainWindow::resizeDocks()
+{
+ AddList addList;
+ addList
+ << AddDockWidget("blue", Qt::LeftDockWidgetArea)
+ << AddDockWidget("red", Qt::TopDockWidgetArea)
+ << AddDockWidget("pink", "red")
+ << AddDockWidget("yellow", Qt::RightDockWidgetArea)
+ << AddDockWidget("orange", Qt::RightDockWidgetArea)
+ << AddDockWidget("green", "orange", Qt::Horizontal)
+ << AddDockWidget("gray", "orange", Qt::Horizontal);
+ /*
+ +--------------------------------+
+ | red/pink |
+ +------+-+-----------------------+
+ | | | yellow |
+ | blue + +--------+------+-------+
+ | | | orange | gray | green |
+ +------+-+--------+------+-------+
+
+ */
+
+ QMainWindow mw(0, Qt::BypassWindowManagerHint);
+ mw.setDockNestingEnabled(true);
+ mw.resize(1800, 600);
+
+ foreach (const AddDockWidget &i, addList)
+ i.apply(&mw);
+
+ foreach (QDockWidget *dw, mw.findChildren<QDockWidget *>())
+ dw->setStyleSheet( "* { background-color: " + dw->objectName() +" }");
+
+ mw.setCentralWidget(new QTextEdit);
+
+ mw.show();
+ QTest::qWaitForWindowExposed(&mw);
+
+ QFETCH(Qt::Orientation, orientation);
+ QFETCH(QStringList, docks);
+ QFETCH(QList<int>, sizes);
+
+ QList<QDockWidget *> list;
+ foreach (const QString &name, docks) {
+ QDockWidget *d = mw.findChild<QDockWidget *>(name);
+ QVERIFY(d);
+ list << d;
+ }
+
+ mw.resizeDocks(list, sizes, orientation);
+
+ qApp->processEvents();
+
+ int totalFromList = 0;
+ int actualTotal = 0;
+ for (int i = 0; i < docks.count(); ++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) {
+ QSize s = list[i]->size();
+ int value = (orientation == Qt::Horizontal) ? s.width() : s.height();
+ QCOMPARE(value, qRound(sizes[i]*actualTotal/double(totalFromList)));
+ }
+}
+
QTEST_MAIN(tst_QMainWindow)
#include "tst_qmainwindow.moc"
diff --git a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
index b8640e9ac3..63da2e3ae3 100644
--- a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
@@ -1,2 +1,5 @@
[updateScrollBars]
osx
+[tileSubWindows]
+osx
+xcb
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 53defce423..e23634c515 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -377,13 +377,13 @@ void tst_QMdiArea::subWindowActivated()
while (workspace->activeSubWindow() ) {
workspace->activeSubWindow()->close();
qApp->processEvents();
- QVERIFY(activeWindow == workspace->activeSubWindow());
+ QCOMPARE(activeWindow, workspace->activeSubWindow());
QCOMPARE(spy.count(), 1);
spy.clear();
}
- QVERIFY(activeWindow == 0);
- QVERIFY(workspace->activeSubWindow() == 0);
+ QVERIFY(!activeWindow);
+ QVERIFY(!workspace->activeSubWindow());
QCOMPARE(workspace->subWindowList().count(), 0);
{
@@ -432,13 +432,13 @@ void tst_QMdiArea::subWindowActivated()
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY( activeWindow == window );
- QVERIFY(workspace->activeSubWindow() == window);
+ QCOMPARE(workspace->activeSubWindow(), window);
window->close();
qApp->processEvents();
QCOMPARE(spy.count(), 1);
spy.clear();
- QVERIFY(workspace->activeSubWindow() == 0);
- QVERIFY( activeWindow == 0 );
+ QVERIFY(!workspace->activeSubWindow());
+ QVERIFY(!activeWindow);
}
}
@@ -518,7 +518,7 @@ void tst_QMdiArea::subWindowActivated2()
#ifdef Q_OS_MAC
QSKIP("QTBUG-25298: This test is unstable on Mac.");
#endif
- if (qApp->platformName().toLower() == QStringLiteral("xcb"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive))
QSKIP("QTBUG-25298: Unstable on some X11 window managers");
QTRY_COMPARE(spy.count(), 1);
QVERIFY(!mdiArea.activeSubWindow());
@@ -564,8 +564,8 @@ void tst_QMdiArea::subWindowActivatedWithMinimize()
window1->close();
qApp->processEvents();
- QVERIFY(workspace->activeSubWindow() == 0);
- QVERIFY( activeWindow == 0 );
+ QVERIFY(!workspace->activeSubWindow());
+ QVERIFY(!activeWindow);
QVERIFY( workspace->subWindowList().count() == 0 );
}
@@ -1104,7 +1104,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QVERIFY(window);
qApp->processEvents();
QCOMPARE(workspace.subWindowList().count(), 1);
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), workspace.viewport()->size());
}
@@ -1115,7 +1115,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QVERIFY(window);
qApp->processEvents();
QCOMPARE(workspace.subWindowList().count(), 2);
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), window->minimumSize());
}
@@ -1127,7 +1127,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QVERIFY(window);
qApp->processEvents();
QCOMPARE(workspace.subWindowList().count(), 3);
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), QSize(1500, 1500));
}
@@ -1142,7 +1142,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QMdiSubWindow *window = new QMdiSubWindow;
workspace.addSubWindow(window);
qApp->processEvents();
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
window->setWidget(new QWidget);
QCOMPARE(workspace.subWindowList().count(), 4);
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
@@ -1206,7 +1206,7 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting()
{
QMdiArea workspace;
QMdiSubWindow window(&workspace);
- QVERIFY(window.windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window.windowFlags(), DefaultWindowFlags);
// 0 because the window list contains widgets and not actual
// windows. Silly, but that's the behavior.
@@ -1219,7 +1219,7 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting()
QCOMPARE(workspace.subWindowList().count(), 0);
window.setParent(&workspace);
QCOMPARE(workspace.subWindowList().count(), 1);
- QVERIFY(window.windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window.windowFlags(), DefaultWindowFlags);
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
workspace.addSubWindow(&window);
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 46d3177a56..5ae0733965 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -78,6 +78,7 @@ public slots:
private slots:
void getSetCheck();
void addActionsAndClear();
+ void addActionsConnect();
void keyboardNavigation_data();
void keyboardNavigation();
@@ -264,6 +265,34 @@ void tst_QMenu::addActionsAndClear()
QCOMPARE(menus[0]->actions().count(), 0);
}
+static void testFunction() { }
+
+void tst_QMenu::addActionsConnect()
+{
+ QMenu menu;
+ const QString text = QLatin1String("bla");
+ const QIcon icon;
+ menu.addAction(text, &menu, SLOT(deleteLater()));
+ menu.addAction(text, &menu, &QMenu::deleteLater);
+ menu.addAction(text, testFunction);
+ menu.addAction(text, &menu, testFunction);
+ menu.addAction(icon, text, &menu, SLOT(deleteLater()));
+ menu.addAction(icon, text, &menu, &QMenu::deleteLater);
+ menu.addAction(icon, text, testFunction);
+ menu.addAction(icon, text, &menu, testFunction);
+#ifndef QT_NO_SHORTCUT
+ const QKeySequence keySequence(Qt::CTRL + Qt::Key_C);
+ menu.addAction(text, &menu, SLOT(deleteLater()), keySequence);
+ menu.addAction(text, &menu, &QMenu::deleteLater, keySequence);
+ menu.addAction(text, testFunction, keySequence);
+ menu.addAction(text, &menu, testFunction, keySequence);
+ menu.addAction(icon, text, &menu, SLOT(deleteLater()), keySequence);
+ menu.addAction(icon, text, &menu, &QMenu::deleteLater, keySequence);
+ menu.addAction(icon, text, testFunction, keySequence);
+ menu.addAction(icon, text, &menu, testFunction, keySequence);
+#endif // !QT_NO_SHORTCUT
+}
+
// We have a separate mouseActivation test for Windows mobile
#ifndef Q_OS_WINCE
void tst_QMenu::mouseActivation()
@@ -334,8 +363,10 @@ void tst_QMenu::keyboardNavigation_data()
QTest::newRow("data9") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << false<< true;
QTest::newRow("data10") << Qt::Key(Qt::Key_Return) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << true << false;
- // Test shortcuts.
- QTest::newRow("shortcut0") << Qt::Key(Qt::Key_V) << Qt::KeyboardModifiers(Qt::AltModifier) << 5 << 0 << true << true << false;
+ if (QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive)) {
+ // Test shortcuts.
+ QTest::newRow("shortcut0") << Qt::Key(Qt::Key_V) << Qt::KeyboardModifiers(Qt::AltModifier) << 5 << 0 << true << true << false;
+ }
}
void tst_QMenu::keyboardNavigation()
@@ -513,7 +544,7 @@ void tst_QMenu::onStatusTipTimer()
menu->close(); //goes out of the menu
QCOMPARE(st, QString("sub action"));
- QVERIFY(menu->isVisible() == false);
+ QVERIFY(!menu->isVisible());
m_onStatusTipTimerExecuted = true;
}
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 31e9c737e2..baf60551c4 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -146,7 +146,7 @@ private:
QAction* m_lastSimpleAcceleratorId;
int m_simpleActivatedCount;
- int m_complexTriggerCount['k'];
+ int m_complexTriggerCount[int('k')];
};
// Testing get/set functions
@@ -534,60 +534,60 @@ void tst_QMenuBar::check_accelKeys()
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_C, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_B, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 1);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 1);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_D, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 1);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 1);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 1);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 1);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_J, Qt::AltModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 1);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 1);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 1);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 1);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 1);
}
#endif
@@ -606,10 +606,10 @@ void tst_QMenuBar::check_cursorKeys1()
// the Popupmenu should be visible now
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
// Simulate a cursor key down click
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
@@ -618,10 +618,10 @@ void tst_QMenuBar::check_cursorKeys1()
// Let's see if the correct slot is called...
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been called
- QCOMPARE(m_complexTriggerCount['b'], 1); // and this should have been called by a signal now
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been called
+ QCOMPARE(m_complexTriggerCount[int('b')], 1); // and this should have been called by a signal now
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
}
#endif
@@ -648,10 +648,10 @@ void tst_QMenuBar::check_cursorKeys2()
// Let's see if the correct slot is called...
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been caled
- QCOMPARE(m_complexTriggerCount['b'], 0); // and this should have been called by a signal ow
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 1);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been caled
+ QCOMPARE(m_complexTriggerCount[int('b')], 0); // and this should have been called by a signal ow
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 1);
}
#endif
@@ -679,10 +679,10 @@ void tst_QMenuBar::check_cursorKeys3()
// Let's see if the correct slot is called...
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been called
- QCOMPARE(m_complexTriggerCount['b'], 1); // and this should have been called by a signal now
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been called
+ QCOMPARE(m_complexTriggerCount[int('b')], 1); // and this should have been called by a signal now
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
}
#endif
@@ -715,17 +715,17 @@ void tst_QMenuBar::check_homeKey()
// and press ENTER
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called...
-// QVERIFY2( m_complexActionTriggerCount['c'] == 1, "Popupmenu should respond to a Home key" );
- QCOMPARE(m_complexTriggerCount['c'], 1);
+// QVERIFY2( m_complexActionTriggerCount[int('c')] == 1, "Popupmenu should respond to a Home key" );
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
- QCOMPARE(m_complexTriggerCount['e'], 0);
- QCOMPARE(m_complexTriggerCount['f'], 0);
- QCOMPARE(m_complexTriggerCount['g'], 0);
- QCOMPARE(m_complexTriggerCount['h'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
+ QCOMPARE(m_complexTriggerCount[int('e')], 0);
+ QCOMPARE(m_complexTriggerCount[int('f')], 0);
+ QCOMPARE(m_complexTriggerCount[int('g')], 0);
+ QCOMPARE(m_complexTriggerCount[int('h')], 0);
}
/*!
@@ -754,17 +754,17 @@ void tst_QMenuBar::check_endKey()
// and press ENTER
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called...
-// QVERIFY2( m_complexActionTriggerCount['h'] == 1, "Popupmenu should respond to an End key" );
- QCOMPARE(m_complexTriggerCount['h'], 1);//, "Popupmenu should respond to an End key");
+// QVERIFY2( m_complexActionTriggerCount[int('h')] == 1, "Popupmenu should respond to an End key" );
+ QCOMPARE(m_complexTriggerCount[int('h')], 1);//, "Popupmenu should respond to an End key");
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
- QCOMPARE(m_complexTriggerCount['e'], 0);
- QCOMPARE(m_complexTriggerCount['f'], 0);
- QCOMPARE(m_complexTriggerCount['g'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
+ QCOMPARE(m_complexTriggerCount[int('e')], 0);
+ QCOMPARE(m_complexTriggerCount[int('f')], 0);
+ QCOMPARE(m_complexTriggerCount[int('g')], 0);
}
/*!
@@ -808,7 +808,7 @@ void tst_QMenuBar::check_escKey()
// and press ENTER
QTest::keyClick( menu.menus.at(1), Qt::Key_Enter );
// Let's see if the correct slot is called...
- QVERIFY2( m_complexTriggerCount['c'] == 1, "Expected item 2C to be selected" );
+ QVERIFY2(m_complexTriggerCount[int('c')] == 1, "Expected item 2C to be selected");
}
#endif
diff --git a/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
new file mode 100644
index 0000000000..725b8e93b4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
@@ -0,0 +1,2 @@
+[clearAndGrab]
+opensuse-13.1
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
index e9f9c67856..638fad6206 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -70,7 +70,7 @@ void tst_QOpenGLWidget::create()
QVERIFY(w->isValid());
QVERIFY(w->context());
- QVERIFY(w->context()->format() == w->format());
+ QCOMPARE(w->context()->format(), w->format());
QVERIFY(w->defaultFramebufferObject() != 0);
}
@@ -304,7 +304,7 @@ void tst_QOpenGLWidget::asViewport()
// the widget stack.
btn->update();
qApp->processEvents();
- QVERIFY(view->paintCount() == 0);
+ QCOMPARE(view->paintCount(), 0);
}
class PaintCountWidget : public QOpenGLWidget
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index e7de6b0b75..2145260013 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -333,7 +333,7 @@ void tst_QPlainTextEdit::selectAllSetsNotSelection()
QSKIP("Test only relevant for systems with selection");
QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection);
- QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar"));
+ QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString("foobar"));
ed->insertPlainText("Hello World");
ed->selectAll();
@@ -905,13 +905,13 @@ void tst_QPlainTextEdit::mouseCursorShape()
{
// always show an IBeamCursor, see change 170146
QVERIFY(!ed->isReadOnly());
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setReadOnly(true);
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setPlainText("Foo");
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
}
#endif
@@ -1324,7 +1324,7 @@ void tst_QPlainTextEdit::preserveCharFormatAfterSetPlainText()
QTextBlock block = ed->document()->begin();
block = block.next();
QCOMPARE(block.text(), QString("This should still be blue"));
- QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue));
+ QCOMPARE(block.begin().fragment().charFormat().foreground().color(), QColor(Qt::blue));
}
void tst_QPlainTextEdit::extraSelections()
@@ -1444,7 +1444,7 @@ void tst_QPlainTextEdit::wordWrapProperty()
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
edit.setDocument(doc);
edit.setWordWrapMode(QTextOption::NoWrap);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
{
QPlainTextEdit edit;
@@ -1452,18 +1452,18 @@ void tst_QPlainTextEdit::wordWrapProperty()
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
edit.setWordWrapMode(QTextOption::NoWrap);
edit.setDocument(doc);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
}
void tst_QPlainTextEdit::lineWrapProperty()
{
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->lineWrapMode() == QPlainTextEdit::WidgetWidth);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->lineWrapMode(), QPlainTextEdit::WidgetWidth);
ed->setLineWrapMode(QPlainTextEdit::NoWrap);
- QVERIFY(ed->lineWrapMode() == QPlainTextEdit::NoWrap);
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(ed->lineWrapMode(), QPlainTextEdit::NoWrap);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->document()->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
void tst_QPlainTextEdit::selectionChanged()
@@ -1560,7 +1560,7 @@ void tst_QPlainTextEdit::findWithRegExp()
bool found = ed->find(rx);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
@@ -1574,7 +1574,7 @@ void tst_QPlainTextEdit::findBackwardWithRegExp()
bool found = ed->find(rx, QTextDocument::FindBackward);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
}
@@ -1586,7 +1586,7 @@ void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
bool found = ed->find(rx);
- QVERIFY(found == false);
+ QVERIFY(!found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
#endif
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 4fd8b99acf..44a554ad82 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -227,8 +227,8 @@ void tst_QPushButton::autoRepeat()
QVERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QTest::keyRelease( testWidget, Qt::Key_Space );
- QVERIFY(press_count == release_count);
- QVERIFY(release_count == click_count);
+ QCOMPARE(press_count, release_count);
+ QCOMPARE(release_count, click_count);
QVERIFY(press_count > 1);
// #### shouldn't I check here to see if multiple signals have been fired???
diff --git a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
index 40e13c8e8d..ce6afc0a57 100644
--- a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
+++ b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
@@ -166,8 +166,8 @@ void tst_QScrollArea::checkHFW_Task_197736()
scrollArea.setWidgetResizable(false);
scrollArea.resize(QSize(100,100));
w->resize(QSize(200,200));
- QVERIFY(w->width() == 200);
- QVERIFY(w->height() == 200);
+ QCOMPARE(w->width(), 200);
+ QCOMPARE(w->height(), 200);
}
QTEST_MAIN(tst_QScrollArea)
diff --git a/tests/auto/widgets/widgets/qsizegrip/BLACKLIST b/tests/auto/widgets/widgets/qsizegrip/BLACKLIST
new file mode 100644
index 0000000000..2c874bcb57
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsizegrip/BLACKLIST
@@ -0,0 +1,2 @@
+[hideAndShowOnWindowStateChange:Qt::Window]
+xcb
diff --git a/tests/auto/widgets/widgets/qspinbox/BLACKLIST b/tests/auto/widgets/widgets/qspinbox/BLACKLIST
new file mode 100644
index 0000000000..5bf6c3beed
--- /dev/null
+++ b/tests/auto/widgets/widgets/qspinbox/BLACKLIST
@@ -0,0 +1,3 @@
+[editingFinished]
+osx-10.8
+osx-10.9
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 05dd834c76..34b05c5291 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -165,6 +165,7 @@ Q_DECLARE_METATYPE(QLocale::Country)
void tst_QSpinBox::getSetCheck()
{
QSpinBox obj1;
+ QCOMPARE(obj1.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhDigitsOnly)));
// int QSpinBox::singleStep()
// void QSpinBox::setSingleStep(int)
obj1.setSingleStep(0);
@@ -202,6 +203,7 @@ void tst_QSpinBox::getSetCheck()
QCOMPARE(INT_MAX, obj1.value());
QDoubleSpinBox obj2;
+ QCOMPARE(obj2.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhFormattedNumbersOnly)));
// double QDoubleSpinBox::singleStep()
// void QDoubleSpinBox::setSingleStep(double)
obj2.setSingleStep(0.0);
diff --git a/tests/auto/widgets/widgets/qtabbar/BLACKLIST b/tests/auto/widgets/widgets/qtabbar/BLACKLIST
new file mode 100644
index 0000000000..b000b08444
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabbar/BLACKLIST
@@ -0,0 +1,2 @@
+[sizeHints]
+ubuntu-14.04
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
index fffbbc2ec7..a991f18110 100644
--- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -165,7 +165,7 @@ void tst_QTabWidget::init()
tw = new QTabWidget(0);
QCOMPARE(tw->count(), 0);
QCOMPARE(tw->currentIndex(), -1);
- QVERIFY(tw->currentWidget() == NULL);
+ QVERIFY(!tw->currentWidget());
}
void tst_QTabWidget::cleanup()
@@ -208,7 +208,7 @@ void tst_QTabWidget::addRemoveTab()
QCOMPARE(tw->count(), 0);
tw->removeTab(-1);
QCOMPARE(tw->count(), 0);
- QVERIFY(tw->widget(-1) == 0);
+ QVERIFY(!tw->widget(-1));
QWidget *w = new QWidget();
int index = tw->addTab(w, LABEL);
@@ -216,7 +216,7 @@ void tst_QTabWidget::addRemoveTab()
QCOMPARE(tw->indexOf(w), index);
QCOMPARE(tw->count(), 1);
- QVERIFY(tw->widget(index) == w);
+ QCOMPARE(tw->widget(index), w);
QCOMPARE(tw->tabText(index), QString(LABEL));
removePage(index);
@@ -238,7 +238,7 @@ void tst_QTabWidget::tabPosition()
void tst_QTabWidget::tabEnabled()
{
// Test bad arguments
- QVERIFY(tw->isTabEnabled(-1) == false);
+ QVERIFY(!tw->isTabEnabled(-1));
tw->setTabEnabled(-1, false);
int index = addPage();
@@ -333,21 +333,21 @@ void tst_QTabWidget::currentWidget()
{
// Test bad arguments
tw->setCurrentWidget(NULL);
- QVERIFY(tw->currentWidget() == NULL);
+ QVERIFY(!tw->currentWidget());
int index = addPage();
QWidget *w = tw->widget(index);
- QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentWidget(), w);
QCOMPARE(tw->currentIndex(), index);
tw->setCurrentWidget(NULL);
- QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentWidget(), w);
QCOMPARE(tw->currentIndex(), index);
int index2 = addPage();
QWidget *w2 = tw->widget(index2);
Q_UNUSED(w2);
- QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentWidget(), w);
QCOMPARE(tw->currentIndex(), index);
removePage(index2);
@@ -372,7 +372,7 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(tw->currentIndex(), firstIndex);
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == firstIndex);
+ QCOMPARE(arguments.at(0).toInt(), firstIndex);
int index = addPage();
QCOMPARE(tw->currentIndex(), firstIndex);
@@ -380,19 +380,19 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(tw->currentIndex(), index);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == index);
+ QCOMPARE(arguments.at(0).toInt(), index);
removePage(index);
QCOMPARE(tw->currentIndex(), firstIndex);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == firstIndex);
+ QCOMPARE(arguments.at(0).toInt(), firstIndex);
removePage(firstIndex);
QCOMPARE(tw->currentIndex(), -1);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == -1);
+ QCOMPARE(arguments.at(0).toInt(), -1);
}
void tst_QTabWidget::cornerWidget()
@@ -400,24 +400,24 @@ void tst_QTabWidget::cornerWidget()
// Test bad arguments
tw->setCornerWidget(NULL, Qt::TopRightCorner);
- QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == 0);
- QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0);
- QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == 0);
- QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == 0);
+ QVERIFY(!tw->cornerWidget(Qt::TopLeftCorner));
+ QVERIFY(!tw->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(!tw->cornerWidget(Qt::BottomLeftCorner));
+ QVERIFY(!tw->cornerWidget(Qt::BottomRightCorner));
QWidget *w = new QWidget(0);
tw->setCornerWidget(w, Qt::TopLeftCorner);
QCOMPARE(w->parent(), (QObject *)tw);
- QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::TopLeftCorner), w);
tw->setCornerWidget(w, Qt::TopRightCorner);
- QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::TopRightCorner), w);
tw->setCornerWidget(w, Qt::BottomLeftCorner);
- QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::BottomLeftCorner), w);
tw->setCornerWidget(w, Qt::BottomRightCorner);
- QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::BottomRightCorner), w);
tw->setCornerWidget(0, Qt::TopRightCorner);
- QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0);
+ QVERIFY(!tw->cornerWidget(Qt::TopRightCorner));
QCOMPARE(w->isHidden(), true);
}
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
index aaa7348bdf..adc768f828 100644
--- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -141,14 +141,14 @@ void tst_QTextBrowser::noReloadOnAnchorJump()
browser->setSource(url);
QCOMPARE(browser->htmlLoadAttempts, 1);
QVERIFY(!browser->toPlainText().isEmpty());
- QVERIFY(browser->source() == url);
+ QCOMPARE(browser->source(), url);
}
void tst_QTextBrowser::bgColorOnSourceChange()
{
browser->setSource(QUrl::fromLocalFile("pagewithbg.html"));
QVERIFY(browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush));
- QVERIFY(browser->document()->rootFrame()->frameFormat().background().color() == Qt::blue);
+ QCOMPARE(browser->document()->rootFrame()->frameFormat().background().color(), QColor(Qt::blue));
browser->setSource(QUrl::fromLocalFile("pagewithoutbg.html"));
QVERIFY(!browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush));
@@ -167,13 +167,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
QVariant val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
QCOMPARE(browser->historyUrl(0), QUrl::fromLocalFile("pagewithbg.html"));
@@ -185,13 +185,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == true);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(val.toBool());
QCOMPARE(browser->historyTitle(-1), QString("Page With BG"));
QCOMPARE(browser->historyTitle(0), QString("Sample Anchor"));
@@ -201,13 +201,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == true);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
QCOMPARE(browser->historyTitle(0), QString("Page With BG"));
@@ -217,13 +217,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == true);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(val.toBool());
}
void tst_QTextBrowser::viewportPositionInHistory()
@@ -244,29 +244,29 @@ void tst_QTextBrowser::relativeLinks()
QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(QUrl)));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
browser->setSource(QUrl("anchor.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("anchor.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
// using QUrl::fromLocalFile()
browser->setSource(QUrl::fromLocalFile("anchor.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("file:anchor.html"));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
}
@@ -446,13 +446,13 @@ void tst_QTextBrowser::sourceInsideLoadResource()
void tst_QTextBrowser::textInteractionFlags_vs_readOnly()
{
QVERIFY(browser->isReadOnly());
- QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction);
browser->setReadOnly(true);
- QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction);
browser->setReadOnly(false);
- QVERIFY(browser->textInteractionFlags() == Qt::TextEditorInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextEditorInteraction);
browser->setReadOnly(true);
- QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction);
}
void tst_QTextBrowser::anchorsWithSelfBuiltHtml()
@@ -525,7 +525,7 @@ void tst_QTextBrowser::loadResourceOnRelativeLocalFiles()
QVERIFY(!browser->toPlainText().isEmpty());
QVariant v = browser->loadResource(QTextDocument::HtmlResource, QUrl("../anchor.html"));
QVERIFY(v.isValid());
- QVERIFY(v.type() == QVariant::ByteArray);
+ QCOMPARE(v.type(), QVariant::ByteArray);
QVERIFY(!v.toByteArray().isEmpty());
}
@@ -658,7 +658,7 @@ void tst_QTextBrowser::urlEncoding()
QCOMPARE(spy.count(), 1);
QUrl url = spy.at(0).at(0).toUrl();
- QVERIFY(url.toEncoded() == QByteArray("http://www.google.com/q=%22"));
+ QCOMPARE(url.toEncoded(), QByteArray("http://www.google.com/q=%22"));
delete browser;
}
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 35a6a8e4e0..0cc812cbca 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -398,12 +398,13 @@ void tst_QTextEdit::cleanup()
void tst_QTextEdit::inlineAttributesOnInsert()
{
- QVERIFY(ed->textCursor().charFormat().foreground().color() != Qt::blue);
+ const QColor blue(Qt::blue);
+ QVERIFY(ed->textCursor().charFormat().foreground().color() != blue);
- ed->setTextColor(Qt::blue);
+ ed->setTextColor(blue);
QTest::keyClick(ed, Qt::Key_A);
- QVERIFY(ed->textCursor().charFormat().foreground().color() == Qt::blue);
+ QCOMPARE(ed->textCursor().charFormat().foreground().color(), blue);
}
void tst_QTextEdit::inlineAttributesOnSelection()
@@ -457,7 +458,7 @@ void tst_QTextEdit::autoBulletList1()
QTest::keyClicks(ed, "*This should become a list");
QVERIFY(ed->textCursor().currentList());
- QVERIFY(ed->textCursor().currentList()->format().style() == QTextListFormat::ListDisc);
+ QCOMPARE(ed->textCursor().currentList()->format().style(), QTextListFormat::ListDisc);
}
void tst_QTextEdit::autoBulletList2()
@@ -582,7 +583,7 @@ void tst_QTextEdit::selectAllSetsNotSelection()
}
QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection);
- QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar"));
+ QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString("foobar"));
ed->insertPlainText("Hello World");
ed->selectAll();
@@ -867,11 +868,12 @@ void tst_QTextEdit::appendShouldUseCurrentFormat()
fmt.setFontItalic(true);
ed->setCurrentCharFormat(fmt);
ed->append("Hello");
+ const QColor blue(Qt::blue);
QTextCursor cursor(ed->document());
QVERIFY(cursor.movePosition(QTextCursor::NextCharacter));
- QVERIFY(cursor.charFormat().foreground().color() != Qt::blue);
+ QVERIFY(cursor.charFormat().foreground().color() != blue);
QVERIFY(!cursor.charFormat().fontItalic());
QVERIFY(cursor.movePosition(QTextCursor::NextBlock));
@@ -883,7 +885,7 @@ void tst_QTextEdit::appendShouldUseCurrentFormat()
}
QVERIFY(cursor.movePosition(QTextCursor::NextCharacter));
- QVERIFY(cursor.charFormat().foreground().color() == Qt::blue);
+ QCOMPARE(cursor.charFormat().foreground().color(), blue);
QVERIFY(cursor.charFormat().fontItalic());
}
@@ -1211,7 +1213,7 @@ void tst_QTextEdit::lineWrapModes()
{
ed->setLineWrapMode(QTextEdit::NoWrap);
// NoWrap at the same time as having all lines that are all left aligned means we optimize to only layout once. The effect is that the width is always 0
- QVERIFY(ed->document()->pageSize().width() == qreal(0));
+ QCOMPARE(ed->document()->pageSize().width(), qreal(0));
QTextCursor cursor = QTextCursor(ed->document());
cursor.insertText(QString("A simple line"));
@@ -1237,13 +1239,13 @@ void tst_QTextEdit::mouseCursorShape()
{
// always show an IBeamCursor, see change 170146
QVERIFY(!ed->isReadOnly());
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setReadOnly(true);
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setPlainText("Foo");
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
}
#endif
@@ -1661,7 +1663,7 @@ void tst_QTextEdit::preserveCharFormatAfterSetPlainText()
QTextBlock block = ed->document()->begin();
block = block.next();
QCOMPARE(block.text(), QString("This should still be blue"));
- QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue));
+ QCOMPARE(block.begin().fragment().charFormat().foreground().color(), QColor(Qt::blue));
}
void tst_QTextEdit::extraSelections()
@@ -1796,25 +1798,25 @@ void tst_QTextEdit::wordWrapProperty()
QTextDocument *doc = new QTextDocument(&edit);
edit.setDocument(doc);
edit.setWordWrapMode(QTextOption::NoWrap);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
{
QTextEdit edit;
QTextDocument *doc = new QTextDocument(&edit);
edit.setWordWrapMode(QTextOption::NoWrap);
edit.setDocument(doc);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
}
void tst_QTextEdit::lineWrapProperty()
{
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->lineWrapMode() == QTextEdit::WidgetWidth);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->lineWrapMode(), QTextEdit::WidgetWidth);
ed->setLineWrapMode(QTextEdit::NoWrap);
- QVERIFY(ed->lineWrapMode() == QTextEdit::NoWrap);
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(ed->lineWrapMode(), QTextEdit::NoWrap);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->document()->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
void tst_QTextEdit::selectionChanged()
@@ -2122,7 +2124,7 @@ void tst_QTextEdit::setDocumentPreservesPalette()
QTextDocument *newDoc = new QTextDocument(ed);
ed->setDocument(newDoc);
- QVERIFY(control->document() == newDoc);
+ QCOMPARE(control->document(), newDoc);
QVERIFY(whitePal.color(QPalette::Active, QPalette::Text)
== control->palette().color(QPalette::Active, QPalette::Text));
}
@@ -2525,7 +2527,7 @@ void tst_QTextEdit::findWithRegExp()
bool found = ed->find(rx);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
@@ -2539,7 +2541,7 @@ void tst_QTextEdit::findBackwardWithRegExp()
bool found = ed->find(rx, QTextDocument::FindBackward);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
}
@@ -2551,7 +2553,7 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
bool found = ed->find(rx);
- QVERIFY(found == false);
+ QVERIFY(!found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
#endif
diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
index 24de35ce89..e653a85d96 100644
--- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
+++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
@@ -67,6 +67,7 @@ private slots:
void allowedAreas();
void orientation();
void addAction();
+ void addActionConnect();
void insertAction();
void addSeparator();
void insertSeparator();
@@ -361,6 +362,23 @@ void tst_QToolBar::addAction()
}
}
+static void testFunction() { }
+
+void tst_QToolBar::addActionConnect()
+{
+ QToolBar tb;
+ const QString text = QLatin1String("bla");
+ const QIcon icon;
+ tb.addAction(text, &tb, SLOT(deleteLater()));
+ tb.addAction(text, &tb, &QMenu::deleteLater);
+ tb.addAction(text, testFunction);
+ tb.addAction(text, &tb, testFunction);
+ tb.addAction(icon, text, &tb, SLOT(deleteLater()));
+ tb.addAction(icon, text, &tb, &QMenu::deleteLater);
+ tb.addAction(icon, text, testFunction);
+ tb.addAction(icon, text, &tb, testFunction);
+}
+
void tst_QToolBar::insertAction()
{
QToolBar tb;
@@ -495,13 +513,13 @@ void tst_QToolBar::insertWidget()
QToolBar tb;
QPointer<QWidget> widget = new QWidget;
QAction *action = tb.addWidget(widget);
- QVERIFY(action->parent() == &tb);
+ QCOMPARE(action->parent(), &tb);
QToolBar tb2;
tb.removeAction(action);
tb2.addAction(action);
QVERIFY(widget && widget->parent() == &tb2);
- QVERIFY(action->parent() == &tb2);
+ QCOMPARE(action->parent(), &tb2);
}
}
@@ -960,10 +978,10 @@ void tst_QToolBar::actionOwnership()
QToolBar *tb2 = new QToolBar;
QPointer<QAction> action = tb1->addAction("test");
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
tb2->addAction(action);
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
delete tb1;
QVERIFY(!action);
@@ -974,13 +992,13 @@ void tst_QToolBar::actionOwnership()
QToolBar *tb2 = new QToolBar;
QPointer<QAction> action = tb1->addAction("test");
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
tb1->removeAction(action);
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
tb2->addAction(action);
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
delete tb1;
QVERIFY(!action);
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
index 03fbae2e57..0d1abe5032 100644
--- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -170,10 +170,10 @@ void tst_QToolButton::collapseTextOnPriority()
QStyleOptionToolButton option;
button.initStyleOption(&option);
- QVERIFY(option.toolButtonStyle == Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(option.toolButtonStyle, Qt::ToolButtonTextBesideIcon);
action.setPriority(QAction::LowPriority);
button.initStyleOption(&option);
- QVERIFY(option.toolButtonStyle == Qt::ToolButtonIconOnly);
+ QCOMPARE(option.toolButtonStyle, Qt::ToolButtonIconOnly);
}
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp
index 2ce32c7cf2..a4a3f1f6b3 100644
--- a/tests/auto/xml/dom/qdom/tst_qdom.cpp
+++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp
@@ -1043,15 +1043,15 @@ void tst_QDom::browseElements()
QVERIFY(!bar.isNull());
QVERIFY(bar.previousSiblingElement("bar").isNull());
QVERIFY(bar.previousSiblingElement().isNull());
- QVERIFY(bar.nextSiblingElement("bar").tagName() == "bar");
+ QCOMPARE(bar.nextSiblingElement("bar").tagName(), QLatin1String("bar"));
QVERIFY(bar.nextSiblingElement("bar").nextSiblingElement("bar").isNull());
QDomElement bop = foo.firstChildElement("bop");
QVERIFY(!bop.isNull());
- QVERIFY(bar.nextSiblingElement() == bop);
- QVERIFY(bop.nextSiblingElement("bop") == foo.lastChildElement("bop"));
- QVERIFY(bop.previousSiblingElement("bar") == foo.firstChildElement("bar"));
- QVERIFY(bop.previousSiblingElement("bar") == foo.firstChildElement());
+ QCOMPARE(bar.nextSiblingElement(), bop);
+ QCOMPARE(bop.nextSiblingElement("bop"), foo.lastChildElement("bop"));
+ QCOMPARE(bop.previousSiblingElement("bar"), foo.firstChildElement("bar"));
+ QCOMPARE(bop.previousSiblingElement("bar"), foo.firstChildElement());
}
void tst_QDom::domNodeMapAndList()
diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
index 04f19f6a2b..a5ac58878e 100644
--- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
+++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
@@ -147,7 +147,7 @@ public slots:
void requestFinished(QNetworkReply *reply)
{
- QVERIFY(reply->error() == QNetworkReply::NoError);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
reply->deleteLater();
}
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent
index 1cff3fd44f..1cff3fd44f 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent
index 45f6d8e74e..45f6d8e74e 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent
index 3436f20001..3436f20001 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent
index c6e97f821f..c6e97f821f 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent
index 4df2f0c2ac..4df2f0c2ac 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent
index ab1d696dd7..ab1d696dd7 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent
Binary files differ
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent
index c6ca61f9c8..c6ca61f9c8 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent
Binary files differ
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent
index 67c3297611..67c3297611 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent
index b19be3a497..b19be3a497 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent
index 8eb1fb9c41..8eb1fb9c41 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent
index 7f25c502dd..7f25c502dd 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent
index 470fd6fe44..470fd6fe44 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent
Binary files differ
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent
index 67c3297611..67c3297611 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent
index 931f3ad6d8..931f3ad6d8 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent
index 40f7ff58a2..40f7ff58a2 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent
index 61def75cb7..61def75cb7 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent
index ade9599032..ade9599032 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent
index bef50b1f38..bef50b1f38 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent
index 8f305a82bd..8f305a82bd 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent
index fbf4ca4947..fbf4ca4947 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent
index fbf4ca4947..fbf4ca4947 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent
index fbf4ca4947..fbf4ca4947 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent
index 52a28f5deb..52a28f5deb 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent
index fbf4ca4947..fbf4ca4947 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent
index 7e372e65e9..7e372e65e9 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent
index a3691d9f08..a3691d9f08 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent
index 6eaf779329..6eaf779329 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent
index 00d2f30e1d..00d2f30e1d 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent
index bf77ef8336..bf77ef8336 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent
index ffd9adde61..ffd9adde61 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent
index 2d46f76fc3..2d46f76fc3 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent
index d18201a98b..d18201a98b 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent
index 815291c6d2..815291c6d2 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent
index 9f8f2afd2b..9f8f2afd2b 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent
index 26f2d8beb2..26f2d8beb2 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent
index e3268819f7..e3268819f7 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent
index aa6d0eccac..aa6d0eccac 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent
index 389d259eb1..389d259eb1 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent
index bdc93af639..bdc93af639 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent
index 712cce3700..712cce3700 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent
index ac249d7b2c..ac249d7b2c 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent
index df94df5560..df94df5560 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent
index e3864460df..e3864460df 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent
index f7f94ab152..f7f94ab152 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent
index bef50b1f38..bef50b1f38 100755..100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent
diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
index 272bafc7dd..42d36a22f8 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
@@ -223,12 +223,12 @@ void tst_qdiriterator::fsiterator()
int c = 0;
dump && printf("\n\n\n\n");
- QFileSystemIterator dir(dirpath,
+ QDirIteratorTest::QFileSystemIterator dir(dirpath,
//QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot,
//QDir::AllEntries | QDir::Hidden,
//QDir::Files | QDir::NoDotAndDotDot,
QDir::Files,
- QFileSystemIterator::Subdirectories);
+ QDirIteratorTest::QFileSystemIterator::Subdirectories);
for (; !dir.atEnd(); dir.next()) {
dump && printf("%d %s\n",
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
index 1b28f462aa..a4db21742d 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
@@ -99,6 +99,8 @@
QT_BEGIN_NAMESPACE
+namespace QDirIteratorTest {
+
class QFileSystemIteratorPrivate
{
public:
@@ -671,4 +673,6 @@ QString QFileSystemIterator::path() const
return QString::fromLocal8Bit(d->m_dirPaths.top());
}
+} // QDirIteratorTest::
+
QT_END_NAMESPACE
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
index b940c0061b..96fa5177a0 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
@@ -38,6 +38,7 @@
QT_BEGIN_NAMESPACE
+namespace QDirIteratorTest {
class QFileSystemIteratorPrivate;
class //Q_CORE_EXPORT
@@ -81,6 +82,8 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemIterator::IteratorFlags)
+} // namespace QDirIteratorTest
+
QT_END_NAMESPACE
#endif
diff --git a/tests/benchmarks/corelib/tools/qringbuffer/main.cpp b/tests/benchmarks/corelib/tools/qringbuffer/main.cpp
index 6bb82a8056..cf55aeaee5 100644
--- a/tests/benchmarks/corelib/tools/qringbuffer/main.cpp
+++ b/tests/benchmarks/corelib/tools/qringbuffer/main.cpp
@@ -48,10 +48,10 @@ void tst_qringbuffer::reserveAndRead()
{
QRingBuffer ringBuffer;
QBENCHMARK {
- for (int i = 1; i < 256; ++i)
+ for (qint64 i = 1; i < 256; ++i)
ringBuffer.reserve(i);
- for (int i = 1; i < 256; ++i)
+ for (qint64 i = 1; i < 256; ++i)
ringBuffer.read(0, i);
}
}
diff --git a/tests/benchmarks/gui/text/qtext/main.cpp b/tests/benchmarks/gui/text/qtext/main.cpp
index 224d9619ec..f20b3f6cce 100644
--- a/tests/benchmarks/gui/text/qtext/main.cpp
+++ b/tests/benchmarks/gui/text/qtext/main.cpp
@@ -42,7 +42,7 @@
#include <QBuffer>
#include <qtest.h>
-Q_DECLARE_METATYPE(QList<QTextLayout::FormatRange>)
+Q_DECLARE_METATYPE(QVector<QTextLayout::FormatRange>)
class tst_QText: public QObject
{
@@ -324,13 +324,13 @@ void tst_QText::layout()
void tst_QText::formattedLayout_data()
{
QTest::addColumn<QString>("text");
- QTest::addColumn<QList<QTextLayout::FormatRange> >("ranges");
+ QTest::addColumn<QVector<QTextLayout::FormatRange> >("ranges");
QTextCharFormat format;
format.setForeground(QColor("steelblue"));
{
- QList<QTextLayout::FormatRange> ranges;
+ QVector<QTextLayout::FormatRange> ranges;
QTextLayout::FormatRange formatRange;
formatRange.format = format;
@@ -341,7 +341,7 @@ void tst_QText::formattedLayout_data()
QTest::newRow("short-single") << m_shortLorem << ranges;
}
{
- QList<QTextLayout::FormatRange> ranges;
+ QVector<QTextLayout::FormatRange> ranges;
QString text = m_lorem.repeated(100);
const int width = 1;
@@ -360,15 +360,15 @@ void tst_QText::formattedLayout_data()
void tst_QText::formattedLayout()
{
QFETCH(QString, text);
- QFETCH(QList<QTextLayout::FormatRange>, ranges);
+ QFETCH(QVector<QTextLayout::FormatRange>, ranges);
QTextLayout layout(text);
- layout.setAdditionalFormats(ranges);
+ layout.setFormats(ranges);
setupTextLayout(&layout);
QBENCHMARK {
QTextLayout layout(text);
- layout.setAdditionalFormats(ranges);
+ layout.setFormats(ranges);
setupTextLayout(&layout);
}
}
diff --git a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
index 63aa6f7250..b5937b76b0 100644
--- a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
+++ b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp
@@ -55,6 +55,8 @@ public slots:
private slots:
void benchmark_data() { generic_data(); }
void benchmark();
+ void benchmarkSelectPrepared_data() { generic_data(); }
+ void benchmarkSelectPrepared();
private:
// returns all database connections
@@ -264,4 +266,42 @@ void tst_QSqlQuery::benchmark()
tst_Databases::safeDropTable( db, tableName );
}
+void tst_QSqlQuery::benchmarkSelectPrepared()
+{
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+ if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 0).toInt() < 5)
+ QSKIP("Test requires MySQL >= 5.0");
+
+ QSqlQuery q(db);
+ const QString tableName(qTableName("benchmark", __FILE__, db));
+
+ tst_Databases::safeDropTable(db, tableName);
+
+ QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + "(id INT NOT NULL)"));
+
+ const int NUM_ROWS = 1000;
+ int expectedSum = 0;
+ QString fillQuery = "INSERT INTO " + tableName + " VALUES (0)";
+ for (int i = 1; i < NUM_ROWS; ++i) {
+ fillQuery += ", (" + QString::number(i) + ")";
+ expectedSum += i;
+ }
+ QVERIFY_SQL(q, exec(fillQuery));
+
+ QVERIFY_SQL(q, prepare("SELECT id FROM "+tableName));
+ QBENCHMARK {
+ QVERIFY_SQL(q, exec());
+ int sum = 0;
+
+ while (q.next())
+ sum += q.value(0).toInt();
+
+ QCOMPARE(sum, expectedSum);
+ }
+
+ tst_Databases::safeDropTable(db, tableName);
+}
+
#include "main.moc"
diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm
index 5dd546479e..23370b0305 100644
--- a/tests/manual/cocoa/qt_on_cocoa/main.mm
+++ b/tests/manual/cocoa/qt_on_cocoa/main.mm
@@ -31,123 +31,35 @@
**
****************************************************************************/
-#include <QtGui>
-#include <QtDeclarative>
+#include "rasterwindow.h"
+#include <QtGui>
#include <QtWidgets/QtWidgets>
-#include <private/qwidgetwindow_p.h>
-#include <QtGui/qpa/qplatformnativeinterface.h>
-
-#include <QtGui/QPixmap>
-
-#include "window.h"
#include <Cocoa/Cocoa.h>
-
-@interface FilledView : NSView
-{
-
+@interface AppDelegate : NSObject <NSApplicationDelegate> {
+ QGuiApplication *m_app;
+ QWindow *m_window;
}
+- (AppDelegate *) initWithArgc:(int)argc argv:(const char **)argv;
+- (void) applicationWillFinishLaunching: (NSNotification *)notification;
+- (void)applicationWillTerminate:(NSNotification *)notification;
@end
-@implementation FilledView
-
-- (void)drawRect:(NSRect)dirtyRect {
- // set any NSColor for filling, say white:
- [[NSColor redColor] setFill];
- NSRectFill(dirtyRect);
-}
-
-@end
-
-@interface QtMacToolbarDelegate : NSObject <NSToolbarDelegate>
+@implementation AppDelegate
+- (AppDelegate *) initWithArgc:(int)argc argv:(const char **)argv
{
-@public
- NSToolbar *toolbar;
-}
-
-- (id)init;
-- (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted;
-- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)tb;
-- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar;
-- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar;
-@end
-
-@implementation QtMacToolbarDelegate
-
-- (id)init
-{
- self = [super init];
- if (self) {
- }
+ m_app = new QGuiApplication(argc, const_cast<char **>(argv));
return self;
}
-- (void)dealloc
-{
- [super dealloc];
-}
-
-- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)tb
-{
- Q_UNUSED(tb);
- NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease];
-// [array addObject : NSToolbarPrintItemIdentifier];
-// [array addObject : NSToolbarShowColorsItemIdentifier];
- [array addObject : @"filledView"];
- return array;
-}
-
-- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)tb
-{
- Q_UNUSED(tb);
- NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease];
-// [array addObject : NSToolbarPrintItemIdentifier];
-// [array addObject : NSToolbarShowColorsItemIdentifier];
- [array addObject : @"filledView"];
- return array;
-}
-
-- (NSArray *)toolbarSelectableItemIdentifiers: (NSToolbar *)tb
-{
- Q_UNUSED(tb);
- NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease];
- return array;
-}
-
-- (IBAction)itemClicked:(id)sender
+- (void) applicationWillFinishLaunching: (NSNotification *)notification
{
+ Q_UNUSED(notification);
-}
-
-- (NSToolbarItem *) toolbar: (NSToolbar *)tb itemForItemIdentifier: (NSString *) itemIdentifier willBeInsertedIntoToolbar:(BOOL) willBeInserted
-{
- Q_UNUSED(tb);
- Q_UNUSED(willBeInserted);
- //const QString identifier = toQString(itemIdentifier);
- //NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
- //return toolbarItem;
-
- //NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
- NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
- FilledView *theView = [[FilledView alloc] init];
- [toolbarItem setView : theView];
- [toolbarItem setMinSize : NSMakeSize(400, 40)];
- [toolbarItem setMaxSize : NSMakeSize(4000, 40)];
- return toolbarItem;
-}
-@end
-
-@interface WindowAndViewAndQtCreator : NSObject {}
-- (void)createWindowAndViewAndQt;
-@end
-
-@implementation WindowAndViewAndQtCreator
-- (void)createWindowAndViewAndQt {
-
- // Create the window
+ // Create the NSWindow
NSRect frame = NSMakeRect(500, 500, 500, 500);
NSWindow* window = [[NSWindow alloc] initWithContentRect:frame
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask
@@ -156,49 +68,31 @@
NSString *title = @"This the NSWindow window";
[window setTitle:title];
-
[window setBackgroundColor:[NSColor blueColor]];
- // Create a tool bar, set Qt delegate
- NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier : @"foobartoolbar"];
- QtMacToolbarDelegate *delegate = [[QtMacToolbarDelegate alloc] init];
- [toolbar setDelegate : delegate];
- [window setToolbar : toolbar];
-
- // Create the QWindow, don't show it.
- Window *qtWindow = new Window();
- qtWindow->create();
-
- //QSGView *qtWindow = new QSGView();
- //qtWindow->setSource(QUrl::fromLocalFile("/Users/msorvig/code/qt5/qtdeclarative/examples/declarative/samegame/samegame.qml"));
- // qtWindow->setWindowFlags(Qt::WindowType(13)); // 13: NativeEmbeddedWindow
-
- // Get the nsview from the QWindow, set it as the content view
- // on the NSWindow created above.
- QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface();
- NSView *qtView = (NSView *)platformNativeInterface->nativeResourceForWindow("nsview", qtWindow);
- [window setContentView:qtView];
+ // Create the QWindow, use its NSView as the content view
+ m_window = new RasterWindow();
+ [window setContentView:reinterpret_cast<NSView *>(m_window->winId())];
+
+ // Show the NSWindow
[window makeKeyAndOrderFront:NSApp];
}
-@end
-int main(int argc, char *argv[])
+- (void)applicationWillTerminate:(NSNotification *)notification
{
- QGuiApplication app(argc, argv);
-
- // fake NSApplicationMain() implementation follows:
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- [NSApplication sharedApplication];
+ Q_UNUSED(notification);
+ delete m_window;
+ delete m_app;
+}
- // schedule call to create the UI.
- WindowAndViewAndQtCreator *windowAndViewAndQtCreator= [WindowAndViewAndQtCreator alloc];
- [NSTimer scheduledTimerWithTimeInterval:0 target:windowAndViewAndQtCreator selector:@selector(createWindowAndViewAndQt) userInfo:nil repeats:NO];
+@end
- [(NSApplication *)NSApp run];
- [NSApp release];
- [pool release];
- exit(0);
- return 0;
+int main(int argc, const char *argv[])
+{
+ // Create NSApplicaiton with delgate
+ NSApplication *app =[NSApplication sharedApplication];
+ app.delegate = [[AppDelegate alloc] initWithArgc:argc argv:argv];
+ return NSApplicationMain (argc, argv);
}
diff --git a/tests/manual/cocoa/qt_on_cocoa/qt_on_cocoa.pro b/tests/manual/cocoa/qt_on_cocoa/qt_on_cocoa.pro
index 3d526909a5..97e4473e15 100644
--- a/tests/manual/cocoa/qt_on_cocoa/qt_on_cocoa.pro
+++ b/tests/manual/cocoa/qt_on_cocoa/qt_on_cocoa.pro
@@ -1,13 +1,11 @@
TEMPLATE = app
OBJECTIVE_SOURCES += main.mm
-HEADERS += window.h
-SOURCES += window.cpp
+HEADERS += rasterwindow.h
+SOURCES += rasterwindow.cpp
LIBS += -framework Cocoa
-QMAKE_INFO_PLIST = Info_mac.plist
-OTHER_FILES = Info_mac.plist
-QT += gui widgets widgets-private gui-private core-private
+QT += gui widgets quick
-QT += declarative
+QT += quick
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/manual/cocoa/qt_on_cocoa/window.cpp b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp
index 9929a50065..9b8f5e63ce 100644
--- a/tests/manual/cocoa/qt_on_cocoa/window.cpp
+++ b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp
@@ -31,9 +31,9 @@
**
****************************************************************************/
-#include "window.h"
+#include "rasterwindow.h"
-#include <private/qguiapplication_p.h>
+//#include <private/qguiapplication_p.h>
#include <QBackingStore>
#include <QPainter>
@@ -48,21 +48,14 @@ QColor colorTable[] =
QColor("#c0ef8f")
};
-Window::Window(QScreen *screen)
- : QWindow(screen)
+RasterWindow::RasterWindow(QRasterWindow *parent)
+ : QRasterWindow(parent)
, m_backgroundColorIndex(colorIndexId++)
{
initialize();
}
-Window::Window(QWindow *parent)
- : QWindow(parent)
- , m_backgroundColorIndex(colorIndexId++)
-{
- initialize();
-}
-
-void Window::initialize()
+void RasterWindow::initialize()
{
if (parent())
setGeometry(QRect(160, 120, 320, 240));
@@ -85,12 +78,12 @@ void Window::initialize()
m_renderTimer = 0;
}
-void Window::mousePressEvent(QMouseEvent *event)
+void RasterWindow::mousePressEvent(QMouseEvent *event)
{
m_lastPos = event->pos();
}
-void Window::mouseMoveEvent(QMouseEvent *event)
+void RasterWindow::mouseMoveEvent(QMouseEvent *event)
{
if (m_lastPos != QPoint(-1, -1)) {
QPainter p(&m_image);
@@ -102,7 +95,7 @@ void Window::mouseMoveEvent(QMouseEvent *event)
scheduleRender();
}
-void Window::mouseReleaseEvent(QMouseEvent *event)
+void RasterWindow::mouseReleaseEvent(QMouseEvent *event)
{
if (m_lastPos != QPoint(-1, -1)) {
QPainter p(&m_image);
@@ -114,16 +107,16 @@ void Window::mouseReleaseEvent(QMouseEvent *event)
scheduleRender();
}
-void Window::exposeEvent(QExposeEvent *)
+void RasterWindow::exposeEvent(QExposeEvent *)
{
scheduleRender();
}
-void Window::resizeEvent(QResizeEvent *)
+void RasterWindow::resizeEvent(QResizeEvent *)
{
QImage old = m_image;
- //qDebug() << "Window::resizeEvent" << width << height;
+ //qDebug() << "RasterWindow::resizeEvent" << width << height;
int width = qMax(geometry().width(), old.width());
int height = qMax(geometry().height(), old.height());
@@ -139,7 +132,7 @@ void Window::resizeEvent(QResizeEvent *)
render();
}
-void Window::keyPressEvent(QKeyEvent *event)
+void RasterWindow::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Backspace:
@@ -156,20 +149,20 @@ void Window::keyPressEvent(QKeyEvent *event)
scheduleRender();
}
-void Window::scheduleRender()
+void RasterWindow::scheduleRender()
{
if (!m_renderTimer)
m_renderTimer = startTimer(1);
}
-void Window::timerEvent(QTimerEvent *)
+void RasterWindow::timerEvent(QTimerEvent *)
{
render();
killTimer(m_renderTimer);
m_renderTimer = 0;
}
-void Window::render()
+void RasterWindow::render()
{
QRect rect(QPoint(), geometry().size());
diff --git a/tests/manual/cocoa/qt_on_cocoa/window.h b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.h
index a36180e0f3..1de66b5302 100644
--- a/tests/manual/cocoa/qt_on_cocoa/window.h
+++ b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.h
@@ -31,14 +31,13 @@
**
****************************************************************************/
-#include <QWindow>
+#include <QRasterWindow>
#include <QImage>
-class Window : public QWindow
+class RasterWindow : public QRasterWindow
{
public:
- Window(QWindow *parent = 0);
- Window(QScreen *screen);
+ RasterWindow(QRasterWindow *parent = 0);
protected:
void mousePressEvent(QMouseEvent *);
diff --git a/tests/manual/diaglib/eventfilter.cpp b/tests/manual/diaglib/eventfilter.cpp
index b35d29cc8a..6df885ebb6 100644
--- a/tests/manual/diaglib/eventfilter.cpp
+++ b/tests/manual/diaglib/eventfilter.cpp
@@ -190,8 +190,13 @@ static void formatApplicationState(QDebug debug)
debug << "\n QGuiApplication::modalWindow = ";
formatObject(mw, debug);
}
- debug << "\n QGuiApplication::focusWindow = ";
- formatObject(QGuiApplication::focusWindow(), debug);
+ const QObject *focusObject = QGuiApplication::focusObject();
+ const QObject *focusWindow = QGuiApplication::focusWindow();
+ debug << "\n QGuiApplication::focusObject = ";
+ formatObject(focusObject, debug);
+ if (focusWindow && focusWindow != focusObject)
+ debug << "\n QGuiApplication::focusWindow = ";
+ formatObject(focusWindow, debug);
#endif // HAVE_GUI_APPLICATION
}
diff --git a/tests/manual/highdpi/dragwidget.cpp b/tests/manual/highdpi/dragwidget.cpp
new file mode 100644
index 0000000000..b203566696
--- /dev/null
+++ b/tests/manual/highdpi/dragwidget.cpp
@@ -0,0 +1,223 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 or version 3 as published by the Free
+ ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+ ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+ ** following information to ensure the GNU Lesser General Public License
+ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#include <QtWidgets>
+#include "dragwidget.h"
+
+class FramedLabel : public QLabel
+{
+public:
+ FramedLabel(const QString &text, QWidget *parent)
+ : QLabel(text, parent)
+ {
+ setAutoFillBackground(true);
+ setFrameShape(QFrame::Panel);
+ setFrameShadow(QFrame::Raised);
+ }
+};
+
+DragWidget::DragWidget(QString text, QWidget *parent)
+ : QWidget(parent), otherWindow(0)
+{
+ int x = 5;
+ int y = 5;
+
+ bool createChildWindow = text.isEmpty(); // OK, yes this is a hack...
+ if (text.isEmpty())
+ text = "You can drag from this window and drop text here";
+
+ QStringList words = text.split(' ');
+ foreach (QString word, words) {
+ if (!word.isEmpty()) {
+ FramedLabel *wordLabel = new FramedLabel(word, this);
+ wordLabel->move(x, y);
+ wordLabel->show();
+ x += wordLabel->width() + 2;
+ if (x >= 245) {
+ x = 5;
+ y += wordLabel->height() + 2;
+ }
+ }
+ }
+
+ /*
+ QPalette newPalette = palette();
+ newPalette.setColor(QPalette::Window, Qt::white);
+ setPalette(newPalette);
+ */
+
+ setAcceptDrops(true);
+ setMinimumSize(400, qMax(200, y));
+ setWindowTitle(tr("Draggable Text Window %1").arg(createChildWindow ? 1 : 2));
+ if (createChildWindow)
+ otherWindow = new DragWidget("Here is a second window that accepts drops");
+}
+
+void DragWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasText()) {
+ if (event->source() == this) {
+ event->setDropAction(Qt::MoveAction);
+ event->accept();
+ } else {
+ event->acceptProposedAction();
+ }
+ } else {
+ event->ignore();
+ }
+}
+
+void DragWidget::dragMoveEvent(QDragMoveEvent * event)
+{
+ dragPos = event->pos();
+ dragTimer.start(500, this);
+ update();
+}
+
+void DragWidget::dragLeaveEvent(QDragLeaveEvent *)
+{
+ dragTimer.stop();
+ update();
+}
+
+
+void DragWidget::dropEvent(QDropEvent *event)
+{
+ if (event->mimeData()->hasText()) {
+ const QMimeData *mime = event->mimeData();
+ QStringList pieces = mime->text().split(QRegExp("\\s+"),
+ QString::SkipEmptyParts);
+ QPoint position = event->pos();
+ QPoint hotSpot;
+
+ QList<QByteArray> hotSpotPos = mime->data("application/x-hotspot").split(' ');
+ if (hotSpotPos.size() == 2) {
+ hotSpot.setX(hotSpotPos.first().toInt());
+ hotSpot.setY(hotSpotPos.last().toInt());
+ }
+ dropPos = position - hotSpot;
+ dropTimer.start(500, this);
+ update();
+
+ foreach (QString piece, pieces) {
+ FramedLabel *newLabel = new FramedLabel(piece, this);
+ newLabel->move(position - hotSpot);
+ newLabel->show();
+
+ position += QPoint(newLabel->width(), 0);
+ }
+
+ if (event->source() == this) {
+ event->setDropAction(Qt::MoveAction);
+ event->accept();
+ } else {
+ event->acceptProposedAction();
+ }
+ } else {
+ event->ignore();
+ }
+ foreach (QObject *child, children()) {
+ if (child->inherits("QWidget")) {
+ QWidget *widget = static_cast<QWidget *>(child);
+ if (!widget->isVisible())
+ widget->deleteLater();
+ }
+ }
+}
+
+void DragWidget::mousePressEvent(QMouseEvent *event)
+{
+ QLabel *child = static_cast<QLabel*>(childAt(event->pos()));
+ if (!child)
+ return;
+
+ QPoint hotSpot = event->pos() - child->pos();
+
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setText(child->text());
+ mimeData->setData("application/x-hotspot",
+ QByteArray::number(hotSpot.x()) + " " + QByteArray::number(hotSpot.y()));
+
+ QPixmap pixmap(child->size());
+ child->render(&pixmap);
+
+ QDrag *drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(pixmap);
+ drag->setHotSpot(hotSpot);
+
+ Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
+
+ if (dropAction == Qt::MoveAction)
+ child->close();
+}
+
+void DragWidget::timerEvent(QTimerEvent *e)
+{
+ if (e->timerId() == dragTimer.timerId())
+ dragTimer.stop();
+ if (e->timerId() == dropTimer.timerId())
+ dropTimer.stop();
+ update();
+}
+
+void DragWidget::paintEvent(QPaintEvent *)
+{
+ QPainter p(this);
+ p.fillRect(rect(), Qt::white);
+
+ if (dropTimer.isActive()) {
+ p.setBrush(Qt::red);
+ p.drawEllipse(dropPos, 50, 50);
+ }
+
+ if (dragTimer.isActive()) {
+ p.setPen(QPen(Qt::blue, 5));
+ QPoint p1 = (rect().topLeft()*3 + rect().bottomRight())/4;
+ QPoint p2 = (rect().topLeft() + rect().bottomRight()*3)/4;
+ p.drawLine(p1, dragPos);
+ p.drawLine(p2, dragPos);
+ }
+}
+
+void DragWidget::showEvent(QShowEvent *)
+{
+ if (otherWindow)
+ otherWindow->show();
+}
+
+void DragWidget::hideEvent(QHideEvent *)
+{
+ if (otherWindow)
+ otherWindow->hide();
+}
diff --git a/tests/manual/highdpi/dragwidget.h b/tests/manual/highdpi/dragwidget.h
new file mode 100644
index 0000000000..0d9631e2f8
--- /dev/null
+++ b/tests/manual/highdpi/dragwidget.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 or version 3 as published by the Free
+ ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+ ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+ ** following information to ensure the GNU Lesser General Public License
+ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#ifndef DRAGWIDGET_H
+#define DRAGWIDGET_H
+
+#include <QWidget>
+#include <QBasicTimer>
+
+QT_BEGIN_NAMESPACE
+class QDragEnterEvent;
+class QDropEvent;
+QT_END_NAMESPACE
+
+class DragWidget : public QWidget
+{
+public:
+ DragWidget(QString text = QString(), QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
+ void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
+ void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void dragMoveEvent(QDragMoveEvent * event) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
+ void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
+private:
+ QPoint dragPos;
+ QPoint dropPos;
+ QBasicTimer dragTimer;
+ QBasicTimer dropTimer;
+ QWidget *otherWindow;
+};
+
+#endif // DRAGWIDGET_H
diff --git a/tests/manual/highdpi/highdpi.pro b/tests/manual/highdpi/highdpi.pro
index 7a2979c74c..7d6b42535e 100644
--- a/tests/manual/highdpi/highdpi.pro
+++ b/tests/manual/highdpi/highdpi.pro
@@ -1,10 +1,17 @@
TEMPLATE = app
TARGET = highdpi
INCLUDEPATH += .
-QT += widgets
-CONFIG+=console
+QT += widgets gui-private
+CONFIG +=console
+CONFIG -= app_bundle
+CONFIG += c++11
# Input
-SOURCES += main.cpp
+SOURCES += \
+ dragwidget.cpp \
+ main.cpp
+
+HEADERS += \
+ dragwidget.h
RESOURCES += \
highdpi.qrc
diff --git a/tests/manual/highdpi/main.cpp b/tests/manual/highdpi/main.cpp
index fd14523a97..692a60d511 100644
--- a/tests/manual/highdpi/main.cpp
+++ b/tests/manual/highdpi/main.cpp
@@ -32,6 +32,7 @@
****************************************************************************/
#include <QMainWindow>
+#include <QMenuBar>
#include <QLabel>
#include <QHBoxLayout>
#include <QApplication>
@@ -39,6 +40,7 @@
#include <QStyle>
#include <QToolBar>
#include <QPushButton>
+#include <QButtonGroup>
#include <QLineEdit>
#include <QScrollBar>
#include <QSlider>
@@ -49,10 +51,219 @@
#include <QWindow>
#include <QScreen>
#include <QFile>
+#include <QMouseEvent>
#include <QTemporaryDir>
+#include <QTimer>
#include <QCommandLineParser>
#include <QCommandLineOption>
+#include <QDebug>
+#include <private/qhighdpiscaling_p.h>
+#include "dragwidget.h"
+
+class DemoContainerBase
+{
+public:
+ DemoContainerBase() : m_widget(0) {}
+ virtual ~DemoContainerBase() {}
+ QString name() { return option().names().first(); }
+ virtual QCommandLineOption &option() = 0;
+ virtual void makeVisible(bool visible, QWidget *parent) = 0;
+ QWidget *widget() { return m_widget; }
+protected:
+ QWidget *m_widget;
+};
+
+typedef QList<DemoContainerBase*> DemoContainerList ;
+
+
+template <class T>
+class DemoContainer : public DemoContainerBase
+{
+public:
+ DemoContainer(const QString &optionName, const QString &description)
+ : m_option(optionName, description)
+ {
+ }
+ ~DemoContainer() { delete m_widget; }
+
+ QCommandLineOption &option() { return m_option; }
+
+ void makeVisible(bool visible, QWidget *parent) {
+ if (visible && !m_widget) {
+ m_widget = new T;
+ m_widget->installEventFilter(parent);
+ }
+ if (m_widget)
+ m_widget->setVisible(visible);
+ }
+private:
+ QCommandLineOption m_option;
+};
+
+class LabelSlider : public QObject
+{
+Q_OBJECT
+public:
+ LabelSlider(QObject *parent, const QString &text, QGridLayout *layout, int row)
+ : QObject(parent)
+ {
+ QLabel *textLabel = new QLabel(text);
+ m_slider = new QSlider();
+ m_slider->setOrientation(Qt::Horizontal);
+ m_slider->setMinimum(1);
+ m_slider->setMaximum(40);
+ m_slider->setValue(10);
+ m_slider->setTracking(false);
+ m_slider->setTickInterval(5);
+ m_slider->setTickPosition(QSlider::TicksBelow);
+ m_label = new QLabel("1.0");
+
+ // set up layouts
+ layout->addWidget(textLabel, row, 0);
+ layout->addWidget(m_slider, row, 1);
+ layout->addWidget(m_label, row, 2);
+
+ // handle slider position change
+ connect(m_slider, &QSlider::sliderMoved, this, &LabelSlider::updateLabel);
+ connect(m_slider, &QSlider::valueChanged, this, &LabelSlider::valueChanged);
+ }
+ void setValue(int scaleFactor) {
+ m_slider->setValue(scaleFactor);
+ updateLabel(scaleFactor);
+ }
+private slots:
+ void updateLabel(int scaleFactor) {
+ // slider value is scale factor times ten;
+ qreal scalefactorF = qreal(scaleFactor) / 10.0;
+
+ // update label, add ".0" if needed.
+ QString number = QString::number(scalefactorF);
+ if (!number.contains("."))
+ number.append(".0");
+ m_label->setText(number);
+ }
+signals:
+ void valueChanged(int scaleFactor);
+private:
+ QSlider *m_slider;
+ QLabel *m_label;
+};
+
+static qreal getScreenFactorWithoutPixelDensity(const QScreen *screen)
+{
+ // this is a hack that relies on knowing the internals of QHighDpiScaling
+ static const char *scaleFactorProperty = "_q_scaleFactor";
+ QVariant screenFactor = screen->property(scaleFactorProperty);
+ return screenFactor.isValid() ? screenFactor.toReal() : 1.0;
+}
+
+static inline qreal getGlobalScaleFactor()
+{
+ QScreen *noScreen = 0;
+ return QHighDpiScaling::factor(noScreen);
+}
+
+class DemoController : public QWidget
+{
+Q_OBJECT
+public:
+ DemoController(DemoContainerList *demos, QCommandLineParser *parser);
+ ~DemoController();
+protected:
+ bool eventFilter(QObject *object, QEvent *event);
+ void closeEvent(QCloseEvent *) { qApp->quit(); }
+private slots:
+ void handleButton(int id, bool toggled);
+private:
+ DemoContainerList *m_demos;
+ QButtonGroup *m_group;
+};
+
+DemoController::DemoController(DemoContainerList *demos, QCommandLineParser *parser)
+ : m_demos(demos)
+{
+ setWindowTitle("screen scale factors");
+ setObjectName("controller"); // make WindowScaleFactorSetter skip this window
+
+ QGridLayout *layout = new QGridLayout;
+ setLayout(layout);
+
+ int layoutRow = 0;
+ LabelSlider *globalScaleSlider = new LabelSlider(this, "Global scale factor", layout, layoutRow++);
+ globalScaleSlider->setValue(int(getGlobalScaleFactor() * 10));
+ connect(globalScaleSlider, &LabelSlider::valueChanged, [](int scaleFactor){
+ // slider value is scale factor times ten;
+ qreal scalefactorF = qreal(scaleFactor) / 10.0;
+ QHighDpiScaling::setGlobalFactor(scalefactorF);
+ });
+
+ // set up one scale control line per screen
+ QList<QScreen *> screens = QGuiApplication::screens();
+ foreach (QScreen *screen, screens) {
+ // create scale control line
+ QSize screenSize = screen->geometry().size();
+ QString screenId = screen->name() + " " + QString::number(screenSize.width())
+ + " " + QString::number(screenSize.height());
+ LabelSlider *slider = new LabelSlider(this, screenId, layout, layoutRow++);
+ slider->setValue(getScreenFactorWithoutPixelDensity(screen) * 10);
+
+ // handle slider value change
+ connect(slider, &LabelSlider::valueChanged, [screen](int scaleFactor){
+ // slider value is scale factor times ten;
+ qreal scalefactorF = qreal(scaleFactor) / 10.0;
+
+ // set scale factor for screen
+ qreal oldFactor = QHighDpiScaling::factor(screen);
+ QHighDpiScaling::setScreenFactor(screen, scalefactorF);
+ qreal newFactor = QHighDpiScaling::factor(screen);
+
+ qDebug() << "factor was / is" << oldFactor << newFactor;
+ });
+ }
+
+ m_group = new QButtonGroup(this);
+ m_group->setExclusive(false);
+
+ for (int i = 0; i < m_demos->size(); ++i) {
+ DemoContainerBase *demo = m_demos->at(i);
+ QPushButton *button = new QPushButton(demo->name());
+ button->setToolTip(demo->option().description());
+ button->setCheckable(true);
+ layout->addWidget(button, layoutRow++, 0, 1, -1);
+ m_group->addButton(button, i);
+
+ if (parser->isSet(demo->option())) {
+ demo->makeVisible(true, this);
+ button->setChecked(true);
+ }
+ }
+ connect(m_group, SIGNAL(buttonToggled(int, bool)), this, SLOT(handleButton(int, bool)));
+}
+
+DemoController::~DemoController()
+{
+ qDeleteAll(*m_demos);
+}
+
+bool DemoController::eventFilter(QObject *object, QEvent *event)
+{
+ if (event->type() == QEvent::Close) {
+ for (int i = 0; i < m_demos->size(); ++i) {
+ DemoContainerBase *demo = m_demos->at(i);
+ if (demo->widget() == object) {
+ m_group->button(i)->setChecked(false);
+ break;
+ }
+ }
+ }
+ return false;
+}
+
+void DemoController::handleButton(int id, bool toggled)
+{
+ m_demos->at(id)->makeVisible(toggled, this);
+}
class PixmapPainter : public QWidget
{
@@ -69,7 +280,6 @@ public:
QIcon qtIcon;
};
-
PixmapPainter::PixmapPainter()
{
pixmap1X = QPixmap(":/qticon32.png");
@@ -172,15 +382,18 @@ class MainWindow : public QMainWindow
{
public:
MainWindow();
+ QMenu *addNewMenu(const QString &title, int itemCount = 5);
QIcon qtIcon;
QIcon qtIcon1x;
QIcon qtIcon2x;
QToolBar *fileToolBar;
+ int menuCount;
};
MainWindow::MainWindow()
+ :menuCount(0)
{
// beware that QIcon auto-loads the @2x versions.
qtIcon1x.addFile(":/qticon16.png");
@@ -192,8 +405,33 @@ MainWindow::MainWindow()
// fileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
fileToolBar->addAction(new QAction(qtIcon1x, QString("1x"), this));
fileToolBar->addAction(new QAction(qtIcon2x, QString("2x"), this));
+ addNewMenu("&Edit");
+ addNewMenu("&Build");
+ addNewMenu("&Debug", 4);
+ addNewMenu("&Transmogrify", 7);
+ addNewMenu("T&ools");
+ addNewMenu("&Help", 2);
}
+
+QMenu *MainWindow::addNewMenu(const QString &title, int itemCount)
+{
+ QMenu *menu = menuBar()->addMenu(title);
+ for (int i = 0; i < itemCount; i++) {
+ menuCount++;
+ QString s = "Menu item " + QString::number(menuCount);
+ if (i == 3) {
+ QMenu *subMenu = menu->addMenu(s);
+ for (int j = 1; j < 4; j++)
+ subMenu->addAction(QString::fromLatin1("SubMenu item %1.%2").arg(menuCount).arg(j));
+ } else {
+ menu->addAction(s);
+ }
+ }
+ return menu;
+}
+
+
class StandardIcons : public QWidget
{
public:
@@ -205,7 +443,7 @@ public:
int dy = 50;
int maxX = 500;
- for (int iconIndex = QStyle::SP_TitleBarMenuButton; iconIndex < QStyle::SP_MediaVolumeMuted; ++iconIndex) {
+ for (uint iconIndex = QStyle::SP_TitleBarMenuButton; iconIndex < QStyle::SP_MediaVolumeMuted; ++iconIndex) {
QIcon icon = qApp->style()->standardIcon(QStyle::StandardPixmap(iconIndex));
QPainter p(this);
p.drawPixmap(x, y, icon.pixmap(dx - 5, dy - 5));
@@ -295,14 +533,27 @@ public:
void paintEvent(QPaintEvent *)
{
QPainter painter(this);
- int y = 40;
- for (int fontSize = 2; fontSize < 18; fontSize += 2) {
+
+ // Points
+ int y = 10;
+ for (int fontSize = 6; fontSize < 18; fontSize += 2) {
QFont font;
font.setPointSize(fontSize);
- QString string = QString(QStringLiteral("%1 The quick brown fox jumped over the lazy Doug.")).arg(fontSize);
+ QString string = QString(QStringLiteral("This text is in point size %1")).arg(fontSize);
+ painter.setFont(font);
+ y += (painter.fontMetrics().lineSpacing());
+ painter.drawText(10, y, string);
+ }
+
+ // Pixels
+ y += painter.fontMetrics().lineSpacing();
+ for (int fontSize = 6; fontSize < 18; fontSize += 2) {
+ QFont font;
+ font.setPixelSize(fontSize);
+ QString string = QString(QStringLiteral("This text is in pixel size %1")).arg(fontSize);
painter.setFont(font);
+ y += (painter.fontMetrics().lineSpacing());
painter.drawText(10, y, string);
- y += (fontSize * 2.5);
}
}
};
@@ -461,97 +712,427 @@ public:
}
};
+class LinePainter : public QWidget
+{
+public:
+ void paintEvent(QPaintEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+
+ QPoint lastMousePoint;
+ QVector<QPoint> linePoints;
+};
-int main(int argc, char **argv)
+void LinePainter::paintEvent(QPaintEvent *)
{
- QApplication app(argc, argv);
- QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QPainter p(this);
+ p.fillRect(QRect(QPoint(0, 0), size()), QBrush(Qt::gray));
- QCommandLineParser parser;
- parser.setApplicationDescription("High DPI tester");
- parser.addHelpOption();
- parser.addVersionOption();
- QCommandLineOption pixmapPainterOption("pixmap", "Test pixmap painter");
- parser.addOption(pixmapPainterOption);
- QCommandLineOption labelOption("label", "Test Labels");
- parser.addOption(labelOption);
- QCommandLineOption mainWindowOption("mainwindow", "Test QMainWindow");
- parser.addOption(mainWindowOption);
- QCommandLineOption standardIconsOption("standard-icons", "Test standard icons");
- parser.addOption(standardIconsOption);
- QCommandLineOption cachingOption("caching", "Test caching");
- parser.addOption(cachingOption);
- QCommandLineOption styleOption("styles", "Test style");
- parser.addOption(styleOption);
- QCommandLineOption fontsOption("fonts", "Test fonts");
- parser.addOption(fontsOption);
- QCommandLineOption iconDrawingOption("icondrawing", "Test icon drawing");
- parser.addOption(iconDrawingOption);
- QCommandLineOption buttonsOption("buttons", "Test buttons");
- parser.addOption(buttonsOption);
+ // Default antialiased line
+ p.setRenderHint(QPainter::Antialiasing);
+ p.drawLines(linePoints);
+
+ // Cosmetic 1 antialiased line
+ QPen pen;
+ pen.setCosmetic(true);
+ pen.setWidth(1);
+ p.setPen(pen);
+ p.translate(3, 3);
+ p.drawLines(linePoints);
+
+ // Aliased cosmetic 1 line
+ p.setRenderHint(QPainter::Antialiasing, false);
+ p.translate(3, 3);
+ p.drawLines(linePoints);
+}
- parser.process(app);
+void LinePainter::mousePressEvent(QMouseEvent *event)
+{
+ lastMousePoint = event->pos();
+}
- QScopedPointer<PixmapPainter> pixmapPainter;
- if (parser.isSet(pixmapPainterOption)) {
- pixmapPainter.reset(new PixmapPainter);
- pixmapPainter->show();
+void LinePainter::mouseReleaseEvent(QMouseEvent *)
+{
+ lastMousePoint = QPoint();
+}
+
+void LinePainter::mouseMoveEvent(QMouseEvent *event)
+{
+ if (lastMousePoint.isNull())
+ return;
+
+ QPoint newMousePoint = event->pos();
+ if (lastMousePoint == newMousePoint)
+ return;
+ linePoints.append(lastMousePoint);
+ linePoints.append(newMousePoint);
+ lastMousePoint = newMousePoint;
+ update();
+}
+
+class CursorTester : public QWidget
+{
+public:
+ CursorTester()
+ :moveLabel(0), moving(false)
+ {
}
- QScopedPointer<Labels> label;
- if (parser.isSet(labelOption)) {
- label.reset(new Labels);
- label->resize(200, 200);
- label->show();
+ inline QRect getRect(int idx) const
+ {
+ int h = height() / 2;
+ return QRect(10, 10 + h * (idx - 1), width() - 20, h - 20);
+ }
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter p(this);
+ QRect r1 = getRect(1);
+ QRect r2 = getRect(2);
+ p.fillRect(r1, QColor(200, 200, 250));
+ p.drawText(r1, "Drag from here to move a window based on QCursor::pos()");
+ p.fillRect(r2, QColor(250, 200, 200));
+ p.drawText(r2, "Drag from here to move a window based on mouse event position");
+
+ if (moving) {
+ p.setPen(Qt::darkGray);
+ QFont f = font();
+ f.setPointSize(8);
+ p.setFont(f);
+ p.drawEllipse(mousePos, 30,60);
+ QPoint pt = mousePos - QPoint(0, 60);
+ QPoint pt2 = pt - QPoint(30,10);
+ QPoint offs(30, 0);
+ p.drawLine(pt, pt2);
+ p.drawLine(pt2 - offs, pt2 + offs);
+ p.drawText(pt2 - offs, "mouse pos");
+
+ p.setPen(QColor(50,130,70));
+ QPoint cursorPos = mapFromGlobal(QCursor::pos());
+ pt = cursorPos - QPoint(0, 30);
+ pt2 = pt + QPoint(60, -20);
+ p.drawEllipse(cursorPos, 60, 30);
+ p.drawLine(pt, pt2);
+ p.drawLine(pt2 - offs, pt2 + offs);
+ p.drawText(pt2 - offs, "cursor pos");
+ }
}
- QScopedPointer<MainWindow> mainWindow;
- if (parser.isSet(mainWindowOption)) {
- mainWindow.reset(new MainWindow);
- mainWindow->show();
+ void mousePressEvent(QMouseEvent *e)
+ {
+ if (moving)
+ return;
+ QRect r1 = getRect(1);
+ QRect r2 = getRect(2);
+
+ moving = r1.contains(e->pos()) || r2.contains(e->pos());
+ if (!moving)
+ return;
+ useCursorPos = r1.contains(e->pos());
+
+ if (!moveLabel)
+ moveLabel = new QLabel(this,Qt::BypassWindowManagerHint|Qt::FramelessWindowHint|Qt::Window );
+
+ if (useCursorPos)
+ moveLabel->setText("I'm following QCursor::pos()");
+ else
+ moveLabel->setText("I'm following QMouseEvent::globalPos()");
+ moveLabel->adjustSize();
+ mouseMoveEvent(e);
+ moveLabel->show();
}
- QScopedPointer<StandardIcons> icons;
- if (parser.isSet(standardIconsOption)) {
- icons.reset(new StandardIcons);
- icons->resize(510, 510);
- icons->show();
+ void mouseReleaseEvent(QMouseEvent *)
+ {
+ if (moveLabel)
+ moveLabel->hide();
+ update();
+ moving = false;
}
- QScopedPointer<Caching> caching;
- if (parser.isSet(cachingOption)) {
- caching.reset(new Caching);
- caching->resize(300, 300);
- caching->show();
+ void mouseMoveEvent(QMouseEvent *e)
+ {
+ if (!moving)
+ return;
+ QPoint pos = useCursorPos ? QCursor::pos() : e->globalPos();
+ pos -= moveLabel->rect().center();
+ moveLabel->move(pos);
+ mousePos = e->pos();
+ update();
}
- QScopedPointer<Style> style;
- if (parser.isSet(styleOption)) {
- style.reset(new Style);
- style->show();
+private:
+ QLabel *moveLabel;
+ bool useCursorPos;
+ bool moving;
+ QPoint mousePos;
+};
+
+
+class ScreenDisplayer : public QWidget
+{
+public:
+ ScreenDisplayer()
+ : QWidget(), moveLabel(0), scaleFactor(1.0)
+ {
}
- QScopedPointer<Fonts> fonts;
- if (parser.isSet(fontsOption)) {
- fonts.reset(new Fonts);
- fonts->show();
+ void timerEvent(QTimerEvent *) {
+ update();
}
- QScopedPointer<IconDrawing> iconDrawing;
- if (parser.isSet(iconDrawingOption)) {
- iconDrawing.reset(new IconDrawing);
- iconDrawing->show();
+ void mousePressEvent(QMouseEvent *) {
+ if (!moveLabel)
+ moveLabel = new QLabel(this,Qt::BypassWindowManagerHint|Qt::FramelessWindowHint|Qt::Window );
+ moveLabel->setText("Hello, Qt this is a label\nwith some text");
+ moveLabel->show();
+ }
+ void mouseMoveEvent(QMouseEvent *e) {
+ if (!moveLabel)
+ return;
+ moveLabel->move(e->pos() / scaleFactor);
+ QString str;
+ QDebug dbg(&str);
+ dbg.setAutoInsertSpaces(false);
+ dbg << moveLabel->geometry();
+ moveLabel->setText(str);
+ }
+ void mouseReleaseEvent(QMouseEvent *) {
+ if (moveLabel)
+ moveLabel->hide();
+ }
+ void showEvent(QShowEvent *) {
+ refreshTimer.start(300, this);
}
+ void hideEvent(QHideEvent *) {
+ refreshTimer.stop();
+ }
+ void paintEvent(QPaintEvent *) {
+ QPainter p(this);
+ QRectF total;
+ QList<QScreen*> screens = qApp->screens();
+ foreach (QScreen *screen, screens) {
+ total |= screen->geometry();
+ }
+ if (total.isEmpty())
+ return;
+
+ scaleFactor = qMin(width()/total.width(), height()/total.height());
+
+ p.fillRect(rect(), Qt::black);
+ p.scale(scaleFactor, scaleFactor);
+ p.translate(-total.topLeft());
+ p.setPen(QPen(Qt::white, 10));
+ p.setBrush(Qt::gray);
+
- QScopedPointer<Buttons> buttons;
- if (parser.isSet(buttonsOption)) {
- buttons.reset(new Buttons);
- buttons->show();
+ foreach (QScreen *screen, screens) {
+ p.drawRect(screen->geometry());
+ QFont f = font();
+ f.setPixelSize(screen->geometry().height() / 8);
+ p.setFont(f);
+ p.drawText(screen->geometry(), Qt::AlignCenter, screen->name());
+ }
+ p.setBrush(QColor(200,220,255,127));
+ foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ if (!widget->isHidden())
+ p.drawRect(widget->geometry());
+ }
+
+ QPolygon cursorShape;
+ cursorShape << QPoint(0,0) << QPoint(20, 60)
+ << QPoint(30, 50) << QPoint(60, 80)
+ << QPoint(80, 60) << QPoint(50, 30)
+ << QPoint(60, 20);
+ cursorShape.translate(QCursor::pos());
+ p.drawPolygon(cursorShape);
}
+private:
+ QLabel *moveLabel;
+ QBasicTimer refreshTimer;
+ qreal scaleFactor;
+};
+
+class PhysicalSizeTest : public QWidget
+{
+Q_OBJECT
+public:
+ PhysicalSizeTest() : QWidget(), m_ignoreResize(false) {}
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *) {
+ qreal ppi = window()->windowHandle()->screen()->physicalDotsPerInchX();
+ QSizeF s = size();
+ if (!m_ignoreResize)
+ m_physicalSize = s / ppi;
+ }
+ bool event(QEvent *event) {
+ if (event->type() == QEvent::ScreenChangeInternal) {
+ // we will get resize events when the scale factor changes
+ m_ignoreResize = true;
+ QTimer::singleShot(100, this, SLOT(handleScreenChange()));
+ }
+ return QWidget::event(event);
+ }
+public slots:
+ void handleScreenChange() {
+ qreal ppi = window()->windowHandle()->screen()->physicalDotsPerInchX();
+ QSizeF newSize = m_physicalSize * ppi;
+ resize(newSize.toSize());
+ m_ignoreResize = false;
+ }
+private:
+ QSizeF m_physicalSize;
+ bool m_ignoreResize;
+};
+
+void PhysicalSizeTest::paintEvent(QPaintEvent *)
+{
+ QPainter p(this);
+ p.setRenderHint(QPainter::Antialiasing);
+
+ qreal ppi = window()->windowHandle()->screen()->physicalDotsPerInchX();
+ qreal ppmm = ppi / 25.4;
+ qreal h = 15 * ppmm;
+ QRectF rulerRect(0,0, width(), h);
+ rulerRect.moveCenter(rect().center());
+
+ QFont f = font();
+ f.setPixelSize(18);
+ p.setFont(f);
+
+ // draw a rectangle in (Qt) pixel coordinates, for comparison
+ QRect pixelRect(0, 0, 300, 50);
+ pixelRect.moveTopLeft(QPoint(5 * ppmm, rulerRect.bottom() + 5 * ppmm));
+ p.fillRect(pixelRect, QColor(199,222,255));
+ p.drawText(pixelRect, "This rectangle is 300x50 pixels");
+
+ f.setPixelSize(4 * ppmm);
+ p.setFont(f);
+
+ QRectF topRect(0, 0, width(), rulerRect.top());
+ p.drawText(topRect, Qt::AlignCenter, "The ruler is drawn in physical units.\nThis window tries to keep its physical size\nwhen moved between screens.");
+
+ // draw a ruler in real physical coordinates
+
+ p.fillRect(rulerRect, QColor(255, 222, 111));
+
+ QPen linePen(Qt::black, 0.3 * ppmm);
+ p.setPen(linePen);
+ f.setBold(true);
+ p.setFont(f);
+
+ qreal vCenter = rulerRect.center().y();
+ p.drawLine(0, vCenter, width(), vCenter);
+
+ // cm
+ for (int i = 0;;) {
+ i++;
+ qreal x = i * ppmm;
+ if (x > width())
+ break;
+ qreal y = rulerRect.bottom();
+ qreal len;
+ if (i % 5)
+ len = 2 * ppmm;
+ else if (i % 10)
+ len = 3 * ppmm;
+ else
+ len = h / 2;
+
+ p.drawLine(QPointF(x, y), QPointF(x, y - len));
+ if (i % 10 == 5) {
+ QRectF textR(0, 0, 5 * ppmm, h / 2 - 2 * ppmm);
+ textR.moveTopLeft(QPointF(x, vCenter));
+ int n = i / 10 + 1;
+ if (n % 10 == 0)
+ p.setPen(Qt::red);
+ p.drawText(textR, Qt::AlignCenter, QString::number(n));
+ p.setPen(linePen);
+ }
+ }
+
+ //inches
+ for (int i = 0;;) {
+ i++;
+ qreal x = i * ppi / 16;
+ if (x > width())
+ break;
+ qreal y = rulerRect.top();
+
+ qreal d = h / 10;
+ qreal len;
+ if (i % 2)
+ len = 1 * d;
+ else if (i % 4)
+ len = 2 * d;
+ else if (i % 8)
+ len = 3 * d;
+ else if (i % 16)
+ len = 4 * d;
+ else
+ len = h / 2;
+
+ p.drawLine(QPointF(x, y), QPointF(x, y + len));
+ if (i % 16 == 12) {
+ QRectF textR(0, 0, 0.25 * ppi, h / 2 - 2 * d);
+ textR.moveBottomLeft(QPointF(x, vCenter));
+ p.drawText(textR, Qt::AlignCenter, QString::number(1 + i/16));
+ }
+ }
+
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+
+ int argumentCount = QCoreApplication::arguments().count();
+
+ QCommandLineParser parser;
+ parser.setApplicationDescription("High DPI tester. Pass one or more of the options to\n"
+ "test various high-dpi aspects. \n"
+ "--interactive is a special option and opens a configuration"
+ " window.");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption controllerOption("interactive", "Show configuration window.");
+ parser.addOption(controllerOption);
+
+
+ DemoContainerList demoList;
+ demoList << new DemoContainer<PixmapPainter>("pixmap", "Test pixmap painter");
+ demoList << new DemoContainer<Labels>("label", "Test Labels");
+ demoList << new DemoContainer<MainWindow>("mainwindow", "Test QMainWindow");
+ demoList << new DemoContainer<StandardIcons>("standard-icons", "Test standard icons");
+ demoList << new DemoContainer<Caching>("caching", "Test caching");
+ demoList << new DemoContainer<Style>("styles", "Test style");
+ demoList << new DemoContainer<Fonts>("fonts", "Test fonts");
+ demoList << new DemoContainer<IconDrawing>("icondrawing", "Test icon drawing");
+ demoList << new DemoContainer<Buttons>("buttons", "Test buttons");
+ demoList << new DemoContainer<LinePainter>("linepainter", "Test line painting");
+ demoList << new DemoContainer<DragWidget>("draganddrop", "Test drag and drop");
+ demoList << new DemoContainer<CursorTester>("cursorpos", "Test cursor and window positioning");
+ demoList << new DemoContainer<ScreenDisplayer>("screens", "Test screen and window positioning");
+ demoList << new DemoContainer<PhysicalSizeTest>("physicalsize", "Test manual highdpi support using physicalDotsPerInch");
+
+
+ foreach (DemoContainerBase *demo, demoList)
+ parser.addOption(demo->option());
+
+ parser.process(app);
+
+ //controller takes ownership of all demos
+ DemoController controller(&demoList, &parser);
+
+ if (parser.isSet(controllerOption) || argumentCount <= 1)
+ controller.show();
if (QApplication::topLevelWidgets().isEmpty())
parser.showHelp(0);
return app.exec();
}
+
+#include "main.moc"
diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp
index 1047ffcdfc..298996a59b 100644
--- a/tests/manual/qscreen/main.cpp
+++ b/tests/manual/qscreen/main.cpp
@@ -36,23 +36,127 @@
#include <QScreen>
#include <QWindow>
#include <QDebug>
+#include <QTextStream>
#include <QFormLayout>
+#include <QMainWindow>
+#include <QMenu>
+#include <QMenuBar>
+#include <QAction>
+#include <QStatusBar>
#include <QLineEdit>
#include <QDesktopWidget>
-int i = 0;
+class ScreenPropertyWatcher : public PropertyWatcher
+{
+ Q_OBJECT
+public:
+ ScreenPropertyWatcher(QWidget *wp = Q_NULLPTR) : PropertyWatcher(Q_NULLPTR, QString(), wp)
+ {
+ // workaround for the fact that virtualSiblings is not a property,
+ // thus there is no change notification:
+ // allow the user to update the field manually
+ connect(this, &PropertyWatcher::updatedAllFields, this, &ScreenPropertyWatcher::updateSiblings);
+ }
+
+ QScreen *screenSubject() const { return qobject_cast<QScreen *>(subject()); }
+ void setScreenSubject(QScreen *s, const QString &annotation = QString())
+ {
+ setSubject(s, annotation);
+ updateSiblings();
+ }
-typedef QHash<QScreen*, PropertyWatcher*> ScreensHash;
-Q_GLOBAL_STATIC(ScreensHash, props);
+public slots:
+ void updateSiblings();
+};
-void updateSiblings(PropertyWatcher* w)
+void ScreenPropertyWatcher::updateSiblings()
{
- QLineEdit *siblingsField = w->findChild<QLineEdit *>("siblings");
- QScreen* screen = (QScreen*)w->subject();
- QStringList siblingsList;
- foreach (QScreen *sibling, screen->virtualSiblings())
- siblingsList << sibling->name();
- siblingsField->setText(siblingsList.join(", "));
+ const QScreen *screen = screenSubject();
+ if (!screen)
+ return;
+ const QString objectName = QLatin1String("siblings");
+ QLineEdit *siblingsField = findChild<QLineEdit *>(objectName);
+ if (!siblingsField) {
+ siblingsField = new QLineEdit(this);
+ siblingsField->setObjectName(objectName);
+ siblingsField->setReadOnly(true);
+ formLayout()->insertRow(0, QLatin1String("virtualSiblings"), siblingsField);
+ }
+ QString text;
+ foreach (const QScreen *sibling, screen->virtualSiblings()) {
+ if (!text.isEmpty())
+ text += QLatin1String(", ");
+ text += sibling->name();
+ }
+ siblingsField->setText(text);
+}
+
+class ScreenWatcherMainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ explicit ScreenWatcherMainWindow(QScreen *screen);
+
+ QScreen *screenSubject() const { return m_watcher->screenSubject(); }
+
+protected:
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
+
+private:
+ const QString m_annotation;
+ ScreenPropertyWatcher *m_watcher;
+};
+
+static int i = 0;
+
+ScreenWatcherMainWindow::ScreenWatcherMainWindow(QScreen *screen)
+ : m_annotation(QLatin1Char('#') + QString::number(i++))
+ , m_watcher(new ScreenPropertyWatcher(this))
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+ setCentralWidget(m_watcher);
+ m_watcher->setScreenSubject(screen, m_annotation);
+
+ QMenu *fileMenu = menuBar()->addMenu(QLatin1String("&File"));
+ QAction *a = fileMenu->addAction(QLatin1String("Close"));
+ a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
+ connect(a, SIGNAL(triggered()), this, SLOT(close()));
+ a = fileMenu->addAction(QLatin1String("Quit"));
+ a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
+ connect(a, SIGNAL(triggered()), qApp, SLOT(quit()));
+}
+
+static inline QString msgScreenChange(const QWidget *w, const QScreen *oldScreen, const QScreen *newScreen)
+{
+ QString result;
+ const QRect geometry = w->geometry();
+ const QPoint pos = QCursor::pos();
+ if (!newScreen) {
+ result = QLatin1String("Screen changed --> null");
+ } else if (!oldScreen) {
+ QTextStream(&result) << "Screen changed null --> \""
+ << newScreen->name() << "\" at " << pos.x() << ',' << pos.y() << " geometry: "
+ << geometry.width() << 'x' << geometry.height() << forcesign << geometry.x()
+ << geometry.y() << '.';
+ } else {
+ QTextStream(&result) << "Screen changed \"" << oldScreen->name() << "\" --> \""
+ << newScreen->name() << "\" at " << pos.x() << ',' << pos.y() << " geometry: "
+ << geometry.width() << 'x' << geometry.height() << forcesign << geometry.x()
+ << geometry.y() << '.';
+ }
+ return result;
+}
+
+bool ScreenWatcherMainWindow::event(QEvent *event)
+{
+ if (event->type() == QEvent::ScreenChangeInternal) {
+ QScreen *newScreen = windowHandle()->screen();
+ const QString message = msgScreenChange(this, m_watcher->screenSubject(), newScreen);
+ qDebug().noquote() << message;
+ statusBar()->showMessage(message);
+ m_watcher->setScreenSubject(newScreen, m_annotation);
+ }
+ return QMainWindow::event(event);
}
void screenAdded(QScreen* screen)
@@ -60,12 +164,7 @@ void screenAdded(QScreen* screen)
screen->setOrientationUpdateMask((Qt::ScreenOrientations)0x0F);
qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), screen->virtualSiblings().count(),
(screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name())));
- PropertyWatcher *w = new PropertyWatcher(screen, QString::number(i++));
- QLineEdit *siblingsField = new QLineEdit();
- siblingsField->setObjectName("siblings");
- siblingsField->setReadOnly(true);
- w->layout()->insertRow(0, "virtualSiblings", siblingsField);
- updateSiblings(w);
+ ScreenWatcherMainWindow *w = new ScreenWatcherMainWindow(screen);
// Set the screen via QDesktopWidget. This corresponds to setScreen() for the underlying
// QWindow. This is essential when having separate X screens since the the positioning below is
@@ -84,18 +183,17 @@ void screenAdded(QScreen* screen)
geom.setHeight(screen->geometry().height() * 9 / 10);
geom.moveCenter(screen->geometry().center());
w->setGeometry(geom);
-
- props->insert(screen, w);
-
- // workaround for the fact that virtualSiblings is not a property,
- // thus there is no change notification:
- // allow the user to update the field manually
- QObject::connect(w, &PropertyWatcher::updatedAllFields, &updateSiblings);
}
void screenRemoved(QScreen* screen)
{
- delete props->take(screen);
+ const QWidgetList topLevels = QApplication::topLevelWidgets();
+ for (int i = topLevels.size() - 1; i >= 0; --i) {
+ if (ScreenWatcherMainWindow *sw = qobject_cast<ScreenWatcherMainWindow *>(topLevels.at(i))) {
+ if (sw->screenSubject() == screen)
+ sw->close();
+ }
+ }
}
int main(int argc, char *argv[])
@@ -108,3 +206,5 @@ int main(int argc, char *argv[])
QObject::connect((const QGuiApplication*)QGuiApplication::instance(), &QGuiApplication::screenRemoved, &screenRemoved);
return a.exec();
}
+
+#include "main.moc"
diff --git a/tests/manual/qscreen/propertywatcher.cpp b/tests/manual/qscreen/propertywatcher.cpp
index cfb5ea272d..b745ef5125 100644
--- a/tests/manual/qscreen/propertywatcher.cpp
+++ b/tests/manual/qscreen/propertywatcher.cpp
@@ -35,33 +35,82 @@
#include <QMetaProperty>
#include <QFormLayout>
#include <QPushButton>
+#include <QLabel>
#include "propertyfield.h"
PropertyWatcher::PropertyWatcher(QObject *subject, QString annotation, QWidget *parent)
- : QWidget(parent), m_subject(subject), m_layout(new QFormLayout)
+ : QWidget(parent), m_subject(Q_NULLPTR), m_formLayout(new QFormLayout(this))
{
- setWindowTitle(QString("Properties of %1 %2 %3")
- .arg(subject->metaObject()->className()).arg(subject->objectName()).arg(annotation));
setMinimumSize(450, 300);
+ m_formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
+ setSubject(subject, annotation);
+}
+
+class UpdatesEnabledBlocker
+{
+ Q_DISABLE_COPY(UpdatesEnabledBlocker);
+public:
+ explicit UpdatesEnabledBlocker(QWidget *w) : m_widget(w)
+ {
+ m_widget->setUpdatesEnabled(false);
+ }
+ ~UpdatesEnabledBlocker()
+ {
+ m_widget->setUpdatesEnabled(true);
+ m_widget->update();
+ }
+
+private:
+ QWidget *m_widget;
+};
+
+void PropertyWatcher::setSubject(QObject *s, const QString &annotation)
+{
+ if (s == m_subject)
+ return;
+
+ UpdatesEnabledBlocker blocker(this);
+
+ if (m_subject) {
+ disconnect(m_subject, &QObject::destroyed, this, &PropertyWatcher::subjectDestroyed);
+ for (int i = m_formLayout->count() - 1; i >= 0; --i) {
+ QLayoutItem *item = m_formLayout->takeAt(i);
+ delete item->widget();
+ delete item;
+ }
+ window()->setWindowTitle(QString());
+ window()->setWindowIconText(QString());
+ }
+
+ m_subject = s;
+ if (!m_subject)
+ return;
+
const QMetaObject* meta = m_subject->metaObject();
+ QString title = QLatin1String("Properties ") + QLatin1String(meta->className());
+ if (!m_subject->objectName().isEmpty())
+ title += QLatin1Char(' ') + m_subject->objectName();
+ if (!annotation.isEmpty())
+ title += QLatin1Char(' ') + annotation;
+ window()->setWindowTitle(title);
- for (int i = 0; i < meta->propertyCount(); ++i) {
- QMetaProperty prop = meta->property(i);
+ for (int i = 0, count = meta->propertyCount(); i < count; ++i) {
+ const QMetaProperty prop = meta->property(i);
if (prop.isReadable()) {
- PropertyField* field = new PropertyField(m_subject, prop);
- m_layout->addRow(prop.name(), field);
+ QLabel *label = new QLabel(prop.name(), this);
+ PropertyField *field = new PropertyField(m_subject, prop, this);
+ m_formLayout->addRow(label, field);
+ if (!qstrcmp(prop.name(), "name"))
+ window()->setWindowIconText(prop.read(m_subject).toString());
+ label->setVisible(true);
+ field->setVisible(true);
}
}
- QPushButton *updateButton = new QPushButton("update");
- connect(updateButton, &QPushButton::clicked, this, &PropertyWatcher::updateAllFields);
- m_layout->addRow("", updateButton);
- m_layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
- setLayout(m_layout);
- connect(subject, &QObject::destroyed, this, &PropertyWatcher::subjectDestroyed);
-}
+ connect(m_subject, &QObject::destroyed, this, &PropertyWatcher::subjectDestroyed);
-PropertyWatcher::~PropertyWatcher()
-{
+ QPushButton *updateButton = new QPushButton(QLatin1String("Update"), this);
+ connect(updateButton, &QPushButton::clicked, this, &PropertyWatcher::updateAllFields);
+ m_formLayout->addRow(QString(), updateButton);
}
void PropertyWatcher::updateAllFields()
diff --git a/tests/manual/qscreen/propertywatcher.h b/tests/manual/qscreen/propertywatcher.h
index 7dccfe3672..01e448845a 100644
--- a/tests/manual/qscreen/propertywatcher.h
+++ b/tests/manual/qscreen/propertywatcher.h
@@ -44,10 +44,12 @@ class PropertyWatcher : public QWidget
Q_OBJECT
public:
- PropertyWatcher(QObject* subject, QString annotation = QString(), QWidget *parent = 0);
- ~PropertyWatcher();
- QFormLayout *layout() { return m_layout; }
- QObject* subject() { return m_subject; }
+ explicit PropertyWatcher(QObject* subject = Q_NULLPTR, QString annotation = QString(), QWidget *parent = Q_NULLPTR);
+
+ QFormLayout *formLayout() { return m_formLayout; }
+
+ QObject *subject() const { return m_subject; }
+ void setSubject(QObject *s, const QString &annotation = QString());
public slots:
void updateAllFields();
@@ -56,9 +58,9 @@ public slots:
signals:
void updatedAllFields(PropertyWatcher* sender);
-protected:
+private:
QObject* m_subject;
- QFormLayout * m_layout;
+ QFormLayout * m_formLayout;
};
#endif // PROPERTY_WATCHER_H
diff --git a/tests/manual/qscreen/qscreen.pro b/tests/manual/qscreen/qscreen.pro
index cec8bbf245..5d587db3f4 100644
--- a/tests/manual/qscreen/qscreen.pro
+++ b/tests/manual/qscreen/qscreen.pro
@@ -1,4 +1,5 @@
QT += core gui widgets
+CONFIG += console
TARGET = qscreen
TEMPLATE = app
diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp
index a3f21140cb..9456bd9b03 100644
--- a/tests/manual/qsysinfo/main.cpp
+++ b/tests/manual/qsysinfo/main.cpp
@@ -134,6 +134,7 @@ int main(int argc, char *argv[])
printf("QSysInfo::productType() = %s\n", qPrintable(QSysInfo::productType()));
printf("QSysInfo::productVersion() = %s\n", qPrintable(QSysInfo::productVersion()));
printf("QSysInfo::prettyProductName() = %s\n", qPrintable(QSysInfo::prettyProductName()));
+ printf("QSysInfo::machineHostName() = %s\n", qPrintable(QSysInfo::machineHostName()));
return 0;
}
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
index 2e4cb6658f..f1d838f01d 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
@@ -73,6 +73,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
mRot = event->rotation();
mButton = event->button();
mButtons = event->buttons();
+ mTimestamp = event->timestamp();
if (isVisible())
update();
break;
@@ -84,6 +85,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
mType = event->type();
mPos = event->pos();
mGPos = event->globalPos();
+ mTimestamp = event->timestamp();
}
default:
break;
@@ -122,6 +124,7 @@ void TabletWidget::paintEvent(QPaintEvent *)
eventInfo << QString("Global position: %1 %2").arg(QString::number(mGPos.x()), QString::number(mGPos.y()));
eventInfo << QString("Local position: %1 %2").arg(QString::number(mPos.x()), QString::number(mPos.y()));
+ eventInfo << QString("Timestamp: %1").arg(QString::number(mTimestamp));
if (mType == QEvent::TabletEnterProximity || mType == QEvent::TabletLeaveProximity
|| mType == QEvent::TabletMove || mType == QEvent::TabletPress
|| mType == QEvent::TabletRelease) {
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h
index 2861eb4814..95631be57b 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.h
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.h
@@ -65,6 +65,7 @@ private:
qreal mPress, mTangential, mRot;
qint64 mUnique;
bool mMouseToo;
+ ulong mTimestamp;
};
#endif // TABLETWIDGET_H
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
index 5a83decfa2..a6fddd4b18 100644
--- a/tests/manual/qtabletevent/regular_widgets/main.cpp
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -39,6 +39,7 @@
#include <QMenuBar>
#include <QMenu>
#include <QAction>
+#include <QStatusBar>
#include <QVector>
#include <QPainter>
#include <QCursor>
@@ -72,6 +73,9 @@ public:
public slots:
void clearPoints() { m_points.clear(); update(); }
+signals:
+ void stats(QString s);
+
protected:
void mouseDoubleClickEvent(QMouseEvent *event) { outputMouseEvent(event); }
void mouseMoveEvent(QMouseEvent *event) { outputMouseEvent(event); }
@@ -81,6 +85,7 @@ protected:
void tabletEvent(QTabletEvent *);
void paintEvent(QPaintEvent *);
+ void timerEvent(QTimerEvent *);
private:
void outputMouseEvent(QMouseEvent *event);
@@ -89,28 +94,36 @@ private:
bool m_lastIsTabletMove;
Qt::MouseButton m_lastButton;
QVector<TabletPoint> m_points;
+ int m_tabletMoveCount;
+ int m_paintEventCount;
};
EventReportWidget::EventReportWidget()
: m_lastIsMouseMove(false)
, m_lastIsTabletMove(false)
, m_lastButton(Qt::NoButton)
-{ }
+ , m_tabletMoveCount(0)
+ , m_paintEventCount(0)
+{
+ startTimer(1000);
+}
void EventReportWidget::paintEvent(QPaintEvent *)
{
QPainter p(this);
+ int lineSpacing = fontMetrics().lineSpacing();
+ int halfLineSpacing = lineSpacing / 2;
const QRectF geom = QRectF(QPoint(0, 0), size());
p.fillRect(geom, Qt::white);
p.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1,1)));
p.setPen(Qt::white);
QPainterPath ellipse;
- ellipse.addEllipse(0, 0, 50, 10);
+ ellipse.addEllipse(0, 0, halfLineSpacing * 5, halfLineSpacing);
foreach (const TabletPoint &t, m_points) {
if (geom.contains(t.pos)) {
QPainterPath pp;
- pp.addEllipse(t.pos, 8, 8);
- QRectF pointBounds(t.pos.x() - 10, t.pos.y() - 10, 20, 20);
+ pp.addEllipse(t.pos, halfLineSpacing, halfLineSpacing);
+ QRectF pointBounds(t.pos.x() - halfLineSpacing, t.pos.y() - halfLineSpacing, lineSpacing, lineSpacing);
switch (t.type) {
case TabletButtonPress:
p.fillPath(pp, Qt::darkGreen);
@@ -133,7 +146,7 @@ void EventReportWidget::paintEvent(QPaintEvent *)
p.drawPath(ellipse);
p.restore();
} else {
- p.drawEllipse(t.pos, t.pressure * 10.0, t.pressure * 10.0);
+ p.drawEllipse(t.pos, t.pressure * halfLineSpacing, t.pressure * halfLineSpacing);
}
p.setPen(Qt::white);
} else {
@@ -143,6 +156,7 @@ void EventReportWidget::paintEvent(QPaintEvent *)
}
}
}
+ ++m_paintEventCount;
}
void EventReportWidget::tabletEvent(QTabletEvent *event)
@@ -152,11 +166,13 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
switch (event->type()) {
case QEvent::TabletEnterProximity:
case QEvent::TabletLeaveProximity:
+ qDebug() << "proximity" << event;
break;
case QEvent::TabletMove:
m_points.push_back(TabletPoint(event->pos(), TabletMove, m_lastButton, event->pointerType(), event->pressure(), event->rotation()));
update();
isMove = true;
+ ++m_tabletMoveCount;
break;
case QEvent::TabletPress:
m_points.push_back(TabletPoint(event->pos(), TabletButtonPress, event->button(), event->pointerType(), event->rotation()));
@@ -192,6 +208,13 @@ void EventReportWidget::outputMouseEvent(QMouseEvent *event)
qDebug() << event;
}
+void EventReportWidget::timerEvent(QTimerEvent *)
+{
+ emit stats(QString("%1 moves/sec, %2 frames/sec").arg(m_tabletMoveCount).arg(m_paintEventCount));
+ m_tabletMoveCount = 0;
+ m_paintEventCount = 0;
+}
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
@@ -201,6 +224,7 @@ int main(int argc, char *argv[])
widget->setMinimumSize(640, 480);
QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
QObject::connect(fileMenu->addAction("Clear"), SIGNAL(triggered()), widget, SLOT(clearPoints()));
+ QObject::connect(widget, SIGNAL(stats(QString)), mainWindow.statusBar(), SLOT(showMessage(QString)));
QAction *quitAction = fileMenu->addAction("Quit");
QObject::connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp
index e1114d7f57..b7029767c9 100644
--- a/tests/manual/touch/main.cpp
+++ b/tests/manual/touch/main.cpp
@@ -32,21 +32,187 @@
****************************************************************************/
#include <QApplication>
+#include <QGesture>
#include <QLabel>
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QMainWindow>
#include <QSplitter>
+#include <QToolBar>
#include <QVector>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QPlainTextEdit>
+#include <QPainter>
+#include <QPainterPath>
#include <QPaintEvent>
#include <QScreen>
+#include <QSharedPointer>
#include <QDebug>
#include <QTextStream>
+bool optIgnoreTouch = false;
+QVector<Qt::GestureType> optGestures;
+
+static inline void drawCircle(const QPointF &center, qreal radius, const QColor &color, QPainter &painter)
+{
+ const QPen oldPen = painter.pen();
+ QPen pen = oldPen;
+ pen.setColor(color);
+ painter.setPen(pen);
+ painter.drawEllipse(center, radius, radius);
+ painter.setPen(oldPen);
+}
+
+static inline void fillCircle(const QPointF &center, qreal radius, const QColor &color, QPainter &painter)
+{
+ QPainterPath painterPath;
+ painterPath.addEllipse(center, radius, radius);
+ painter.fillPath(painterPath, color);
+}
+
+// Draws an arrow assuming a mathematical coordinate system, Y axis pointing
+// upwards, angle counterclockwise (that is, 45' is pointing up/right).
+static void drawArrow(const QPointF &center, qreal length, qreal angleDegrees,
+ const QColor &color, int arrowSize, QPainter &painter)
+{
+ painter.save();
+ painter.translate(center); // Transform center to (0,0) rotate and draw arrow pointing right.
+ painter.rotate(-angleDegrees);
+ QPen pen = painter.pen();
+ pen.setColor(color);
+ pen.setWidth(2);
+ painter.setPen(pen);
+ const QPointF endPoint(length, 0);
+ painter.drawLine(QPointF(0, 0), endPoint);
+ painter.drawLine(endPoint, endPoint + QPoint(-arrowSize, -arrowSize));
+ painter.drawLine(endPoint, endPoint + QPoint(-arrowSize, arrowSize));
+ painter.restore();
+}
+
+QDebug operator<<(QDebug debug, const QTouchDevice *d)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QTouchDevice(" << d->name() << ',';
+ switch (d->type()) {
+ case QTouchDevice::TouchScreen:
+ debug << "TouchScreen";
+ break;
+ case QTouchDevice::TouchPad:
+ debug << "TouchPad";
+ break;
+ }
+ debug << ", capabilities=" << d->capabilities()
+ << ", maximumTouchPoints=" << d->maximumTouchPoints() << ')';
+ return debug;
+}
+
+// Hierarchy of classes containing gesture parameters and drawing functionality.
+class Gesture {
+ Q_DISABLE_COPY(Gesture)
+public:
+ static Gesture *fromQGesture(const QWidget *w, const QGesture *source);
+ virtual ~Gesture() {}
+
+ virtual void draw(const QRectF &rect, QPainter &painter) const = 0;
+
+protected:
+ explicit Gesture(const QWidget *w, const QGesture *source) : m_type(source->gestureType())
+ , m_hotSpot(w->mapFromGlobal(source->hotSpot().toPoint()))
+ , m_hasHotSpot(source->hasHotSpot()) {}
+
+ QPointF drawHotSpot(const QRectF &rect, QPainter &painter) const
+ {
+ const QPointF h = m_hasHotSpot ? m_hotSpot : rect.center();
+ painter.drawEllipse(h, 15, 15);
+ return h;
+ }
+
+private:
+ Qt::GestureType m_type;
+ QPointF m_hotSpot;
+ bool m_hasHotSpot;
+};
+
+class PanGesture : public Gesture {
+public:
+ explicit PanGesture(const QWidget *w, const QPanGesture *source) : Gesture(w, source)
+ , m_offset(source->offset()) {}
+
+ void draw(const QRectF &rect, QPainter &painter) const Q_DECL_OVERRIDE
+ {
+ const QPointF hotSpot = drawHotSpot(rect, painter);
+ painter.drawLine(hotSpot, hotSpot + m_offset);
+ }
+
+private:
+ QPointF m_offset;
+};
+
+class SwipeGesture : public Gesture {
+public:
+ explicit SwipeGesture(const QWidget *w, const QSwipeGesture *source) : Gesture(w, source)
+ , m_horizontal(source->horizontalDirection()), m_vertical(source->verticalDirection())
+ , m_angle(source->swipeAngle()) {}
+
+ void draw(const QRectF &rect, QPainter &painter) const Q_DECL_OVERRIDE;
+
+private:
+ QSwipeGesture::SwipeDirection m_horizontal;
+ QSwipeGesture::SwipeDirection m_vertical;
+ qreal m_angle;
+};
+
+static qreal swipeDirectionAngle(QSwipeGesture::SwipeDirection d)
+{
+ switch (d) {
+ case QSwipeGesture::NoDirection:
+ case QSwipeGesture::Right:
+ break;
+ case QSwipeGesture::Left:
+ return 180;
+ case QSwipeGesture::Up:
+ return 90;
+ case QSwipeGesture::Down:
+ return 270;
+ }
+ return 0;
+}
+
+void SwipeGesture::draw(const QRectF &rect, QPainter &painter) const
+{
+ enum { arrowLength = 50, arrowHeadSize = 10 };
+ const QPointF hotSpot = drawHotSpot(rect, painter);
+ drawArrow(hotSpot, arrowLength, swipeDirectionAngle(m_horizontal), Qt::red, arrowHeadSize, painter);
+ drawArrow(hotSpot, arrowLength, swipeDirectionAngle(m_vertical), Qt::green, arrowHeadSize, painter);
+ drawArrow(hotSpot, arrowLength, m_angle, Qt::blue, arrowHeadSize, painter);
+}
+
+Gesture *Gesture::fromQGesture(const QWidget *w, const QGesture *source)
+{
+ Gesture *result = Q_NULLPTR;
+ switch (source->gestureType()) {
+ case Qt::TapGesture:
+ case Qt::TapAndHoldGesture:
+ case Qt::PanGesture:
+ result = new PanGesture(w, static_cast<const QPanGesture *>(source));
+ break;
+ case Qt::PinchGesture:
+ case Qt::CustomGesture:
+ case Qt::LastGestureType:
+ break;
+ case Qt::SwipeGesture:
+ result = new SwipeGesture(w, static_cast<const QSwipeGesture *>(source));
+ break;
+ }
+ return result;
+}
+
+typedef QSharedPointer<Gesture> GesturePtr;
+typedef QVector<GesturePtr> GesturePtrs;
+
typedef QVector<QEvent::Type> EventTypeVector;
class EventFilter : public QObject {
@@ -68,33 +234,189 @@ bool EventFilter::eventFilter(QObject *o, QEvent *e)
static int n = 0;
if (m_types.contains(e->type())) {
QString message;
- QDebug(&message) << '#' << n++ << ' ' << o->objectName() << ' ' << e;
+ QDebug debug(&message);
+ debug << '#' << n++ << ' ' << o->objectName() << ' ';
+ switch (e->type()) {
+ case QEvent::Gesture:
+ case QEvent::GestureOverride:
+ debug << static_cast<const QGestureEvent *>(e); // Special operator
+ break;
+ default:
+ debug << e;
+ break;
+ }
emit eventReceived(message);
}
return false;
}
+enum PointType {
+ TouchPoint,
+ MousePress,
+ MouseRelease
+};
+
+struct Point
+{
+ Point(const QPointF &p = QPoint(), PointType t = TouchPoint,
+ Qt::MouseEventSource s = Qt::MouseEventNotSynthesized) : pos(p), type(t), source(s) {}
+
+ QColor color() const;
+
+ QPointF pos;
+ PointType type;
+ Qt::MouseEventSource source;
+};
+
+QColor Point::color() const
+{
+ Qt::GlobalColor globalColor = Qt::black;
+ if (type != TouchPoint) {
+ switch (source) {
+ case Qt::MouseEventSynthesizedBySystem:
+ globalColor = Qt::red;
+ break;
+ case Qt::MouseEventSynthesizedByQt:
+ globalColor = Qt::blue;
+ break;
+ case Qt::MouseEventNotSynthesized:
+ break;
+ }
+ }
+ const QColor result(globalColor);
+ return type == MousePress ? result.lighter() : result;
+}
+
class TouchTestWidget : public QWidget {
+ Q_OBJECT
+ Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints)
public:
- explicit TouchTestWidget(QWidget *parent = 0) : QWidget(parent)
+ explicit TouchTestWidget(QWidget *parent = 0) : QWidget(parent), m_drawPoints(true)
{
setAttribute(Qt::WA_AcceptTouchEvents);
+ foreach (Qt::GestureType t, optGestures)
+ grabGesture(t);
}
- bool event(QEvent *event) Q_DECL_OVERRIDE
- {
- switch (event->type()) {
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
+ bool drawPoints() const { return m_drawPoints; }
+
+public slots:
+ void clearPoints();
+ void setDrawPoints(bool drawPoints);
+
+signals:
+ void logMessage(const QString &);
+
+protected:
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+
+private:
+ void handleGestureEvent(QGestureEvent *gestureEvent);
+
+ QVector<Point> m_points;
+ GesturePtrs m_gestures;
+ bool m_drawPoints;
+};
+
+void TouchTestWidget::clearPoints()
+{
+ if (!m_points.isEmpty() || !m_gestures.isEmpty()) {
+ m_points.clear();
+ m_gestures.clear();
+ update();
+ }
+}
+
+void TouchTestWidget::setDrawPoints(bool drawPoints)
+{
+ if (m_drawPoints != drawPoints) {
+ clearPoints();
+ m_drawPoints = drawPoints;
+ }
+}
+
+bool TouchTestWidget::event(QEvent *event)
+{
+ const QEvent::Type type = event->type();
+ switch (type) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ if (m_drawPoints) {
+ const QMouseEvent *me = static_cast<const QMouseEvent *>(event);
+ m_points.append(Point(me->localPos(),
+ type == QEvent::MouseButtonPress ? MousePress : MouseRelease,
+ me->source()));
+ update();
+ }
+ break;
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ if (m_drawPoints) {
+ foreach (const QTouchEvent::TouchPoint &p, static_cast<const QTouchEvent *>(event)->touchPoints())
+ m_points.append(Point(p.pos(), TouchPoint));
+ update();
+ }
+ case QEvent::TouchEnd:
+ if (optIgnoreTouch)
+ event->ignore();
+ else
event->accept();
- return true;
- default:
- break;
+ return true;
+ case QEvent::Gesture:
+ handleGestureEvent(static_cast<QGestureEvent *>(event));
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(event);
+}
+
+void TouchTestWidget::handleGestureEvent(QGestureEvent *gestureEvent)
+{
+ foreach (QGesture *gesture, gestureEvent->gestures()) {
+ if (optGestures.contains(gesture->gestureType())) {
+ switch (gesture->state()) {
+ case Qt::NoGesture:
+ break;
+ case Qt::GestureStarted:
+ case Qt::GestureUpdated:
+ gestureEvent->accept(gesture);
+ break;
+ case Qt::GestureFinished:
+ gestureEvent->accept(gesture);
+ if (Gesture *g = Gesture::fromQGesture(this, gesture)) {
+ m_gestures.append(GesturePtr(g));
+ update();
+ }
+ break;
+ case Qt::GestureCanceled:
+ emit logMessage(QLatin1String("=== Qt::GestureCanceled ==="));
+ break;
+ }
}
- return QWidget::event(event);
}
-};
+}
+
+void TouchTestWidget::paintEvent(QPaintEvent *)
+{
+ // Draw touch points as dots, mouse press as light filled circles, mouse release as circles.
+ QPainter painter(this);
+ const QRectF geom = QRectF(QPointF(0, 0), QSizeF(size()));
+ painter.fillRect(geom, Qt::white);
+ painter.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1, 1)));
+ foreach (const Point &point, m_points) {
+ if (geom.contains(point.pos)) {
+ const qreal radius = point.type == TouchPoint ? 1 : 4;
+ if (point.type == MouseRelease) {
+ drawCircle(point.pos, radius, point.color(), painter);
+ } else
+ fillCircle(point.pos, radius, point.color(), painter);
+ }
+ }
+ foreach (const GesturePtr &gp, m_gestures)
+ gp->draw(geom, painter);
+}
class MainWindow : public QMainWindow
{
@@ -108,7 +430,7 @@ public slots:
void dumpTouchDevices();
private:
- QWidget *m_touchWidget;
+ TouchTestWidget *m_touchWidget;
QPlainTextEdit *m_logTextEdit;
};
@@ -119,23 +441,38 @@ MainWindow::MainWindow()
setWindowTitle(QStringLiteral("Touch Event Tester ") + QT_VERSION_STR);
setObjectName("MainWin");
+ QToolBar *toolBar = new QToolBar(this);
+ addToolBar(Qt::TopToolBarArea, toolBar);
QMenu *fileMenu = menuBar()->addMenu("File");
- QAction *da = fileMenu->addAction(QStringLiteral("Dump devices"));
- da->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
- connect(da, SIGNAL(triggered()), this, SLOT(dumpTouchDevices()));
- QAction *qa = fileMenu->addAction(QStringLiteral("Quit"));
- qa->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
- connect(qa, SIGNAL(triggered()), this, SLOT(close()));
+ QAction *dumpDeviceAction = fileMenu->addAction(QStringLiteral("Dump devices"));
+ dumpDeviceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
+ connect(dumpDeviceAction, SIGNAL(triggered()), this, SLOT(dumpTouchDevices()));
+ toolBar->addAction(dumpDeviceAction);
+ QAction *clearLogAction = fileMenu->addAction(QStringLiteral("Clear Log"));
+ clearLogAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
+ connect(clearLogAction, SIGNAL(triggered()), m_logTextEdit, SLOT(clear()));
+ toolBar->addAction(clearLogAction);
+ QAction *toggleDrawPointAction = fileMenu->addAction(QStringLiteral("Draw Points"));
+ toggleDrawPointAction->setCheckable(true);
+ toggleDrawPointAction->setChecked(m_touchWidget->drawPoints());
+ connect(toggleDrawPointAction, SIGNAL(toggled(bool)), m_touchWidget, SLOT(setDrawPoints(bool)));
+ toolBar->addAction(toggleDrawPointAction);
+ QAction *clearPointAction = fileMenu->addAction(QStringLiteral("Clear Points"));
+ clearPointAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
+ connect(clearPointAction, SIGNAL(triggered()), m_touchWidget, SLOT(clearPoints()));
+ toolBar->addAction(clearPointAction);
+ QAction *quitAction = fileMenu->addAction(QStringLiteral("Quit"));
+ quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ toolBar->addAction(quitAction);
- QSplitter *mainSplitter = new QSplitter(Qt::Vertical);
+ QSplitter *mainSplitter = new QSplitter(Qt::Vertical, this);
m_touchWidget->setObjectName(QStringLiteral("TouchWidget"));
- const QSize screenSize = QGuiApplication::primaryScreen()->availableGeometry().size();
- m_touchWidget->setMinimumSize(screenSize / 2);
mainSplitter->addWidget(m_touchWidget);
+ connect(m_touchWidget, &TouchTestWidget::logMessage, this, &MainWindow::appendToLog);
m_logTextEdit->setObjectName(QStringLiteral("LogTextEdit"));
- m_logTextEdit->setMinimumHeight(screenSize.height() / 4);
mainSplitter->addWidget(m_logTextEdit);
setCentralWidget(mainSplitter);
@@ -165,19 +502,57 @@ int main(int argc, char *argv[])
const QCommandLineOption globalFilterOption(QStringLiteral("global"),
QStringLiteral("Global event filter"));
parser.addOption(globalFilterOption);
+
+ const QCommandLineOption ignoreTouchOption(QStringLiteral("ignore"),
+ QStringLiteral("Ignore touch events (for testing mouse emulation)."));
+ parser.addOption(ignoreTouchOption);
+ const QCommandLineOption noTouchLogOption(QStringLiteral("notouchlog"),
+ QStringLiteral("Do not log touch events (for testing gestures)."));
+ parser.addOption(noTouchLogOption);
+ const QCommandLineOption noMouseLogOption(QStringLiteral("nomouselog"),
+ QStringLiteral("Do not log mouse events (for testing gestures)."));
+ parser.addOption(noMouseLogOption);
+
+ const QCommandLineOption tapGestureOption(QStringLiteral("tap"), QStringLiteral("Grab tap gesture."));
+ parser.addOption(tapGestureOption);
+ const QCommandLineOption tapAndHoldGestureOption(QStringLiteral("tap-and-hold"),
+ QStringLiteral("Grab tap-and-hold gesture."));
+ parser.addOption(tapAndHoldGestureOption);
+ const QCommandLineOption panGestureOption(QStringLiteral("pan"), QStringLiteral("Grab pan gesture."));
+ parser.addOption(panGestureOption);
+ const QCommandLineOption pinchGestureOption(QStringLiteral("pinch"), QStringLiteral("Grab pinch gesture."));
+ parser.addOption(pinchGestureOption);
+ const QCommandLineOption swipeGestureOption(QStringLiteral("swipe"), QStringLiteral("Grab swipe gesture."));
+ parser.addOption(swipeGestureOption);
parser.process(QApplication::arguments());
+ optIgnoreTouch = parser.isSet(ignoreTouchOption);
+ if (parser.isSet(tapGestureOption))
+ optGestures.append(Qt::TapGesture);
+ if (parser.isSet(tapAndHoldGestureOption))
+ optGestures.append(Qt::TapAndHoldGesture);
+ if (parser.isSet(panGestureOption))
+ optGestures.append(Qt::PanGesture);
+ if (parser.isSet(pinchGestureOption))
+ optGestures.append(Qt::PinchGesture);
+ if (parser.isSet(swipeGestureOption))
+ optGestures.append(Qt::SwipeGesture);
MainWindow w;
+ const QSize screenSize = QGuiApplication::primaryScreen()->availableGeometry().size();
+ w.resize(screenSize / 2);
+ const QSize sizeDiff = screenSize - w.size();
+ w.move(sizeDiff.width() / 2, sizeDiff.height() / 2);
w.show();
- const QSize pos = QGuiApplication::primaryScreen()->availableGeometry().size() - w.size();
- w.move(pos.width() / 2, pos.height() / 2);
EventTypeVector eventTypes;
- eventTypes << QEvent::MouseButtonPress << QEvent::MouseButtonRelease
- << QEvent::MouseButtonDblClick
- << QEvent::TouchBegin << QEvent::TouchUpdate << QEvent::TouchEnd;
+ if (!parser.isSet(noMouseLogOption))
+ eventTypes << QEvent::MouseButtonPress << QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick;
if (parser.isSet(mouseMoveOption))
eventTypes << QEvent::MouseMove;
+ if (!parser.isSet(noTouchLogOption))
+ eventTypes << QEvent::TouchBegin << QEvent::TouchUpdate << QEvent::TouchEnd;
+ if (!optGestures.isEmpty())
+ eventTypes << QEvent::Gesture << QEvent::GestureOverride;
QObject *filterTarget = parser.isSet(globalFilterOption)
? static_cast<QObject *>(&a)
: static_cast<QObject *>(w.touchWidget());