summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/auto/android/runtests_androiddeployqt.pl13
-rw-r--r--tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp2
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp32
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp32
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp36
-rw-r--r--tests/auto/corelib/global/global.pro2
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp24
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp64
-rw-r--r--tests/auto/corelib/global/qhooks/qhooks.pro4
-rw-r--r--tests/auto/corelib/global/qhooks/tst_qhooks.cpp90
-rw-r--r--tests/auto/corelib/global/qlogging/app/app.pro3
-rw-r--r--tests/auto/corelib/global/qlogging/app/main.cpp31
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp260
-rw-r--r--tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp4
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp161
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp22
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp76
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp12
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp40
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp56
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp17
-rw-r--r--tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp139
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp20
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp17
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp257
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp53
-rw-r--r--tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp40
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp86
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp36
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp30
-rw-r--r--tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp21
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp115
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp324
-rw-r--r--tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp10
-rw-r--r--tests/auto/corelib/kernel/qmath/tst_qmath.cpp119
-rw-r--r--tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp14
-rw-r--r--tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp4
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp19
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp33
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp20
-rw-r--r--tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp6
-rw-r--r--tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp25
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp99
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp6
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp11
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp6
-rw-r--r--tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp1336
-rw-r--r--tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp38
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp57
-rw-r--r--tests/auto/corelib/tools/collections/.gitignore (renamed from tests/auto/other/collections/.gitignore)0
-rw-r--r--tests/auto/corelib/tools/collections/collections.pro (renamed from tests/auto/other/collections/collections.pro)0
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp (renamed from tests/auto/other/collections/tst_collections.cpp)156
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp46
-rw-r--r--tests/auto/corelib/tools/qdate/tst_qdate.cpp9
-rw-r--r--tests/auto/corelib/tools/qregularexpression/.gitignore1
-rw-r--r--tests/auto/corelib/tools/qregularexpression/forceoptimize/forceoptimize.pro8
-rw-r--r--tests/auto/corelib/tools/qregularexpression/forceoptimize/tst_qregularexpression_forceoptimize.cpp52
-rw-r--r--tests/auto/corelib/tools/qregularexpression/qregularexpression.pro2
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp71
-rw-r--r--tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp135
-rw-r--r--tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp6
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp285
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp144
-rw-r--r--tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp30
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp24
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp61
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp164
-rw-r--r--tests/auto/corelib/tools/tools.pro1
-rw-r--r--tests/auto/corelib/xml/qxmlstream/data/009.ref2
-rw-r--r--tests/auto/corelib/xml/qxmlstream/data/010.ref2
-rw-r--r--tests/auto/corelib/xml/qxmlstream/data/011.ref2
-rw-r--r--tests/auto/corelib/xml/qxmlstream/data/012.ref2
-rw-r--r--tests/auto/corelib/xml/qxmlstream/data/035.ref2
-rw-r--r--tests/auto/corelib/xml/qxmlstream/data/036.ref2
-rw-r--r--tests/auto/gui/image/qicoimageformat/icons/valid/yellow.curbin0 -> 4286 bytes
-rw-r--r--tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp19
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp163
-rw-r--r--tests/auto/gui/image/qpicture/tst_qpicture.cpp107
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp100
-rw-r--r--tests/auto/gui/kernel/kernel.pro1
-rw-r--r--tests/auto/gui/kernel/qclipboard/paster/main.cpp55
-rw-r--r--tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp79
-rw-r--r--tests/auto/gui/kernel/qguiapplication/icons/appicon.pngbin0 -> 175 bytes
-rw-r--r--tests/auto/gui/kernel/qguiapplication/icons/usericon.pngbin0 -> 14743 bytes
-rw-r--r--tests/auto/gui/kernel/qguiapplication/qguiapplication.pro2
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp79
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc6
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp6
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp61
-rw-r--r--tests/auto/gui/kernel/qpixelformat/qpixelformat.pro6
-rw-r--r--tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp243
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp155
-rw-r--r--tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp35
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp13
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp50
-rw-r--r--tests/auto/gui/painting/qpen/tst_qpen.cpp53
-rw-r--r--tests/auto/gui/qopengl/qopengl.pro2
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp283
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp134
-rw-r--r--tests/auto/gui/text/qrawfont/tst_qrawfont.cpp39
-rw-r--r--tests/auto/network/access/spdy/tst_spdy.cpp15
-rw-r--r--tests/auto/network/ssl/qsslcertificate/pkcs12/README8
-rw-r--r--tests/auto/network/ssl/qsslcertificate/pkcs12/inter.crt22
-rw-r--r--tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.crt23
-rw-r--r--tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.key32
-rw-r--r--tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.p12bin0 -> 3821 bytes
-rw-r--r--tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro3
-rw-r--r--tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp51
-rw-r--r--tests/auto/opengl/qgl/tst_qgl.cpp35
-rw-r--r--tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp20
-rw-r--r--tests/auto/opengl/qglthreads/tst_qglthreads.cpp53
-rw-r--r--tests/auto/other/compiler/compiler.pro4
-rw-r--r--tests/auto/other/compiler/othersource.cpp51
-rw-r--r--tests/auto/other/compiler/tst_compiler.cpp758
-rw-r--r--tests/auto/other/lancelot/scripts/text.qps12
-rw-r--r--tests/auto/other/other.pro1
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp237
-rw-r--r--tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp76
-rw-r--r--tests/auto/other/qobjectrace/tst_qobjectrace.cpp25
-rw-r--r--tests/auto/other/qvariant_common/tst_qvariant_common.h27
-rw-r--r--tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp168
-rw-r--r--tests/auto/testlib/selftests/expected_assert.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_assert.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_assert.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_badxml.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_badxml.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_badxml.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibcounting.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibcounting.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibeventcounter.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibtickcounter.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibwalltime.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_commandlinedata.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_commandlinedata.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_commandlinedata.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_counting.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_counting.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_counting.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_datatable.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_datatable.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_datatable.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_exceptionthrow.lightxml3
-rw-r--r--tests/auto/testlib/selftests/expected_exceptionthrow.xml3
-rw-r--r--tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_expectfail.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_expectfail.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_expectfail.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_failcleanup.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_failcleanup.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_failcleanup.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_failinit.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_failinit.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_failinit.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_failinitdata.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_failinitdata.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_failinitdata.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_fetchbogus.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_fetchbogus.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_fetchbogus.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_findtestdata.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_findtestdata.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_findtestdata.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_globaldata.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_globaldata.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_globaldata.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_longstring.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_longstring.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_longstring.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_maxwarnings.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_maxwarnings.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_maxwarnings.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_singleskip.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_singleskip.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_singleskip.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skip.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skip.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_skip.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipcleanup.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipcleanup.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipcleanup.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipinit.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipinit.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipinit.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipinitdata.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipinitdata.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_skipinitdata.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_strcmp.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_strcmp.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_strcmp.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_subtest.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_subtest.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_subtest.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_verbose1.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_verbose1.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_verbose1.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_verbose2.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_verbose2.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_verbose2.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.xunitxml1
-rw-r--r--tests/auto/testlib/selftests/expected_xunit.lightxml1
-rw-r--r--tests/auto/testlib/selftests/expected_xunit.xml1
-rw-r--r--tests/auto/testlib/selftests/expected_xunit.xunitxml1
-rwxr-xr-xtests/auto/testlib/selftests/generate_expected_output.py3
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp28
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp19
-rw-r--r--tests/auto/tools/qmake/testdata/functions/functions.pro9
-rw-r--r--tests/auto/tools/rcc/data/images/images.expected47
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp40
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp113
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp124
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp40
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp73
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp18
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp163
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp18
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp243
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp11
-rw-r--r--tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp6
-rw-r--r--tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp19
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp10
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp15
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp47
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp14
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro8
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp266
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp15
-rw-r--r--tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp28
-rw-r--r--tests/auto/widgets/widgets/widgets.pro2
-rw-r--r--tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp90
-rw-r--r--tests/benchmarks/corelib/tools/qdatetime/main.cpp6
-rw-r--r--tests/benchmarks/corelib/tools/qregexp/qregexp.pro2
-rw-r--r--tests/benchmarks/corelib/tools/qringbuffer/main.cpp84
-rw-r--r--tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro7
-rw-r--r--tests/benchmarks/corelib/tools/qstring/main.cpp6
-rw-r--r--tests/benchmarks/corelib/tools/tools.pro1
-rw-r--r--tests/benchmarks/gui/kernel/kernel.pro4
-rw-r--r--tests/benchmarks/gui/kernel/qapplication/main.cpp2
-rw-r--r--tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp60
-rw-r--r--tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp4
-rw-r--r--tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp2
-rw-r--r--tests/benchmarks/gui/text/qfontmetrics/main.cpp1
-rw-r--r--tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp2
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/main.mm2
-rw-r--r--tests/manual/dialogs/filedialogpanel.cpp15
-rw-r--r--tests/manual/dialogs/filedialogpanel.h3
-rw-r--r--tests/manual/dialogs/printdialogpanel.cpp12
-rw-r--r--tests/manual/highdpi/highdpi.pro2
-rw-r--r--tests/manual/highdpi/main.cpp176
-rw-r--r--tests/manual/manual.pro5
-rw-r--r--tests/manual/qopenglcontext/main.cpp54
-rw-r--r--tests/manual/qopenglcontext/qopenglcontext.pro9
-rw-r--r--tests/manual/qopenglcontext/qopenglcontextwindow.cpp173
-rw-r--r--tests/manual/qopenglcontext/qopenglcontextwindow.h76
-rw-r--r--tests/manual/qopenglcontext/qticon64.pngbin0 -> 6474 bytes
-rw-r--r--tests/manual/qopenglwidget/openglwidget/main.cpp17
-rw-r--r--tests/manual/qopenglwidget/openglwidget/openglwidget.cpp7
-rw-r--r--tests/manual/qopenglwidget/openglwidget/openglwidget.h2
-rw-r--r--tests/manual/qscreen/main.cpp11
-rw-r--r--tests/manual/qscreen/propertywatcher.cpp3
-rw-r--r--tests/manual/qtabletevent/device_information/main.cpp20
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.cpp34
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.h7
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp105
-rw-r--r--tests/manual/widgets/itemviews/itemviews.pro2
-rw-r--r--tests/manual/widgets/itemviews/qheaderview/qheaderview.pro (renamed from tests/manual/widgets/itemviews/qheaderview/qheaderviewtest.pro)0
-rw-r--r--tests/manual/widgets/itemviews/qtreeview/qtreeview.pro (renamed from tests/manual/widgets/itemviews/qtreeview/qtreeviewtest.pro)0
-rw-r--r--tests/manual/widgets/itemviews/qtreewidget/qtreewidget.pro (renamed from tests/manual/widgets/itemviews/qtreewidget/qtreewidgettest.pro)0
-rw-r--r--tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp67
-rw-r--r--tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro8
-rw-r--r--tests/manual/widgets/kernel/layoutreplace/layoutreplace.pro (renamed from tests/manual/widgets/kernel/layoutreplace/main.pro)0
-rw-r--r--tests/manual/widgets/kernel/qtooltip/qtooltip.pro (renamed from tests/manual/widgets/kernel/qtooltip/main.pro)0
-rw-r--r--tests/manual/widgets/qgraphicsview/rubberband/rubberband.pro (renamed from tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.pro)0
290 files changed, 9290 insertions, 1714 deletions
diff --git a/tests/auto/android/runtests_androiddeployqt.pl b/tests/auto/android/runtests_androiddeployqt.pl
index c949e1cf87..28fe976c50 100755
--- a/tests/auto/android/runtests_androiddeployqt.pl
+++ b/tests/auto/android/runtests_androiddeployqt.pl
@@ -79,6 +79,7 @@ my $total_failed = 0;
my $failed_insignificants = 0;
my $ci_use = 0;
my $start = time();
+my $uninstall = 0;
GetOptions('h|help' => \$help
, man => \$man
@@ -98,6 +99,7 @@ GetOptions('h|help' => \$help
, 'testcase=s' => \$testcase
, 'silent' => sub { $silent = 1 }
, 'ci' => sub { $ci_use = 1 }
+ , 'uninstall' => sub { $uninstall = 1 }
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;
@@ -300,6 +302,7 @@ sub waitForProcess
my $src_dir_qt=abs_path(dirname($0)."/../../..");
my $quadruplor_dir="$src_dir_qt/tests/auto/android";
my $qmake_path="$src_dir_qt/bin/qmake";
+my $androiddeployqt_path="$src_dir_qt/bin/androiddeployqt";
my $tests_dir="$src_dir_qt/tests$testsubset";
my $temp_dir=tempdir(CLEANUP => 1);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -349,6 +352,7 @@ sub startTest
{
#killProcess($packageName);
print "Someone should kill $packageName\n";
+ system("$adb_tool $device_serial uninstall $packageName") if ($uninstall);
return 1;
}
@@ -362,6 +366,7 @@ sub startTest
my $insig =
print_output("$output_dir/$output_file.txt", $packageName, $insignificance);
}
+ system("$adb_tool $device_serial uninstall $packageName") if ($uninstall);
return 1;
}
@@ -389,9 +394,9 @@ foreach (split("\n",$testsFiles))
print $res if (!$silent);
my $application=basename(cwd);
if ($silent) {
- $cmd="androiddeployqt --install ${deployqt_device_serial} --output ${temp_dir} --deployment debug --verbose --input android-libtst_${application}.so-deployment-settings.json >/dev/null 2>&1";
+ $cmd="$androiddeployqt_path --install ${deployqt_device_serial} --output ${temp_dir} --deployment debug --verbose --input android-libtst_${application}.so-deployment-settings.json >/dev/null 2>&1";
} else {
- $cmd="androiddeployqt --install ${deployqt_device_serial} --output ${temp_dir} --deployment debug --verbose --input android-libtst_${application}.so-deployment-settings.json";
+ $cmd="$androiddeployqt_path --install ${deployqt_device_serial} --output ${temp_dir} --deployment debug --verbose --input android-libtst_${application}.so-deployment-settings.json";
}
$res = qx(${cmd});
print $res if (!$silent);
@@ -496,6 +501,10 @@ Suppress output of system commands.
Enables checking if test is insignificant or not. Also prints test
summary after all tests has been executed.
+=item B<-uninstall>
+
+Uninstalls the test after has been executed.
+
=item B<-h --help>
Print a brief help message and exits.
diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
index f6d9d2c14f..c0a3ae6114 100644
--- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
@@ -137,7 +137,7 @@ private:
void tst_QAnimationGroup::emptyGroup()
{
QSequentialAnimationGroup group;
- QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy groupStateChangedSpy(&group, &QSequentialAnimationGroup::stateChanged);
QVERIFY(groupStateChangedSpy.isValid());
QCOMPARE(group.state(), QAnimationGroup::Stopped);
diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index 2021eefd8f..bbe9e1a816 100644
--- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -256,10 +256,10 @@ void tst_QParallelAnimationGroup::stateChanged()
group.addAnimation(anim3);
group.addAnimation(anim4);
- QSignalSpy spy1(anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy spy2(anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy spy3(anim3, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy spy4(anim4, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy spy1(anim1, &TestAnimation::stateChanged);
+ QSignalSpy spy2(anim2, &TestAnimation::stateChanged);
+ QSignalSpy spy3(anim3, &TestAnimation::stateChanged);
+ QSignalSpy spy4(anim4, &TestAnimation::stateChanged);
QVERIFY(spy1.isValid());
QVERIFY(spy2.isValid());
@@ -434,8 +434,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
anim.setEndValue(100);
anim.setDuration(200);
- QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy groupStateChangedSpy(&group, &QParallelAnimationGroup::stateChanged);
+ QSignalSpy childStateChangedSpy(&anim, &TestAnimation::stateChanged);
QVERIFY(groupStateChangedSpy.isValid());
QVERIFY(childStateChangedSpy.isValid());
@@ -601,8 +601,8 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
anim2.setEndValue(100);
anim2.setDuration(200);
- QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy stateChangedSpy1(&anim1, &TestAnimation::stateChanged);
+ QSignalSpy stateChangedSpy2(&anim2, &TestAnimation::stateChanged);
QVERIFY(stateChangedSpy1.isValid());
QVERIFY(stateChangedSpy2.isValid());
@@ -669,20 +669,20 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
anim3.setEndValue(100);
anim3.setDuration(10);
- QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy finishedSpy1(&anim1, SIGNAL(finished()));
+ QSignalSpy stateChangedSpy1(&anim1, &TestAnimation::stateChanged);
+ QSignalSpy finishedSpy1(&anim1, &TestAnimation::finished);
QVERIFY(stateChangedSpy1.isValid());
QVERIFY(finishedSpy1.isValid());
- QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy finishedSpy2(&anim2, SIGNAL(finished()));
+ QSignalSpy stateChangedSpy2(&anim2, &TestAnimation::stateChanged);
+ QSignalSpy finishedSpy2(&anim2, &TestAnimation::finished);
QVERIFY(stateChangedSpy2.isValid());
QVERIFY(finishedSpy2.isValid());
- QSignalSpy stateChangedSpy3(&anim3, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy finishedSpy3(&anim3, SIGNAL(finished()));
+ QSignalSpy stateChangedSpy3(&anim3, &TestAnimation::stateChanged);
+ QSignalSpy finishedSpy3(&anim3, &TestAnimation::finished);
QVERIFY(stateChangedSpy3.isValid());
QVERIFY(finishedSpy3.isValid());
@@ -760,7 +760,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
loopsForever.setDuration(100);
loopsForever.setLoopCount(-1);
- QSignalSpy stateChangedSpy(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy stateChangedSpy(&anim1, &TestAnimation::stateChanged);
QVERIFY(stateChangedSpy.isValid());
group.addAnimation(&anim1);
@@ -968,7 +968,7 @@ void tst_QParallelAnimationGroup::pauseResume()
{
QParallelAnimationGroup group;
TestAnimation2 *anim = new TestAnimation2(250, &group); // 0, duration = 250;
- QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy spy(anim, &TestAnimation::stateChanged);
QVERIFY(spy.isValid());
QCOMPARE(group.duration(), 250);
group.start();
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index dc731ee765..0dab56a9cc 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -230,9 +230,9 @@ void tst_QPropertyAnimation::statesAndSignals()
anim = new DummyPropertyAnimation;
anim->setDuration(100);
- QSignalSpy finishedSpy(anim, SIGNAL(finished()));
- QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy currentLoopSpy(anim, SIGNAL(currentLoopChanged(int)));
+ QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished);
+ QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged);
+ QSignalSpy currentLoopSpy(anim, &QPropertyAnimation::currentLoopChanged);
QVERIFY(finishedSpy.isValid());
QVERIFY(runningSpy.isValid());
@@ -311,8 +311,8 @@ void tst_QPropertyAnimation::deletion1()
QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object, "minimumWidth");
//test that the animation is deleted correctly depending of the deletion flag passed in start()
- QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+ QSignalSpy runningSpy(anim.data(), &QPropertyAnimation::stateChanged);
+ QSignalSpy finishedSpy(anim.data(), &QPropertyAnimation::finished);
QVERIFY(runningSpy.isValid());
QVERIFY(finishedSpy.isValid());
anim->setStartValue(10);
@@ -355,8 +355,8 @@ void tst_QPropertyAnimation::deletion2()
anim->setEndValue(20);
anim->setDuration(200);
- QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+ QSignalSpy runningSpy(anim.data(), &QPropertyAnimation::stateChanged);
+ QSignalSpy finishedSpy(anim.data(), &QPropertyAnimation::finished);
QVERIFY(runningSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -389,8 +389,8 @@ void tst_QPropertyAnimation::deletion3()
anim->setEndValue(20);
anim->setDuration(200);
- QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+ QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged);
+ QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished);
QVERIFY(runningSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -490,7 +490,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
//normal case: the animation finishes and is deleted
QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole");
anim->setEndValue(100);
- QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy runningSpy(anim.data(), &QVariantAnimation::stateChanged);
QVERIFY(runningSpy.isValid());
anim->start(QVariantAnimation::DeleteWhenStopped);
QTest::qWait(anim->duration() + 100);
@@ -501,7 +501,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
{
QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole");
anim->setEndValue(100);
- QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy runningSpy(anim.data(), &QVariantAnimation::stateChanged);
QVERIFY(runningSpy.isValid());
anim->start(QVariantAnimation::DeleteWhenStopped);
QTest::qWait(anim->duration()/2);
@@ -850,7 +850,7 @@ void tst_QPropertyAnimation::setStartEndValues()
void tst_QPropertyAnimation::zeroDurationStart()
{
DummyPropertyAnimation anim;
- QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy spy(&anim, &DummyPropertyAnimation::stateChanged);
QVERIFY(spy.isValid());
anim.setDuration(0);
QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
@@ -972,7 +972,7 @@ void tst_QPropertyAnimation::operationsInStates()
o.setProperty("ole", 42);
QPropertyAnimation anim(&o, "ole");
anim.setEndValue(100);
- QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy spy(&anim, &QPropertyAnimation::stateChanged);
QVERIFY(spy.isValid());
anim.stop();
@@ -1132,7 +1132,7 @@ void tst_QPropertyAnimation::valueChanged()
QPropertyAnimation anim(&o, "ole");
anim.setEndValue(5);
anim.setDuration(1000);
- QSignalSpy spy(&anim, SIGNAL(valueChanged(QVariant)));
+ QSignalSpy spy(&anim, &QPropertyAnimation::valueChanged);
QVERIFY(spy.isValid());
anim.start();
@@ -1263,8 +1263,8 @@ void tst_QPropertyAnimation::zeroLoopCount()
anim->setDuration(20);
anim->setLoopCount(0);
- QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+ QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged);
+ QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished);
QVERIFY(runningSpy.isValid());
QVERIFY(finishedSpy.isValid());
diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 51f07993cd..cbd484c016 100644
--- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -637,8 +637,8 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
sequence->addAnimation(a3_s_o1);
sequence->setLoopCount(2);
- QSignalSpy a1StateChangedSpy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy a1StateChangedSpy(a1_s_o1, &QVariantAnimation::stateChanged);
+ QSignalSpy seqStateChangedSpy(sequence, &QAnimationGroup::stateChanged);
QVERIFY(a1StateChangedSpy.isValid());
QVERIFY(seqStateChangedSpy.isValid());
@@ -744,8 +744,8 @@ void tst_QSequentialAnimationGroup::restart()
{
// sequence operating on same object/property
QAnimationGroup *sequence = new QSequentialAnimationGroup();
- QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimation*)));
- QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy seqCurrentAnimChangedSpy(static_cast<QSequentialAnimationGroup*>(sequence), &QSequentialAnimationGroup::currentAnimationChanged);
+ QSignalSpy seqStateChangedSpy(sequence, &QAnimationGroup::stateChanged);
QVERIFY(seqCurrentAnimChangedSpy.isValid());
QVERIFY(seqStateChangedSpy.isValid());
@@ -756,7 +756,7 @@ void tst_QSequentialAnimationGroup::restart()
for (int i = 0; i < 3; i++) {
anims[i] = new DummyPropertyAnimation;
anims[i]->setDuration(100);
- animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ animsStateChanged[i] = new QSignalSpy(anims[i], &QVariantAnimation::stateChanged);
QVERIFY(animsStateChanged[i]->isValid());
}
@@ -816,10 +816,10 @@ void tst_QSequentialAnimationGroup::looping()
QAbstractAnimation *a2_s_o1 = new DummyPropertyAnimation;
QAbstractAnimation *a3_s_o1 = new DummyPropertyAnimation;
- QSignalSpy a1Spy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy a2Spy(a2_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy a3Spy(a3_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy seqSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy a1Spy(a1_s_o1, &QAbstractAnimation::stateChanged);
+ QSignalSpy a2Spy(a2_s_o1, &QAbstractAnimation::stateChanged);
+ QSignalSpy a3Spy(a3_s_o1, &QAbstractAnimation::stateChanged);
+ QSignalSpy seqSpy(sequence, &QSequentialAnimationGroup::stateChanged);
QVERIFY(a1Spy.isValid());
QVERIFY(a2Spy.isValid());
@@ -833,7 +833,7 @@ void tst_QSequentialAnimationGroup::looping()
sequence->setLoopCount(2);
QSequentialAnimationGroup group;
- QSignalSpy groupSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy groupSpy(&group, &QSequentialAnimationGroup::stateChanged);
QVERIFY(groupSpy.isValid());
group.addAnimation(sequence);
@@ -1101,8 +1101,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
anim.setEndValue(100);
anim.setDuration(200);
- QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy groupStateChangedSpy(&group, &QSequentialAnimationGroup::stateChanged);
+ QSignalSpy childStateChangedSpy(&anim, &TestAnimation::stateChanged);
QVERIFY(groupStateChangedSpy.isValid());
QVERIFY(childStateChangedSpy.isValid());
@@ -1268,8 +1268,8 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild()
anim2->setEndValue(100);
anim2->setDuration(200);
- QSignalSpy stateChangedSpy1(anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- QSignalSpy stateChangedSpy2(anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy stateChangedSpy1(anim1, &TestAnimation::stateChanged);
+ QSignalSpy stateChangedSpy2(anim2, &TestAnimation::stateChanged);
QVERIFY(stateChangedSpy1.isValid());
QVERIFY(stateChangedSpy2.isValid());
@@ -1345,7 +1345,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
anim3->setEndValue(100);
anim3->setDuration(0);
- QSignalSpy stateChangedSpy(anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy stateChangedSpy(anim1, &TestAnimation::stateChanged);
QVERIFY(stateChangedSpy.isValid());
group.addAnimation(anim1);
@@ -1417,7 +1417,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
//first we test a group with one uncontrolled animation
QSequentialAnimationGroup group;
UncontrolledAnimation notTimeDriven(&o1, &group);
- QSignalSpy spy(&group, SIGNAL(finished()));
+ QSignalSpy spy(&group, &QSequentialAnimationGroup::finished);
QVERIFY(spy.isValid());
group.start();
@@ -1437,7 +1437,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
// lets make sure the seeking will work again
spy.clear();
DummyPropertyAnimation anim(&group);
- QSignalSpy animStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy animStateChangedSpy(&anim, &DummyPropertyAnimation::stateChanged);
QVERIFY(animStateChangedSpy.isValid());
group.setCurrentTime(300);
@@ -1639,7 +1639,7 @@ void tst_QSequentialAnimationGroup::pauseResume()
QPropertyAnimation *anim = new QPropertyAnimation(&dummy, "foo", &group);
anim->setDuration(250);
anim->setEndValue(250);
- QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ QSignalSpy spy(anim, &QPropertyAnimation::stateChanged);
QVERIFY(spy.isValid());
QCOMPARE(group.duration(), 250);
group.start();
diff --git a/tests/auto/corelib/global/global.pro b/tests/auto/corelib/global/global.pro
index c05905bd15..219e9de818 100644
--- a/tests/auto/corelib/global/global.pro
+++ b/tests/auto/corelib/global/global.pro
@@ -9,4 +9,4 @@ SUBDIRS=\
qlogging \
qtendian \
qglobalstatic \
-
+ qhooks
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index 73a69a1309..42add6150a 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -50,6 +50,7 @@ private slots:
void constExpr();
void signedness();
void classEnum();
+ void initializerLists();
};
void tst_QFlags::testFlag() const
@@ -143,6 +144,9 @@ enum class MyStrictEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 };
Q_DECLARE_FLAGS( MyStrictFlags, MyStrictEnum )
Q_DECLARE_OPERATORS_FOR_FLAGS( MyStrictFlags )
+enum class MyStrictNoOpEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 };
+Q_DECLARE_FLAGS( MyStrictNoOpFlags, MyStrictNoOpEnum )
+
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isComplex );
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isStatic );
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isLarge );
@@ -253,6 +257,26 @@ void tst_QFlags::classEnum()
#endif
}
+void tst_QFlags::initializerLists()
+{
+#if defined(Q_COMPILER_INITIALIZER_LISTS)
+ Qt::MouseButtons bts = { Qt::LeftButton, Qt::RightButton };
+ QVERIFY(bts.testFlag(Qt::LeftButton));
+ QVERIFY(bts.testFlag(Qt::RightButton));
+ QVERIFY(!bts.testFlag(Qt::MiddleButton));
+
+#if defined(Q_COMPILER_CLASS_ENUM)
+ MyStrictNoOpFlags flags = { MyStrictNoOpEnum::StrictOne, MyStrictNoOpEnum::StrictFour };
+ QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictOne));
+ QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictFour));
+ QVERIFY(!flags.testFlag(MyStrictNoOpEnum::StrictTwo));
+#endif // Q_COMPILER_CLASS_ENUM
+
+#else
+ QSKIP("This test requires C++11 initializer_list support.");
+#endif // Q_COMPILER_INITIALIZER_LISTS
+}
+
// (statically) check QTypeInfo for QFlags instantiations:
enum MyEnum { Zero, One, Two, Four=4 };
Q_DECLARE_FLAGS( MyFlags, MyEnum )
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 4eb3e4fc98..0389ae7976 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -43,6 +43,9 @@
#include <QtTest/QtTest>
#include <QtCore/qtypetraits.h>
+#include <QPair>
+#include <QTextCodec>
+
class tst_QGlobal: public QObject
{
Q_OBJECT
@@ -60,6 +63,8 @@ private slots:
void isEnum();
void qAlignOf();
void integerForSize();
+ void qprintable();
+ void qprintable_data();
};
void tst_QGlobal::qIsNull()
@@ -588,5 +593,64 @@ void tst_QGlobal::integerForSize()
Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Unsigned) == 8);
}
+typedef QPair<const char *, const char *> stringpair;
+Q_DECLARE_METATYPE(stringpair)
+
+void tst_QGlobal::qprintable()
+{
+ QFETCH(QList<stringpair>, localestrings);
+ QFETCH(int, utf8index);
+
+ QVERIFY(utf8index >= 0 && utf8index < localestrings.count());
+ if (utf8index < 0 || utf8index >= localestrings.count())
+ return;
+
+ const char *const utf8string = localestrings.at(utf8index).second;
+
+ QString string = QString::fromUtf8(utf8string);
+
+ foreach (const stringpair &pair, localestrings) {
+ QTextCodec *codec = QTextCodec::codecForName(pair.first);
+ if (!codec)
+ continue;
+ QTextCodec::setCodecForLocale(codec);
+ // test qPrintable()
+ QVERIFY(qstrcmp(qPrintable(string), pair.second) == 0);
+ foreach (const stringpair &pair2, localestrings) {
+ if (pair2.second == pair.second)
+ continue;
+ QVERIFY(qstrcmp(qPrintable(string), pair2.second) != 0);
+ }
+ // test qUtf8Printable()
+ QVERIFY(qstrcmp(qUtf8Printable(string), utf8string) == 0);
+ foreach (const stringpair &pair2, localestrings) {
+ if (qstrcmp(pair2.second, utf8string) == 0)
+ continue;
+ QVERIFY(qstrcmp(qUtf8Printable(string), pair2.second) != 0);
+ }
+ }
+
+ QTextCodec::setCodecForLocale(0);
+}
+
+void tst_QGlobal::qprintable_data()
+{
+ QTest::addColumn<QList<stringpair> >("localestrings");
+ QTest::addColumn<int>("utf8index"); // index of utf8 string
+
+ // Unicode: HIRAGANA LETTER A, I, U, E, O (U+3442, U+3444, U+3446, U+3448, U+344a)
+ static const char *const utf8string = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a";
+ static const char *const eucjpstring = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa";
+ static const char *const sjisstring = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8";
+
+ QList<stringpair> japanesestrings;
+ japanesestrings << stringpair("UTF-8", utf8string)
+ << stringpair("EUC-JP", eucjpstring)
+ << stringpair("Shift_JIS", sjisstring);
+
+ QTest::newRow("Japanese") << japanesestrings << 0;
+
+}
+
QTEST_APPLESS_MAIN(tst_QGlobal)
#include "tst_qglobal.moc"
diff --git a/tests/auto/corelib/global/qhooks/qhooks.pro b/tests/auto/corelib/global/qhooks/qhooks.pro
new file mode 100644
index 0000000000..f886e7d49a
--- /dev/null
+++ b/tests/auto/corelib/global/qhooks/qhooks.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase parallel_test
+TARGET = tst_qhooks
+QT = core-private testlib
+SOURCES = tst_qhooks.cpp
diff --git a/tests/auto/corelib/global/qhooks/tst_qhooks.cpp b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp
new file mode 100644
index 0000000000..817c0b8173
--- /dev/null
+++ b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Volker Krause <volker.krause@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtCore/private/qhooks_p.h>
+
+class tst_QHooks: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testVersion();
+ void testAddRemoveObject();
+};
+
+void tst_QHooks::testVersion()
+{
+ QVERIFY(qtHookData[QHooks::HookDataVersion] >= 1);
+ QCOMPARE(qtHookData[QHooks::HookDataSize], (quintptr)QHooks::LastHookIndex);
+ QCOMPARE(qtHookData[QHooks::QtVersion], (quintptr)QT_VERSION);
+}
+
+static int objectCount = 0;
+
+static void objectAddHook(QObject*)
+{
+ ++objectCount;
+}
+
+static void objectRemoveHook(QObject*)
+{
+ --objectCount;
+}
+
+void tst_QHooks::testAddRemoveObject()
+{
+ QCOMPARE(qtHookData[QHooks::AddQObject], (quintptr)0);
+ QCOMPARE(qtHookData[QHooks::RemoveQObject], (quintptr)0);
+
+ qtHookData[QHooks::AddQObject] = (quintptr)&objectAddHook;
+ qtHookData[QHooks::RemoveQObject] = (quintptr)&objectRemoveHook;
+
+ QCOMPARE(objectCount, 0);
+ QObject *obj = new QObject;
+ QVERIFY(objectCount > 0);
+ delete obj;
+ QCOMPARE(objectCount, 0);
+}
+
+QTEST_APPLESS_MAIN(tst_QHooks)
+#include "tst_qhooks.moc"
diff --git a/tests/auto/corelib/global/qlogging/app/app.pro b/tests/auto/corelib/global/qlogging/app/app.pro
index 24ac571bac..b11e792a4c 100644
--- a/tests/auto/corelib/global/qlogging/app/app.pro
+++ b/tests/auto/corelib/global/qlogging/app/app.pro
@@ -10,3 +10,6 @@ CONFIG += console
SOURCES += main.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+gcc:!mingw: QMAKE_LFLAGS += -rdynamic
+
diff --git a/tests/auto/corelib/global/qlogging/app/main.cpp b/tests/auto/corelib/global/qlogging/app/main.cpp
index 621059caad..e190a48873 100644
--- a/tests/auto/corelib/global/qlogging/app/main.cpp
+++ b/tests/auto/corelib/global/qlogging/app/main.cpp
@@ -42,11 +42,37 @@
#include <QCoreApplication>
#include <QLoggingCategory>
+#ifdef Q_CC_GNU
+#define NEVER_INLINE __attribute__((__noinline__))
+#else
+#define NEVER_INLINE
+#endif
+
struct T {
T() { qDebug("static constructor"); }
~T() { qDebug("static destructor"); }
} t;
+class MyClass : public QObject
+{
+ Q_OBJECT
+public slots:
+ virtual NEVER_INLINE QString mySlot1();
+private:
+ virtual NEVER_INLINE void myFunction(int a);
+};
+
+QString MyClass::mySlot1()
+{
+ myFunction(34);
+ return QString();
+}
+
+void MyClass::myFunction(int a)
+{
+ qDebug() << "from_a_function" << a;
+}
+
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@@ -65,5 +91,10 @@ int main(int argc, char **argv)
qDebug("qDebug2");
+ MyClass cl;
+ QMetaObject::invokeMethod(&cl, "mySlot1");
+
return 0;
}
+
+#include "main.moc"
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index 21e07630e2..1df5404995 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -63,8 +64,12 @@ private slots:
void cleanupFuncinfo();
#endif
+ void qMessagePattern_data();
void qMessagePattern();
- void qMessagePatternIf();
+ void setMessagePattern();
+
+ void formatLogMessage_data();
+ void formatLogMessage();
private:
QString m_appDir;
@@ -641,11 +646,95 @@ void tst_qmessagehandler::cleanupFuncinfo()
}
#endif
+void tst_qmessagehandler::qMessagePattern_data()
+{
+ QTest::addColumn<QString>("pattern");
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QList<QByteArray> >("expected");
+
+ // %{file} is tricky because of shadow builds
+ QTest::newRow("basic") << "%{type} %{appname} %{line} %{function} %{message}" << true << (QList<QByteArray>()
+ << "debug 52 T::T static constructor"
+ // we can't be sure whether the QT_MESSAGE_PATTERN is already destructed
+ << "static destructor"
+ << "debug tst_qlogging 73 MyClass::myFunction from_a_function 34"
+ << "debug tst_qlogging 83 main qDebug"
+ << "warning tst_qlogging 84 main qWarning"
+ << "critical tst_qlogging 85 main qCritical"
+ << "warning tst_qlogging 88 main qDebug with category"
+ << "debug tst_qlogging 92 main qDebug2");
+
+
+ QTest::newRow("invalid") << "PREFIX: %{unknown} %{message}" << false << (QList<QByteArray>()
+ << "QT_MESSAGE_PATTERN: Unknown placeholder %{unknown}"
+ << "PREFIX: qDebug");
+
+ // test the if condition
+ QTest::newRow("ifs") << "[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{if-category}%{category}: %{endif}%{message}"
+ << true << (QList<QByteArray>()
+ << "[D] static constructor"
+ // we can't be sure whether the QT_MESSAGE_PATTERN is already destructed
+ << "static destructor"
+ << "[D] qDebug"
+ << "[W] qWarning"
+ << "[C] qCritical"
+ << "[W] category: qDebug with category"
+ << "[D] qDebug2");
+
+ // test few errors cases
+ QTest::newRow("ifs-invalid1") << "PREFIX: %{unknown} %{endif} %{if-warning}"
+ << false << (QList<QByteArray>()
+ << "QT_MESSAGE_PATTERN: Unknown placeholder %{unknown}"
+ << "QT_MESSAGE_PATTERN: %{endif} without an %{if-*}"
+ << "QT_MESSAGE_PATTERN: missing %{endif}");
+
+ QTest::newRow("ifs-invalid2") << "A %{if-debug}DEBUG%{if-warning}WARNING%{endif} %{message} "
+ << false << (QList<QByteArray>()
+ << "QT_MESSAGE_PATTERN: %{if-*} cannot be nested"
+ << "A DEBUG qDebug "
+ << "A qWarning ");
+
+ // This test won't work when midnight is too close... wait a bit
+ while (QTime::currentTime() > QTime(23, 59, 30))
+ QTest::qWait(10000);
+ QTest::newRow("time") << "/%{time yyyy - MM - d}/%{message}"
+ << true << (QList<QByteArray>()
+ << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + "/qDebug"));
+
+ // %{time} should have a padding of 6 so if it takes less than 10 seconds to show
+ // the first message, there should be 5 spaces
+ QTest::newRow("time") << "<%{time}>%{message}" << true << (QList<QByteArray>()
+ << "< ");
+
+#ifdef __GLIBC__
+#ifdef QT_NAMESPACE
+#define QT_NAMESPACE_STR QT_STRINGIFY(QT_NAMESPACE::)
+#else
+#define QT_NAMESPACE_STR ""
+#endif
+
+#ifndef QT_NO_DEBUG
+ QTest::newRow("backtrace") << "[%{backtrace}] %{message}" << true << (QList<QByteArray>()
+ // MyClass::qt_static_metacall is explicitly marked as hidden in the Q_OBJECT macro
+ << "[MyClass::myFunction|MyClass::mySlot1|?app?|" QT_NAMESPACE_STR "QMetaMethod::invoke|" QT_NAMESPACE_STR "QMetaObject::invokeMethod] from_a_function 34");
+#endif
+
+ QTest::newRow("backtrace depth,separator") << "[%{backtrace depth=2 separator=\"\n\"}] %{message}" << true << (QList<QByteArray>()
+ << "[MyClass::myFunction\nMyClass::mySlot1] from_a_function 34");
+#endif
+
+}
+
+
void tst_qmessagehandler::qMessagePattern()
{
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#else
+ QFETCH(QString, pattern);
+ QFETCH(bool, valid);
+ QFETCH(QList<QByteArray>, expected);
+
QProcess process;
const QString appExe = m_appDir + "/app";
@@ -653,8 +742,7 @@ void tst_qmessagehandler::qMessagePattern()
// test QT_MESSAGE_PATTERN
//
QStringList environment = m_baseEnvironment;
- // %{file} is tricky because of shadow builds
- environment.prepend("QT_MESSAGE_PATTERN=\"%{type} %{appname} %{line} %{function} %{message}\"");
+ environment.prepend("QT_MESSAGE_PATTERN=\"" + pattern + "\"");
process.setEnvironment(environment);
process.start(appExe);
@@ -665,35 +753,33 @@ void tst_qmessagehandler::qMessagePattern()
QByteArray output = process.readAllStandardError();
// qDebug() << output;
QVERIFY(!output.isEmpty());
+ QCOMPARE(!output.contains("QT_MESSAGE_PATTERN"), valid);
- QVERIFY(output.contains("debug 46 T::T static constructor"));
- // we can't be sure whether the QT_MESSAGE_PATTERN is already destructed
- QVERIFY(output.contains("static destructor"));
- QVERIFY(output.contains("debug tst_qlogging 57 main qDebug"));
- QVERIFY(output.contains("warning tst_qlogging 58 main qWarning"));
- QVERIFY(output.contains("critical tst_qlogging 59 main qCritical"));
- QVERIFY(output.contains("warning tst_qlogging 62 main qDebug with category"));
- QVERIFY(output.contains("debug tst_qlogging 66 main qDebug2"));
-
- environment = m_baseEnvironment;
- environment.prepend("QT_MESSAGE_PATTERN=\"PREFIX: %{unknown} %{message}\"");
- process.setEnvironment(environment);
-
- process.start(appExe);
- QVERIFY2(process.waitForStarted(), qPrintable(
- QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
- process.waitForFinished();
-
- output = process.readAllStandardError();
-// qDebug() << output;
- QVERIFY(!output.isEmpty());
+ foreach (const QByteArray &e, expected) {
+ if (!output.contains(e)) {
+ qDebug() << output;
+ qDebug() << "expected: " << e;
+ QVERIFY(output.contains(e));
+ }
+ }
+#endif
+}
- QVERIFY(output.contains("QT_MESSAGE_PATTERN: Unknown placeholder %{unknown}"));
- QVERIFY(output.contains("PREFIX: qDebug"));
+void tst_qmessagehandler::setMessagePattern()
+{
+#ifdef QT_NO_PROCESS
+ QSKIP("This test requires QProcess support");
+#else
//
// test qSetMessagePattern
//
+
+ QProcess process;
+ const QString appExe = m_appDir + "/app";
+
+ // make sure there is no QT_MESSAGE_PATTERN in the environment
+ QStringList environment = m_baseEnvironment;
QMutableListIterator<QString> iter(environment);
while (iter.hasNext()) {
if (iter.next().startsWith("QT_MESSAGE_PATTERN"))
@@ -706,7 +792,7 @@ void tst_qmessagehandler::qMessagePattern()
QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
process.waitForFinished();
- output = process.readAllStandardError();
+ QByteArray output = process.readAllStandardError();
//qDebug() << output;
QByteArray expected = "static constructor\n"
"[debug] qDebug\n"
@@ -720,73 +806,63 @@ void tst_qmessagehandler::qMessagePattern()
#endif // !QT_NO_PROCESS
}
-void tst_qmessagehandler::qMessagePatternIf()
-{
-#ifdef QT_NO_PROCESS
- QSKIP("This test requires QProcess support");
-#else
- QProcess process;
- const QString appExe = m_appDir + "/app";
-
- QStringList environment = m_baseEnvironment;
- environment.prepend("QT_MESSAGE_PATTERN=\"[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{if-category}%{category}: %{endif}%{message}\"");
- process.setEnvironment(environment);
- process.start(appExe);
- QVERIFY2(process.waitForStarted(), qPrintable(
- QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
- process.waitForFinished();
-
- QByteArray output = process.readAllStandardError();
- // qDebug() << output;
- QVERIFY(!output.isEmpty());
- QVERIFY(!output.contains("QT_MESSAGE_PATTERN"));
-
- QVERIFY(output.contains("[D] static constructor"));
- // we can't be sure whether the QT_MESSAGE_PATTERN is already destructed
- QVERIFY(output.contains("static destructor"));
- QVERIFY(output.contains("[D] qDebug"));
- QVERIFY(output.contains("[W] qWarning"));
- QVERIFY(output.contains("[C] qCritical"));
- QVERIFY(output.contains("[W] category: qDebug with category"));
- QVERIFY(output.contains("[D] qDebug2"));
+Q_DECLARE_METATYPE(QtMsgType)
- //
- // Tests some errors
- //
- environment = m_baseEnvironment;
- environment.prepend("QT_MESSAGE_PATTERN=\"PREFIX: %{unknown} %{endif} %{if-warning}\"");
- process.setEnvironment(environment);
-
- process.start(appExe);
- QVERIFY2(process.waitForStarted(), qPrintable(
- QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
- process.waitForFinished();
-
- output = process.readAllStandardError();
- // qDebug() << output;
- QVERIFY(!output.isEmpty());
- QVERIFY(output.contains("QT_MESSAGE_PATTERN: Unknown placeholder %{unknown}"));
- QVERIFY(output.contains("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}"));
- QVERIFY(output.contains("QT_MESSAGE_PATTERN: missing %{endif}"));
-
-
- environment = m_baseEnvironment;
- environment.prepend("QT_MESSAGE_PATTERN=\"A %{if-debug}DEBUG%{if-warning}WARNING%{endif} %{message} \"");
- process.setEnvironment(environment);
-
- process.start(appExe);
- QVERIFY2(process.waitForStarted(), qPrintable(
- QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
- process.waitForFinished();
+void tst_qmessagehandler::formatLogMessage_data()
+{
+ QTest::addColumn<QString>("pattern");
+ QTest::addColumn<QString>("result");
+
+ QTest::addColumn<QtMsgType>("type");
+ QTest::addColumn<QByteArray>("file");
+ QTest::addColumn<int>("line");
+ QTest::addColumn<QByteArray>("function");
+ QTest::addColumn<QByteArray>("category");
+ QTest::addColumn<QString>("message");
+
+#define BA QByteArrayLiteral
+
+ QTest::newRow("basic") << "%{type} %{file} %{line} %{function} %{message}"
+ << "debug main.cpp 1 func msg\n"
+ << QtDebugMsg << BA("main.cpp") << 1 << BA("func") << BA("") << "msg";
+
+ // test the if conditions
+ QString format = "[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{if-category}%{category}: %{endif}%{message}";
+ QTest::newRow("if-debug")
+ << format << "[D] msg\n"
+ << QtDebugMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
+ QTest::newRow("if_warning")
+ << format << "[W] msg\n"
+ << QtWarningMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
+ QTest::newRow("if_critical")
+ << format << "[C] msg\n"
+ << QtCriticalMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
+ QTest::newRow("if_fatal")
+ << format << "[F] msg\n"
+ << QtFatalMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
+ QTest::newRow("if_cat")
+ << format << "[F] cat: msg\n"
+ << QtFatalMsg << BA("") << 0 << BA("func") << BA("cat") << "msg";
+}
- output = process.readAllStandardError();
- // qDebug() << output;
- QVERIFY(!output.isEmpty());
- QVERIFY(output.contains("QT_MESSAGE_PATTERN: %{if-*} cannot be nested"));
- QVERIFY(output.contains("A DEBUG qDebug"));
- QVERIFY(output.contains("A qWarning"));
-#endif // !QT_NO_PROCESS
+void tst_qmessagehandler::formatLogMessage()
+{
+ QFETCH(QString, pattern);
+ QFETCH(QString, result);
+
+ QFETCH(QtMsgType, type);
+ QFETCH(QByteArray, file);
+ QFETCH(int, line);
+ QFETCH(QByteArray, function);
+ QFETCH(QByteArray, category);
+ QFETCH(QString, message);
+
+ qSetMessagePattern(pattern);
+ QMessageLogContext ctxt(file, line, function, category.isEmpty() ? 0 : category.data());
+ QString r = qFormatLogMessage(type, ctxt, message);
+ QCOMPARE(r, result);
}
+
QTEST_MAIN(tst_qmessagehandler)
#include "tst_qlogging.moc"
diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
index a6d76ea7b6..a477d6bc6c 100644
--- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
@@ -270,7 +270,9 @@ static int NColorRoles[] = {
QPalette::ToolTipText + 1, // Qt_5_0
QPalette::ToolTipText + 1, // Qt_5_1
QPalette::ToolTipText + 1, // Qt_5_2
- 0 // add the correct value for Qt_5_3 here later
+ QPalette::ToolTipText + 1, // Qt_5_3
+ QPalette::ToolTipText + 1, // Qt_5_4
+ 0 // add the correct value for Qt_5_5 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 99c4ee7edc..764c928d76 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -56,11 +56,16 @@ private slots:
void criticalWithoutDebug() const;
void debugWithBool() const;
void debugSpaceHandling() const;
+ void debugNoQuotes() const;
void stateSaver() const;
void veryLongWarningMessage() const;
+ void qDebugQChar() const;
void qDebugQStringRef() const;
void qDebugQLatin1String() const;
+ void qDebugQByteArray() const;
+ void qDebugQFlags() const;
void textStreamModifiers() const;
+ void resetFormat() const;
void defaultMessagehandler() const;
void threadSafety() const;
};
@@ -167,7 +172,8 @@ public:
QDebug operator<< (QDebug s, const MyPoint& point)
{
const QDebugStateSaver saver(s);
- return s.nospace() << "MyPoint(" << point.v1 << ", " << point.v2 << ")";
+ s.nospace() << "MyPoint(" << point.v1 << ", " << point.v2 << ")";
+ return s;
}
class MyLine
@@ -203,10 +209,45 @@ void tst_QDebug::debugSpaceHandling() const
d << 1 << 2;
MyLine line(MyPoint(10, 11), MyPoint (12, 13));
d << line;
+ d << "bar";
// With the old implementation of MyPoint doing dbg.nospace() << ...; dbg.space() we ended up with
// MyLine(MyPoint(10, 11) , MyPoint(12, 13) )
}
- QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 MyLine(MyPoint(10, 11), MyPoint(12, 13))"));
+ QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 MyLine(MyPoint(10, 11), MyPoint(12, 13)) bar"));
+
+ QVERIFY(qDebug().autoInsertSpaces());
+ qDebug() << QPoint(21, 22) << QRect(23, 24, 25, 26) << QLine(27, 28, 29, 30);
+ QCOMPARE(s_msg, QString::fromLatin1("QPoint(21,22) QRect(23,24 25x26) QLine(QPoint(27,28),QPoint(29,30))"));
+ qDebug() << QPointF(21, 22) << QRectF(23, 24, 25, 26) << QLineF(27, 28, 29, 30);
+ QCOMPARE(s_msg, QString::fromLatin1("QPointF(21,22) QRectF(23,24 25x26) QLineF(QPointF(27,28),QPointF(29,30))"));
+ qDebug() << QMimeType() << QMimeDatabase().mimeTypeForName("application/pdf") << "foo";
+ QCOMPARE(s_msg, QString::fromLatin1("QMimeType(invalid) QMimeType(\"application/pdf\") foo"));
+}
+
+void tst_QDebug::debugNoQuotes() const
+{
+ MessageHandlerSetter mhs(myMessageHandler);
+ {
+ QDebug d = qDebug();
+ d << QStringLiteral("Hello");
+ d.noquote();
+ d << QStringLiteral("Hello");
+ d.quote();
+ d << QStringLiteral("Hello");
+ }
+ QCOMPARE(s_msg, QString::fromLatin1("\"Hello\" Hello \"Hello\""));
+
+ {
+ QDebug d = qDebug();
+ d << QChar('H');
+ d << QLatin1String("Hello");
+ d << QByteArray("Hello");
+ d.noquote();
+ d << QChar('H');
+ d << QLatin1String("Hello");
+ d << QByteArray("Hello");
+ }
+ QCOMPARE(s_msg, QString::fromLatin1("'H' \"Hello\" \"Hello\" H Hello Hello"));
}
void tst_QDebug::stateSaver() const
@@ -214,13 +255,46 @@ void tst_QDebug::stateSaver() const
MessageHandlerSetter mhs(myMessageHandler);
{
QDebug d = qDebug();
+ d << 42;
+ {
+ QDebugStateSaver saver(d);
+ d << 43;
+ }
+ d << 44;
+ }
+ QCOMPARE(s_msg, QString::fromLatin1("42 43 44"));
+
+ {
+ QDebug d = qDebug();
{
QDebugStateSaver saver(d);
d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42;
}
- d.space() << 42;
+ d << 42;
}
QCOMPARE(s_msg, QString::fromLatin1("02a 42"));
+
+ {
+ QDebug d = qDebug();
+ {
+ QDebugStateSaver saver(d);
+ d.nospace().noquote() << QStringLiteral("Hello");
+ }
+ d << QStringLiteral("World");
+ }
+ QCOMPARE(s_msg, QString::fromLatin1("Hello \"World\""));
+
+ {
+ QDebug d = qDebug();
+ d.noquote().nospace() << QStringLiteral("Hello") << hex << 42;
+ {
+ QDebugStateSaver saver(d);
+ d.resetFormat();
+ d << QStringLiteral("World") << 42;
+ }
+ d << QStringLiteral("!") << 42;
+ }
+ QCOMPARE(s_msg, QString::fromLatin1("Hello2a\"World\" 42!2a"));
}
void tst_QDebug::veryLongWarningMessage() const
@@ -241,6 +315,23 @@ void tst_QDebug::veryLongWarningMessage() const
QCOMPARE(QString::fromLatin1(s_function), function);
}
+void tst_QDebug::qDebugQChar() const
+{
+ MessageHandlerSetter mhs(myMessageHandler);
+ {
+ QDebug d = qDebug();
+ d << QChar('f');
+ d.nospace().noquote() << QChar('o') << QChar('o');
+ }
+ QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO;
+ QCOMPARE(s_msgType, QtDebugMsg);
+ QCOMPARE(s_msg, QString::fromLatin1("'f' oo"));
+ QCOMPARE(QString::fromLatin1(s_file), file);
+ QCOMPARE(s_line, line);
+ QCOMPARE(QString::fromLatin1(s_function), function);
+
+}
+
void tst_QDebug::qDebugQStringRef() const
{
/* Use a basic string. */
@@ -276,13 +367,55 @@ void tst_QDebug::qDebugQStringRef() const
void tst_QDebug::qDebugQLatin1String() const
{
MessageHandlerSetter mhs(myMessageHandler);
- { qDebug() << QLatin1String("foo") << QLatin1String("") << QLatin1String("barbaz", 3); }
+ {
+ QDebug d = qDebug();
+ d << QLatin1String("foo") << QLatin1String("") << QLatin1String("barbaz", 3);
+ d.nospace().noquote() << QLatin1String("baz");
+ }
+ QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO;
+ QCOMPARE(s_msgType, QtDebugMsg);
+ QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz"));
+ QCOMPARE(QString::fromLatin1(s_file), file);
+ QCOMPARE(s_line, line);
+ QCOMPARE(QString::fromLatin1(s_function), function);
+}
+
+void tst_QDebug::qDebugQByteArray() const
+{
+ MessageHandlerSetter mhs(myMessageHandler);
+ {
+ QDebug d = qDebug();
+ d << QByteArrayLiteral("foo") << QByteArrayLiteral("") << QByteArray("barbaz", 3);
+ d.nospace().noquote() << QByteArrayLiteral("baz");
+ }
+ QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO;
+ QCOMPARE(s_msgType, QtDebugMsg);
+ QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz"));
+ QCOMPARE(QString::fromLatin1(s_file), file);
+ QCOMPARE(s_line, line);
+ QCOMPARE(QString::fromLatin1(s_function), function);
+}
+
+enum TestEnum {
+ Flag1 = 0x1,
+ Flag2 = 0x10
+};
+
+Q_DECLARE_FLAGS(TestFlags, TestEnum)
+
+void tst_QDebug::qDebugQFlags() const
+{
+ QFlags<TestEnum> flags(Flag1 | Flag2);
+
+ MessageHandlerSetter mhs(myMessageHandler);
+ { qDebug() << flags; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\""));
+ QCOMPARE(s_msg, QString::fromLatin1("QFlags(0x1|0x10)"));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
+
}
void tst_QDebug::textStreamModifiers() const
@@ -297,6 +430,22 @@ void tst_QDebug::textStreamModifiers() const
QCOMPARE(QString::fromLatin1(s_function), function);
}
+void tst_QDebug::resetFormat() const
+{
+ MessageHandlerSetter mhs(myMessageHandler);
+ {
+ QDebug d = qDebug();
+ d.nospace().noquote() << hex << int(0xf);
+ d.resetFormat() << int(0xf) << QStringLiteral("foo");
+ }
+ QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO;
+ QCOMPARE(s_msgType, QtDebugMsg);
+ QCOMPARE(s_msg, QString::fromLatin1("f15 \"foo\""));
+ QCOMPARE(QString::fromLatin1(s_file), file);
+ QCOMPARE(s_line, line);
+ QCOMPARE(QString::fromLatin1(s_function), function);
+}
+
void tst_QDebug::defaultMessagehandler() const
{
MessageHandlerSetter mhs(0); // set 0, should set default handler
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 60d1517ed3..9ce931d78a 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -3028,17 +3028,21 @@ void tst_QFile::mapResource()
void tst_QFile::mapOpenMode_data()
{
QTest::addColumn<int>("openMode");
+ QTest::addColumn<int>("flags");
- QTest::newRow("ReadOnly") << int(QIODevice::ReadOnly);
+ QTest::newRow("ReadOnly") << int(QIODevice::ReadOnly) << int(QFileDevice::NoOptions);
//QTest::newRow("WriteOnly") << int(QIODevice::WriteOnly); // this doesn't make sense
- QTest::newRow("ReadWrite") << int(QIODevice::ReadWrite);
- QTest::newRow("ReadOnly,Unbuffered") << int(QIODevice::ReadOnly | QIODevice::Unbuffered);
- QTest::newRow("ReadWrite,Unbuffered") << int(QIODevice::ReadWrite | QIODevice::Unbuffered);
+ QTest::newRow("ReadWrite") << int(QIODevice::ReadWrite) << int(QFileDevice::NoOptions);
+ QTest::newRow("ReadOnly,Unbuffered") << int(QIODevice::ReadOnly | QIODevice::Unbuffered) << int(QFileDevice::NoOptions);
+ QTest::newRow("ReadWrite,Unbuffered") << int(QIODevice::ReadWrite | QIODevice::Unbuffered) << int(QFileDevice::NoOptions);
+ QTest::newRow("ReadOnly + MapPrivate") << int(QIODevice::ReadOnly) << int(QFileDevice::MapPrivateOption);
+ QTest::newRow("ReadWrite + MapPrivate") << int(QIODevice::ReadWrite) << int(QFileDevice::MapPrivateOption);
}
void tst_QFile::mapOpenMode()
{
QFETCH(int, openMode);
+ QFETCH(int, flags);
static const qint64 fileSize = 4096;
QByteArray pattern(fileSize, 'A');
@@ -3060,11 +3064,15 @@ void tst_QFile::mapOpenMode()
// open according to our mode
QVERIFY(file.open(QIODevice::OpenMode(openMode)));
- uchar *memory = file.map(0, fileSize);
+ uchar *memory = file.map(0, fileSize, QFileDevice::MemoryMapFlags(flags));
+#if defined(Q_OS_WINCE)
+ QEXPECT_FAIL("ReadOnly + MapPrivate" , "Windows CE does not support MapPrivateOption.", Abort);
+ QEXPECT_FAIL("ReadWrite + MapPrivate", "Windows CE does not support MapPrivateOption.", Abort);
+#endif
QVERIFY(memory);
QVERIFY(memcmp(memory, pattern, fileSize) == 0);
- if (openMode & QIODevice::WriteOnly) {
+ if ((openMode & QIODevice::WriteOnly) || (flags & QFileDevice::MapPrivateOption)) {
// try to write to the file
*memory = 'a';
file.unmap(memory);
@@ -3073,7 +3081,7 @@ void tst_QFile::mapOpenMode()
file.seek(0);
char c;
QVERIFY(file.getChar(&c));
- QCOMPARE(c, 'a');
+ QCOMPARE(c, (flags & QFileDevice::MapPrivateOption) ? 'A' : 'a');
}
file.close();
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 8174cd942f..37cb296ebb 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -78,9 +78,79 @@
#define Q_NO_SYMLINKS
#endif
-QT_BEGIN_NAMESPACE
-extern Q_AUTOTEST_EXPORT bool qIsLikelyToBeNfs(int /* handle */);
-QT_END_NAMESPACE
+
+#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
+inline bool qt_isEvilFsTypeName(const char *name)
+{
+ return (qstrncmp(name, "nfs", 3) == 0
+ || qstrncmp(name, "autofs", 6) == 0
+ || qstrncmp(name, "cachefs", 7) == 0);
+}
+
+#if defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)
+# include <sys/param.h>
+# include <sys/mount.h>
+
+bool qIsLikelyToBeNfs(int handle)
+{
+ struct statfs buf;
+ if (fstatfs(handle, &buf) != 0)
+ return false;
+ return qt_isEvilFsTypeName(buf.f_fstypename);
+}
+
+#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
+
+# include <sys/vfs.h>
+# ifdef QT_LINUXBASE
+ // LSB 3.2 has fstatfs in sys/statfs.h, sys/vfs.h is just an empty dummy header
+# include <sys/statfs.h>
+# endif
+
+# ifndef NFS_SUPER_MAGIC
+# define NFS_SUPER_MAGIC 0x00006969
+# endif
+# ifndef AUTOFS_SUPER_MAGIC
+# define AUTOFS_SUPER_MAGIC 0x00000187
+# endif
+# ifndef AUTOFSNG_SUPER_MAGIC
+# define AUTOFSNG_SUPER_MAGIC 0x7d92b1a0
+# endif
+
+bool qIsLikelyToBeNfs(int handle)
+{
+ struct statfs buf;
+ if (fstatfs(handle, &buf) != 0)
+ return false;
+ return buf.f_type == NFS_SUPER_MAGIC
+ || buf.f_type == AUTOFS_SUPER_MAGIC
+ || buf.f_type == AUTOFSNG_SUPER_MAGIC;
+}
+
+#elif defined(Q_OS_SOLARIS) || defined(Q_OS_IRIX) || defined(Q_OS_AIX) || defined(Q_OS_HPUX) \
+ || defined(Q_OS_OSF) || defined(Q_OS_QNX) || defined(Q_OS_SCO) \
+ || defined(Q_OS_UNIXWARE) || defined(Q_OS_RELIANT) || defined(Q_OS_NETBSD)
+
+# include <sys/statvfs.h>
+
+bool qIsLikelyToBeNfs(int handle)
+{
+ struct statvfs buf;
+ if (fstatvfs(handle, &buf) != 0)
+ return false;
+#if defined(Q_OS_NETBSD)
+ return qt_isEvilFsTypeName(buf.f_fstypename);
+#else
+ return qt_isEvilFsTypeName(buf.f_basetype);
+#endif
+}
+#else
+inline bool qIsLikelyToBeNfs(int /* handle */)
+{
+ return false;
+}
+#endif
+#endif
class tst_QFileInfo : public QObject
{
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index e06af5a799..7e04fa5957 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -140,7 +140,7 @@ void tst_QFileSystemWatcher::basicTest()
watcher.setObjectName(QLatin1String("_qt_autotest_force_engine_") + backend);
QVERIFY(watcher.addPath(testFile.fileName()));
- QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::fileChanged);
QVERIFY(changedSpy.isValid());
QEventLoop eventLoop;
QTimer timer;
@@ -278,7 +278,7 @@ void tst_QFileSystemWatcher::watchDirectory()
watcher.setObjectName(QLatin1String("_qt_autotest_force_engine_") + backend);
QVERIFY(watcher.addPath(testDir.absolutePath()));
- QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::directoryChanged);
QVERIFY(changedSpy.isValid());
QEventLoop eventLoop;
QTimer timer;
@@ -441,8 +441,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
QVERIFY(watcher.addPath(testDir.absolutePath()));
QVERIFY(watcher.addPath(testFileName));
- QSignalSpy fileChangedSpy(&watcher, SIGNAL(fileChanged(QString)));
- QSignalSpy dirChangedSpy(&watcher, SIGNAL(directoryChanged(QString)));
+ QSignalSpy fileChangedSpy(&watcher, &QFileSystemWatcher::fileChanged);
+ QSignalSpy dirChangedSpy(&watcher, &QFileSystemWatcher::directoryChanged);
QVERIFY(fileChangedSpy.isValid());
QVERIFY(dirChangedSpy.isValid());
QEventLoop eventLoop;
@@ -601,7 +601,7 @@ void tst_QFileSystemWatcher::QTBUG2331()
QVERIFY(watcher.addPath(temporaryDirectory.path()));
// watch signal
- QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::directoryChanged);
QVERIFY(changedSpy.isValid());
// remove directory, we should get one change signal, and we should no longer
@@ -680,7 +680,7 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved()
connect(&watcher, SIGNAL(fileChanged(QString)), &signalReceiver, SLOT(fileChanged(QString)));
// watch signals
- QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::fileChanged);
QVERIFY(changedSpy.isValid());
// move files to second directory
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index b0d7a76f0f..6d49238e51 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -44,7 +44,6 @@
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(TST_LOG, "tst.log")
-Q_LOGGING_CATEGORY(TST_LOG1, "tst.log1")
Q_LOGGING_CATEGORY(Digia_Oslo_Office_com, "Digia.Oslo.Office.com")
Q_LOGGING_CATEGORY(Digia_Oulu_Office_com, "Digia.Oulu.Office.com")
Q_LOGGING_CATEGORY(Digia_Berlin_Office_com, "Digia.Berlin.Office.com")
@@ -278,6 +277,14 @@ private slots:
QCOMPARE(customCategory.isCriticalEnabled(), true);
QCOMPARE(customCategory.isEnabled(QtCriticalMsg), true);
+ QLoggingCategory onlyWarningsCategory("withType", QtWarningMsg);
+ QCOMPARE(onlyWarningsCategory.isDebugEnabled(), false);
+ QCOMPARE(onlyWarningsCategory.isEnabled(QtDebugMsg), false);
+ QCOMPARE(onlyWarningsCategory.isWarningEnabled(), true);
+ QCOMPARE(onlyWarningsCategory.isEnabled(QtWarningMsg), true);
+ QCOMPARE(onlyWarningsCategory.isCriticalEnabled(), true);
+ QCOMPARE(onlyWarningsCategory.isEnabled(QtCriticalMsg), true);
+
// make sure nothing has printed warnings
QVERIFY(logMessage.isEmpty());
}
@@ -367,6 +374,35 @@ private slots:
QCOMPARE(logMessage, buf);
}
+ Q_LOGGING_CATEGORY(TST_MACRO_1, "tst.macro.1")
+#ifdef Q_COMPILER_VARIADIC_MACROS
+ Q_LOGGING_CATEGORY(TST_MACRO_2, "tst.macro.2", QtDebugMsg)
+ Q_LOGGING_CATEGORY(TST_MACRO_3, "tst.macro.3", QtFatalMsg)
+#endif
+
+ void QLoggingCategoryMacro()
+ {
+ const QLoggingCategory &cat1 = TST_MACRO_1();
+ QCOMPARE(cat1.categoryName(), "tst.macro.1");
+ QCOMPARE(cat1.isDebugEnabled(), true);
+ QCOMPARE(cat1.isWarningEnabled(), true);
+ QCOMPARE(cat1.isCriticalEnabled(), true);
+
+#ifdef Q_COMPILER_VARIADIC_MACROS
+ const QLoggingCategory &cat2 = TST_MACRO_2();
+ QCOMPARE(cat2.categoryName(), "tst.macro.2");
+ QCOMPARE(cat2.isDebugEnabled(), true);
+ QCOMPARE(cat2.isWarningEnabled(), true);
+ QCOMPARE(cat2.isCriticalEnabled(), true);
+
+ const QLoggingCategory &cat3 = TST_MACRO_3();
+ QCOMPARE(cat3.categoryName(), "tst.macro.3");
+ QCOMPARE(cat3.isDebugEnabled(), false);
+ QCOMPARE(cat3.isWarningEnabled(), false);
+ QCOMPARE(cat3.isCriticalEnabled(), false);
+#endif
+ }
+
void qCDebugMacros()
{
QString buf;
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 82a0f3f832..1d6418cbc0 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -259,7 +259,7 @@ void tst_QProcess::simpleStart()
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
process = new QProcess;
- QSignalSpy spy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
+ QSignalSpy spy(process, &QProcess::stateChanged);
QVERIFY(spy.isValid());
connect(process, SIGNAL(readyRead()), this, SLOT(readFromProcess()));
@@ -351,7 +351,7 @@ void tst_QProcess::crashTest()
{
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
process = new QProcess;
- QSignalSpy stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
+ QSignalSpy stateSpy(process, &QProcess::stateChanged);
QVERIFY(stateSpy.isValid());
process->start("testProcessCrash/testProcessCrash");
QVERIFY(process->waitForStarted(5000));
@@ -359,8 +359,8 @@ void tst_QProcess::crashTest()
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
- QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy spy2(process, SIGNAL(finished(int,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));
QVERIFY(spy.isValid());
QVERIFY(spy2.isValid());
@@ -394,8 +394,8 @@ void tst_QProcess::crashTest2()
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
- QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy spy2(process, SIGNAL(finished(int,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));
QVERIFY(spy.isValid());
QVERIFY(spy2.isValid());
@@ -503,8 +503,8 @@ void tst_QProcess::echoTest2()
QCOMPARE(process->error(), QProcess::Timedout);
process->write("Hello");
- QSignalSpy spy1(process, SIGNAL(readyReadStandardOutput()));
- QSignalSpy spy2(process, SIGNAL(readyReadStandardError()));
+ QSignalSpy spy1(process, &QProcess::readyReadStandardOutput);
+ QSignalSpy spy2(process, &QProcess::readyReadStandardError);
QVERIFY(spy1.isValid());
QVERIFY(spy2.isValid());
@@ -685,7 +685,7 @@ void tst_QProcess::readTimeoutAndThenCrash()
QCOMPARE(process->error(), QProcess::Timedout);
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
- QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
+ QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
QVERIFY(spy.isValid());
process->kill();
@@ -887,7 +887,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
QProcess proc;
connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
- QSignalSpy spy(&proc, SIGNAL(readyRead()));
+ QSignalSpy spy(&proc, &QProcess::readyRead);
QVERIFY(spy.isValid());
proc.start("testProcessEcho/testProcessEcho");
@@ -1283,7 +1283,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
process->start("testProcessEcho/testProcessEcho");
QVERIFY(process->waitForStarted(5000));
- QSignalSpy spy(process, SIGNAL(readyRead()));
+ QSignalSpy spy(process, &QProcess::readyRead);
QVERIFY(spy.isValid());
process->write("foo");
QTestEventLoop::instance().enterLoop(30);
@@ -1323,7 +1323,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
process->start("testProcessEcho/testProcessEcho");
QVERIFY(process->waitForStarted(5000));
- QSignalSpy spy(process, SIGNAL(bytesWritten(qint64)));
+ QSignalSpy spy(process, &QProcess::bytesWritten);
QVERIFY(spy.isValid());
process->write("f");
QTestEventLoop::instance().enterLoop(30);
@@ -1538,10 +1538,10 @@ void tst_QProcess::failToStart()
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
QProcess process;
- QSignalSpy stateSpy(&process, SIGNAL(stateChanged(QProcess::ProcessState)));
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ 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));
QVERIFY(stateSpy.isValid());
QVERIFY(errorSpy.isValid());
@@ -1605,9 +1605,9 @@ void tst_QProcess::failToStartWithWait()
QProcess process;
QEventLoop loop;
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ 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));
QVERIFY(errorSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -1632,9 +1632,9 @@ void tst_QProcess::failToStartWithEventLoop()
QProcess process;
QEventLoop loop;
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ 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));
QVERIFY(errorSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -1864,9 +1864,9 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
QProcess process;
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy1(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ 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));
QVERIFY(errorSpy.isValid());
QVERIFY(finishedSpy1.isValid());
@@ -2202,7 +2202,7 @@ void tst_QProcess::invalidProgramString()
QProcess process;
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
- QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError)));
+ QSignalSpy spy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
QVERIFY(spy.isValid());
process.start(programString);
@@ -2218,8 +2218,8 @@ void tst_QProcess::onlyOneStartedSignal()
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
QProcess process;
- QSignalSpy spyStarted(&process, SIGNAL(started()));
- QSignalSpy spyFinished(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy spyStarted(&process, &QProcess::started);
+ QSignalSpy spyFinished(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(spyStarted.isValid());
QVERIFY(spyFinished.isValid());
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index 515a10426c..230030d5cd 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -47,6 +47,9 @@ class tst_QResourceEngine: public QObject
{
Q_OBJECT
+public:
+ tst_QResourceEngine() : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) {}
+
private slots:
void initTestCase();
void cleanupTestCase();
@@ -59,20 +62,24 @@ private slots:
void searchPath();
void doubleSlashInRoot();
void setLocale();
+
+private:
+ const QString m_runtimeResourceRcc;
};
void tst_QResourceEngine::initTestCase()
{
- QVERIFY(QResource::registerResource(QFINDTESTDATA("runtime_resource.rcc")));
- QVERIFY(QResource::registerResource(QFINDTESTDATA("runtime_resource.rcc"), "/secondary_root/"));
+ QVERIFY(!m_runtimeResourceRcc.isEmpty());
+ QVERIFY(QResource::registerResource(m_runtimeResourceRcc));
+ QVERIFY(QResource::registerResource(m_runtimeResourceRcc, "/secondary_root/"));
}
void tst_QResourceEngine::cleanupTestCase()
{
// make sure we don't leak memory
- QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc")));
- QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc"), "/secondary_root/"));
+ QVERIFY(QResource::unregisterResource(m_runtimeResourceRcc));
+ QVERIFY(QResource::unregisterResource(m_runtimeResourceRcc, "/secondary_root/"));
}
void tst_QResourceEngine::checkStructure_data()
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
index 87bcfe572d..08b943ba72 100644
--- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
+++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
@@ -93,6 +93,8 @@ private slots:
void transactionalWriteNoPermissionsOnFile();
void transactionalWriteCanceled();
void transactionalWriteErrorRenaming();
+ void symlink();
+ void directory();
};
static inline QByteArray msgCannotOpen(const QFileDevice &f)
@@ -340,5 +342,142 @@ void tst_QSaveFile::transactionalWriteErrorRenaming()
QCOMPARE(file.error(), QFile::RenameError);
}
+void tst_QSaveFile::symlink()
+{
+#ifdef Q_OS_UNIX
+ QByteArray someData = "some data";
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+
+ const QString targetFile = dir.path() + QLatin1String("/outfile");
+ const QString linkFile = dir.path() + QLatin1String("/linkfile");
+ {
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.write("Hello"), Q_INT64_C(5));
+ file.close();
+ }
+
+ QVERIFY(QFile::link(targetFile, linkFile));
+
+ QString canonical = QFileInfo(linkFile).canonicalFilePath();
+ QCOMPARE(canonical, QFileInfo(targetFile).canonicalFilePath());
+
+ // Try saving into it
+ {
+ QSaveFile saveFile(linkFile);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ //Check that the linkFile is still a link and still has the same canonical path
+ QFileInfo info(linkFile);
+ QVERIFY(info.isSymLink());
+ QCOMPARE(QFileInfo(linkFile).canonicalFilePath(), canonical);
+
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ file.remove();
+ }
+
+ // Save into a symbolic link that point to a removed file
+ someData = "more stuff";
+ {
+ QSaveFile saveFile(linkFile);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ QFileInfo info(linkFile);
+ QVERIFY(info.isSymLink());
+ QCOMPARE(QFileInfo(linkFile).canonicalFilePath(), canonical);
+
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+
+ // link to a link in another directory
+ QTemporaryDir dir2;
+ QVERIFY(dir2.isValid());
+
+ const QString linkFile2 = dir2.path() + QLatin1String("/linkfile");
+ QVERIFY(QFile::link(linkFile, linkFile2));
+ QCOMPARE(QFileInfo(linkFile2).canonicalFilePath(), canonical);
+
+
+ someData = "hello everyone";
+
+ {
+ QSaveFile saveFile(linkFile2);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+
+ //cyclic link
+ const QString cyclicLink = dir.path() + QLatin1String("/cyclic");
+ QVERIFY(QFile::link(cyclicLink, cyclicLink));
+ {
+ QSaveFile saveFile(cyclicLink);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ QFile file(cyclicLink);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+
+ //cyclic link2
+ QVERIFY(QFile::link(cyclicLink + QLatin1Char('1'), cyclicLink + QLatin1Char('2')));
+ QVERIFY(QFile::link(cyclicLink + QLatin1Char('2'), cyclicLink + QLatin1Char('1')));
+
+ {
+ QSaveFile saveFile(cyclicLink + QLatin1Char('1'));
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ // the explicit file becomes a file instead of a link
+ QVERIFY(!QFileInfo(cyclicLink + QLatin1Char('1')).isSymLink());
+ QVERIFY(QFileInfo(cyclicLink + QLatin1Char('2')).isSymLink());
+
+ QFile file(cyclicLink + QLatin1Char('1'));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+#endif
+}
+
+void tst_QSaveFile::directory()
+{
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+
+ const QString subdir = dir.path() + QLatin1String("/subdir");
+ QVERIFY(QDir(dir.path()).mkdir(QStringLiteral("subdir")));
+ {
+ QFile sf(subdir);
+ QVERIFY(!sf.open(QIODevice::WriteOnly));
+ }
+
+#ifdef Q_OS_UNIX
+ //link to a directory
+ const QString linkToDir = dir.path() + QLatin1String("/linkToDir");
+ QVERIFY(QFile::link(subdir, linkToDir));
+
+ {
+ QFile sf(linkToDir);
+ QVERIFY(!sf.open(QIODevice::WriteOnly));
+ }
+#endif
+}
+
QTEST_MAIN(tst_QSaveFile)
#include "tst_qsavefile.moc"
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 7247b02498..c373e80408 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -56,7 +56,7 @@
#define Q_XDG_PLATFORM
#endif
-static const int MaxStandardLocation = QStandardPaths::GenericConfigLocation;
+static const int MaxStandardLocation = QStandardPaths::AppDataLocation;
class tst_qstandardpaths : public QObject
{
@@ -129,7 +129,8 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths
"ConfigLocation",
"DownloadLocation",
"GenericCacheLocation",
- "GenericConfigLocation"
+ "GenericConfigLocation",
+ "AppDataLocation"
};
void tst_qstandardpaths::dump()
@@ -238,7 +239,8 @@ void tst_qstandardpaths::enableTestMode()
// Check this for locations where test programs typically write. Not desktop, download, music etc...
typedef QHash<QStandardPaths::StandardLocation, QString> LocationHash;
LocationHash testLocations;
- testLocations.insert(QStandardPaths::DataLocation, QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ testLocations.insert(QStandardPaths::AppDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
+ testLocations.insert(QStandardPaths::AppLocalDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
testLocations.insert(QStandardPaths::GenericDataLocation, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
testLocations.insert(QStandardPaths::ConfigLocation, QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
testLocations.insert(QStandardPaths::GenericConfigLocation, QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
@@ -294,18 +296,18 @@ void tst_qstandardpaths::testDataLocation()
// applications are sandboxed.
#if !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WINRT)
const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths");
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/tst_qstandardpaths");
QCoreApplication::instance()->setOrganizationName("Qt");
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/tst_qstandardpaths");
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/Qt/tst_qstandardpaths");
QCoreApplication::instance()->setApplicationName("QtTest");
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/QtTest");
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/Qt/QtTest");
#endif
#ifdef Q_XDG_PLATFORM
setDefaultLocations();
const QString expectedAppDataDir = QDir::homePath() + QString::fromLatin1("/.local/share/Qt/QtTest");
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), expectedAppDataDir);
- const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), expectedAppDataDir);
+ const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation);
QCOMPARE(appDataDirs.count(), 3);
QCOMPARE(appDataDirs.at(0), expectedAppDataDir);
QCOMPARE(appDataDirs.at(1), QString::fromLatin1("/usr/local/share/Qt/QtTest"));
@@ -463,7 +465,7 @@ void tst_qstandardpaths::testAllWritableLocations_data()
QTest::newRow("PicturesLocation") << QStandardPaths::PicturesLocation;
QTest::newRow("TempLocation") << QStandardPaths::TempLocation;
QTest::newRow("HomeLocation") << QStandardPaths::HomeLocation;
- QTest::newRow("DataLocation") << QStandardPaths::DataLocation;
+ QTest::newRow("AppLocalDataLocation") << QStandardPaths::AppLocalDataLocation;
QTest::newRow("DownloadLocation") << QStandardPaths::DownloadLocation;
}
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index 5ad798ae1f..74220d7f97 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -251,6 +251,11 @@ void tst_QTemporaryFile::autoRemove()
QTemporaryFile file("tempXXXXXX");
QVERIFY(file.open());
fileName = file.fileName();
+ // QTBUG-39976, file mappings should be cleared as well.
+ QVERIFY(file.write("test"));
+ QVERIFY(file.flush());
+ uchar *mapped = file.map(0, file.size());
+ QVERIFY(mapped);
file.close();
}
QVERIFY(!QFile::exists(fileName));
@@ -441,13 +446,15 @@ void tst_QTemporaryFile::rename()
void tst_QTemporaryFile::renameFdLeak()
{
#ifdef Q_OS_UNIX
+ const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA(__FILE__));
+ QVERIFY(!sourceFile.isEmpty());
// Test this on Unix only
// Open a bunch of files to force the fd count to go up
static const int count = 10;
int bunch_of_files[count];
for (int i = 0; i < count; ++i) {
- bunch_of_files[i] = ::open(qPrintable(QFINDTESTDATA("tst_qtemporaryfile.cpp")), O_RDONLY);
+ bunch_of_files[i] = ::open(sourceFile.constData(), O_RDONLY);
QVERIFY(bunch_of_files[i] != -1);
}
@@ -642,8 +649,10 @@ void tst_QTemporaryFile::createNativeFile_data()
QTest::addColumn<bool>("valid");
QTest::addColumn<QByteArray>("content");
- QTest::newRow("nativeFile") << QFINDTESTDATA("resources/test.txt") << (qint64)-1 << false << QByteArray();
- QTest::newRow("nativeFileWithPos") << QFINDTESTDATA("resources/test.txt") << (qint64)5 << false << QByteArray();
+ const QString nativeFilePath = QFINDTESTDATA("resources/test.txt");
+
+ QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray();
+ QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray();
QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test");
QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test");
}
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 2ae085cb0b..f402421165 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -245,6 +245,8 @@ private:
QTemporaryDir tempDir;
QString testFileName;
+ const QString m_rfc3261FilePath;
+ const QString m_shiftJisFilePath;
};
void runOnExit()
@@ -256,11 +258,16 @@ Q_DESTRUCTOR_FUNCTION(runOnExit)
tst_QTextStream::tst_QTextStream()
: tempDir(QDir::tempPath() + "/tst_qtextstream.XXXXXX")
+ , m_rfc3261FilePath(QFINDTESTDATA("rfc3261.txt"))
+ , m_shiftJisFilePath(QFINDTESTDATA("shift-jis.txt"))
{
}
void tst_QTextStream::initTestCase()
{
+ QVERIFY(!m_rfc3261FilePath.isEmpty());
+ QVERIFY(!m_shiftJisFilePath.isEmpty());
+
testFileName = tempDir.path() + "/testfile";
// chdir into the testdata dir and refer to our helper apps with relative paths
@@ -768,7 +775,7 @@ void tst_QTextStream::generateAllData(bool for_QString)
// ------------------------------------------------------------------------------
void tst_QTextStream::readLineUntilNull()
{
- QFile file(QFINDTESTDATA("rfc3261.txt"));
+ QFile file(m_rfc3261FilePath);
QVERIFY(file.open(QFile::ReadOnly));
QTextStream stream(&file);
@@ -887,7 +894,7 @@ void tst_QTextStream::lineCount_data()
QTest::newRow("buffersize+1 line") << QByteArray(16384, '\n') << 16384;
QTest::newRow("buffersize+2 line") << QByteArray(16385, '\n') << 16385;
- QFile file(QFINDTESTDATA("rfc3261.txt")); file.open(QFile::ReadOnly);
+ QFile file(m_rfc3261FilePath); file.open(QFile::ReadOnly);
QTest::newRow("rfc3261") << file.readAll() << 15067;
}
@@ -923,7 +930,7 @@ void tst_QTextStream::performance()
stopWatch.restart();
int nlines1 = 0;
- QFile file(QFINDTESTDATA("rfc3261.txt"));
+ QFile file(m_rfc3261FilePath);
QVERIFY(file.open(QFile::ReadOnly));
while (!file.atEnd()) {
@@ -935,7 +942,7 @@ void tst_QTextStream::performance()
stopWatch.restart();
int nlines2 = 0;
- QFile file2(QFINDTESTDATA("rfc3261.txt"));
+ QFile file2(m_rfc3261FilePath);
QVERIFY(file2.open(QFile::ReadOnly));
QTextStream stream(&file2);
@@ -1155,7 +1162,7 @@ void tst_QTextStream::readNewlines()
// ------------------------------------------------------------------------------
void tst_QTextStream::seek()
{
- QFile file(QFINDTESTDATA("rfc3261.txt"));
+ QFile file(m_rfc3261FilePath);
QVERIFY(file.open(QFile::ReadOnly));
QTextStream stream(&file);
@@ -1248,7 +1255,7 @@ void tst_QTextStream::pos()
}
{
// Latin1 device
- QFile file(QFINDTESTDATA("rfc3261.txt"));
+ QFile file(m_rfc3261FilePath);
QVERIFY(file.open(QIODevice::ReadOnly));
QTextStream stream(&file);
@@ -1280,7 +1287,7 @@ void tst_QTextStream::pos()
{
// Shift-JIS device
for (int i = 0; i < 2; ++i) {
- QFile file(QFINDTESTDATA("shift-jis.txt"));
+ QFile file(m_shiftJisFilePath);
if (i == 0)
QVERIFY(file.open(QIODevice::ReadOnly));
else
@@ -1788,8 +1795,6 @@ void tst_QTextStream::writeSeekWriteNoBOM()
QCOMPARE(out16.buffer(), first);
}
-
-
// ------------------------------------------------------------------------------
void tst_QTextStream::generateOperatorCharData(bool for_QString)
{
@@ -2142,14 +2147,36 @@ void tst_QTextStream::byteArray_read_operator_FromDevice()
{ \
QFETCH(qulonglong, number); \
QFETCH(QByteArray, data); \
+ QFETCH(QByteArray, dataWithSeparators); \
\
QBuffer buffer; \
buffer.open(QBuffer::WriteOnly); \
QTextStream stream(&buffer); \
+ stream.setLocale(QLocale::c()); \
stream << (type)number; \
stream.flush(); \
+ QCOMPARE(buffer.data().constData(), data.constData()); \
\
+ QLocale locale("en-US"); \
+ buffer.reset(); buffer.buffer().clear(); \
+ stream.setLocale(locale); \
+ stream << (type)number; \
+ stream.flush(); \
+ QCOMPARE(buffer.data(), dataWithSeparators); \
+ \
+ locale.setNumberOptions(QLocale::OmitGroupSeparator); \
+ buffer.reset(); buffer.buffer().clear(); \
+ stream.setLocale(locale); \
+ stream << (type)number; \
+ stream.flush(); \
QCOMPARE(buffer.data().constData(), data.constData()); \
+ \
+ locale = QLocale("de-DE"); \
+ buffer.reset(); buffer.buffer().clear(); \
+ stream.setLocale(locale); \
+ stream << (type)number; \
+ stream.flush(); \
+ QCOMPARE(buffer.data(), dataWithSeparators.replace(',', '.')); \
}
// ------------------------------------------------------------------------------
@@ -2157,16 +2184,17 @@ void tst_QTextStream::signedShort_write_operator_ToDevice_data()
{
QTest::addColumn<qulonglong>("number");
QTest::addColumn<QByteArray>("data");
-
- QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0");
- QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1");
- QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767");
- QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("-32768");
- QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("-32767");
- QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("-1");
- QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("0");
- QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("1");
+ QTest::addColumn<QByteArray>("dataWithSeparators");
+
+ QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
+ QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
+ QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("-32768") << QByteArray("-32,768");
+ QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("-32767") << QByteArray("-32,767");
+ QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("1") << QByteArray("1");
}
IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(signedShort, signed short)
;
@@ -2176,16 +2204,17 @@ void tst_QTextStream::unsignedShort_write_operator_ToDevice_data()
{
QTest::addColumn<qulonglong>("number");
QTest::addColumn<QByteArray>("data");
-
- QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0");
- QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("65535");
- QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767");
- QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768");
- QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769");
- QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535");
- QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("0");
- QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("1");
+ QTest::addColumn<QByteArray>("dataWithSeparators");
+
+ QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
+ QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("65535") << QByteArray("65,535");
+ QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
+ QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
+ QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
+ QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535") << QByteArray("65,535");
+ QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("1") << QByteArray("1");
}
IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(unsignedShort, unsigned short)
;
@@ -2195,22 +2224,23 @@ void tst_QTextStream::signedInt_write_operator_ToDevice_data()
{
QTest::addColumn<qulonglong>("number");
QTest::addColumn<QByteArray>("data");
-
- QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0");
- QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1");
- QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767");
- QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768");
- QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769");
- QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535");
- QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536");
- QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537");
- QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647");
- QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("-2147483648");
- QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("-2147483647");
- QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("-1");
- QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("0");
- QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("1");
+ QTest::addColumn<QByteArray>("dataWithSeparators");
+
+ QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
+ QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
+ QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
+ QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
+ QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535") << QByteArray("65,535");
+ QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536") << QByteArray("65,536");
+ QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537") << QByteArray("65,537");
+ QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647") << QByteArray("2,147,483,647");
+ QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("-2147483648") << QByteArray("-2,147,483,648");
+ QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("-2147483647") << QByteArray("-2,147,483,647");
+ QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("1") << QByteArray("1");
}
IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(signedInt, signed int)
;
@@ -2220,22 +2250,23 @@ void tst_QTextStream::unsignedInt_write_operator_ToDevice_data()
{
QTest::addColumn<qulonglong>("number");
QTest::addColumn<QByteArray>("data");
-
- QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0");
- QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("4294967295");
- QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767");
- QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768");
- QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769");
- QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535");
- QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536");
- QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537");
- QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647");
- QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("2147483648");
- QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("2147483649");
- QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("4294967295");
- QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("0");
- QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("1");
+ QTest::addColumn<QByteArray>("dataWithSeparators");
+
+ QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
+ QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("4294967295") << QByteArray("4,294,967,295");
+ QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
+ QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
+ QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
+ QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535") << QByteArray("65,535");
+ QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536") << QByteArray("65,536");
+ QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537") << QByteArray("65,537");
+ QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647") << QByteArray("2,147,483,647");
+ QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("2147483648") << QByteArray("2,147,483,648");
+ QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("2147483649") << QByteArray("2,147,483,649");
+ QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("4294967295") << QByteArray("4,294,967,295");
+ QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("1") << QByteArray("1");
}
IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(unsignedInt, unsigned int)
;
@@ -2245,26 +2276,27 @@ void tst_QTextStream::qlonglong_write_operator_ToDevice_data()
{
QTest::addColumn<qulonglong>("number");
QTest::addColumn<QByteArray>("data");
-
- QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0");
- QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1");
- QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767");
- QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768");
- QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769");
- QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535");
- QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536");
- QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537");
- QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647");
- QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("2147483648");
- QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("2147483649");
- QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("4294967295");
- QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("4294967296");
- QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("4294967297");
- QTest::newRow("9223372036854775807") << Q_UINT64_C(9223372036854775807) << QByteArray("9223372036854775807");
- QTest::newRow("9223372036854775808") << Q_UINT64_C(9223372036854775808) << QByteArray("-9223372036854775808");
- QTest::newRow("9223372036854775809") << Q_UINT64_C(9223372036854775809) << QByteArray("-9223372036854775807");
- QTest::newRow("18446744073709551615") << Q_UINT64_C(18446744073709551615) << QByteArray("-1");
+ QTest::addColumn<QByteArray>("dataWithSeparators");
+
+ QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
+ QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
+ QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
+ QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
+ QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535") << QByteArray("65,535");
+ QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536") << QByteArray("65,536");
+ QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537") << QByteArray("65,537");
+ QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647") << QByteArray("2,147,483,647");
+ QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("2147483648") << QByteArray("2,147,483,648");
+ QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("2147483649") << QByteArray("2,147,483,649");
+ QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("4294967295") << QByteArray("4,294,967,295");
+ QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("4294967296") << QByteArray("4,294,967,296");
+ QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("4294967297") << QByteArray("4,294,967,297");
+ QTest::newRow("9223372036854775807") << Q_UINT64_C(9223372036854775807) << QByteArray("9223372036854775807") << QByteArray("9,223,372,036,854,775,807");
+ QTest::newRow("9223372036854775808") << Q_UINT64_C(9223372036854775808) << QByteArray("-9223372036854775808") << QByteArray("-9,223,372,036,854,775,808");
+ QTest::newRow("9223372036854775809") << Q_UINT64_C(9223372036854775809) << QByteArray("-9223372036854775807") << QByteArray("-9,223,372,036,854,775,807");
+ QTest::newRow("18446744073709551615") << Q_UINT64_C(18446744073709551615) << QByteArray("-1") << QByteArray("-1");
}
IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(qlonglong, qlonglong)
;
@@ -2274,26 +2306,27 @@ void tst_QTextStream::qulonglong_write_operator_ToDevice_data()
{
QTest::addColumn<qulonglong>("number");
QTest::addColumn<QByteArray>("data");
-
- QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0");
- QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("18446744073709551615");
- QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767");
- QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768");
- QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769");
- QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535");
- QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536");
- QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537");
- QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647");
- QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("2147483648");
- QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("2147483649");
- QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("4294967295");
- QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("4294967296");
- QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("4294967297");
- QTest::newRow("9223372036854775807") << Q_UINT64_C(9223372036854775807) << QByteArray("9223372036854775807");
- QTest::newRow("9223372036854775808") << Q_UINT64_C(9223372036854775808) << QByteArray("9223372036854775808");
- QTest::newRow("9223372036854775809") << Q_UINT64_C(9223372036854775809) << QByteArray("9223372036854775809");
- QTest::newRow("18446744073709551615") << Q_UINT64_C(18446744073709551615) << QByteArray("18446744073709551615");
+ QTest::addColumn<QByteArray>("dataWithSeparators");
+
+ QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
+ QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
+ QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("18446744073709551615") << QByteArray("18,446,744,073,709,551,615");
+ QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
+ QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
+ QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
+ QTest::newRow("65535") << Q_UINT64_C(65535) << QByteArray("65535") << QByteArray("65,535");
+ QTest::newRow("65536") << Q_UINT64_C(65536) << QByteArray("65536") << QByteArray("65,536");
+ QTest::newRow("65537") << Q_UINT64_C(65537) << QByteArray("65537") << QByteArray("65,537");
+ QTest::newRow("2147483647") << Q_UINT64_C(2147483647) << QByteArray("2147483647") << QByteArray("2,147,483,647");
+ QTest::newRow("2147483648") << Q_UINT64_C(2147483648) << QByteArray("2147483648") << QByteArray("2,147,483,648");
+ QTest::newRow("2147483649") << Q_UINT64_C(2147483649) << QByteArray("2147483649") << QByteArray("2,147,483,649");
+ QTest::newRow("4294967295") << Q_UINT64_C(4294967295) << QByteArray("4294967295") << QByteArray("4,294,967,295");
+ QTest::newRow("4294967296") << Q_UINT64_C(4294967296) << QByteArray("4294967296") << QByteArray("4,294,967,296");
+ QTest::newRow("4294967297") << Q_UINT64_C(4294967297) << QByteArray("4294967297") << QByteArray("4,294,967,297");
+ QTest::newRow("9223372036854775807") << Q_UINT64_C(9223372036854775807) << QByteArray("9223372036854775807") << QByteArray("9,223,372,036,854,775,807");
+ QTest::newRow("9223372036854775808") << Q_UINT64_C(9223372036854775808) << QByteArray("9223372036854775808") << QByteArray("9,223,372,036,854,775,808");
+ QTest::newRow("9223372036854775809") << Q_UINT64_C(9223372036854775809) << QByteArray("9223372036854775809") << QByteArray("9,223,372,036,854,775,809");
+ QTest::newRow("18446744073709551615") << Q_UINT64_C(18446744073709551615) << QByteArray("18446744073709551615") << QByteArray("18,446,744,073,709,551,615");
}
IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(qulonglong, qulonglong)
;
@@ -2304,12 +2337,14 @@ void tst_QTextStream::generateRealNumbersDataWrite()
{
QTest::addColumn<double>("number");
QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<QByteArray>("dataWithSeparators");
- QTest::newRow("0") << 0.0 << QByteArray("0");
- QTest::newRow("3.14") << 3.14 << QByteArray("3.14");
- QTest::newRow("-3.14") << -3.14 << QByteArray("-3.14");
- QTest::newRow("1.2e+10") << 1.2e+10 << QByteArray("1.2e+10");
- QTest::newRow("-1.2e+10") << -1.2e+10 << QByteArray("-1.2e+10");
+ QTest::newRow("0") << 0.0 << QByteArray("0") << QByteArray("0");
+ QTest::newRow("3.14") << 3.14 << QByteArray("3.14") << QByteArray("3.14");
+ QTest::newRow("-3.14") << -3.14 << QByteArray("-3.14") << QByteArray("-3.14");
+ QTest::newRow("1.2e+10") << 1.2e+10 << QByteArray("1.2e+10") << QByteArray("1.2e+10");
+ QTest::newRow("-1.2e+10") << -1.2e+10 << QByteArray("-1.2e+10") << QByteArray("-1.2e+10");
+ QTest::newRow("12345") << 12345. << QByteArray("12345") << QByteArray("12,345");
}
// ------------------------------------------------------------------------------
@@ -2320,14 +2355,22 @@ void tst_QTextStream::generateRealNumbersDataWrite()
{ \
QFETCH(double, number); \
QFETCH(QByteArray, data); \
+ QFETCH(QByteArray, dataWithSeparators); \
\
QBuffer buffer; \
buffer.open(QBuffer::WriteOnly); \
QTextStream stream(&buffer); \
+ stream.setLocale(QLocale::c()); \
float f = (float)number; \
stream << f; \
stream.flush(); \
QCOMPARE(buffer.data().constData(), data.constData()); \
+ \
+ buffer.reset(); \
+ stream.setLocale(QLocale("en-US")); \
+ stream << f; \
+ stream.flush(); \
+ QCOMPARE(buffer.data(), dataWithSeparators); \
}
IMPLEMENT_STREAM_LEFT_REAL_OPERATOR_TEST(float, float)
IMPLEMENT_STREAM_LEFT_REAL_OPERATOR_TEST(double, float)
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index d5eab54363..ac4be31d0e 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -165,6 +165,8 @@ private slots:
void binaryData();
void fromUserInput_data();
void fromUserInput();
+ void fromUserInputWithCwd_data();
+ void fromUserInputWithCwd();
void fileName_data();
void fileName();
void isEmptyForEncodedUrl();
@@ -235,6 +237,11 @@ void tst_QUrl::constructing()
QVERIFY(url == url);
QVERIFY(!(url < url));
+ QUrl fromLocal = QUrl::fromLocalFile(QString());
+ QVERIFY(!fromLocal.isValid());
+ QVERIFY(fromLocal.isEmpty());
+ QCOMPARE(fromLocal.toString(), QString());
+
QUrl justHost("qt-project.org");
QVERIFY(!justHost.isEmpty());
QVERIFY(justHost.host().isEmpty());
@@ -2920,6 +2927,52 @@ void tst_QUrl::fromUserInput()
QCOMPARE(url, guessUrlFromString);
}
+void tst_QUrl::fromUserInputWithCwd_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("directory");
+ QTest::addColumn<QUrl>("guessedUrlDefault");
+ QTest::addColumn<QUrl>("guessedUrlAssumeLocalFile");
+
+ // Null
+ QTest::newRow("null") << QString() << QString() << QUrl() << QUrl();
+
+ // Existing file
+ QDirIterator it(QDir::currentPath(), QDir::NoDotDot | QDir::AllEntries);
+ int c = 0;
+ while (it.hasNext()) {
+ it.next();
+ QUrl url = QUrl::fromLocalFile(it.filePath());
+ QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.fileName() << QDir::currentPath() << url << url;
+ }
+ QDir parent = QDir::current();
+ QVERIFY(parent.cdUp());
+ QUrl parentUrl = QUrl::fromLocalFile(parent.path());
+ QTest::newRow("dotdot") << ".." << QDir::currentPath() << parentUrl << parentUrl;
+
+ QTest::newRow("nonexisting") << "nonexisting" << QDir::currentPath() << QUrl("http://nonexisting") << QUrl::fromLocalFile(QDir::currentPath() + "/nonexisting");
+ QTest::newRow("short-url") << "example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl::fromLocalFile(QDir::currentPath() + "/example.org");
+ QTest::newRow("full-url") << "http://example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl("http://example.org");
+ QTest::newRow("absolute") << "/doesnotexist.txt" << QDir::currentPath() << QUrl("file:///doesnotexist.txt") << QUrl("file:///doesnotexist.txt");
+#ifdef Q_OS_WIN
+ QTest::newRow("windows-absolute") << "c:/doesnotexist.txt" << QDir::currentPath() << QUrl("file:///c:/doesnotexist.txt") << QUrl("file:///c:/doesnotexist.txt");
+#endif
+}
+
+void tst_QUrl::fromUserInputWithCwd()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, directory);
+ QFETCH(QUrl, guessedUrlDefault);
+ QFETCH(QUrl, guessedUrlAssumeLocalFile);
+
+ QUrl url = QUrl::fromUserInput(string, directory);
+ QCOMPARE(url, guessedUrlDefault);
+
+ url = QUrl::fromUserInput(string, directory, QUrl::AssumeLocalFile);
+ QCOMPARE(url, guessedUrlAssumeLocalFile);
+}
+
void tst_QUrl::fileName_data()
{
QTest::addColumn<QString>("urlStr");
diff --git a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
index 8321f76bec..16f94e7c5d 100644
--- a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
+++ b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
@@ -58,6 +58,7 @@ private slots:
void readFile();
void waitForNotified_data();
void waitForNotified();
+ void waitForAnyNotified();
void brokenPipe();
void multipleOperations();
@@ -195,6 +196,45 @@ void tst_QWinOverlappedIoNotifier::waitForNotified()
QCOMPARE(notifier.waitForNotified(100, &overlapped), false);
}
+void tst_QWinOverlappedIoNotifier::waitForAnyNotified()
+{
+ const QString fileName = QDir::toNativeSeparators(sourceFileInfo.absoluteFilePath());
+ const int readBufferSize = sourceFileInfo.size();
+
+ QWinOverlappedIoNotifier notifier;
+ HANDLE hFile = CreateFile(reinterpret_cast<const wchar_t*>(fileName.utf16()),
+ GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
+ notifier.setHandle(hFile);
+ notifier.setEnabled(true);
+ QVERIFY(notifier.waitForAnyNotified(100) == 0);
+
+ OVERLAPPED overlapped1;
+ ZeroMemory(&overlapped1, sizeof(OVERLAPPED));
+ QByteArray buffer1(readBufferSize, 0);
+ BOOL readSuccess = ReadFile(hFile, buffer1.data(), buffer1.size(), NULL, &overlapped1);
+ QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING);
+
+ OVERLAPPED overlapped2;
+ ZeroMemory(&overlapped2, sizeof(OVERLAPPED));
+ QByteArray buffer2(readBufferSize, 0);
+ readSuccess = ReadFile(hFile, buffer2.data(), buffer2.size(), NULL, &overlapped2);
+ QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING);
+
+ QSet<OVERLAPPED *> overlappedObjects;
+ overlappedObjects << &overlapped1 << &overlapped2;
+
+ for (int i = 1; i <= 2; ++i) {
+ OVERLAPPED *notifiedOverlapped = notifier.waitForAnyNotified(3000);
+ QVERIFY(overlappedObjects.contains(notifiedOverlapped));
+ overlappedObjects.remove(notifiedOverlapped);
+ }
+
+ CloseHandle(hFile);
+ QVERIFY(overlappedObjects.isEmpty());
+ QVERIFY(notifier.waitForAnyNotified(100) == 0);
+}
+
void tst_QWinOverlappedIoNotifier::brokenPipe()
{
QWinOverlappedIoNotifier notifier;
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 2d2ae14fb8..0503371714 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -158,6 +158,8 @@ public:
QVector<QVector<QString> > table;
};
+Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint);
+
QtTestModel::QtTestModel(int rows, int columns, QObject *parent)
: QAbstractItemModel(parent), cCount(columns), rCount(rows), wrongIndex(false)
{
@@ -353,6 +355,8 @@ void tst_QAbstractItemModel::init()
insertCommand->setStartRow(0);
insertCommand->setEndRow(9);
insertCommand->doCommand();
+
+ qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>();
}
void tst_QAbstractItemModel::cleanup()
@@ -807,8 +811,8 @@ void tst_QAbstractItemModel::removeRows()
{
QtTestModel model(10, 10);
- QSignalSpy rowsAboutToBeRemovedSpy(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
- QSignalSpy rowsRemovedSpy(&model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
+ QSignalSpy rowsAboutToBeRemovedSpy(&model, &QtTestModel::rowsAboutToBeRemoved);
+ QSignalSpy rowsRemovedSpy(&model, &QtTestModel::rowsRemoved);
QVERIFY(rowsAboutToBeRemovedSpy.isValid());
QVERIFY(rowsRemovedSpy.isValid());
@@ -822,8 +826,8 @@ void tst_QAbstractItemModel::removeColumns()
{
QtTestModel model(10, 10);
- QSignalSpy columnsAboutToBeRemovedSpy(&model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)));
- QSignalSpy columnsRemovedSpy(&model, SIGNAL(columnsRemoved(QModelIndex,int,int)));
+ QSignalSpy columnsAboutToBeRemovedSpy(&model, &QtTestModel::columnsAboutToBeRemoved);
+ QSignalSpy columnsRemovedSpy(&model, &QtTestModel::columnsRemoved);
QVERIFY(columnsAboutToBeRemovedSpy.isValid());
QVERIFY(columnsRemovedSpy.isValid());
@@ -837,8 +841,8 @@ void tst_QAbstractItemModel::insertRows()
{
QtTestModel model(10, 10);
- QSignalSpy rowsAboutToBeInsertedSpy(&model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
- QSignalSpy rowsInsertedSpy(&model, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy rowsAboutToBeInsertedSpy(&model, &QtTestModel::rowsAboutToBeInserted);
+ QSignalSpy rowsInsertedSpy(&model, &QtTestModel::rowsInserted);
QVERIFY(rowsAboutToBeInsertedSpy.isValid());
QVERIFY(rowsInsertedSpy.isValid());
@@ -852,8 +856,8 @@ void tst_QAbstractItemModel::insertColumns()
{
QtTestModel model(10, 10);
- QSignalSpy columnsAboutToBeInsertedSpy(&model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)));
- QSignalSpy columnsInsertedSpy(&model, SIGNAL(columnsInserted(QModelIndex,int,int)));
+ QSignalSpy columnsAboutToBeInsertedSpy(&model, &QtTestModel::columnsAboutToBeInserted);
+ QSignalSpy columnsInsertedSpy(&model, &QtTestModel::columnsInserted);
QVERIFY(columnsAboutToBeInsertedSpy.isValid());
QVERIFY(columnsInsertedSpy.isValid());
@@ -867,8 +871,8 @@ void tst_QAbstractItemModel::moveRows()
{
QtTestModel model(10, 10);
- QSignalSpy rowsAboutToBeMovedSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy rowsMovedSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy rowsAboutToBeMovedSpy(&model, &QtTestModel::rowsAboutToBeMoved);
+ QSignalSpy rowsMovedSpy(&model, &QtTestModel::rowsMoved);
QVERIFY(rowsAboutToBeMovedSpy.isValid());
QVERIFY(rowsMovedSpy.isValid());
@@ -882,8 +886,8 @@ void tst_QAbstractItemModel::moveColumns()
{
QtTestModel model(10, 10);
- QSignalSpy columnsAboutToBeMovedSpy(&model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy columnsMovedSpy(&model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy columnsAboutToBeMovedSpy(&model, &QtTestModel::columnsAboutToBeMoved);
+ QSignalSpy columnsMovedSpy(&model, &QtTestModel::columnsMoved);
QVERIFY(columnsAboutToBeMovedSpy.isValid());
QVERIFY(columnsMovedSpy.isValid());
@@ -901,7 +905,7 @@ void tst_QAbstractItemModel::reset()
{
QtTestModel model(10, 10);
- QSignalSpy resetSpy(&model, SIGNAL(modelReset()));
+ QSignalSpy resetSpy(&model, &QtTestModel::modelReset);
QVERIFY(resetSpy.isValid());
model.reset();
QCOMPARE(resetSpy.count(), 1);
@@ -1023,8 +1027,8 @@ void tst_QAbstractItemModel::testMoveSameParentDown()
}
}
- QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -1138,8 +1142,8 @@ void tst_QAbstractItemModel::testMoveSameParentUp()
}
}
- QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -1287,8 +1291,8 @@ void tst_QAbstractItemModel::testMoveToGrandParent()
}
}
- QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -1427,8 +1431,8 @@ void tst_QAbstractItemModel::testMoveToSibling()
persistentList << QPersistentModelIndex(idx);
}
- QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -1577,8 +1581,8 @@ void tst_QAbstractItemModel::testMoveToUncle()
persistentList << QPersistentModelIndex(idx);
}
- QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -1684,8 +1688,8 @@ void tst_QAbstractItemModel::testMoveToDescendants()
persistentList << QPersistentModelIndex(idx);
}
- QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -1748,8 +1752,8 @@ void tst_QAbstractItemModel::testMoveWithinOwnRange()
QFETCH(int, endRow);
QFETCH(int, destRow);
- QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -1841,8 +1845,8 @@ void ListenerObject::slotReset()
void tst_QAbstractItemModel::testReset()
{
- QSignalSpy beforeResetSpy(m_model, SIGNAL(modelAboutToBeReset()));
- QSignalSpy afterResetSpy(m_model, SIGNAL(modelReset()));
+ QSignalSpy beforeResetSpy(m_model, &DynamicTreeModel::modelAboutToBeReset);
+ QSignalSpy afterResetSpy(m_model, &DynamicTreeModel::modelReset);
QVERIFY(beforeResetSpy.isValid());
QVERIFY(afterResetSpy.isValid());
@@ -1874,8 +1878,8 @@ void tst_QAbstractItemModel::testReset()
// Delete it because its slots test things which are not true after this point.
delete listener;
- QSignalSpy proxyBeforeResetSpy(nullProxy, SIGNAL(modelAboutToBeReset()));
- QSignalSpy proxyAfterResetSpy(nullProxy, SIGNAL(modelReset()));
+ QSignalSpy proxyBeforeResetSpy(nullProxy, &QSortFilterProxyModel::modelAboutToBeReset);
+ QSignalSpy proxyAfterResetSpy(nullProxy, &QSortFilterProxyModel::modelReset);
// Before setting it, it does not have custom roles.
QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray());
@@ -1925,8 +1929,8 @@ void tst_QAbstractItemModel::testDataChanged()
{
CustomRoleModel model;
- QSignalSpy withRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
- QSignalSpy withoutRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
+ QSignalSpy withRoles(&model, &CustomRoleModel::dataChanged);
+ QSignalSpy withoutRoles(&model, &CustomRoleModel::dataChanged);
QVERIFY(withRoles.isValid());
QVERIFY(withoutRoles.isValid());
@@ -2027,8 +2031,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
QCOMPARE(model.rowCount(p1), 10);
QCOMPARE(model.rowCount(p2), 10);
- QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
- QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QSignalSpy beforeSpy(&model, &DynamicTreeModel::layoutAboutToBeChanged);
+ QSignalSpy afterSpy(&model, &DynamicTreeModel::layoutChanged);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -2043,8 +2047,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
const QVariantList beforeSignal = beforeSpy.first();
const QVariantList afterSignal = afterSpy.first();
- QCOMPARE(beforeSignal.size(), 1);
- QCOMPARE(afterSignal.size(), 1);
+ QCOMPARE(beforeSignal.size(), 2);
+ QCOMPARE(afterSignal.size(), 2);
const QList<QPersistentModelIndex> beforeParents = beforeSignal.first().value<QList<QPersistentModelIndex> >();
QCOMPARE(beforeParents.size(), 2);
@@ -2093,8 +2097,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
const QPersistentModelIndex p2FirstPersistent = model.index(0, 0, p2);
const QPersistentModelIndex p2LastPersistent = model.index(9, 0, p2);
- QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
- QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QSignalSpy beforeSpy(&model, &DynamicTreeModel::layoutAboutToBeChanged);
+ QSignalSpy afterSpy(&model, &DynamicTreeModel::layoutChanged);
QVERIFY(beforeSpy.isValid());
QVERIFY(afterSpy.isValid());
@@ -2116,8 +2120,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged()
const QVariantList beforeSignal = beforeSpy.first();
const QVariantList afterSignal = afterSpy.first();
- QCOMPARE(beforeSignal.size(), 1);
- QCOMPARE(afterSignal.size(), 1);
+ QCOMPARE(beforeSignal.size(), 2);
+ QCOMPARE(afterSignal.size(), 2);
QVERIFY(p1FirstPersistent.row() == 1);
QVERIFY(p1LastPersistent.row() == 0);
diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index ea0a14c18c..5d21509c86 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -163,10 +163,10 @@ void tst_QIdentityProxyModel::insertRows()
verifyIdentity(m_model);
- QSignalSpy modelBeforeSpy(m_model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
- QSignalSpy modelAfterSpy(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)));
- QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
- QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy modelBeforeSpy(m_model, &QStandardItemModel::rowsAboutToBeInserted);
+ QSignalSpy modelAfterSpy(m_model, &QStandardItemModel::rowsInserted);
+ QSignalSpy proxyBeforeSpy(m_proxy, &QStandardItemModel::rowsAboutToBeInserted);
+ QSignalSpy proxyAfterSpy(m_proxy, &QStandardItemModel::rowsInserted);
QVERIFY(modelBeforeSpy.isValid());
QVERIFY(modelAfterSpy.isValid());
@@ -203,10 +203,10 @@ void tst_QIdentityProxyModel::removeRows()
verifyIdentity(m_model);
- QSignalSpy modelBeforeSpy(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
- QSignalSpy modelAfterSpy(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
- QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
- QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
+ QSignalSpy modelBeforeSpy(m_model, &QStandardItemModel::rowsAboutToBeRemoved);
+ QSignalSpy modelAfterSpy(m_model, &QStandardItemModel::rowsRemoved);
+ QSignalSpy proxyBeforeSpy(m_proxy, &QStandardItemModel::rowsAboutToBeRemoved);
+ QSignalSpy proxyAfterSpy(m_proxy, &QStandardItemModel::rowsRemoved);
QVERIFY(modelBeforeSpy.isValid());
QVERIFY(modelAfterSpy.isValid());
@@ -257,10 +257,10 @@ void tst_QIdentityProxyModel::moveRows()
verifyIdentity(&model);
- QSignalSpy modelBeforeSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy modelAfterSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::rowsMoved);
+ QSignalSpy proxyBeforeSpy(m_proxy, &QIdentityProxyModel::rowsAboutToBeMoved);
+ QSignalSpy proxyAfterSpy(m_proxy, &QIdentityProxyModel::rowsMoved);
QVERIFY(modelBeforeSpy.isValid());
QVERIFY(modelAfterSpy.isValid());
@@ -318,10 +318,10 @@ void tst_QIdentityProxyModel::reset()
verifyIdentity(&model);
- QSignalSpy modelBeforeSpy(&model, SIGNAL(modelAboutToBeReset()));
- QSignalSpy modelAfterSpy(&model, SIGNAL(modelReset()));
- QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(modelAboutToBeReset()));
- QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(modelReset()));
+ QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::modelAboutToBeReset);
+ QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::modelReset);
+ QSignalSpy proxyBeforeSpy(m_proxy, &QIdentityProxyModel::modelAboutToBeReset);
+ QSignalSpy proxyAfterSpy(m_proxy, &QIdentityProxyModel::modelReset);
QVERIFY(modelBeforeSpy.isValid());
QVERIFY(modelAfterSpy.isValid());
@@ -351,8 +351,8 @@ void tst_QIdentityProxyModel::dataChanged()
verifyIdentity(&model);
- QSignalSpy modelSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
- QSignalSpy proxySpy(m_proxy, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+ QSignalSpy modelSpy(&model, &DataChangedModel::dataChanged);
+ QSignalSpy proxySpy(m_proxy, &QIdentityProxyModel::dataChanged);
QVERIFY(modelSpy.isValid());
QVERIFY(proxySpy.isValid());
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index 30434bfd56..df4d8d0916 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -608,7 +608,7 @@ void tst_QItemModel::setData()
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
QVERIFY(currentModel);
- QSignalSpy spy(currentModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
+ QSignalSpy spy(currentModel, &QAbstractItemModel::dataChanged);
QVERIFY(spy.isValid());
QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false);
QCOMPARE(spy.count(), 0);
@@ -670,7 +670,7 @@ void tst_QItemModel::setHeaderData()
QVERIFY(index.isValid());
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
- QSignalSpy spy(currentModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
+ QSignalSpy spy(currentModel, &QAbstractItemModel::headerDataChanged);
QVERIFY(spy.isValid());
QString text = "Index private pointers should always be the same";
@@ -711,7 +711,7 @@ void tst_QItemModel::sort()
QVERIFY(currentModel->hasChildren(topIndex));
QModelIndex index = currentModel->index(0, 0, topIndex);
QVERIFY(index.isValid());
- QSignalSpy spy(currentModel, SIGNAL(layoutChanged()));
+ QSignalSpy spy(currentModel, &QAbstractItemModel::layoutChanged);
QVERIFY(spy.isValid());
for (int i=-1; i < 10; ++i){
currentModel->sort(i);
@@ -849,12 +849,12 @@ void tst_QItemModel::remove()
// When a row or column is removed there should be two signals.
// Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot
- QSignalSpy columnsAboutToBeRemovedSpy(currentModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)));
- QSignalSpy rowsAboutToBeRemovedSpy(currentModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
- QSignalSpy columnsRemovedSpy(currentModel, SIGNAL(columnsRemoved(QModelIndex,int,int)));
- QSignalSpy rowsRemovedSpy(currentModel, SIGNAL(rowsRemoved(QModelIndex,int,int)));
- QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset()));
- QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged()));
+ QSignalSpy columnsAboutToBeRemovedSpy(currentModel, &QAbstractItemModel::columnsAboutToBeRemoved);
+ QSignalSpy rowsAboutToBeRemovedSpy(currentModel, &QAbstractItemModel::rowsAboutToBeRemoved);
+ QSignalSpy columnsRemovedSpy(currentModel, &QAbstractItemModel::columnsRemoved);
+ QSignalSpy rowsRemovedSpy(currentModel, &QAbstractItemModel::rowsRemoved);
+ QSignalSpy modelResetSpy(currentModel, &QAbstractItemModel::modelReset);
+ QSignalSpy modelLayoutChangedSpy(currentModel, &QAbstractItemModel::layoutChanged);
QVERIFY(columnsAboutToBeRemovedSpy.isValid());
QVERIFY(rowsAboutToBeRemovedSpy.isValid());
@@ -1191,12 +1191,12 @@ void tst_QItemModel::insert()
// When a row or column is inserted there should be two signals.
// Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot
- QSignalSpy columnsAboutToBeInsertedSpy(currentModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)));
- QSignalSpy rowsAboutToBeInsertedSpy(currentModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
- QSignalSpy columnsInsertedSpy(currentModel, SIGNAL(columnsInserted(QModelIndex,int,int)));
- QSignalSpy rowsInsertedSpy(currentModel, SIGNAL(rowsInserted(QModelIndex,int,int)));
- QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset()));
- QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged()));
+ QSignalSpy columnsAboutToBeInsertedSpy(currentModel, &QAbstractItemModel::columnsAboutToBeInserted);
+ QSignalSpy rowsAboutToBeInsertedSpy(currentModel, &QAbstractItemModel::rowsAboutToBeInserted);
+ QSignalSpy columnsInsertedSpy(currentModel, &QAbstractItemModel::columnsInserted);
+ QSignalSpy rowsInsertedSpy(currentModel, &QAbstractItemModel::rowsInserted);
+ QSignalSpy modelResetSpy(currentModel, &QAbstractItemModel::modelReset);
+ QSignalSpy modelLayoutChangedSpy(currentModel, &QAbstractItemModel::layoutChanged);
QVERIFY(columnsAboutToBeInsertedSpy.isValid());
QVERIFY(rowsAboutToBeInsertedSpy.isValid());
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 9e3457a25a..a4e219a040 100644
--- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -1529,7 +1529,7 @@ void tst_QItemSelectionModel::resetModel()
MyStandardItemModel model(20, 20);
QItemSelectionModel *selectionModel = new QItemSelectionModel(&model);
- QSignalSpy spy(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QSignalSpy spy(selectionModel, &QItemSelectionModel::selectionChanged);
QVERIFY(spy.isValid());
selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
@@ -1592,7 +1592,7 @@ void tst_QItemSelectionModel::removeRows()
MyStandardItemModel model(rowCount, columnCount);
QItemSelectionModel selections(&model);
- QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QSignalSpy spy(&selections, &QItemSelectionModel::selectionChanged);
QVERIFY(spy.isValid());
QModelIndex tl = model.index(selectTop, selectLeft);
@@ -1655,7 +1655,7 @@ void tst_QItemSelectionModel::removeColumns()
MyStandardItemModel model(rowCount, columnCount);
QItemSelectionModel selections(&model);
- QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QSignalSpy spy(&selections, &QItemSelectionModel::selectionChanged);
QVERIFY(spy.isValid());
QModelIndex tl = model.index(selectTop, selectLeft);
@@ -1914,12 +1914,9 @@ void tst_QItemSelectionModel::setCurrentIndex()
treemodel->index(0, 0, treemodel->index(0, 0)),
QItemSelectionModel::SelectCurrent);
- QSignalSpy currentSpy(&selectionModel,
- SIGNAL(currentChanged(QModelIndex,QModelIndex)));
- QSignalSpy rowSpy(&selectionModel,
- SIGNAL(currentRowChanged(QModelIndex,QModelIndex)));
- QSignalSpy columnSpy(&selectionModel,
- SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)));
+ QSignalSpy currentSpy(&selectionModel, &QItemSelectionModel::currentChanged);
+ QSignalSpy rowSpy(&selectionModel, &QItemSelectionModel::currentRowChanged);
+ QSignalSpy columnSpy(&selectionModel, &QItemSelectionModel::currentColumnChanged);
QVERIFY(currentSpy.isValid());
QVERIFY(rowSpy.isValid());
@@ -2223,7 +2220,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal()
QItemSelectionModel selectionModel(&model);
selectionModel.select(sel, QItemSelectionModel::SelectCurrent);
- QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QSignalSpy deselectSpy(&selectionModel, &QItemSelectionModel::selectionChanged);
QVERIFY(deselectSpy.isValid());
model.removeRows(0, 1, root);
QVERIFY(deselectSpy.count() == 1);
@@ -2406,7 +2403,7 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange()
RemovalObserver ro(&selModel);
- QSignalSpy spy(&selModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QSignalSpy spy(&selModel, &QItemSelectionModel::selectionChanged);
QVERIFY(spy.isValid());
bool ok = model.removeRows(4, 2);
@@ -2738,7 +2735,7 @@ void tst_QItemSelectionModel::testClearCurrentIndex()
QItemSelectionModel selectionModel(&model, 0);
- QSignalSpy currentIndexSpy(&selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)));
+ QSignalSpy currentIndexSpy(&selectionModel, &QItemSelectionModel::currentChanged);
QVERIFY(currentIndexSpy.isValid());
QModelIndex firstIndex = model.index(0, 0);
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 0f72b419a0..471e5e6655 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -150,6 +150,8 @@ private slots:
void chainedProxyModelRoleNames();
void noMapAfterSourceDelete();
+ void forwardDropApi();
+
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
void checkHierarchy(const QStringList &data, const QAbstractItemModel *model);
@@ -159,6 +161,8 @@ private:
QSortFilterProxyModel *m_proxy;
};
+Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint)
+
// Testing get/set functions
void tst_QSortFilterProxyModel::getSetCheck()
{
@@ -177,6 +181,7 @@ void tst_QSortFilterProxyModel::getSetCheck()
tst_QSortFilterProxyModel::tst_QSortFilterProxyModel()
: m_model(0), m_proxy(0)
{
+ qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>();
}
void tst_QSortFilterProxyModel::initTestCase()
@@ -1472,7 +1477,7 @@ void tst_QSortFilterProxyModel::filterCurrent()
view.show();
view.setModel(&proxy);
- QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)));
+ QSignalSpy spy(view.selectionModel(), &QItemSelectionModel::currentChanged);
QVERIFY(spy.isValid());
view.setCurrentIndex(proxy.index(0, 0));
@@ -1620,10 +1625,10 @@ void tst_QSortFilterProxyModel::removeSourceRows()
proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder));
(void)proxy.rowCount(QModelIndex()); // force mapping
- QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
- QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
- QSignalSpy aboutToRemoveSpy(&proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
- QSignalSpy aboutToInsertSpy(&proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
+ QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved);
+ QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted);
+ QSignalSpy aboutToRemoveSpy(&proxy, &QSortFilterProxyModel::rowsAboutToBeRemoved);
+ QSignalSpy aboutToInsertSpy(&proxy, &QSortFilterProxyModel::rowsAboutToBeInserted);
QVERIFY(removeSpy.isValid());
QVERIFY(insertSpy.isValid());
@@ -1801,8 +1806,8 @@ void tst_QSortFilterProxyModel::changeFilter()
proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder));
(void)proxy.rowCount(QModelIndex()); // force mapping
- QSignalSpy initialRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
- QSignalSpy initialInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy initialRemoveSpy(&proxy, &QSortFilterProxyModel::rowsRemoved);
+ QSignalSpy initialInsertSpy(&proxy, &QSortFilterProxyModel::rowsInserted);
QVERIFY(initialRemoveSpy.isValid());
QVERIFY(initialInsertSpy.isValid());
@@ -1825,8 +1830,8 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initialProxyItems.at(i));
}
- QSignalSpy finalRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
- QSignalSpy finalInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy finalRemoveSpy(&proxy, &QSortFilterProxyModel::rowsRemoved);
+ QSignalSpy finalInsertSpy(&proxy, &QSortFilterProxyModel::rowsInserted);
QVERIFY(finalRemoveSpy.isValid());
QVERIFY(finalInsertSpy.isValid());
@@ -1976,8 +1981,8 @@ void tst_QSortFilterProxyModel::changeSourceData()
proxy.setFilterRegExp(filter);
- QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
- QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved);
+ QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted);
QVERIFY(removeSpy.isValid());
QVERIFY(insertSpy.isValid());
@@ -2075,7 +2080,7 @@ void tst_QSortFilterProxyModel::selectionFilteredOut()
view.show();
view.setModel(&proxy);
- QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)));
+ QSignalSpy spy(view.selectionModel(), &QItemSelectionModel::currentChanged);
QVERIFY(spy.isValid());
view.setCurrentIndex(proxy.index(0, 0));
@@ -2190,8 +2195,8 @@ void tst_QSortFilterProxyModel::insertIntoChildrenlessItem()
QSortFilterProxyModel proxy;
proxy.setSourceModel(&model);
- QSignalSpy colsInsertedSpy(&proxy, SIGNAL(columnsInserted(QModelIndex,int,int)));
- QSignalSpy rowsInsertedSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy colsInsertedSpy(&proxy, &QSortFilterProxyModel::columnsInserted);
+ QSignalSpy rowsInsertedSpy(&proxy, &QSortFilterProxyModel::rowsInserted);
QVERIFY(colsInsertedSpy.isValid());
QVERIFY(rowsInsertedSpy.isValid());
@@ -2270,7 +2275,7 @@ void tst_QSortFilterProxyModel::insertRowIntoFilteredParent()
EvenOddFilterModel proxy;
proxy.setSourceModel(&model);
- QSignalSpy spy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy spy(&proxy, &EvenOddFilterModel::rowsInserted);
QVERIFY(spy.isValid());
QStandardItem *itemA = new QStandardItem();
@@ -2299,8 +2304,8 @@ void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild()
QStandardItem *itemC = new QStandardItem("C");
itemA->appendRow(itemC); // filtered
- QSignalSpy removedSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int)));
- QSignalSpy insertedSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy removedSpy(&proxy, &QSortFilterProxyModel::rowsRemoved);
+ QSignalSpy insertedSpy(&proxy, &QSortFilterProxyModel::rowsInserted);
QVERIFY(removedSpy.isValid());
QVERIFY(insertedSpy.isValid());
@@ -2903,8 +2908,8 @@ void tst_QSortFilterProxyModel::appearsAndSort()
QCOMPARE(sourceModel.rowCount(), 3);
QCOMPARE(proxyModel.rowCount(), 0); //all rows are hidden at first;
- QSignalSpy spyAbout1(&proxyModel, SIGNAL(layoutAboutToBeChanged()));
- QSignalSpy spyChanged1(&proxyModel, SIGNAL(layoutChanged()));
+ QSignalSpy spyAbout1(&proxyModel, &PModel::layoutAboutToBeChanged);
+ QSignalSpy spyChanged1(&proxyModel, &PModel::layoutChanged);
QVERIFY(spyAbout1.isValid());
QVERIFY(spyChanged1.isValid());
@@ -2915,8 +2920,8 @@ void tst_QSortFilterProxyModel::appearsAndSort()
secondProxyModel.setDynamicSortFilter(true);
secondProxyModel.sort(0, Qt::DescendingOrder);
QCOMPARE(secondProxyModel.rowCount(), 0); //all rows are hidden at first;
- QSignalSpy spyAbout2(&secondProxyModel, SIGNAL(layoutAboutToBeChanged()));
- QSignalSpy spyChanged2(&secondProxyModel, SIGNAL(layoutChanged()));
+ QSignalSpy spyAbout2(&secondProxyModel, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy spyChanged2(&secondProxyModel, &QSortFilterProxyModel::layoutChanged);
QVERIFY(spyAbout2.isValid());
QVERIFY(spyChanged2.isValid());
@@ -3443,25 +3448,25 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged()
proxy2.setSourceModel(&proxy);
proxy2.setObjectName("proxy2");
- QSignalSpy dataChangedSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
+ QSignalSpy dataChangedSpy(&model, &QSortFilterProxyModel::dataChanged);
QVERIFY(dataChangedSpy.isValid());
// Verify that the no-arg signal is still emitted.
- QSignalSpy layoutAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged()));
- QSignalSpy layoutChangedSpy(&proxy, SIGNAL(layoutChanged()));
+ QSignalSpy layoutAboutToBeChangedSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy layoutChangedSpy(&proxy, &QSortFilterProxyModel::layoutChanged);
QVERIFY(layoutAboutToBeChangedSpy.isValid());
QVERIFY(layoutChangedSpy.isValid());
- QSignalSpy parentsAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
- QSignalSpy parentsChangedSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QSignalSpy parentsAboutToBeChangedSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy parentsChangedSpy(&proxy, &QSortFilterProxyModel::layoutChanged);
QVERIFY(parentsAboutToBeChangedSpy.isValid());
QVERIFY(parentsChangedSpy.isValid());
- QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
- QSignalSpy proxy2ParentsChangedSpy(&proxy2, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy proxy2ParentsChangedSpy(&proxy2, &QSortFilterProxyModel::layoutChanged);
QVERIFY(proxy2ParentsAboutToBeChangedSpy.isValid());
QVERIFY(proxy2ParentsChangedSpy.isValid());
@@ -3484,8 +3489,8 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged()
QVariantList beforeSignal = parentsAboutToBeChangedSpy.first();
QVariantList afterSignal = parentsChangedSpy.first();
- QCOMPARE(beforeSignal.size(), 1);
- QCOMPARE(afterSignal.size(), 1);
+ QCOMPARE(beforeSignal.size(), 2);
+ QCOMPARE(afterSignal.size(), 2);
QList<QPersistentModelIndex> beforeParents = beforeSignal.first().value<QList<QPersistentModelIndex> >();
QList<QPersistentModelIndex> afterParents = afterSignal.first().value<QList<QPersistentModelIndex> >();
@@ -3620,16 +3625,16 @@ void tst_QSortFilterProxyModel::moveSourceRows()
filterBothProxy.setSourceModel(&proxy);
filterBothProxy.setFilterRegExp("5"); // The parents are 6 and 3. This filters both out.
- QSignalSpy modelBeforeSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy modelAfterSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy proxyBeforeMoveSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy proxyAfterMoveSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
- QSignalSpy proxyBeforeParentLayoutSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
- QSignalSpy proxyAfterParentLayoutSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
- QSignalSpy filterBeforeParentLayoutSpy(&filterProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
- QSignalSpy filterAfterParentLayoutSpy(&filterProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
- QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)));
- QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)));
+ QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::rowsAboutToBeMoved);
+ QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::rowsMoved);
+ QSignalSpy proxyBeforeMoveSpy(m_proxy, &QSortFilterProxyModel::rowsAboutToBeMoved);
+ QSignalSpy proxyAfterMoveSpy(m_proxy, &QSortFilterProxyModel::rowsMoved);
+ QSignalSpy proxyBeforeParentLayoutSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy proxyAfterParentLayoutSpy(&proxy, &QSortFilterProxyModel::layoutChanged);
+ QSignalSpy filterBeforeParentLayoutSpy(&filterProxy, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy filterAfterParentLayoutSpy(&filterProxy, &QSortFilterProxyModel::layoutChanged);
+ QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, &QSortFilterProxyModel::layoutAboutToBeChanged);
+ QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, &QSortFilterProxyModel::layoutChanged);
QVERIFY(modelBeforeSpy.isValid());
QVERIFY(modelAfterSpy.isValid());
@@ -3872,5 +3877,35 @@ void tst_QSortFilterProxyModel::noMapAfterSourceDelete()
QVERIFY(!persistent.isValid());
}
+// QTBUG-39549, test whether canDropMimeData(), dropMimeData() are proxied as well
+// by invoking them on a QSortFilterProxyModel proxying a QStandardItemModel that allows drops
+// on row #1, filtering for that row.
+class DropTestModel : public QStandardItemModel {
+public:
+ explicit DropTestModel(QObject *parent = 0) : QStandardItemModel(0, 1, parent)
+ {
+ appendRow(new QStandardItem(QStringLiteral("Row0")));
+ appendRow(new QStandardItem(QStringLiteral("Row1")));
+ }
+
+ bool canDropMimeData(const QMimeData *, Qt::DropAction,
+ int row, int /* column */, const QModelIndex & /* parent */) const Q_DECL_OVERRIDE
+ { return row == 1; }
+
+ bool dropMimeData(const QMimeData *, Qt::DropAction,
+ int row, int /* column */, const QModelIndex & /* parent */) Q_DECL_OVERRIDE
+ { return row == 1; }
+};
+
+void tst_QSortFilterProxyModel::forwardDropApi()
+{
+ QSortFilterProxyModel model;
+ model.setSourceModel(new DropTestModel(&model));
+ model.setFilterFixedString(QStringLiteral("Row1"));
+ QCOMPARE(model.rowCount(), 1);
+ QVERIFY(model.canDropMimeData(0, Qt::CopyAction, 0, 0, QModelIndex()));
+ QVERIFY(model.dropMimeData(0, Qt::CopyAction, 0, 0, QModelIndex()));
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index a17fe7561a..ebe7333c47 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -90,7 +90,9 @@ private Q_SLOTS:
void nullValues();
void nullArrays();
void nullObject();
+ void constNullObject();
+ void undefinedKeys();
void keySorting();
void undefinedValues();
@@ -132,13 +134,21 @@ private Q_SLOTS:
void testTrailingComma();
void testDetachBug();
+ void testJsonValueRefDefault();
void valueEquals();
+ void objectEquals_data();
+ void objectEquals();
+ void arrayEquals_data();
+ void arrayEquals();
void bom();
void nesting();
void longStrings();
+
+ void arrayInitializerList();
+ void objectInitializerList();
private:
QString testDataDir;
};
@@ -709,6 +719,28 @@ void tst_QtJson::testValueRef()
void tst_QtJson::testObjectIteration()
{
QJsonObject object;
+
+ for (QJsonObject::iterator it = object.begin(); it != object.end(); ++it)
+ QVERIFY(false);
+
+ object["undefined"];
+ for (QJsonObject::iterator it = object.begin(); it != object.end(); ++it)
+ QVERIFY(false);
+
+ const QString property = "kkk";
+ object.insert(property, 11);
+ object.take(property);
+ for (QJsonObject::iterator it = object.begin(); it != object.end(); ++it)
+ QVERIFY(false);
+
+ object.insert(property, 11);
+ object["aaa"]; // before "kkk"
+ object["zzz"]; // after "kkk"
+ for (QJsonObject::iterator it = object.begin(); it != object.end(); ++it)
+ QCOMPARE(it.key(), property);
+
+ object = QJsonObject();
+
for (int i = 0; i < 10; ++i)
object[QString::number(i)] = (double)i;
@@ -982,6 +1014,7 @@ void tst_QtJson::nullObject()
nonNull.insert(QLatin1String("foo"), QLatin1String("bar"));
QCOMPARE(nullObject, QJsonObject());
+ QCOMPARE(nullObject.size(), 0);
QVERIFY(nullObject != nonNull);
QVERIFY(nonNull != nullObject);
@@ -999,8 +1032,54 @@ void tst_QtJson::nullObject()
QCOMPARE(nullObject.keys(), QStringList());
nullObject.remove("foo");
QCOMPARE(nullObject, QJsonObject());
+ QCOMPARE(QJsonValue(nullObject["foo"]), QJsonValue(QJsonValue::Undefined));
QCOMPARE(nullObject.take("foo"), QJsonValue(QJsonValue::Undefined));
QCOMPARE(nullObject.contains("foo"), false);
+ QCOMPARE(nullObject, QJsonObject());
+ QCOMPARE(nullObject.size(), 0);
+
+ // There is not way to check if internal temporary storage for QJsonValueRef is removed correctly by
+ // remove, take or compaction but at least we should not crash
+ nullObject["foo"];
+ QCOMPARE(nullObject.size(), 0);
+ nullObject.remove("foo");
+ QCOMPARE(nullObject.size(), 0);
+ nullObject["foo"];
+ QCOMPARE(nullObject.size(), 0);
+ nullObject.take("foo");
+ QCOMPARE(nullObject.size(), 0);
+ QString property("foo");
+ for (int i = 0; i < 128; ++i)
+ nullObject[property + QString::number(i)];
+
+ QCOMPARE(nullObject.size(), 0);
+}
+
+void tst_QtJson::constNullObject()
+{
+ const QJsonObject nullObject;
+ QJsonObject nonNull;
+ nonNull.insert(QLatin1String("foo"), QLatin1String("bar"));
+
+ QCOMPARE(nullObject, QJsonObject());
+ QVERIFY(nullObject != nonNull);
+ QVERIFY(nonNull != nullObject);
+
+ QCOMPARE(nullObject.size(), 0);
+ QCOMPARE(nullObject.keys(), QStringList());
+ QCOMPARE(nullObject, QJsonObject());
+ QCOMPARE(nullObject.contains("foo"), false);
+ QCOMPARE(nullObject["foo"], QJsonValue(QJsonValue::Undefined));
+}
+
+void tst_QtJson::undefinedKeys()
+{
+ QJsonObject null;
+ QVERIFY(null.keys().isEmpty());
+
+ // check that an internal udefined doesn't show up
+ null["undefined"];
+ QVERIFY(null.keys().isEmpty());
}
void tst_QtJson::keySorting()
@@ -1138,6 +1217,11 @@ void tst_QtJson::toVariantMap()
QVariantMap map = object.toVariantMap();
QVERIFY(map.isEmpty());
+ // check an empty object with an internal undefined
+ QJsonValueRef unused = object["undefined"];
+ Q_UNUSED(unused);
+ QVERIFY(object.toVariantMap().isEmpty());
+
object.insert("Key", QString("Value"));
object.insert("null", QJsonValue());
QJsonArray array;
@@ -2309,6 +2393,129 @@ void tst_QtJson::valueEquals()
QVERIFY(QJsonValue("\xc3\xa9") == QJsonValue(QString("\xc3\xa9")));
}
+void tst_QtJson::objectEquals_data()
+{
+ QTest::addColumn<QJsonObject>("left");
+ QTest::addColumn<QJsonObject>("right");
+ QTest::addColumn<bool>("result");
+
+ QTest::newRow("two defaults") << QJsonObject() << QJsonObject() << true;
+
+ QJsonObject object1;
+ object1.insert("property", 1);
+ QJsonObject object2;
+ object2["property"] = 1;
+ QJsonObject object3;
+ object3.insert("property1", 1);
+ object3.insert("property2", 2);
+
+ QTest::newRow("the same object (1 vs 2)") << object1 << object2 << true;
+ QTest::newRow("the same object (3 vs 3)") << object3 << object3 << true;
+ QTest::newRow("different objects (2 vs 3)") << object2 << object3 << false;
+ QTest::newRow("object vs default") << object1 << QJsonObject() << false;
+
+ QJsonObject empty;
+ empty.insert("property", 1);
+ empty.take("property");
+ QTest::newRow("default vs empty") << QJsonObject() << empty << true;
+ QTest::newRow("empty vs empty") << empty << empty << true;
+ QTest::newRow("object vs empty") << object1 << empty << false;
+
+ QJsonObject referencedEmpty;
+ referencedEmpty["undefined"];
+ QTest::newRow("referenced empty vs default") << referencedEmpty << QJsonObject() << true;
+ QTest::newRow("referenced empty vs referenced empty") << referencedEmpty << referencedEmpty << true;
+ QTest::newRow("referenced empty vs object") << referencedEmpty << object1 << false;
+
+ QJsonObject referencedObject1;
+ referencedObject1.insert("property", 1);
+ referencedObject1["undefined"];
+ QJsonObject referencedObject2;
+ referencedObject2.insert("property", 1);
+ referencedObject2["aaaaaaaaa"]; // earlier then "property"
+ referencedObject2["zzzzzzzzz"]; // after "property"
+ QTest::newRow("referenced object vs default") << referencedObject1 << QJsonObject() << false;
+ QTest::newRow("referenced object vs referenced object") << referencedObject1 << referencedObject1 << true;
+ QTest::newRow("referenced object vs object (same)") << referencedObject1 << object1 << true;
+ QTest::newRow("referenced object vs object (different)") << referencedObject1 << object3 << false;
+ QTest::newRow("referenced object vs referenced object (same)") << referencedObject1 << referencedObject2 << true;
+}
+
+void tst_QtJson::objectEquals()
+{
+ QFETCH(QJsonObject, left);
+ QFETCH(QJsonObject, right);
+ QFETCH(bool, result);
+
+ QCOMPARE(left == right, result);
+ QCOMPARE(right == left, result);
+
+ // invariants checks
+ QCOMPARE(left, left);
+ QCOMPARE(right, right);
+ QCOMPARE(left != right, !result);
+ QCOMPARE(right != left, !result);
+
+ // The same but from QJsonValue perspective
+ QCOMPARE(QJsonValue(left) == QJsonValue(right), result);
+ QCOMPARE(QJsonValue(left) != QJsonValue(right), !result);
+ QCOMPARE(QJsonValue(right) == QJsonValue(left), result);
+ QCOMPARE(QJsonValue(right) != QJsonValue(left), !result);
+}
+
+void tst_QtJson::arrayEquals_data()
+{
+ QTest::addColumn<QJsonArray>("left");
+ QTest::addColumn<QJsonArray>("right");
+ QTest::addColumn<bool>("result");
+
+ QTest::newRow("two defaults") << QJsonArray() << QJsonArray() << true;
+
+ QJsonArray array1;
+ array1.append(1);
+ QJsonArray array2;
+ array2.append(2111);
+ array2[0] = 1;
+ QJsonArray array3;
+ array3.insert(0, 1);
+ array3.insert(1, 2);
+
+ QTest::newRow("the same array (1 vs 2)") << array1 << array2 << true;
+ QTest::newRow("the same array (3 vs 3)") << array3 << array3 << true;
+ QTest::newRow("different arrays (2 vs 3)") << array2 << array3 << false;
+ QTest::newRow("array vs default") << array1 << QJsonArray() << false;
+
+ QJsonArray empty;
+ empty.append(1);
+ empty.takeAt(0);
+ QTest::newRow("default vs empty") << QJsonArray() << empty << true;
+ QTest::newRow("empty vs default") << empty << QJsonArray() << true;
+ QTest::newRow("empty vs empty") << empty << empty << true;
+ QTest::newRow("array vs empty") << array1 << empty << false;
+}
+
+void tst_QtJson::arrayEquals()
+{
+ QFETCH(QJsonArray, left);
+ QFETCH(QJsonArray, right);
+ QFETCH(bool, result);
+
+ QCOMPARE(left == right, result);
+ QCOMPARE(right == left, result);
+
+ // invariants checks
+ QCOMPARE(left, left);
+ QCOMPARE(right, right);
+ QCOMPARE(left != right, !result);
+ QCOMPARE(right != left, !result);
+
+ // The same but from QJsonValue perspective
+ QCOMPARE(QJsonValue(left) == QJsonValue(right), result);
+ QCOMPARE(QJsonValue(left) != QJsonValue(right), !result);
+ QCOMPARE(QJsonValue(right) == QJsonValue(left), result);
+ QCOMPARE(QJsonValue(right) != QJsonValue(left), !result);
+}
+
void tst_QtJson::bom()
{
QFile file(testDataDir + "/bom.json");
@@ -2425,5 +2632,122 @@ void tst_QtJson::longStrings()
}
}
+void tst_QtJson::testJsonValueRefDefault()
+{
+ QJsonObject empty;
+
+ QCOMPARE(empty["n/a"].toString(), QString());
+ QCOMPARE(empty["n/a"].toString("default"), QStringLiteral("default"));
+
+ QCOMPARE(empty["n/a"].toBool(), false);
+ QCOMPARE(empty["n/a"].toBool(true), true);
+
+ QCOMPARE(empty["n/a"].toInt(), 0);
+ QCOMPARE(empty["n/a"].toInt(42), 42);
+
+ QCOMPARE(empty["n/a"].toDouble(), 0.0);
+ QCOMPARE(empty["n/a"].toDouble(42.0), 42.0);
+}
+
+void tst_QtJson::arrayInitializerList()
+{
+#ifndef Q_COMPILER_INITIALIZER_LISTS
+ QSKIP("initializer_list is enabled only with c++11 support");
+#else
+ QVERIFY(QJsonArray{}.isEmpty());
+ QCOMPARE(QJsonArray{"one"}.count(), 1);
+ QCOMPARE(QJsonArray{1}.count(), 1);
+
+ {
+ QJsonArray a{1.3, "hello", 0};
+ QCOMPARE(QJsonValue(a[0]), QJsonValue(1.3));
+ QCOMPARE(QJsonValue(a[1]), QJsonValue("hello"));
+ QCOMPARE(QJsonValue(a[2]), QJsonValue(0));
+ QCOMPARE(a.count(), 3);
+ }
+ {
+ QJsonObject o;
+ o["property"] = 1;
+ QJsonArray a1 {o};
+ QCOMPARE(a1.count(), 1);
+ QCOMPARE(a1[0].toObject(), o);
+
+ QJsonArray a2 {o, 23};
+ QCOMPARE(a2.count(), 2);
+ QCOMPARE(a2[0].toObject(), o);
+ QCOMPARE(QJsonValue(a2[1]), QJsonValue(23));
+
+ QJsonArray a3 { a1, o, a2 };
+ QCOMPARE(QJsonValue(a3[0]), QJsonValue(a1));
+ QCOMPARE(QJsonValue(a3[1]), QJsonValue(o));
+ QCOMPARE(QJsonValue(a3[2]), QJsonValue(a2));
+
+ QJsonArray a4 { 1, QJsonArray{1,2,3}, QJsonArray{"hello", 2}, QJsonObject{{"one", 1}} };
+ QCOMPARE(a4.count(), 4);
+ QCOMPARE(QJsonValue(a4[0]), QJsonValue(1));
+
+ {
+ QJsonArray a41 = a4[1].toArray();
+ QJsonArray a42 = a4[2].toArray();
+ QJsonObject a43 = a4[3].toObject();
+ QCOMPARE(a41.count(), 3);
+ QCOMPARE(a42.count(), 2);
+ QCOMPARE(a43.count(), 1);
+
+ QCOMPARE(QJsonValue(a41[2]), QJsonValue(3));
+ QCOMPARE(QJsonValue(a42[1]), QJsonValue(2));
+ QCOMPARE(QJsonValue(a43["one"]), QJsonValue(1));
+ }
+ }
+#endif
+}
+
+void tst_QtJson::objectInitializerList()
+{
+#ifndef Q_COMPILER_INITIALIZER_LISTS
+ QSKIP("initializer_list is enabled only with c++11 support");
+#else
+ QVERIFY(QJsonObject{}.isEmpty());
+
+ { // one property
+ QJsonObject one {{"one", 1}};
+ QCOMPARE(one.count(), 1);
+ QVERIFY(one.contains("one"));
+ QCOMPARE(QJsonValue(one["one"]), QJsonValue(1));
+ }
+ { // two properties
+ QJsonObject two {
+ {"one", 1},
+ {"two", 2}
+ };
+ QCOMPARE(two.count(), 2);
+ QVERIFY(two.contains("one"));
+ QVERIFY(two.contains("two"));
+ QCOMPARE(QJsonValue(two["one"]), QJsonValue(1));
+ QCOMPARE(QJsonValue(two["two"]), QJsonValue(2));
+ }
+ { // nested object
+ QJsonObject object{{"nested", QJsonObject{{"innerProperty", 2}}}};
+ QCOMPARE(object.count(), 1);
+ QVERIFY(object.contains("nested"));
+ QVERIFY(object["nested"].isObject());
+
+ QJsonObject nested = object["nested"].toObject();
+ QCOMPARE(QJsonValue(nested["innerProperty"]), QJsonValue(2));
+ }
+ { // nested array
+ QJsonObject object{{"nested", QJsonArray{"innerValue", 2.1, "bum cyk cyk"}}};
+ QCOMPARE(object.count(), 1);
+ QVERIFY(object.contains("nested"));
+ QVERIFY(object["nested"].isArray());
+
+ QJsonArray nested = object["nested"].toArray();
+ QCOMPARE(nested.count(), 3);
+ QCOMPARE(QJsonValue(nested[0]), QJsonValue("innerValue"));
+ QCOMPARE(QJsonValue(nested[1]), QJsonValue(2.1));
+ }
+#endif
+}
+
QTEST_MAIN(tst_QtJson)
#include "tst_qtjson.moc"
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
index a7833aa835..ce9577e0ed 100644
--- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
@@ -195,8 +195,8 @@ protected:
void tst_QEventLoop::processEvents()
{
- QSignalSpy aboutToBlockSpy(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()));
- QSignalSpy awakeSpy(QAbstractEventDispatcher::instance(), SIGNAL(awake()));
+ QSignalSpy aboutToBlockSpy(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock);
+ QSignalSpy awakeSpy(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::awake);
QVERIFY(aboutToBlockSpy.isValid());
QVERIFY(awakeSpy.isValid());
@@ -282,7 +282,7 @@ void tst_QEventLoop::exec()
thread.cond.wait(&thread.mutex);
// make sure the eventloop runs
- QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), SIGNAL(awake()));
+ QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), &QAbstractEventDispatcher::awake);
QVERIFY(spy.isValid());
thread.cond.wakeOne();
thread.cond.wait(&thread.mutex);
@@ -345,7 +345,7 @@ void tst_QEventLoop::wakeUp()
thread.start();
(void) eventLoop.exec();
- QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), SIGNAL(awake()));
+ QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), &QAbstractEventDispatcher::awake);
QVERIFY(spy.isValid());
thread.eventLoop->wakeUp();
@@ -633,7 +633,7 @@ void tst_QEventLoop::testQuitLock()
QTimer timer;
timer.setInterval(100);
- QSignalSpy timerSpy(&timer, SIGNAL(timeout()));
+ QSignalSpy timerSpy(&timer, &QTimer::timeout);
timer.start();
QEventLoopPrivate* privateClass = static_cast<QEventLoopPrivate*>(QObjectPrivate::get(&eventLoop));
diff --git a/tests/auto/corelib/kernel/qmath/tst_qmath.cpp b/tests/auto/corelib/kernel/qmath/tst_qmath.cpp
index 24934ac138..8d6964cbcd 100644
--- a/tests/auto/corelib/kernel/qmath/tst_qmath.cpp
+++ b/tests/auto/corelib/kernel/qmath/tst_qmath.cpp
@@ -54,6 +54,14 @@ private slots:
void degreesToRadians();
void radiansToDegrees_data();
void radiansToDegrees();
+ void qNextPowerOfTwo32S_data();
+ void qNextPowerOfTwo32S();
+ void qNextPowerOfTwo64S_data();
+ void qNextPowerOfTwo64S();
+ void qNextPowerOfTwo32U_data();
+ void qNextPowerOfTwo32U();
+ void qNextPowerOfTwo64U_data();
+ void qNextPowerOfTwo64U();
};
void tst_QMath::fastSinCos()
@@ -137,6 +145,117 @@ void tst_QMath::radiansToDegrees()
QCOMPARE(qRadiansToDegrees(radiansDouble), degreesDouble);
}
+
+void tst_QMath::qNextPowerOfTwo32S_data()
+{
+ QTest::addColumn<qint32>("input");
+ QTest::addColumn<quint32>("output");
+
+ QTest::newRow("0") << 0 << 1U;
+ QTest::newRow("1") << 1 << 2U;
+ QTest::newRow("2") << 2 << 4U;
+ QTest::newRow("17") << 17 << 32U;
+ QTest::newRow("128") << 128 << 256U;
+ QTest::newRow("65535") << 65535 << 65536U;
+ QTest::newRow("65536") << 65536 << 131072U;
+ QTest::newRow("2^30") << (1 << 30) << (1U << 31);
+ QTest::newRow("2^30 + 1") << (1 << 30) + 1 << (1U << 31);
+ QTest::newRow("2^31 - 1") << 0x7FFFFFFF << (1U<<31);
+ QTest::newRow("-1") << -1 << 0U;
+ QTest::newRow("-128") << -128 << 0U;
+ QTest::newRow("-(2^31)") << int(0x80000000) << 0U;
+}
+
+void tst_QMath::qNextPowerOfTwo32S()
+{
+ QFETCH(qint32, input);
+ QFETCH(quint32, output);
+
+ QCOMPARE(qNextPowerOfTwo(input), output);
+}
+
+void tst_QMath::qNextPowerOfTwo32U_data()
+{
+ QTest::addColumn<quint32>("input");
+ QTest::addColumn<quint32>("output");
+
+ QTest::newRow("0") << 0U << 1U;
+ QTest::newRow("1") << 1U << 2U;
+ QTest::newRow("2") << 2U << 4U;
+ QTest::newRow("17") << 17U << 32U;
+ QTest::newRow("128") << 128U << 256U;
+ QTest::newRow("65535") << 65535U << 65536U;
+ QTest::newRow("65536") << 65536U << 131072U;
+ QTest::newRow("2^30") << (1U << 30) << (1U << 31);
+ QTest::newRow("2^30 + 1") << (1U << 30) + 1 << (1U << 31);
+ QTest::newRow("2^31 - 1") << 2147483647U << 2147483648U;
+ QTest::newRow("2^31") << 2147483648U << 0U;
+ QTest::newRow("2^31 + 1") << 2147483649U << 0U;
+}
+
+void tst_QMath::qNextPowerOfTwo32U()
+{
+ QFETCH(quint32, input);
+ QFETCH(quint32, output);
+
+ QCOMPARE(qNextPowerOfTwo(input), output);
+}
+
+void tst_QMath::qNextPowerOfTwo64S_data()
+{
+ QTest::addColumn<qint64>("input");
+ QTest::addColumn<quint64>("output");
+
+ QTest::newRow("0") << Q_INT64_C(0) << Q_UINT64_C(1);
+ QTest::newRow("1") << Q_INT64_C(1) << Q_UINT64_C(2);
+ QTest::newRow("2") << Q_INT64_C(2) << Q_UINT64_C(4);
+ QTest::newRow("17") << Q_INT64_C(17) << Q_UINT64_C(32);
+ QTest::newRow("128") << Q_INT64_C(128) << Q_UINT64_C(256);
+ QTest::newRow("65535") << Q_INT64_C(65535) << Q_UINT64_C(65536);
+ QTest::newRow("65536") << Q_INT64_C(65536) << Q_UINT64_C(131072);
+ QTest::newRow("2^31 - 1") << Q_INT64_C(2147483647) << Q_UINT64_C(0x80000000);
+ QTest::newRow("2^31") << Q_INT64_C(2147483648) << Q_UINT64_C(0x100000000);
+ QTest::newRow("2^31 + 1") << Q_INT64_C(2147483649) << Q_UINT64_C(0x100000000);
+ QTest::newRow("2^63 - 1") << Q_INT64_C(0x7FFFFFFFFFFFFFFF) << Q_UINT64_C(0x8000000000000000);
+ QTest::newRow("-1") << Q_INT64_C(-1) << Q_UINT64_C(0);
+ QTest::newRow("-128") << Q_INT64_C(-128) << Q_UINT64_C(0);
+ QTest::newRow("-(2^31)") << -Q_INT64_C(0x80000000) << Q_UINT64_C(0);
+ QTest::newRow("-(2^63)") << (qint64)Q_INT64_C(0x8000000000000000) << Q_UINT64_C(0);
+}
+
+void tst_QMath::qNextPowerOfTwo64S()
+{
+ QFETCH(qint64, input);
+ QFETCH(quint64, output);
+
+ QCOMPARE(qNextPowerOfTwo(input), output);
+}
+
+void tst_QMath::qNextPowerOfTwo64U_data()
+{
+ QTest::addColumn<quint64>("input");
+ QTest::addColumn<quint64>("output");
+
+ QTest::newRow("0") << Q_UINT64_C(0) << Q_UINT64_C(1);
+ QTest::newRow("1") << Q_UINT64_C(1) << Q_UINT64_C(2);
+ QTest::newRow("2") << Q_UINT64_C(2) << Q_UINT64_C(4);
+ QTest::newRow("17") << Q_UINT64_C(17) << Q_UINT64_C(32);
+ QTest::newRow("128") << Q_UINT64_C(128) << Q_UINT64_C(256);
+ QTest::newRow("65535") << Q_UINT64_C(65535) << Q_UINT64_C(65536);
+ QTest::newRow("65536") << Q_UINT64_C(65536) << Q_UINT64_C(131072);
+ QTest::newRow("2^63 - 1") << Q_UINT64_C(0x7FFFFFFFFFFFFFFF) << Q_UINT64_C(0x8000000000000000);
+ QTest::newRow("2^63") << Q_UINT64_C(0x8000000000000000) << Q_UINT64_C(0);
+ QTest::newRow("2^63 + 1") << Q_UINT64_C(0x8000000000000001) << Q_UINT64_C(0);
+}
+
+void tst_QMath::qNextPowerOfTwo64U()
+{
+ QFETCH(quint64, input);
+ QFETCH(quint64, output);
+
+ QCOMPARE(qNextPowerOfTwo(input), output);
+}
+
QTEST_APPLESS_MAIN(tst_QMath)
#include "tst_qmath.moc"
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
index 3afc2bc574..a920ea7a01 100644
--- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
@@ -561,9 +561,11 @@ void tst_QMetaObject::invokeMetaMember()
QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist"));
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Q_ARG(QString, "arg")));
- QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)");
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)\n"
+ "Candidates are:\n sl3(QString,QString,QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Q_ARG(QString, "arg")));
- QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)");
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)\n"
+ "Candidates are:\n sl1(QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg")));
//should not have changed since last test.
@@ -747,9 +749,11 @@ void tst_QMetaObject::invokeBlockingQueuedMetaMember()
QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist", Qt::BlockingQueuedConnection));
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg")));
- QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)");
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)\n"
+ "Candidates are:\n sl3(QString,QString,QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg")));
- QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)");
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)\n"
+ "Candidates are:\n sl1(QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg")));
//should not have changed since last test.
@@ -857,7 +861,7 @@ void tst_QMetaObject::invokeTypedefTypes()
{
qRegisterMetaType<CustomString>("CustomString");
QtTestCustomObject obj;
- QSignalSpy spy(&obj, SIGNAL(sig_custom(CustomString)));
+ QSignalSpy spy(&obj, &QtTestCustomObject::sig_custom);
QVERIFY(spy.isValid());
QCOMPARE(spy.count(), 0);
diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
index 0e7005799e..62e41a96c5 100644
--- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
@@ -1593,7 +1593,7 @@ void tst_QMetaObjectBuilder::usage_signal()
{
QScopedPointer<TestObject> testObject(new TestObject);
- QSignalSpy propChangedSpy(testObject.data(), SIGNAL(intPropChanged(int)));
+ QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged);
testObject->emitIntPropChanged();
QCOMPARE(propChangedSpy.count(), 1);
QCOMPARE(propChangedSpy.at(0).count(), 1);
@@ -1608,7 +1608,7 @@ void tst_QMetaObjectBuilder::usage_property()
QCOMPARE(prop.type(), QVariant::Int);
QCOMPARE(prop.toInt(), testObject->intProp());
- QSignalSpy propChangedSpy(testObject.data(), SIGNAL(intPropChanged(int)));
+ QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged);
QVERIFY(testObject->intProp() != 123);
testObject->setProperty("intProp", 123);
QCOMPARE(propChangedSpy.count(), 1);
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 959c79ed60..9a86dc03e5 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -1341,6 +1341,8 @@ static QByteArray createTypeName(const char *begin, const char *va)
}
#endif
+Q_DECLARE_METATYPE(const void*)
+
void tst_QMetaType::automaticTemplateRegistration()
{
#define TEST_SEQUENTIAL_CONTAINER(CONTAINER, VALUE_TYPE) \
@@ -1358,6 +1360,17 @@ void tst_QMetaType::automaticTemplateRegistration()
TEST_SEQUENTIAL_CONTAINER(std::list, int)
{
+ std::vector<bool> vecbool;
+ vecbool.push_back(true);
+ vecbool.push_back(false);
+ vecbool.push_back(true);
+ QVERIFY(QVariant::fromValue(vecbool).value<std::vector<bool> >().front() == true);
+ QVector<std::vector<bool> > vectorList;
+ vectorList << vecbool;
+ QVERIFY(QVariant::fromValue(vectorList).value<QVector<std::vector<bool> > >().first().front() == true);
+ }
+
+ {
QList<QByteArray> bytearrayList;
bytearrayList << QByteArray("foo");
QVERIFY(QVariant::fromValue(bytearrayList).value<QList<QByteArray> >().first() == QByteArray("foo"));
@@ -1577,6 +1590,12 @@ void tst_QMetaType::automaticTemplateRegistration()
)
CREATE_AND_VERIFY_CONTAINER(QList, QList<QMap<int, QHash<char, QVariantList> > >)
+ CREATE_AND_VERIFY_CONTAINER(QVector, void*)
+ CREATE_AND_VERIFY_CONTAINER(QVector, const void*)
+ CREATE_AND_VERIFY_CONTAINER(QList, void*)
+ CREATE_AND_VERIFY_CONTAINER(QPair, void*, void*)
+ CREATE_AND_VERIFY_CONTAINER(QHash, void*, void*)
+ CREATE_AND_VERIFY_CONTAINER(QHash, const void*, const void*)
#endif // Q_COMPILER_VARIADIC_MACROS
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 1c0a495116..0308e870be 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -270,6 +270,21 @@ public slots:
int ReceiverObject::sequence = 0;
+static void playWithObjects()
+{
+ // Do operations that will lock the internal signalSlotLock mutex on many QObjects.
+ // The more QObjects, the higher the chance that the signalSlotLock mutex used
+ // is already in use. If the number of objects is higher than the number of mutexes in
+ // the pool (currently 131), the deadlock should always trigger. Use an even higher number
+ // to be on the safe side.
+ const int objectCount = 1024;
+ SenderObject lotsOfObjects[objectCount];
+ for (int i = 0; i < objectCount; ++i) {
+ QObject::connect(&lotsOfObjects[i], &SenderObject::signal1,
+ &lotsOfObjects[i], &SenderObject::aPublicSlot);
+ }
+}
+
void tst_QObject::initTestCase()
{
const QString testDataDir = QFileInfo(QFINDTESTDATA("signalbug")).absolutePath();
@@ -1368,10 +1383,10 @@ struct CheckInstanceCount
struct CustomType
{
CustomType(int l1 = 0, int l2 = 0, int l3 = 0): i1(l1), i2(l2), i3(l3)
- { ++instanceCount; }
+ { ++instanceCount; playWithObjects(); }
CustomType(const CustomType &other): i1(other.i1), i2(other.i2), i3(other.i3)
- { ++instanceCount; }
- ~CustomType() { --instanceCount; }
+ { ++instanceCount; playWithObjects(); }
+ ~CustomType() { --instanceCount; playWithObjects(); }
int i1, i2, i3;
int value() { return i1 + i2 + i3; }
@@ -5749,17 +5764,7 @@ public:
{}
~MyFunctor() {
- // Do operations that will lock the internal signalSlotLock mutex on many QObjects.
- // The more QObjects, the higher the chance that the signalSlotLock mutex used
- // is already in use. If the number of objects is higher than the number of mutexes in
- // the pool (currently 131), the deadlock should always trigger. Use an even higher number
- // to be on the safe side.
- const int objectCount = 1024;
- SenderObject lotsOfObjects[objectCount];
- for (int i = 0; i < objectCount; ++i) {
- QObject::connect(&lotsOfObjects[i], &SenderObject::signal1,
- &lotsOfObjects[i], &SenderObject::aPublicSlot);
- }
+ playWithObjects();
}
void operator()() {
diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp
index ce5e83288f..82f0a846bc 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp
+++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -114,7 +114,7 @@ private slots:
void uniqueKey();
protected:
- QString helperBinary();
+ static QString helperBinary();
int remove(const QString &key);
QString rememberKey(const QString &key)
@@ -131,10 +131,14 @@ protected:
QStringList keys;
QList<QSharedMemory*> jail;
QSharedMemory *existingSharedMemory;
+
+private:
+ const QString m_helperBinary;
};
-tst_QSharedMemory::tst_QSharedMemory() :
- existingSharedMemory(0)
+tst_QSharedMemory::tst_QSharedMemory()
+ : existingSharedMemory(0)
+ , m_helperBinary(tst_QSharedMemory::helperBinary())
{
}
@@ -144,7 +148,7 @@ tst_QSharedMemory::~tst_QSharedMemory()
void tst_QSharedMemory::initTestCase()
{
- QVERIFY2(!helperBinary().isEmpty(), "Could not find helper binary");
+ QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary");
}
void tst_QSharedMemory::init()
@@ -455,7 +459,7 @@ void tst_QSharedMemory::readOnly()
rememberKey("readonly_segfault");
// ### on windows disable the popup somehow
QProcess p;
- p.start(helperBinary(), QStringList("readonly_segfault"));
+ p.start(m_helperBinary, QStringList("readonly_segfault"));
p.setProcessChannelMode(QProcess::ForwardedChannels);
p.waitForFinished();
QCOMPARE(p.error(), QProcess::Crashed);
@@ -753,7 +757,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
rememberKey("market");
QProcess producer;
- producer.start(helperBinary(), QStringList("producer"));
+ producer.start(m_helperBinary, QStringList("producer"));
QVERIFY2(producer.waitForStarted(), "Could not start helper binary");
QVERIFY2(producer.waitForReadyRead(), "Helper process failed to create shared memory segment: " +
producer.readAllStandardError());
@@ -764,7 +768,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
for (int i = 0; i < processes; ++i) {
QProcess *p = new QProcess;
p->setProcessChannelMode(QProcess::ForwardedChannels);
- p->start(helperBinary(), consumerArguments);
+ p->start(m_helperBinary, consumerArguments);
if (p->waitForStarted(2000))
consumers.append(p);
else
diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
index 5632bcacc4..c650041e1e 100644
--- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
+++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
@@ -267,12 +267,12 @@ void tst_QSocketNotifier::posixSockets()
{
QSocketNotifier rn(posixSocket, QSocketNotifier::Read);
connect(&rn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QSignalSpy readSpy(&rn, SIGNAL(activated(int)));
+ QSignalSpy readSpy(&rn, &QSocketNotifier::activated);
QVERIFY(readSpy.isValid());
// No write notifier, some systems trigger write notification on socket creation, but not all
QSocketNotifier en(posixSocket, QSocketNotifier::Exception);
connect(&en, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QSignalSpy errorSpy(&en, SIGNAL(activated(int)));
+ QSignalSpy errorSpy(&en, &QSocketNotifier::activated);
QVERIFY(errorSpy.isValid());
passive->write("hello",6);
@@ -289,7 +289,7 @@ void tst_QSocketNotifier::posixSockets()
QSocketNotifier wn(posixSocket, QSocketNotifier::Write);
connect(&wn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QSignalSpy writeSpy(&wn, SIGNAL(activated(int)));
+ QSignalSpy writeSpy(&wn, &QSocketNotifier::activated);
QVERIFY(writeSpy.isValid());
qt_safe_write(posixSocket, "goodbye", 8);
diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp
index 9e33f56a34..42f2709384 100644
--- a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp
+++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -80,17 +80,20 @@ private slots:
#endif // QT_NO_PROCESS
private:
- QString helperBinary();
+ static QString helperBinary();
QSystemSemaphore *existingLock;
+
+ const QString m_helperBinary;
};
tst_QSystemSemaphore::tst_QSystemSemaphore()
+ : m_helperBinary(helperBinary())
{
}
void tst_QSystemSemaphore::initTestCase()
{
- QVERIFY2(!helperBinary().isEmpty(), "Could not find helper binary");
+ QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary");
}
void tst_QSystemSemaphore::init()
@@ -193,12 +196,12 @@ void tst_QSystemSemaphore::basicProcesses()
QProcess release;
release.setProcessChannelMode(QProcess::ForwardedChannels);
- acquire.start(helperBinary(), QStringList("acquire"));
+ acquire.start(m_helperBinary, QStringList("acquire"));
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state() == QProcess::Running);
acquire.kill();
- release.start(helperBinary(), QStringList("release"));
+ release.start(m_helperBinary, QStringList("release"));
QVERIFY2(release.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
release.waitForFinished(HELPERWAITTIME);
@@ -227,7 +230,7 @@ void tst_QSystemSemaphore::processes()
QProcess *p = new QProcess;
p->setProcessChannelMode(QProcess::ForwardedChannels);
consumers.append(p);
- p->start(helperBinary(), QStringList(scripts.at(i)));
+ p->start(m_helperBinary, QStringList(scripts.at(i)));
}
while (!consumers.isEmpty()) {
@@ -247,14 +250,14 @@ void tst_QSystemSemaphore::undo()
QStringList acquireArguments = QStringList("acquire");
QProcess acquire;
acquire.setProcessChannelMode(QProcess::ForwardedChannels);
- acquire.start(helperBinary(), acquireArguments);
+ acquire.start(m_helperBinary, acquireArguments);
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state()== QProcess::NotRunning);
// At process exit the kernel should auto undo
- acquire.start(helperBinary(), acquireArguments);
+ acquire.start(m_helperBinary, acquireArguments);
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state()== QProcess::NotRunning);
@@ -273,18 +276,18 @@ void tst_QSystemSemaphore::initialValue()
QProcess release;
release.setProcessChannelMode(QProcess::ForwardedChannels);
- acquire.start(helperBinary(), acquireArguments);
+ acquire.start(m_helperBinary, acquireArguments);
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state()== QProcess::NotRunning);
- acquire.start(helperBinary(), acquireArguments << QLatin1String("2"));
+ acquire.start(m_helperBinary, acquireArguments << QLatin1String("2"));
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state()== QProcess::Running);
acquire.kill();
- release.start(helperBinary(), releaseArguments);
+ release.start(m_helperBinary, releaseArguments);
QVERIFY2(release.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
release.waitForFinished(HELPERWAITTIME);
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 27ea3faf81..31c627afcb 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -77,6 +77,7 @@ private slots:
void cancelLongTimer();
void singleShotStaticFunctionZeroTimeout();
void recurseOnTimeoutAndStopTimer();
+ void singleShotToFunctors();
void dontBlockEvents();
void postedEventsShouldNotStarveTimers();
@@ -586,6 +587,14 @@ void tst_QTimer::singleShotStaticFunctionZeroTimeout()
QCOMPARE(helper.count, 1);
QTest::qWait(500);
QCOMPARE(helper.count, 1);
+
+ TimerHelper nhelper;
+
+ QTimer::singleShot(0, &nhelper, &TimerHelper::timeout);
+ QCoreApplication::processEvents();
+ QCOMPARE(nhelper.count, 1);
+ QCoreApplication::processEvents();
+ QCOMPARE(nhelper.count, 1);
}
class RecursOnTimeoutAndStopTimerTimer : public QObject
@@ -631,6 +640,96 @@ void tst_QTimer::recurseOnTimeoutAndStopTimer()
QVERIFY(!t.two->isActive());
}
+struct CountedStruct
+{
+ CountedStruct(int *count, QThread *t = Q_NULLPTR) : count(count), thread(t) { }
+ ~CountedStruct() { }
+ void operator()() const { ++(*count); if (thread) QCOMPARE(QThread::currentThread(), thread); }
+
+ int *count;
+ QThread *thread;
+};
+
+static QEventLoop _e;
+static QThread *_t = Q_NULLPTR;
+
+class StaticEventLoop
+{
+public:
+ static void quitEventLoop() { _e.quit(); if (_t) QCOMPARE(QThread::currentThread(), _t); }
+};
+
+void tst_QTimer::singleShotToFunctors()
+{
+ int count = 0;
+ QEventLoop e;
+
+ QTimer::singleShot(0, CountedStruct(&count));
+ QCoreApplication::processEvents();
+ QCOMPARE(count, 1);
+
+ QTimer::singleShot(0, &StaticEventLoop::quitEventLoop);
+ QCOMPARE(_e.exec(), 0);
+
+ QThread t1;
+ QObject c1;
+ c1.moveToThread(&t1);
+
+ QObject::connect(&t1, SIGNAL(started()), &e, SLOT(quit()));
+ t1.start();
+ QCOMPARE(e.exec(), 0);
+
+ QTimer::singleShot(0, &c1, CountedStruct(&count, &t1));
+ QTest::qWait(500);
+ QCOMPARE(count, 2);
+
+ t1.quit();
+ t1.wait();
+
+ _t = new QThread;
+ QObject c2;
+ c2.moveToThread(_t);
+
+ QObject::connect(_t, SIGNAL(started()), &e, SLOT(quit()));
+ _t->start();
+ QCOMPARE(e.exec(), 0);
+
+ QTimer::singleShot(0, &c2, &StaticEventLoop::quitEventLoop);
+ QCOMPARE(_e.exec(), 0);
+
+ _t->quit();
+ _t->wait();
+ _t->deleteLater();
+ _t = Q_NULLPTR;
+
+ {
+ QObject c3;
+ QTimer::singleShot(500, &c3, CountedStruct(&count));
+ }
+ QTest::qWait(800);
+ QCOMPARE(count, 2);
+
+#if defined(Q_COMPILER_LAMBDA)
+ QTimer::singleShot(0, [&count] { ++count; });
+ QCoreApplication::processEvents();
+ QCOMPARE(count, 3);
+
+ QObject context;
+ QThread thread;
+
+ context.moveToThread(&thread);
+ QObject::connect(&thread, SIGNAL(started()), &e, SLOT(quit()));
+ thread.start();
+ QCOMPARE(e.exec(), 0);
+
+ QTimer::singleShot(0, &context, [&count, &thread] { ++count; QCOMPARE(QThread::currentThread(), &thread); });
+ QTest::qWait(500);
+ QCOMPARE(count, 4);
+
+ thread.quit();
+ thread.wait();
+#endif
+}
class DontBlockEvents : public QObject
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index aef79e0c2f..660d0f804e 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -318,18 +318,16 @@ void tst_QVariant::constructor_invalid()
QFETCH(uint, typeId);
{
- MessageHandlerInvalidType msg;
+ 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);
- QVERIFY(msg.ok);
}
{
- MessageHandlerInvalidType msg;
+ 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);
- QVERIFY(msg.ok);
}
}
diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
index d60e1514b9..2244f3e041 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
@@ -456,10 +456,21 @@ void tst_QLibrary::loadHints()
if (int(loadHints) != 0) {
lh |= library.loadHints();
library.setLoadHints(lh);
+
+ // confirm that another QLibrary doesn't get affected - QTBUG-39642
+ QCOMPARE(QLibrary().loadHints(), QLibrary::LoadHints());
}
library.setFileName(lib);
QCOMPARE(library.loadHints(), lh);
bool ok = library.load();
+
+ // we can't change the hints anymore
+ library.setLoadHints(QLibrary::LoadHints());
+ QCOMPARE(library.loadHints(), lh);
+
+ // confirm that a new QLibrary inherits the hints too
+ QCOMPARE(QLibrary(lib).loadHints(), lh);
+
if ( result ) {
QVERIFY( ok );
QVERIFY(library.unload());
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
index 351e3a23e0..4447eb7a0b 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
@@ -264,8 +264,8 @@ void tst_QPluginLoader::deleteinstanceOnUnload()
PluginInterface *instance2 = qobject_cast<PluginInterface*>(loader2.instance());
QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok"));
- QSignalSpy spy1(loader1.instance(), SIGNAL(destroyed()));
- QSignalSpy spy2(loader2.instance(), SIGNAL(destroyed()));
+ QSignalSpy spy1(loader1.instance(), &QObject::destroyed);
+ QSignalSpy spy2(loader2.instance(), &QObject::destroyed);
QVERIFY(spy1.isValid());
QVERIFY(spy2.isValid());
if (pass == 0) {
@@ -423,7 +423,7 @@ void tst_QPluginLoader::reloadPlugin()
QVERIFY(instance);
QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok"));
- QSignalSpy spy(loader.instance(), SIGNAL(destroyed()));
+ QSignalSpy spy(loader.instance(), &QObject::destroyed);
QVERIFY(spy.isValid());
QVERIFY(loader.unload()); // refcount reached 0, did really unload
QCOMPARE(spy.count(), 1);
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
index 2d7beaa7c8..67f3477eee 100644
--- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
@@ -71,6 +71,43 @@ static int globalTick;
QCoreApplication::exec(); \
}
+#define TEST_RUNNING_CHANGED(RUNNING) \
+{ \
+ QTRY_COMPARE(runningSpy.count(), 1); \
+ QList<QVariant> runningArgs = runningSpy.takeFirst(); \
+ QVERIFY(runningArgs.at(0).type() == QVariant::Bool); \
+ QVERIFY(runningArgs.at(0).toBool() == RUNNING); \
+ QCOMPARE(machine.isRunning(), runningArgs.at(0).toBool()); \
+}
+
+#define TEST_RUNNING_CHANGED_STARTED_STOPPED \
+{ \
+ QTRY_COMPARE(runningSpy.count(), 2); \
+ QList<QVariant> runningArgs = runningSpy.takeFirst(); \
+ QVERIFY(runningArgs.at(0).type() == QVariant::Bool); \
+ QVERIFY(runningArgs.at(0).toBool() == true); \
+ runningArgs = runningSpy.takeFirst(); \
+ QVERIFY(runningArgs.at(0).type() == QVariant::Bool); \
+ QVERIFY(runningArgs.at(0).toBool() == false); \
+ QCOMPARE(machine.isRunning(), runningArgs.at(0).toBool()); \
+}
+
+#define DEFINE_ACTIVE_SPY(VAR) \
+ QSignalSpy VAR##_activeSpy(VAR, &QState::activeChanged); \
+ QVERIFY(VAR##_activeSpy.isValid());
+
+#define TEST_ACTIVE_CHANGED(VAR, COUNT) \
+{ \
+ QTRY_COMPARE(VAR##_activeSpy.count(), COUNT); \
+ bool active = true; \
+ foreach (const QList<QVariant> &activeArgs, static_cast<QList<QList<QVariant> > >(VAR##_activeSpy)) { \
+ QVERIFY(activeArgs.at(0).type() == QVariant::Bool); \
+ QVERIFY(activeArgs.at(0).toBool() == active); \
+ active = !active; \
+ } \
+ QCOMPARE(VAR->active(), !active); \
+}
+
class SignalEmitter : public QObject
{
Q_OBJECT
@@ -120,6 +157,7 @@ private slots:
#endif
void historyStates();
void startAndStop();
+ void setRunning();
void targetStateWithNoParent();
void targetStateDeleted();
void transitionToRootState();
@@ -277,6 +315,7 @@ void tst_QStateMachine::transitionToRootState()
machine.setObjectName("machine");
QState *initialState = new QState();
+ DEFINE_ACTIVE_SPY(initialState);
initialState->setObjectName("initial");
machine.addState(initialState);
machine.setInitialState(initialState);
@@ -291,12 +330,14 @@ void tst_QStateMachine::transitionToRootState()
QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(initialState));
+ TEST_ACTIVE_CHANGED(initialState, 1);
machine.postEvent(new QEvent(QEvent::User));
QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 'initial'");
QCoreApplication::processEvents();
QVERIFY(machine.configuration().isEmpty());
QVERIFY(!machine.isRunning());
+ TEST_ACTIVE_CHANGED(initialState, 2);
}
void tst_QStateMachine::transitionFromRootState()
@@ -916,10 +957,13 @@ void tst_QStateMachine::historyStateAfterRestart()
s2->addTransition(new EventTransition(QEvent::User, s1));
for (int x = 0; x < 2; ++x) {
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(s1));
@@ -952,10 +996,11 @@ void tst_QStateMachine::historyStateAfterRestart()
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s22));
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
QVERIFY(stoppedSpy.isValid());
machine.stop();
QTRY_COMPARE(stoppedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
}
}
@@ -1094,11 +1139,15 @@ void tst_QStateMachine::rootState()
QCOMPARE(machine.machine(), (QStateMachine*)0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QCOMPARE(s1->parentState(), static_cast<QState*>(&machine));
QState *s2 = new QState();
+ DEFINE_ACTIVE_SPY(s2);
s2->setParent(&machine);
QCOMPARE(s2->parentState(), static_cast<QState*>(&machine));
+ TEST_ACTIVE_CHANGED(s1, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
}
void tst_QStateMachine::machineWithParent()
@@ -1232,13 +1281,15 @@ void tst_QStateMachine::stateEntryAndExit()
QCOMPARE(trans->sourceState(), (QState*)s2);
}
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(stoppedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.setInitialState(s1);
QCOMPARE(machine.initialState(), (QAbstractState*)s1);
@@ -1252,11 +1303,11 @@ void tst_QStateMachine::stateEntryAndExit()
QVERIFY(machine.configuration().isEmpty());
globalTick = 0;
QVERIFY(!machine.isRunning());
- QSignalSpy s1EnteredSpy(s1, SIGNAL(entered()));
- QSignalSpy s1ExitedSpy(s1, SIGNAL(exited()));
- QSignalSpy tTriggeredSpy(t, SIGNAL(triggered()));
- QSignalSpy s2EnteredSpy(s2, SIGNAL(entered()));
- QSignalSpy s2ExitedSpy(s2, SIGNAL(exited()));
+ QSignalSpy s1EnteredSpy(s1, &TestState::entered);
+ QSignalSpy s1ExitedSpy(s1, &TestState::exited);
+ QSignalSpy tTriggeredSpy(t, &TestTransition::triggered);
+ QSignalSpy s2EnteredSpy(s2, &TestState::entered);
+ QSignalSpy s2ExitedSpy(s2, &TestState::exited);
QVERIFY(s1EnteredSpy.isValid());
QVERIFY(s1ExitedSpy.isValid());
@@ -1269,6 +1320,7 @@ void tst_QStateMachine::stateEntryAndExit()
QTRY_COMPARE(startedSpy.count(), 1);
QTRY_COMPARE(finishedSpy.count(), 1);
QTRY_COMPARE(stoppedSpy.count(), 0);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(s3));
@@ -1312,16 +1364,19 @@ void tst_QStateMachine::stateEntryAndExit()
s12->addTransition(t2);
s2->addTransition(s3);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.setInitialState(s1);
globalTick = 0;
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(s3));
@@ -1366,6 +1421,7 @@ void tst_QStateMachine::assignProperty()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QTest::ignoreMessage(QtWarningMsg, "QState::assignProperty: cannot assign property 'foo' of null object");
s1->assignProperty(0, "foo", QVariant());
@@ -1376,32 +1432,39 @@ void tst_QStateMachine::assignProperty()
machine.setInitialState(s1);
machine.start();
QTRY_COMPARE(s1->objectName(), QString::fromLatin1("s1"));
+ TEST_ACTIVE_CHANGED(s1, 2);
s1->assignProperty(s1, "objectName", "foo");
machine.start();
QTRY_COMPARE(s1->objectName(), QString::fromLatin1("foo"));
+ TEST_ACTIVE_CHANGED(s1, 4);
s1->assignProperty(s1, "noSuchProperty", 123);
machine.start();
QTRY_COMPARE(s1->dynamicPropertyNames().size(), 1);
QCOMPARE(s1->dynamicPropertyNames().at(0), QByteArray("noSuchProperty"));
QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
+ TEST_ACTIVE_CHANGED(s1, 6);
{
- QSignalSpy propertiesAssignedSpy(s1, SIGNAL(propertiesAssigned()));
+ QSignalSpy propertiesAssignedSpy(s1, &QState::propertiesAssigned);
QVERIFY(propertiesAssignedSpy.isValid());
machine.start();
QTRY_COMPARE(propertiesAssignedSpy.count(), 1);
+ TEST_ACTIVE_CHANGED(s1, 8);
}
// nested states
{
QState *s11 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s11);
QString str = QString::fromLatin1("set by nested state");
s11->assignProperty(s11, "objectName", str);
s1->setInitialState(s11);
machine.start();
QTRY_COMPARE(s11->objectName(), str);
+ TEST_ACTIVE_CHANGED(s1, 10);
+ TEST_ACTIVE_CHANGED(s11, 2);
}
}
@@ -1419,8 +1482,10 @@ void tst_QStateMachine::assignPropertyWithAnimation()
obj.setProperty("foo", 321);
obj.setProperty("bar", 654);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(&obj, "foo", 123);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(&obj, "foo", 456);
s2->assignProperty(&obj, "bar", 789);
QAbstractTransition *trans = s1->addTransition(s2);
@@ -1444,12 +1509,17 @@ void tst_QStateMachine::assignPropertyWithAnimation()
s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(obj.property("foo").toInt(), 456);
QCOMPARE(obj.property("bar").toInt(), 789);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
}
// Two animations
{
@@ -1458,8 +1528,10 @@ void tst_QStateMachine::assignPropertyWithAnimation()
obj.setProperty("foo", 321);
obj.setProperty("bar", 654);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(&obj, "foo", 123);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(&obj, "foo", 456);
s2->assignProperty(&obj, "bar", 789);
QAbstractTransition *trans = s1->addTransition(s2);
@@ -1473,12 +1545,17 @@ void tst_QStateMachine::assignPropertyWithAnimation()
s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(obj.property("foo").toInt(), 456);
QCOMPARE(obj.property("bar").toInt(), 789);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
}
// Animation group
{
@@ -1487,9 +1564,11 @@ void tst_QStateMachine::assignPropertyWithAnimation()
obj.setProperty("foo", 321);
obj.setProperty("bar", 654);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(&obj, "foo", 123);
s1->assignProperty(&obj, "bar", 321);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(&obj, "foo", 456);
s2->assignProperty(&obj, "bar", 654);
s2->assignProperty(&obj, "baz", 789);
@@ -1502,13 +1581,18 @@ void tst_QStateMachine::assignPropertyWithAnimation()
s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(obj.property("foo").toInt(), 456);
QCOMPARE(obj.property("bar").toInt(), 654);
QCOMPARE(obj.property("baz").toInt(), 789);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
}
// Nested states
{
@@ -1517,6 +1601,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
obj.setProperty("foo", 321);
obj.setProperty("bar", 654);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QCOMPARE(s1->childMode(), QState::ExclusiveStates);
s1->setChildMode(QState::ParallelStates);
QCOMPARE(s1->childMode(), QState::ParallelStates);
@@ -1527,12 +1612,15 @@ void tst_QStateMachine::assignPropertyWithAnimation()
s1->assignProperty(&obj, "foo", 123);
s1->assignProperty(&obj, "bar", 456);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->setObjectName("s2");
s2->assignProperty(&obj, "foo", 321);
QState *s21 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s21);
s21->setObjectName("s21");
s21->assignProperty(&obj, "bar", 654);
QState *s22 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s22);
s22->setObjectName("s22");
s22->assignProperty(&obj, "bar", 789);
s2->setInitialState(s21);
@@ -1552,12 +1640,19 @@ void tst_QStateMachine::assignPropertyWithAnimation()
s22->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(obj.property("foo").toInt(), 321);
QCOMPARE(obj.property("bar").toInt(), 789);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s21, 2);
+ TEST_ACTIVE_CHANGED(s22, 2);
}
// Aborted animation
{
@@ -1568,9 +1663,11 @@ void tst_QStateMachine::assignPropertyWithAnimation()
obj.setProperty("bar", 654);
QState *group = new QState(&machine);
QState *s1 = new QState(group);
+ DEFINE_ACTIVE_SPY(s1);
group->setInitialState(s1);
s1->assignProperty(&obj, "foo", 123);
QState *s2 = new QState(group);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(&obj, "foo", 456);
s2->assignProperty(&obj, "bar", 789);
QAbstractTransition *trans = s1->addTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
@@ -1581,13 +1678,14 @@ void tst_QStateMachine::assignPropertyWithAnimation()
anim2.setDuration(8000);
trans->addAnimation(&anim2);
QState *s3 = new QState(group);
+ DEFINE_ACTIVE_SPY(s3);
s3->assignProperty(&obj, "foo", 911);
s2->addTransition(&emitter, SIGNAL(signalWithNoArg()), s3);
machine.setInitialState(group);
machine.start();
QTRY_COMPARE(machine.configuration().contains(s1), true);
- QSignalSpy propertiesAssignedSpy(s2, SIGNAL(propertiesAssigned()));
+ QSignalSpy propertiesAssignedSpy(s2, &QState::propertiesAssigned);
QVERIFY(propertiesAssignedSpy.isValid());
emitter.emitSignalWithNoArg();
QTRY_COMPARE(machine.configuration().contains(s2), true);
@@ -1597,6 +1695,10 @@ void tst_QStateMachine::assignPropertyWithAnimation()
QVERIFY(propertiesAssignedSpy.isEmpty());
QCOMPARE(obj.property("foo").toInt(), 911);
QCOMPARE(obj.property("bar").toInt(), 789);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
}
}
@@ -1668,6 +1770,7 @@ void tst_QStateMachine::postEvent()
machine.postEvent(&e);
}
StringEventPoster *s1 = new StringEventPoster("a");
+ DEFINE_ACTIVE_SPY(s1);
if (x == 1)
s1->setDelay(100);
QFinalState *s2 = new QFinalState;
@@ -1675,12 +1778,16 @@ void tst_QStateMachine::postEvent()
machine.addState(s1);
machine.addState(s2);
machine.setInitialState(s1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
+ TEST_ACTIVE_CHANGED(s1, 2);
s1->setString("b");
QFinalState *s3 = new QFinalState();
@@ -1691,6 +1798,7 @@ void tst_QStateMachine::postEvent()
QTRY_COMPARE(finishedSpy.count(), 1);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s3));
+ TEST_ACTIVE_CHANGED(s1, 4);
}
}
@@ -1701,17 +1809,21 @@ void tst_QStateMachine::cancelDelayedEvent()
QVERIFY(!machine.cancelDelayedEvent(-1));
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QFinalState *s2 = new QFinalState(&machine);
s1->addTransition(new StringTransition("a", s2));
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s1, 1);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
-
int id1 = machine.postDelayedEvent(new StringEvent("c"), 50000);
QVERIFY(id1 != -1);
int id2 = machine.postDelayedEvent(new StringEvent("b"), 25000);
@@ -1725,9 +1837,11 @@ void tst_QStateMachine::cancelDelayedEvent()
QVERIFY(machine.cancelDelayedEvent(id2));
QVERIFY(!machine.cancelDelayedEvent(id2));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(s1, 2);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
}
@@ -1736,28 +1850,37 @@ void tst_QStateMachine::postDelayedEventAndStop()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QFinalState *s2 = new QFinalState(&machine);
s1->addTransition(new StringTransition("a", s2));
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s1, 1);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
int id1 = machine.postDelayedEvent(new StringEvent("a"), 0);
QVERIFY(id1 != -1);
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
QVERIFY(stoppedSpy.isValid());
machine.stop();
QTRY_COMPARE(stoppedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(s1, 1);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
machine.start();
QTRY_COMPARE(startedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s1, 3);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
@@ -1765,11 +1888,16 @@ void tst_QStateMachine::postDelayedEventAndStop()
QVERIFY(id2 != -1);
machine.stop();
QTRY_COMPARE(stoppedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(s1, 3);
machine.start();
QTRY_COMPARE(startedSpy.count(), 3);
+ TEST_RUNNING_CHANGED(true);
QTestEventLoop::instance().enterLoop(2);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
+ TEST_ACTIVE_CHANGED(s1, 5);
+ QVERIFY(machine.isRunning());
}
class DelayedEventPosterThread : public QThread
@@ -1806,6 +1934,7 @@ void tst_QStateMachine::postDelayedEventFromThread()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QFinalState *f = new QFinalState(&machine);
s1->addTransition(new EventTransition(QEvent::User, f));
machine.setInitialState(s1);
@@ -1813,11 +1942,14 @@ void tst_QStateMachine::postDelayedEventFromThread()
DelayedEventPosterThread poster(&machine);
poster.start();
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
-
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s1, 2);
QVERIFY(poster.firstEventWasCancelled);
}
@@ -1825,17 +1957,24 @@ void tst_QStateMachine::stopAndPostEvent()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
QVERIFY(stoppedSpy.isValid());
machine.stop();
QCOMPARE(stoppedSpy.count(), 0);
machine.postEvent(new QEvent(QEvent::User));
QTRY_COMPARE(stoppedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(s1, 1);
QCoreApplication::processEvents();
}
@@ -1843,17 +1982,24 @@ void tst_QStateMachine::stateFinished()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s1_1 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s1_1);
QFinalState *s1_2 = new QFinalState(s1);
s1_1->addTransition(s1_2);
s1->setInitialState(s1_1);
QFinalState *s2 = new QFinalState(&machine);
s1->addTransition(s1, SIGNAL(finished()), s2);
machine.setInitialState(s1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s1_1, 2);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
}
@@ -1888,11 +2034,14 @@ void tst_QStateMachine::parallelStates()
s1->addTransition(s1, SIGNAL(finished()), s2);
machine.setInitialState(s1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
globalTick = 0;
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
@@ -1927,15 +2076,19 @@ void tst_QStateMachine::parallelRootState()
QCOMPARE(root->childMode(), QState::ParallelStates);
QState *s1 = new QState(root);
+ DEFINE_ACTIVE_SPY(s1);
QFinalState *s1_f = new QFinalState(s1);
s1->setInitialState(s1_f);
QState *s2 = new QState(root);
+ DEFINE_ACTIVE_SPY(s2);
QFinalState *s2_f = new QFinalState(s2);
s2->setInitialState(s2_f);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
@@ -1945,22 +2098,32 @@ void tst_QStateMachine::parallelRootState()
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s2_f));
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ QVERIFY(!machine.isRunning());
}
void tst_QStateMachine::allSourceToTargetConfigurations()
{
QStateMachine machine;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
s0->setObjectName("s0");
QState *s1 = new QState(s0);
+ DEFINE_ACTIVE_SPY(s1);
s1->setObjectName("s1");
QState *s11 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s11);
s11->setObjectName("s11");
QState *s2 = new QState(s0);
+ DEFINE_ACTIVE_SPY(s2);
s2->setObjectName("s2");
QState *s21 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s21);
s21->setObjectName("s21");
QState *s211 = new QState(s21);
+ DEFINE_ACTIVE_SPY(s211);
s211->setObjectName("s211");
QFinalState *f = new QFinalState(&machine);
f->setObjectName("f");
@@ -1984,30 +2147,94 @@ void tst_QStateMachine::allSourceToTargetConfigurations()
s2->addTransition(new StringTransition("f", s11));
s0->addTransition(new StringTransition("e", s211));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s21, 0);
+ TEST_ACTIVE_CHANGED(s211, 0);
machine.postEvent(new StringEvent("a"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 3);
+ TEST_ACTIVE_CHANGED(s11, 3);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s21, 0);
+ TEST_ACTIVE_CHANGED(s211, 0);
+
machine.postEvent(new StringEvent("b"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 5);
+ TEST_ACTIVE_CHANGED(s11, 5);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s21, 0);
+ TEST_ACTIVE_CHANGED(s211, 0);
+
machine.postEvent(new StringEvent("c"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 6);
+ TEST_ACTIVE_CHANGED(s11, 6);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 1);
+ TEST_ACTIVE_CHANGED(s211, 1);
+
machine.postEvent(new StringEvent("d"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 6);
+ TEST_ACTIVE_CHANGED(s11, 6);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 3);
+ TEST_ACTIVE_CHANGED(s211, 3);
+
machine.postEvent(new StringEvent("e"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
+ TEST_ACTIVE_CHANGED(s1, 6);
+ TEST_ACTIVE_CHANGED(s11, 6);
+ TEST_ACTIVE_CHANGED(s2, 3);
+ TEST_ACTIVE_CHANGED(s21, 5);
+ TEST_ACTIVE_CHANGED(s211, 5);
+
machine.postEvent(new StringEvent("f"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
+ TEST_ACTIVE_CHANGED(s1, 7);
+ TEST_ACTIVE_CHANGED(s11, 7);
+ TEST_ACTIVE_CHANGED(s2, 4);
+ TEST_ACTIVE_CHANGED(s21, 6);
+ TEST_ACTIVE_CHANGED(s211, 6);
+
machine.postEvent(new StringEvent("g"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
+ TEST_ACTIVE_CHANGED(s1, 8);
+ TEST_ACTIVE_CHANGED(s11, 8);
+ TEST_ACTIVE_CHANGED(s2, 5);
+ TEST_ACTIVE_CHANGED(s21, 7);
+ TEST_ACTIVE_CHANGED(s211, 7);
+
machine.postEvent(new StringEvent("h"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 4);
+ TEST_ACTIVE_CHANGED(s1, 8);
+ TEST_ACTIVE_CHANGED(s11, 8);
+ TEST_ACTIVE_CHANGED(s2, 6);
+ TEST_ACTIVE_CHANGED(s21, 8);
+ TEST_ACTIVE_CHANGED(s211, 8);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
}
class TestSignalTransition : public QSignalTransition
@@ -2073,6 +2300,7 @@ void tst_QStateMachine::signalTransitions()
{
QStateMachine machine;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QTest::ignoreMessage(QtWarningMsg, "QState::addTransition: sender cannot be null");
QCOMPARE(s0->addTransition(0, SIGNAL(noSuchSignal()), 0), (QSignalTransition*)0);
@@ -2094,7 +2322,9 @@ void tst_QStateMachine::signalTransitions()
QCOMPARE(trans->senderObject(), (QObject*)&emitter);
QCOMPARE(trans->signal(), QByteArray(SIGNAL(signalWithNoArg())));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
@@ -2103,7 +2333,8 @@ void tst_QStateMachine::signalTransitions()
emitter.emitSignalWithNoArg();
QTRY_COMPARE(finishedSpy.count(), 1);
-
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 2);
emitter.emitSignalWithNoArg();
trans->setSignal(SIGNAL(signalWithIntArg(int)));
@@ -2112,6 +2343,8 @@ void tst_QStateMachine::signalTransitions()
QCoreApplication::processEvents();
emitter.emitSignalWithIntArg(123);
QTRY_COMPARE(finishedSpy.count(), 2);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 4);
machine.start();
QCoreApplication::processEvents();
@@ -2119,6 +2352,8 @@ void tst_QStateMachine::signalTransitions()
QCOMPARE(trans->signal(), QByteArray(SIGNAL(signalWithNoArg())));
emitter.emitSignalWithNoArg();
QTRY_COMPARE(finishedSpy.count(), 3);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 6);
SignalEmitter emitter2;
machine.start();
@@ -2126,16 +2361,22 @@ void tst_QStateMachine::signalTransitions()
trans->setSenderObject(&emitter2);
emitter2.emitSignalWithNoArg();
QTRY_COMPARE(finishedSpy.count(), 4);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 8);
machine.start();
QCoreApplication::processEvents();
QTest::ignoreMessage(QtWarningMsg, "QSignalTransition: no such signal: SignalEmitter::noSuchSignal()");
trans->setSignal(SIGNAL(noSuchSignal()));
QCOMPARE(trans->signal(), QByteArray(SIGNAL(noSuchSignal())));
+ TEST_RUNNING_CHANGED(true);
+ TEST_ACTIVE_CHANGED(s0, 9);
+ QVERIFY(machine.isRunning());
}
{
QStateMachine machine;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QFinalState *s1 = new QFinalState(&machine);
SignalEmitter emitter;
QSignalTransition *trans = s0->addTransition(&emitter, "signalWithNoArg()", s1);
@@ -2145,40 +2386,52 @@ void tst_QStateMachine::signalTransitions()
QCOMPARE(trans->senderObject(), (QObject*)&emitter);
QCOMPARE(trans->signal(), QByteArray("signalWithNoArg()"));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
-
+ TEST_ACTIVE_CHANGED(s0, 1);
emitter.emitSignalWithNoArg();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 2);
trans->setSignal("signalWithIntArg(int)");
QCOMPARE(trans->signal(), QByteArray("signalWithIntArg(int)"));
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
emitter.emitSignalWithIntArg(123);
QTRY_COMPARE(finishedSpy.count(), 2);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 4);
}
{
QStateMachine machine;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QFinalState *s1 = new QFinalState(&machine);
SignalEmitter emitter;
TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithIntArg(int)), s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
-
+ TEST_ACTIVE_CHANGED(s0, 1);
emitter.emitSignalWithIntArg(123);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 2);
QCOMPARE(trans->eventTestSenderReceived(), (QObject*)&emitter);
QCOMPARE(trans->eventTestSignalIndexReceived(), emitter.metaObject()->indexOfSignal("signalWithIntArg(int)"));
QCOMPARE(trans->eventTestArgumentsReceived().size(), 1);
@@ -2191,21 +2444,27 @@ void tst_QStateMachine::signalTransitions()
{
QStateMachine machine;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QFinalState *s1 = new QFinalState(&machine);
SignalEmitter emitter;
TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithStringArg(QString)), s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
QString testString = QString::fromLatin1("hello");
emitter.emitSignalWithStringArg(testString);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 2);
QCOMPARE(trans->eventTestSenderReceived(), (QObject*)&emitter);
QCOMPARE(trans->eventTestSignalIndexReceived(), emitter.metaObject()->indexOfSignal("signalWithStringArg(QString)"));
QCOMPARE(trans->eventTestArgumentsReceived().size(), 1);
@@ -2218,6 +2477,7 @@ void tst_QStateMachine::signalTransitions()
{
QStateMachine machine;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QFinalState *s1 = new QFinalState(&machine);
TestSignalTransition *trans = new TestSignalTransition();
@@ -2232,52 +2492,69 @@ void tst_QStateMachine::signalTransitions()
trans->setTargetState(s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
emitter.emitSignalWithNoArg();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s0, 2);
}
// Multiple transitions for same (object,signal)
{
QStateMachine machine;
SignalEmitter emitter;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QSignalTransition *t0 = s0->addTransition(&emitter, SIGNAL(signalWithNoArg()), s1);
QSignalTransition *t1 = s1->addTransition(&emitter, SIGNAL(signalWithNoArg()), s0);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 0);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s0));
emitter.emitSignalWithNoArg();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s1, 1);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
s0->removeTransition(t0);
emitter.emitSignalWithNoArg();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
+ TEST_ACTIVE_CHANGED(s1, 2);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s0));
emitter.emitSignalWithNoArg();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
+ TEST_ACTIVE_CHANGED(s1, 2);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s0));
s1->removeTransition(t1);
emitter.emitSignalWithNoArg();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
+ TEST_ACTIVE_CHANGED(s1, 2);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s0));
@@ -2285,6 +2562,9 @@ void tst_QStateMachine::signalTransitions()
s1->addTransition(t1);
emitter.emitSignalWithNoArg();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 4);
+ TEST_ACTIVE_CHANGED(s1, 3);
+ QVERIFY(machine.isRunning());
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
}
@@ -2293,6 +2573,7 @@ void tst_QStateMachine::signalTransitions()
QStateMachine machine;
SignalEmitter emitter;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QFinalState *s1 = new QFinalState(&machine);
s0->addTransition(&emitter, SIGNAL(signalWithNoArg()), s1);
QFinalState *s2 = new QFinalState(&machine);
@@ -2300,30 +2581,45 @@ void tst_QStateMachine::signalTransitions()
QFinalState *s3 = new QFinalState(&machine);
s0->addTransition(&emitter, SIGNAL(signalWithStringArg(QString)), s3);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.setInitialState(s0);
machine.start();
+ TEST_ACTIVE_CHANGED(s0, 1);
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
emitter.emitSignalWithNoArg();
+ TEST_ACTIVE_CHANGED(s0, 2);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
machine.start();
+ TEST_ACTIVE_CHANGED(s0, 3);
QTRY_COMPARE(startedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(true);
emitter.emitSignalWithIntArg(123);
+ TEST_ACTIVE_CHANGED(s0, 4);
QTRY_COMPARE(finishedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
machine.start();
+ QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 5);
QTRY_COMPARE(startedSpy.count(), 3);
+ TEST_RUNNING_CHANGED(true);
emitter.emitSignalWithStringArg("hello");
+ TEST_ACTIVE_CHANGED(s0, 6);
QTRY_COMPARE(finishedSpy.count(), 3);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s3));
}
@@ -2332,6 +2628,7 @@ void tst_QStateMachine::signalTransitions()
QStateMachine machine;
SignalEmitter emitter;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
QFinalState *s1 = new QFinalState(&machine);
QSignalTransition *t0 = s0->addTransition(&emitter, SIGNAL(signalWithNoArg()), s1);
QVERIFY(t0 != 0);
@@ -2341,18 +2638,25 @@ void tst_QStateMachine::signalTransitions()
QVERIFY(t1 != 0);
QCOMPARE(t1->signal(), QByteArray(SIGNAL(signalWithStringArg(QString))));
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.setInitialState(s0);
machine.start();
+ QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
QTRY_COMPARE(startedSpy.count(), 1);
QCOMPARE(finishedSpy.count(), 0);
+ TEST_RUNNING_CHANGED(true);
emitter.emitSignalWithNoArg();
+ TEST_ACTIVE_CHANGED(s0, 2);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
}
}
@@ -2406,7 +2710,9 @@ void tst_QStateMachine::eventTransitions()
QCOMPARE(trans->targetState(), (QAbstractState*)s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
@@ -2414,6 +2720,7 @@ void tst_QStateMachine::eventTransitions()
QTest::mousePress(&button, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QTest::mousePress(&button, Qt::LeftButton);
@@ -2423,12 +2730,14 @@ void tst_QStateMachine::eventTransitions()
QCoreApplication::processEvents();
QTest::mouseRelease(&button, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 2);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
machine.start();
QCoreApplication::processEvents();
trans->setEventType(QEvent::MouseButtonPress);
QTest::mousePress(&button, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 3);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QPushButton button2;
machine.start();
@@ -2436,6 +2745,7 @@ void tst_QStateMachine::eventTransitions()
trans->setEventSource(&button2);
QTest::mousePress(&button2, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 4);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
}
for (int x = 0; x < 2; ++x) {
QStateMachine machine;
@@ -2459,7 +2769,9 @@ void tst_QStateMachine::eventTransitions()
QCOMPARE(trans->targetState(), (QAbstractState*)s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
@@ -2469,6 +2781,7 @@ void tst_QStateMachine::eventTransitions()
QCoreApplication::processEvents();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
}
{
QStateMachine machine;
@@ -2485,16 +2798,19 @@ void tst_QStateMachine::eventTransitions()
trans->setTargetState(s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
-
+ TEST_RUNNING_CHANGED(true);
QTest::mousePress(&button, Qt::LeftButton);
QCoreApplication::processEvents();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
}
{
@@ -2508,16 +2824,20 @@ void tst_QStateMachine::eventTransitions()
trans->setTargetState(s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
+ TEST_RUNNING_CHANGED(true);
QTest::keyPress(&button, Qt::Key_A);
QCoreApplication::processEvents();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
}
{
QStateMachine machine;
@@ -2534,16 +2854,20 @@ void tst_QStateMachine::eventTransitions()
trans->setTargetState(s1);
s0->addTransition(trans);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
+ TEST_RUNNING_CHANGED(true);
QTest::keyPress(&button, Qt::Key_A);
QCoreApplication::processEvents();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
}
// Multiple transitions for same (object,event)
{
@@ -2557,7 +2881,7 @@ void tst_QStateMachine::eventTransitions()
t1->setTargetState(s0);
s1->addTransition(t1);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
@@ -2607,23 +2931,29 @@ void tst_QStateMachine::eventTransitions()
t1->setTargetState(s2);
s0->addTransition(t1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.setInitialState(s0);
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
QTest::mousePress(&button, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
machine.start();
QTRY_COMPARE(startedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(true);
QTest::mouseRelease(&button, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 2);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
}
@@ -2637,12 +2967,15 @@ void tst_QStateMachine::eventTransitions()
trans->setTargetState(s1);
s0->addTransition(trans);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QTest::ignoreMessage(QtWarningMsg, "QObject event transitions are not supported for custom types");
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
}
// custom transition
{
@@ -2655,16 +2988,20 @@ void tst_QStateMachine::eventTransitions()
QCOMPARE(trans->eventSourceReceived(), (QObject*)0);
QCOMPARE(trans->eventTypeReceived(), QEvent::None);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.setInitialState(s0);
machine.start();
QCoreApplication::processEvents();
+ TEST_RUNNING_CHANGED(true);
QTest::mousePress(&button, Qt::LeftButton);
QCoreApplication::processEvents();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(trans->eventSourceReceived(), (QObject*)&button);
QCOMPARE(trans->eventTypeReceived(), QEvent::MouseButtonPress);
@@ -2684,16 +3021,20 @@ void tst_QStateMachine::graphicsSceneEventTransitions()
s1->addTransition(t);
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
QVERIFY(finishedSpy.count() == 0);
+ TEST_RUNNING_CHANGED(true);
QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
scene.sendEvent(textItem, &mouseEvent);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
}
#endif
@@ -2703,8 +3044,11 @@ void tst_QStateMachine::historyStates()
QStateMachine machine;
QState *root = &machine;
QState *s0 = new QState(root);
+ DEFINE_ACTIVE_SPY(s0);
QState *s00 = new QState(s0);
+ DEFINE_ACTIVE_SPY(s00);
QState *s01 = new QState(s0);
+ DEFINE_ACTIVE_SPY(s01);
QHistoryState *s0h;
if (x == 0) {
s0h = new QHistoryState(s0);
@@ -2724,6 +3068,7 @@ void tst_QStateMachine::historyStates()
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
s0h->setDefaultState(s0);
QState *s1 = new QState(root);
+ DEFINE_ACTIVE_SPY(s1);
QFinalState *s2 = new QFinalState(root);
s00->addTransition(new StringTransition("a", s01));
@@ -2734,50 +3079,75 @@ void tst_QStateMachine::historyStates()
root->setInitialState(s0);
s0->setInitialState(s00);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s00, 1);
+ TEST_ACTIVE_CHANGED(s01, 0);
+ TEST_ACTIVE_CHANGED(s1, 0);
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s0));
QVERIFY(machine.configuration().contains(s00));
machine.postEvent(new StringEvent("a"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s00, 2);
+ TEST_ACTIVE_CHANGED(s01, 1);
+ TEST_ACTIVE_CHANGED(s1, 0);
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s0));
QVERIFY(machine.configuration().contains(s01));
machine.postEvent(new StringEvent("b"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s00, 2);
+ TEST_ACTIVE_CHANGED(s01, 2);
+ TEST_ACTIVE_CHANGED(s1, 1);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
machine.postEvent(new StringEvent("c"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 3);
+ TEST_ACTIVE_CHANGED(s00, 2);
+ TEST_ACTIVE_CHANGED(s01, 3);
+ TEST_ACTIVE_CHANGED(s1, 2);
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s0));
QVERIFY(machine.configuration().contains(s01));
machine.postEvent(new StringEvent("d"));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s0, 4);
+ TEST_ACTIVE_CHANGED(s00, 2);
+ TEST_ACTIVE_CHANGED(s01, 4);
+ TEST_ACTIVE_CHANGED(s1, 2);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
}
}
void tst_QStateMachine::startAndStop()
{
QStateMachine machine;
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(stoppedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
QVERIFY(!machine.isRunning());
QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start.");
@@ -2785,62 +3155,160 @@ void tst_QStateMachine::startAndStop()
QCOMPARE(startedSpy.count(), 0);
QCOMPARE(stoppedSpy.count(), 0);
QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.count(), 0);
QVERIFY(!machine.isRunning());
machine.stop();
QCOMPARE(startedSpy.count(), 0);
QCOMPARE(stoppedSpy.count(), 0);
QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.count(), 0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
QTRY_COMPARE(machine.isRunning(), true);
QTRY_COMPARE(startedSpy.count(), 1);
QCOMPARE(stoppedSpy.count(), 0);
QCOMPARE(finishedSpy.count(), 0);
+ TEST_RUNNING_CHANGED(true);
QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(s1));
QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start(): already running");
machine.start();
+ QCOMPARE(runningSpy.count(), 0);
machine.stop();
+ TEST_ACTIVE_CHANGED(s1, 1);
QTRY_COMPARE(machine.isRunning(), false);
QTRY_COMPARE(stoppedSpy.count(), 1);
QCOMPARE(startedSpy.count(), 1);
QCOMPARE(finishedSpy.count(), 0);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(machine.configuration().count(), 1);
QVERIFY(machine.configuration().contains(s1));
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 3);
machine.stop();
+ TEST_ACTIVE_CHANGED(s1, 3);
QTRY_COMPARE(startedSpy.count(), 2);
+ QTRY_COMPARE(stoppedSpy.count(), 2);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+}
+
+void tst_QStateMachine::setRunning()
+{
+ QStateMachine machine;
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+
+ QVERIFY(startedSpy.isValid());
+ QVERIFY(stoppedSpy.isValid());
+ QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
+
+ QVERIFY(!machine.isRunning());
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start.");
+ machine.setRunning(true);
+ QCOMPARE(startedSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.count(), 0);
+ QVERIFY(!machine.isRunning());
+ machine.setRunning(false);
+ QCOMPARE(startedSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(runningSpy.count(), 0);
+
+ QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
+ machine.setInitialState(s1);
+ machine.setRunning(true);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QTRY_COMPARE(machine.isRunning(), true);
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+ TEST_RUNNING_CHANGED(true);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start(): already running");
+ machine.setRunning(true);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QCOMPARE(runningSpy.count(), 0);
+
+ machine.setRunning(false);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QTRY_COMPARE(machine.isRunning(), false);
+ QTRY_COMPARE(stoppedSpy.count(), 1);
+ QCOMPARE(startedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+ TEST_RUNNING_CHANGED(false);
+ QCOMPARE(machine.configuration().count(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.setRunning(false);
+ QCOMPARE(runningSpy.count(), 0);
+ TEST_ACTIVE_CHANGED(s1, 1);
+
+ machine.start();
+ TEST_ACTIVE_CHANGED(s1, 3);
+ machine.setRunning(false);
+ TEST_ACTIVE_CHANGED(s1, 3);
+ QTRY_COMPARE(startedSpy.count(), 2);
+ QTRY_COMPARE(stoppedSpy.count(), 2);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ QState *s1_1 = new QState(s1);
+ QFinalState *s1_2 = new QFinalState(s1);
+ s1_1->addTransition(s1_2);
+ s1->setInitialState(s1_1);
+ QFinalState *s2 = new QFinalState(&machine);
+ s1->addTransition(s1, SIGNAL(finished()), s2);
+ machine.setRunning(false);
+ QCOMPARE(runningSpy.count(), 0);
+ machine.setRunning(true);
+ TEST_ACTIVE_CHANGED(s1, 6);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ QTRY_COMPARE(startedSpy.count(), 3);
QCOMPARE(stoppedSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 1);
}
void tst_QStateMachine::targetStateWithNoParent()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->setObjectName("s1");
QState s2;
s1->addTransition(&s2);
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(stoppedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'");
+ TEST_ACTIVE_CHANGED(s1, 2);
QTRY_COMPARE(startedSpy.count(), 1);
QCOMPARE(machine.isRunning(), false);
QCOMPARE(stoppedSpy.count(), 1);
QCOMPARE(finishedSpy.count(), 0);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(machine.error(), QStateMachine::NoCommonAncestorForTransitionError);
}
@@ -2865,12 +3333,15 @@ void tst_QStateMachine::defaultGlobalRestorePolicy()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s1->addTransition(new EventTransition(QEvent::User, s2));
s2->addTransition(new EventTransition(QEvent::User, s3));
@@ -2879,18 +3350,28 @@ void tst_QStateMachine::defaultGlobalRestorePolicy()
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 2);
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 4);
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 4);
}
@@ -2900,17 +3381,20 @@ void tst_QStateMachine::noInitialStateForInitialState()
QStateMachine machine;
QState *initialState = new QState(&machine);
+ DEFINE_ACTIVE_SPY(initialState);
initialState->setObjectName("initialState");
machine.setInitialState(initialState);
QState *childState = new QState(initialState);
+ DEFINE_ACTIVE_SPY(childState);
(void)childState;
QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: "
"Missing initial state in compound state 'initialState'");
machine.start();
QCoreApplication::processEvents();
-
+ TEST_ACTIVE_CHANGED(initialState, 1);
+ TEST_ACTIVE_CHANGED(childState, 0);
QCOMPARE(machine.isRunning(), false);
QCOMPARE(int(machine.error()), int(QStateMachine::NoInitialStateError));
}
@@ -2925,12 +3409,15 @@ void tst_QStateMachine::globalRestorePolicySetToDontRestore()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s1->addTransition(new EventTransition(QEvent::User, s2));
s2->addTransition(new EventTransition(QEvent::User, s3));
@@ -2939,18 +3426,28 @@ void tst_QStateMachine::globalRestorePolicySetToDontRestore()
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 2);
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 4);
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 4);
}
@@ -2965,12 +3462,15 @@ void tst_QStateMachine::globalRestorePolicySetToRestore()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s1->addTransition(new EventTransition(QEvent::User, s2));
s2->addTransition(new EventTransition(QEvent::User, s3));
@@ -2979,18 +3479,28 @@ void tst_QStateMachine::globalRestorePolicySetToRestore()
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QCOMPARE(propertyHolder->property("a").toInt(), 3);
QCOMPARE(propertyHolder->property("b").toInt(), 2);
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
QCOMPARE(propertyHolder->property("a").toInt(), 1);
QCOMPARE(propertyHolder->property("b").toInt(), 4);
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QCOMPARE(propertyHolder->property("a").toInt(), 1);
QCOMPARE(propertyHolder->property("b").toInt(), 2);
}
@@ -3015,7 +3525,9 @@ void tst_QStateMachine::simpleAnimation()
object->setProperty("fooBar", 1.0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "fooBar", 2.0);
EventTransition *et = new EventTransition(QEvent::User, s2);
@@ -3024,16 +3536,24 @@ void tst_QStateMachine::simpleAnimation()
s1->addTransition(et);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s2->addTransition(animation, SIGNAL(finished()), s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
machine.postEvent(new QEvent(QEvent::User));
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("fooBar").toDouble(), 2.0);
}
@@ -3059,7 +3579,9 @@ void tst_QStateMachine::twoAnimations()
object->setProperty("bar", 3.0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 2.0);
s2->assignProperty(object, "bar", 10.0);
@@ -3077,15 +3599,23 @@ void tst_QStateMachine::twoAnimations()
s1->addTransition(et);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
machine.postEvent(new QEvent(QEvent::User));
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("foo").toDouble(), 2.0);
@@ -3102,8 +3632,10 @@ void tst_QStateMachine::twoAnimatedTransitions()
object->setProperty("foo", 1.0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
EventTransition *trans = new EventTransition(QEvent::User, s2);
@@ -3111,10 +3643,12 @@ void tst_QStateMachine::twoAnimatedTransitions()
trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s2->addTransition(fooAnimation, SIGNAL(finished()), s3);
QState *s4 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s4);
s4->assignProperty(object, "foo", 2.0);
QPropertyAnimation *fooAnimation2 = new QPropertyAnimation(object, "foo", s4);
trans = new EventTransition(QEvent::User, s4);
@@ -3122,22 +3656,39 @@ void tst_QStateMachine::twoAnimatedTransitions()
trans->addAnimation(fooAnimation2);
QState *s5 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s5);
QObject::connect(s5, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s4->addTransition(fooAnimation2, SIGNAL(finished()), s5);
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
+ TEST_ACTIVE_CHANGED(s5, 0);
machine.postEvent(new QEvent(QEvent::User));
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ TEST_ACTIVE_CHANGED(s4, 0);
+ TEST_ACTIVE_CHANGED(s5, 0);
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("foo").toDouble(), 5.0);
machine.postEvent(new QEvent(QEvent::User));
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 2);
+ TEST_ACTIVE_CHANGED(s5, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s5));
QCOMPARE(object->property("foo").toDouble(), 2.0);
}
@@ -3150,8 +3701,10 @@ void tst_QStateMachine::playAnimationTwice()
object->setProperty("foo", 1.0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
EventTransition *trans = new EventTransition(QEvent::User, s2);
@@ -3159,16 +3712,19 @@ void tst_QStateMachine::playAnimationTwice()
trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s2->addTransition(fooAnimation, SIGNAL(finished()), s3);
QState *s4 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s4);
s4->assignProperty(object, "foo", 2.0);
trans = new EventTransition(QEvent::User, s4);
s3->addTransition(trans);
trans->addAnimation(fooAnimation);
QState *s5 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s5);
QObject::connect(s5, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s4->addTransition(fooAnimation, SIGNAL(finished()), s5);
@@ -3176,15 +3732,31 @@ void tst_QStateMachine::playAnimationTwice()
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
+ TEST_ACTIVE_CHANGED(s5, 0);
machine.postEvent(new QEvent(QEvent::User));
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ TEST_ACTIVE_CHANGED(s4, 0);
+ TEST_ACTIVE_CHANGED(s5, 0);
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("foo").toDouble(), 5.0);
machine.postEvent(new QEvent(QEvent::User));
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 2);
+ TEST_ACTIVE_CHANGED(s5, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s5));
QCOMPARE(object->property("foo").toDouble(), 2.0);
}
@@ -3200,15 +3772,19 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
SlotCalledCounter counter;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 2.0);
QState *s2Child = new QState(s2);
+ DEFINE_ACTIVE_SPY(s2Child);
s2Child->assignProperty(object, "bar", 10.0);
s2->setInitialState(s2Child);
QState *s2Child2 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s2Child2);
s2Child2->assignProperty(object, "bar", 11.0);
QAbstractTransition *at = new EventTransition(QEvent::User, s2Child2);
s2Child->addTransition(at);
@@ -3230,6 +3806,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
at->addAnimation(animation);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s2->addTransition(s2Child, SIGNAL(propertiesAssigned()), s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3237,10 +3814,27 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s2Child, 0);
+ TEST_ACTIVE_CHANGED(s2Child2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s2Child, 1);
+ TEST_ACTIVE_CHANGED(s2Child2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
+
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s2Child, 2);
+ TEST_ACTIVE_CHANGED(s2Child2, 0);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("foo").toDouble(), 2.0);
QCOMPARE(object->property("bar").toDouble(), 10.0);
@@ -3254,31 +3848,41 @@ void tst_QStateMachine::propertiesAssignedSignalTransitionsReuseAnimationGroup()
object->setProperty("foo", 0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(object, "foo", 123);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 456);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s3->assignProperty(object, "foo", 789);
QFinalState *s4 = new QFinalState(&machine);
QParallelAnimationGroup animationGroup;
animationGroup.addAnimation(new QPropertyAnimation(object, "foo"));
- QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished()));
+ QSignalSpy animationFinishedSpy(&animationGroup, &QParallelAnimationGroup::finished);
QVERIFY(animationFinishedSpy.isValid());
s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2)->addAnimation(&animationGroup);
s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3)->addAnimation(&animationGroup);
s3->addTransition(s3, SIGNAL(propertiesAssigned()), s4);
machine.setInitialState(s1);
- QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy machineFinishedSpy(&machine, &QStateMachine::finished);
QVERIFY(machineFinishedSpy.isValid());
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
QTRY_COMPARE(machineFinishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ QVERIFY(!machine.isRunning());
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s4));
QCOMPARE(object->property("foo").toInt(), 789);
-
QCOMPARE(animationFinishedSpy.count(), 2);
+
}
void tst_QStateMachine::animatedGlobalRestoreProperty()
@@ -3292,12 +3896,16 @@ void tst_QStateMachine::animatedGlobalRestoreProperty()
SlotCalledCounter counter;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 2.0);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QState *s4 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s4);
QObject::connect(s4, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
QAbstractTransition *at = new EventTransition(QEvent::User, s2);
@@ -3319,11 +3927,24 @@ void tst_QStateMachine::animatedGlobalRestoreProperty()
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s4));
QCOMPARE(object->property("foo").toDouble(), 1.0);
QCOMPARE(counter.counter, 2);
@@ -3337,8 +3958,10 @@ void tst_QStateMachine::specificTargetValueOfAnimation()
object->setProperty("foo", 1.0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 2.0);
QPropertyAnimation *anim = new QPropertyAnimation(object, "foo");
@@ -3348,16 +3971,28 @@ void tst_QStateMachine::specificTargetValueOfAnimation()
trans->addAnimation(anim);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s2->addTransition(anim, SIGNAL(finished()), s3);
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
+
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("foo").toDouble(), 2.0);
QCOMPARE(anim->endValue().toDouble(), 10.0);
@@ -3373,11 +4008,14 @@ void tst_QStateMachine::addDefaultAnimation()
object->setProperty("foo", 1.0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 2.0);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s1->addTransition(new EventTransition(QEvent::User, s2));
@@ -3389,10 +4027,21 @@ void tst_QStateMachine::addDefaultAnimation()
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
+
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("foo").toDouble(), 2.0);
@@ -3410,11 +4059,14 @@ void tst_QStateMachine::addDefaultAnimationWithUnusedAnimation()
SlotCalledCounter counter;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 2.0);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
s1->addTransition(new EventTransition(QEvent::User, s2));
@@ -3431,10 +4083,21 @@ void tst_QStateMachine::addDefaultAnimationWithUnusedAnimation()
machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
+
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("foo").toDouble(), 2.0);
QCOMPARE(counter.counter, 1);
@@ -3491,12 +4154,15 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
SlotCalledCounter counter;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(object, "foo", 2.0);
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
QAbstractTransition *at = new EventTransition(QEvent::User, s2);
@@ -3514,10 +4180,21 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
+
QCOREAPPLICATION_EXEC(5000);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QVERIFY(machine.configuration().contains(s3));
QCOMPARE(counter.counter, 2); // specific animation started and stopped
@@ -3535,20 +4212,26 @@ void tst_QStateMachine::parallelStateAssignmentsDone()
propertyHolder->setProperty("zoot", 789);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QState *parallelState = new QState(QState::ParallelStates, &machine);
parallelState->assignProperty(propertyHolder, "foo", 321);
QState *s2 = new QState(parallelState);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(propertyHolder, "bar", 654);
QState *s3 = new QState(parallelState);
+ DEFINE_ACTIVE_SPY(s3);
s3->assignProperty(propertyHolder, "zoot", 987);
s1->addTransition(new EventTransition(QEvent::User, parallelState));
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QCOMPARE(propertyHolder->property("foo").toInt(), 123);
QCOMPARE(propertyHolder->property("bar").toInt(), 456);
@@ -3557,6 +4240,10 @@ void tst_QStateMachine::parallelStateAssignmentsDone()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QCOMPARE(propertyHolder->property("foo").toInt(), 321);
QCOMPARE(propertyHolder->property("bar").toInt(), 654);
QCOMPARE(propertyHolder->property("zoot").toInt(), 987);
@@ -3567,21 +4254,27 @@ void tst_QStateMachine::transitionsFromParallelStateWithNoChildren()
QStateMachine machine;
QState *parallelState = new QState(QState::ParallelStates, &machine);
+ DEFINE_ACTIVE_SPY(parallelState);
machine.setInitialState(parallelState);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
parallelState->addTransition(new EventTransition(QEvent::User, s1));
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(parallelState, 1);
+ TEST_ACTIVE_CHANGED(s1, 0);
QCOMPARE(1, machine.configuration().size());
QVERIFY(machine.configuration().contains(parallelState));
machine.postEvent(new QEvent(QEvent::User));
-
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(parallelState, 2);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QVERIFY(machine.isRunning());
QCOMPARE(1, machine.configuration().size());
QVERIFY(machine.configuration().contains(s1));
}
@@ -3591,23 +4284,35 @@ void tst_QStateMachine::parallelStateTransition()
QStateMachine machine;
QState *parallelState = new QState(QState::ParallelStates, &machine);
+ DEFINE_ACTIVE_SPY(parallelState);
machine.setInitialState(parallelState);
QState *s1 = new QState(parallelState);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(parallelState);
+ DEFINE_ACTIVE_SPY(s2);
QState *s1InitialChild = new QState(s1);
+ DEFINE_ACTIVE_SPY(s1InitialChild);
s1->setInitialState(s1InitialChild);
QState *s2InitialChild = new QState(s2);
+ DEFINE_ACTIVE_SPY(s2InitialChild);
s2->setInitialState(s2InitialChild);
QState *s1OtherChild = new QState(s1);
+ DEFINE_ACTIVE_SPY(s1OtherChild);
s1->addTransition(new EventTransition(QEvent::User, s1OtherChild));
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(parallelState, 1);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s1InitialChild, 1);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s2InitialChild, 1);
+ TEST_ACTIVE_CHANGED(s1OtherChild, 0);
QVERIFY(machine.configuration().contains(parallelState));
QVERIFY(machine.configuration().contains(s1));
@@ -3619,10 +4324,17 @@ void tst_QStateMachine::parallelStateTransition()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(parallelState, 1);
+ TEST_ACTIVE_CHANGED(s1, 3);
+ TEST_ACTIVE_CHANGED(s1InitialChild, 2);
+ TEST_ACTIVE_CHANGED(s2, 3);
+ TEST_ACTIVE_CHANGED(s2InitialChild, 3);
+ TEST_ACTIVE_CHANGED(s1OtherChild, 1);
+ QVERIFY(machine.isRunning());
+
QVERIFY(machine.configuration().contains(parallelState));
QVERIFY(machine.configuration().contains(s1));
-
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s1OtherChild));
QVERIFY(machine.configuration().contains(s2InitialChild));
@@ -3640,16 +4352,20 @@ void tst_QStateMachine::nestedRestoreProperties()
propertyHolder->setProperty("bar", 2);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(propertyHolder, "foo", 3);
QState *s21 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s21);
s21->assignProperty(propertyHolder, "bar", 4);
s2->setInitialState(s21);
QState *s22 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s22);
s22->assignProperty(propertyHolder, "bar", 5);
s1->addTransition(new EventTransition(QEvent::User, s2));
@@ -3658,6 +4374,10 @@ void tst_QStateMachine::nestedRestoreProperties()
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s21, 0);
+ TEST_ACTIVE_CHANGED(s22, 0);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
QCOMPARE(propertyHolder->property("foo").toInt(), 1);
@@ -3666,6 +4386,10 @@ void tst_QStateMachine::nestedRestoreProperties()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 1);
+ TEST_ACTIVE_CHANGED(s22, 0);
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s21));
@@ -3675,6 +4399,11 @@ void tst_QStateMachine::nestedRestoreProperties()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 2);
+ TEST_ACTIVE_CHANGED(s22, 1);
+ QVERIFY(machine.isRunning());
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s22));
@@ -3692,16 +4421,20 @@ void tst_QStateMachine::nestedRestoreProperties2()
propertyHolder->setProperty("bar", 2);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(propertyHolder, "foo", 3);
QState *s21 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s21);
s21->assignProperty(propertyHolder, "bar", 4);
s2->setInitialState(s21);
QState *s22 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s22);
s22->assignProperty(propertyHolder, "foo", 6);
s22->assignProperty(propertyHolder, "bar", 5);
@@ -3712,6 +4445,10 @@ void tst_QStateMachine::nestedRestoreProperties2()
machine.start();
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s21, 0);
+ TEST_ACTIVE_CHANGED(s22, 0);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
QCOMPARE(propertyHolder->property("foo").toInt(), 1);
@@ -3720,6 +4457,10 @@ void tst_QStateMachine::nestedRestoreProperties2()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 1);
+ TEST_ACTIVE_CHANGED(s22, 0);
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s21));
@@ -3729,6 +4470,10 @@ void tst_QStateMachine::nestedRestoreProperties2()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 2);
+ TEST_ACTIVE_CHANGED(s22, 1);
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s22));
@@ -3738,6 +4483,10 @@ void tst_QStateMachine::nestedRestoreProperties2()
machine.postEvent(new QEvent(QEvent::User));
QCoreApplication::processEvents();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 3);
+ TEST_ACTIVE_CHANGED(s22, 2);
QCOMPARE(machine.configuration().size(), 2);
QVERIFY(machine.configuration().contains(s2));
QVERIFY(machine.configuration().contains(s21));
@@ -3750,6 +4499,7 @@ void tst_QStateMachine::nestedStateMachines()
{
QStateMachine machine;
QState *group = new QState(&machine);
+ DEFINE_ACTIVE_SPY(group);
group->setChildMode(QState::ParallelStates);
QStateMachine *subMachines[3];
for (int i = 0; i < 3; ++i) {
@@ -3770,23 +4520,29 @@ void tst_QStateMachine::nestedStateMachines()
group->addTransition(group, SIGNAL(finished()), final);
machine.setInitialState(group);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
QTRY_COMPARE(machine.configuration().count(), 1+2*3);
QVERIFY(machine.configuration().contains(group));
for (int i = 0; i < 3; ++i)
QVERIFY(machine.configuration().contains(subMachines[i]));
QCoreApplication::processEvents(); // starts the submachines
+ TEST_ACTIVE_CHANGED(group, 1);
for (int i = 0; i < 3; ++i)
subMachines[i]->postEvent(new QEvent(QEvent::User));
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
+ TEST_ACTIVE_CHANGED(group, 2);
}
void tst_QStateMachine::goToState()
@@ -3795,10 +4551,13 @@ void tst_QStateMachine::goToState()
QState *s1 = new QState(&machine);
QState *s2 = new QState(&machine);
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
QStateMachinePrivate::get(&machine)->goToState(s2);
QCoreApplication::processEvents();
@@ -3838,10 +4597,13 @@ void tst_QStateMachine::goToStateFromSourceWithTransition()
s1->addTransition(new QSignalTransition);
QState *s2 = new QState(&machine);
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
QStateMachinePrivate::get(&machine)->goToState(s2);
QCoreApplication::processEvents();
@@ -3873,7 +4635,9 @@ void tst_QStateMachine::clonedSignals()
SignalEmitter emitter;
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
CloneSignalTransition *t1 = new CloneSignalTransition(&emitter, SIGNAL(signalWithDefaultArg()), s2);
s1->addTransition(t1);
@@ -3884,6 +4648,9 @@ void tst_QStateMachine::clonedSignals()
emitter.emitSignalWithDefaultArg();
QTest::qWait(1);
QCOMPARE(t1->eventSignalIndex, emitter.metaObject()->indexOfSignal("signalWithDefaultArg()"));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ QVERIFY(machine.isRunning());
}
class EventPosterThread : public QThread
@@ -3928,10 +4695,13 @@ void tst_QStateMachine::postEventFromOtherThread()
poster.start();
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(finishedSpy.isValid());
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
}
#ifndef QT_NO_WIDGETS
@@ -3979,25 +4749,29 @@ void tst_QStateMachine::stopInTransitionToFinalState()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
QFinalState *s2 = new QFinalState(&machine);
QAbstractTransition *t1 = s1->addTransition(s2);
machine.setInitialState(s1);
QObject::connect(t1, SIGNAL(triggered()), &machine, SLOT(stop()));
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
- QSignalSpy s2EnteredSpy(s2, SIGNAL(entered()));
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
+ QSignalSpy s2EnteredSpy(s2, &QFinalState::entered);
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
QVERIFY(stoppedSpy.isValid());
QVERIFY(finishedSpy.isValid());
QVERIFY(s2EnteredSpy.isValid());
+ QVERIFY(runningSpy.isValid());
machine.start();
-
// Stopping should take precedence over finished.
QTRY_COMPARE(stoppedSpy.count(), 1);
QCOMPARE(finishedSpy.count(), 0);
QCOMPARE(s2EnteredSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s2));
+ TEST_ACTIVE_CHANGED(s1, 2);
}
class StopInEventTestTransition : public QAbstractTransition
@@ -4026,24 +4800,31 @@ void tst_QStateMachine::stopInEventTest()
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->addTransition(new StopInEventTestTransition());
machine.setInitialState(s1);
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
QVERIFY(startedSpy.isValid());
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
- QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
QVERIFY(stoppedSpy.isValid());
QVERIFY(finishedSpy.isValid());
machine.postEvent(new QEvent(QEvent::User), QStateMachine::EventPriority(eventPriority));
QTRY_COMPARE(stoppedSpy.count(), 1);
QCOMPARE(finishedSpy.count(), 0);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(machine.configuration().size(), 1);
QVERIFY(machine.configuration().contains(s1));
+ TEST_ACTIVE_CHANGED(s1, 1);
}
class IncrementReceiversTest : public QObject
@@ -4064,26 +4845,33 @@ void tst_QStateMachine::testIncrementReceivers()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QFinalState *s2 = new QFinalState(&machine);
IncrementReceiversTest testObject;
s1->addTransition(&testObject, SIGNAL(mySignal()), s2);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
machine.start();
+ TEST_RUNNING_CHANGED(true);
QMetaObject::invokeMethod(&testObject, "mySignal", Qt::QueuedConnection);
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
QCOMPARE(testObject.signalList.size(), 1);
QCOMPARE(testObject.signalList.at(0), QMetaMethod::fromSignal(&IncrementReceiversTest::mySignal));
+ TEST_ACTIVE_CHANGED(s1, 2);
}
void tst_QStateMachine::initialStateIsEnteredBeforeStartedEmitted()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QFinalState *s2 = new QFinalState(&machine);
@@ -4091,15 +4879,20 @@ void tst_QStateMachine::initialStateIsEnteredBeforeStartedEmitted()
// transition should trigger.
s1->addTransition(&machine, SIGNAL(started()), s2);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
machine.start();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
+ TEST_ACTIVE_CHANGED(s1, 2);
}
void tst_QStateMachine::deletePropertyAssignmentObjectBeforeEntry()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QObject *o1 = new QObject;
@@ -4114,6 +4907,8 @@ void tst_QStateMachine::deletePropertyAssignmentObjectBeforeEntry()
QCOMPARE(o2->objectName(), QString::fromLatin1("bar"));
delete o2;
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QVERIFY(machine.isRunning());
}
void tst_QStateMachine::deletePropertyAssignmentObjectBeforeRestore()
@@ -4121,8 +4916,10 @@ void tst_QStateMachine::deletePropertyAssignmentObjectBeforeRestore()
QStateMachine machine;
machine.setGlobalRestorePolicy(QState::RestoreProperties);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s1->addTransition(new EventTransition(QEvent::User, s2));
QObject *o1 = new QObject;
@@ -4133,6 +4930,8 @@ void tst_QStateMachine::deletePropertyAssignmentObjectBeforeRestore()
QVERIFY(o1->objectName().isEmpty());
QVERIFY(o2->objectName().isEmpty());
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QCOMPARE(o1->objectName(), QString::fromLatin1("foo"));
QCOMPARE(o2->objectName(), QString::fromLatin1("bar"));
@@ -4144,6 +4943,9 @@ void tst_QStateMachine::deletePropertyAssignmentObjectBeforeRestore()
QVERIFY(o2->objectName().isEmpty());
delete o2;
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ QVERIFY(machine.isRunning());
}
void tst_QStateMachine::deleteInitialState()
@@ -4167,24 +4969,36 @@ void tst_QStateMachine::setPropertyAfterRestore()
object->setProperty("a", 1);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
s1->assignProperty(object, "a", 2);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s1->addTransition(new EventTransition(QEvent::User, s2));
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s3->assignProperty(object, "a", 4);
s2->addTransition(new EventTransition(QEvent::User, s3));
QState *s4 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s4);
s3->addTransition(new EventTransition(QEvent::User, s4));
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QCOMPARE(object->property("a").toInt(), 2);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
QTRY_VERIFY(machine.configuration().contains(s2));
QCOMPARE(object->property("a").toInt(), 1); // restored
@@ -4193,10 +5007,19 @@ void tst_QStateMachine::setPropertyAfterRestore()
object->setProperty("a", 3);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ TEST_ACTIVE_CHANGED(s4, 0);
QTRY_VERIFY(machine.configuration().contains(s3));
QCOMPARE(object->property("a").toInt(), 4);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 1);
+ QVERIFY(machine.isRunning());
QTRY_VERIFY(machine.configuration().contains(s4));
QCOMPARE(object->property("a").toInt(), 3); // restored
@@ -4221,14 +5044,15 @@ void tst_QStateMachine::transitionWithNoTarget()
object->setProperty("a", 1);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
s1->assignProperty(object, "a", 2);
EventTransition *t1 = new EventTransition(QEvent::User, /*target=*/0);
s1->addTransition(t1);
- QSignalSpy s1EnteredSpy(s1, SIGNAL(entered()));
- QSignalSpy s1ExitedSpy(s1, SIGNAL(exited()));
- QSignalSpy t1TriggeredSpy(t1, SIGNAL(triggered()));
+ QSignalSpy s1EnteredSpy(s1, &QState::entered);
+ QSignalSpy s1ExitedSpy(s1, &QState::exited);
+ QSignalSpy t1TriggeredSpy(t1, &EventTransition::triggered);
machine.start();
QTRY_VERIFY(machine.configuration().contains(s1));
@@ -4254,6 +5078,8 @@ void tst_QStateMachine::transitionWithNoTarget()
QCOMPARE(object->property("a").toInt(), 3);
delete object;
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QVERIFY(machine.isRunning());
}
void tst_QStateMachine::initialStateIsFinal()
@@ -4261,10 +5087,13 @@ void tst_QStateMachine::initialStateIsFinal()
QStateMachine machine;
QFinalState *f = new QFinalState(&machine);
machine.setInitialState(f);
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
machine.start();
QTRY_VERIFY(machine.configuration().contains(f));
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED_STARTED_STOPPED;
}
class PropertyObject : public QObject
@@ -4293,53 +5122,95 @@ void tst_QStateMachine::restorePropertiesSimple()
QCOMPARE(po->propWriteCount(), 1);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(po, "prop", 4);
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s1->addTransition(new EventTransition(QEvent::User, s2));
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s3->assignProperty(po, "prop", 6);
s2->addTransition(new EventTransition(QEvent::User, s3));
QState *s4 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s4);
s4->assignProperty(po, "prop", 8);
s3->addTransition(new EventTransition(QEvent::User, s4));
QState *s5 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s5);
s4->addTransition(new EventTransition(QEvent::User, s5));
QState *s6 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s6);
s5->addTransition(new EventTransition(QEvent::User, s6));
machine.start();
-
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
+ TEST_ACTIVE_CHANGED(s5, 0);
+ TEST_ACTIVE_CHANGED(s6, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QCOMPARE(po->propWriteCount(), 2);
QCOMPARE(po->prop(), 4);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
+ TEST_ACTIVE_CHANGED(s4, 0);
+ TEST_ACTIVE_CHANGED(s5, 0);
+ TEST_ACTIVE_CHANGED(s6, 0);
QTRY_VERIFY(machine.configuration().contains(s2));
QCOMPARE(po->propWriteCount(), 3);
QCOMPARE(po->prop(), 2); // restored
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ TEST_ACTIVE_CHANGED(s4, 0);
+ TEST_ACTIVE_CHANGED(s5, 0);
+ TEST_ACTIVE_CHANGED(s6, 0);
QTRY_VERIFY(machine.configuration().contains(s3));
QCOMPARE(po->propWriteCount(), 4);
QCOMPARE(po->prop(), 6);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 1);
+ TEST_ACTIVE_CHANGED(s5, 0);
+ TEST_ACTIVE_CHANGED(s6, 0);
QTRY_VERIFY(machine.configuration().contains(s4));
QCOMPARE(po->propWriteCount(), 5);
QCOMPARE(po->prop(), 8);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 2);
+ TEST_ACTIVE_CHANGED(s5, 1);
+ TEST_ACTIVE_CHANGED(s6, 0);
QTRY_VERIFY(machine.configuration().contains(s5));
QCOMPARE(po->propWriteCount(), 6);
QCOMPARE(po->prop(), 2); // restored
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 2);
+ TEST_ACTIVE_CHANGED(s5, 2);
+ TEST_ACTIVE_CHANGED(s6, 1);
+ QVERIFY(machine.isRunning());
QTRY_VERIFY(machine.configuration().contains(s6));
QCOMPARE(po->propWriteCount(), 6);
@@ -4356,76 +5227,158 @@ void tst_QStateMachine::restoreProperties2()
QCOMPARE(po->propWriteCount(), 1);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(po, "prop", 4);
machine.setInitialState(s1);
QState *s11 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s11);
s1->setInitialState(s11);
QState *s12 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s12);
s11->addTransition(new EventTransition(QEvent::User, s12));
QState *s13 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s13);
s13->assignProperty(po, "prop", 6);
s12->addTransition(new EventTransition(QEvent::User, s13));
QState *s14 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s14);
s14->assignProperty(po, "prop", 8);
s13->addTransition(new EventTransition(QEvent::User, s14));
QState *s15 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s15);
s14->addTransition(new EventTransition(QEvent::User, s15));
QState *s16 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s16);
s15->addTransition(new EventTransition(QEvent::User, s16));
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(po, "prop", 10);
s16->addTransition(new EventTransition(QEvent::User, s2));
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
s2->addTransition(new EventTransition(QEvent::User, s3));
machine.start();
-
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 1);
+ TEST_ACTIVE_CHANGED(s12, 0);
+ TEST_ACTIVE_CHANGED(s13, 0);
+ TEST_ACTIVE_CHANGED(s14, 0);
+ TEST_ACTIVE_CHANGED(s15, 0);
+ TEST_ACTIVE_CHANGED(s16, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QTRY_VERIFY(machine.configuration().contains(s11));
QCOMPARE(po->propWriteCount(), 2);
QCOMPARE(po->prop(), 4);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 1);
+ TEST_ACTIVE_CHANGED(s13, 0);
+ TEST_ACTIVE_CHANGED(s14, 0);
+ TEST_ACTIVE_CHANGED(s15, 0);
+ TEST_ACTIVE_CHANGED(s16, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QTRY_VERIFY(machine.configuration().contains(s12));
QCOMPARE(po->propWriteCount(), 2);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 1);
+ TEST_ACTIVE_CHANGED(s14, 0);
+ TEST_ACTIVE_CHANGED(s15, 0);
+ TEST_ACTIVE_CHANGED(s16, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QTRY_VERIFY(machine.configuration().contains(s13));
QCOMPARE(po->propWriteCount(), 3);
QCOMPARE(po->prop(), 6);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 2);
+ TEST_ACTIVE_CHANGED(s14, 1);
+ TEST_ACTIVE_CHANGED(s15, 0);
+ TEST_ACTIVE_CHANGED(s16, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QTRY_VERIFY(machine.configuration().contains(s14));
QCOMPARE(po->propWriteCount(), 4);
QCOMPARE(po->prop(), 8);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 2);
+ TEST_ACTIVE_CHANGED(s14, 2);
+ TEST_ACTIVE_CHANGED(s15, 1);
+ TEST_ACTIVE_CHANGED(s16, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QTRY_VERIFY(machine.configuration().contains(s15));
QCOMPARE(po->propWriteCount(), 5);
QCOMPARE(po->prop(), 4); // restored s1
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 2);
+ TEST_ACTIVE_CHANGED(s14, 2);
+ TEST_ACTIVE_CHANGED(s15, 2);
+ TEST_ACTIVE_CHANGED(s16, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s3, 0);
QTRY_VERIFY(machine.configuration().contains(s16));
QCOMPARE(po->propWriteCount(), 5);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 2);
+ TEST_ACTIVE_CHANGED(s14, 2);
+ TEST_ACTIVE_CHANGED(s15, 2);
+ TEST_ACTIVE_CHANGED(s16, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s3, 0);
QTRY_VERIFY(machine.configuration().contains(s2));
QCOMPARE(po->propWriteCount(), 6);
QCOMPARE(po->prop(), 10);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 2);
+ TEST_ACTIVE_CHANGED(s14, 2);
+ TEST_ACTIVE_CHANGED(s15, 2);
+ TEST_ACTIVE_CHANGED(s16, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
+ QVERIFY(machine.isRunning());
QTRY_VERIFY(machine.configuration().contains(s3));
QCOMPARE(po->propWriteCount(), 7);
QCOMPARE(po->prop(), 2); // restored original
delete po;
+
}
void tst_QStateMachine::restoreProperties3()
@@ -4438,40 +5391,66 @@ void tst_QStateMachine::restoreProperties3()
QCOMPARE(po->propWriteCount(), 1);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(po, "prop", 4);
machine.setInitialState(s1);
QState *s11 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s11);
s11->assignProperty(po, "prop", 6);
s1->setInitialState(s11);
QState *s12 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s12);
s11->addTransition(new EventTransition(QEvent::User, s12));
QState *s13 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s13);
s13->assignProperty(po, "prop", 8);
s12->addTransition(new EventTransition(QEvent::User, s13));
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s13->addTransition(new EventTransition(QEvent::User, s2));
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 1);
+ TEST_ACTIVE_CHANGED(s12, 0);
+ TEST_ACTIVE_CHANGED(s13, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s11));
QCOMPARE(po->propWriteCount(), 3);
QCOMPARE(po->prop(), 6); // s11
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 1);
+ TEST_ACTIVE_CHANGED(s13, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s12));
QCOMPARE(po->propWriteCount(), 4);
QCOMPARE(po->prop(), 4); // restored s1
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s13));
QCOMPARE(po->propWriteCount(), 5);
QCOMPARE(po->prop(), 8);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s13, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ QVERIFY(machine.isRunning());
QTRY_VERIFY(machine.configuration().contains(s2));
QCOMPARE(po->propWriteCount(), 6);
QCOMPARE(po->prop(), 2); // restored original
@@ -4493,31 +5472,47 @@ void tst_QStateMachine::restoreProperties4()
QCOMPARE(po2->propWriteCount(), 1);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->setChildMode(QState::ParallelStates);
machine.setInitialState(s1);
QState *s11 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s11);
QState *s111 = new QState(s11);
+ DEFINE_ACTIVE_SPY(s111);
s111->assignProperty(po1, "prop", 6);
s11->setInitialState(s111);
QState *s112 = new QState(s11);
+ DEFINE_ACTIVE_SPY(s112);
s112->assignProperty(po1, "prop", 8);
s111->addTransition(new EventTransition(QEvent::User, s112));
QState *s12 = new QState(s1);
+ DEFINE_ACTIVE_SPY(s12);
QState *s121 = new QState(s12);
+ DEFINE_ACTIVE_SPY(s121);
s121->assignProperty(po2, "prop", 10);
s12->setInitialState(s121);
QState *s122 = new QState(s12);
+ DEFINE_ACTIVE_SPY(s122);
s122->assignProperty(po2, "prop", 12);
s121->addTransition(new EventTransition(static_cast<QEvent::Type>(QEvent::User+1), s122));
QState *s2 = new QState(&machine);
s112->addTransition(new EventTransition(QEvent::User, s2));
+ DEFINE_ACTIVE_SPY(s2);
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 1);
+ TEST_ACTIVE_CHANGED(s111, 1);
+ TEST_ACTIVE_CHANGED(s112, 0);
+ TEST_ACTIVE_CHANGED(s12, 1);
+ TEST_ACTIVE_CHANGED(s121, 1);
+ TEST_ACTIVE_CHANGED(s122, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QVERIFY(machine.configuration().contains(s11));
@@ -4530,18 +5525,42 @@ void tst_QStateMachine::restoreProperties4()
QCOMPARE(po2->prop(), 10);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 1);
+ TEST_ACTIVE_CHANGED(s111, 2);
+ TEST_ACTIVE_CHANGED(s112, 1);
+ TEST_ACTIVE_CHANGED(s12, 1);
+ TEST_ACTIVE_CHANGED(s121, 1);
+ TEST_ACTIVE_CHANGED(s122, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s112));
QCOMPARE(po1->propWriteCount(), 3);
QCOMPARE(po1->prop(), 8);
QCOMPARE(po2->propWriteCount(), 2);
machine.postEvent(new QEvent(static_cast<QEvent::Type>(QEvent::User+1)));
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s11, 1);
+ TEST_ACTIVE_CHANGED(s111, 2);
+ TEST_ACTIVE_CHANGED(s112, 1);
+ TEST_ACTIVE_CHANGED(s12, 1);
+ TEST_ACTIVE_CHANGED(s121, 2);
+ TEST_ACTIVE_CHANGED(s122, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s122));
QCOMPARE(po1->propWriteCount(), 3);
QCOMPARE(po2->propWriteCount(), 3);
QCOMPARE(po2->prop(), 12);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s11, 2);
+ TEST_ACTIVE_CHANGED(s111, 2);
+ TEST_ACTIVE_CHANGED(s112, 2);
+ TEST_ACTIVE_CHANGED(s12, 2);
+ TEST_ACTIVE_CHANGED(s121, 2);
+ TEST_ACTIVE_CHANGED(s122, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
QTRY_VERIFY(machine.configuration().contains(s2));
QCOMPARE(po1->propWriteCount(), 4);
QCOMPARE(po1->prop(), 2); // restored original
@@ -4562,27 +5581,37 @@ void tst_QStateMachine::restorePropertiesSelfTransition()
QCOMPARE(po->propWriteCount(), 1);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(po, "prop", 4);
s1->addTransition(new EventTransition(QEvent::User, s1));
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s1->addTransition(new EventTransition(static_cast<QEvent::Type>(QEvent::User+1), s2));
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QCOMPARE(po->propWriteCount(), 2);
QCOMPARE(po->prop(), 4);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 3);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_COMPARE(po->propWriteCount(), 3);
QCOMPARE(po->prop(), 4);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 5);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_COMPARE(po->propWriteCount(), 4);
QCOMPARE(po->prop(), 4);
machine.postEvent(new QEvent(static_cast<QEvent::Type>(QEvent::User+1)));
+ TEST_ACTIVE_CHANGED(s1, 6);
+ TEST_ACTIVE_CHANGED(s2, 1);
QTRY_VERIFY(machine.configuration().contains(s2));
QCOMPARE(po->propWriteCount(), 5);
QCOMPARE(po->prop(), 2); // restored
@@ -4601,12 +5630,15 @@ void tst_QStateMachine::changeStateWhileAnimatingProperty()
o2->setProperty("y", 20.);
QState *group = new QState(&machine);
+ DEFINE_ACTIVE_SPY(group);
machine.setInitialState(group);
QState *s0 = new QState(group);
+ DEFINE_ACTIVE_SPY(s0);
group->setInitialState(s0);
QState *s1 = new QState(group);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(o1, "x", 15.);
QPropertyAnimation *a1 = new QPropertyAnimation(o1, "x", s1);
a1->setDuration(800);
@@ -4614,6 +5646,7 @@ void tst_QStateMachine::changeStateWhileAnimatingProperty()
group->addTransition(new EventTransition(QEvent::User, s1));
QState *s2 = new QState(group);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(o2, "y", 25.);
QPropertyAnimation *a2 = new QPropertyAnimation(o2, "y", s2);
a2->setDuration(800);
@@ -4621,23 +5654,46 @@ void tst_QStateMachine::changeStateWhileAnimatingProperty()
group->addTransition(new EventTransition(static_cast<QEvent::Type>(QEvent::User+1), s2));
machine.start();
+ TEST_ACTIVE_CHANGED(group, 1);
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 0);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s0));
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(group, 3);
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QCOREAPPLICATION_EXEC(400);
machine.postEvent(new QEvent(static_cast<QEvent::Type>(QEvent::User+1)));
+ TEST_ACTIVE_CHANGED(group, 5);
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
QTRY_VERIFY(machine.configuration().contains(s2));
QCOREAPPLICATION_EXEC(300);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(group, 7);
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s1, 3);
+ TEST_ACTIVE_CHANGED(s2, 2);
QTRY_VERIFY(machine.configuration().contains(s1));
QCOREAPPLICATION_EXEC(200);
machine.postEvent(new QEvent(static_cast<QEvent::Type>(QEvent::User+1)));
+ TEST_ACTIVE_CHANGED(group, 9);
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s1, 4);
+ TEST_ACTIVE_CHANGED(s2, 3);
QTRY_VERIFY(machine.configuration().contains(s2));
QCOREAPPLICATION_EXEC(100);
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(group, 11);
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s1, 5);
+ TEST_ACTIVE_CHANGED(s2, 4);
QTRY_VERIFY(machine.configuration().contains(s1));
-
QTRY_COMPARE(o1->property("x").toDouble(), 15.);
QTRY_COMPARE(o2->property("y").toDouble(), 20.);
@@ -4679,15 +5735,19 @@ void tst_QStateMachine::propertiesAreAssignedBeforeEntryCallbacks()
machine.setGlobalRestorePolicy(static_cast<QState::RestorePolicy>(restorePolicy));
AssignPropertyTestState *s1 = new AssignPropertyTestState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
s1->assignProperty(s1, "wasAssigned", true);
machine.setInitialState(s1);
AssignPropertyTestState *s2 = new AssignPropertyTestState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s2->assignProperty(s2, "wasAssigned", true);
s1->addTransition(new EventTransition(QEvent::User, s2));
QVERIFY(!s1->property("wasAssigned").toBool());
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QVERIFY(s1->onEntryPassed);
@@ -4695,6 +5755,8 @@ void tst_QStateMachine::propertiesAreAssignedBeforeEntryCallbacks()
QVERIFY(!s2->property("wasAssigned").toBool());
machine.postEvent(new QEvent(QEvent::User));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
QTRY_VERIFY(machine.configuration().contains(s2));
QVERIFY(s2->onEntryPassed);
@@ -4706,18 +5768,26 @@ void tst_QStateMachine::multiTargetTransitionInsideParallelStateGroup()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QState *s2 = new QState(QState::ParallelStates, &machine);
+ DEFINE_ACTIVE_SPY(s2);
QState *s21 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s21);
QState *s211 = new QState(s21);
+ DEFINE_ACTIVE_SPY(s211);
QState *s212 = new QState(s21);
+ DEFINE_ACTIVE_SPY(s212);
s21->setInitialState(s212);
QState *s22 = new QState(s2);
+ DEFINE_ACTIVE_SPY(s22);
QState *s221 = new QState(s22);
+ DEFINE_ACTIVE_SPY(s221);
QState *s222 = new QState(s22);
+ DEFINE_ACTIVE_SPY(s222);
s22->setInitialState(s222);
QAbstractTransition *t1 = new EventTransition(QEvent::User, QList<QAbstractState *>() << s211 << s221);
@@ -4725,7 +5795,14 @@ void tst_QStateMachine::multiTargetTransitionInsideParallelStateGroup()
machine.start();
QTRY_VERIFY(machine.configuration().contains(s1));
-
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
+ TEST_ACTIVE_CHANGED(s21, 0);
+ TEST_ACTIVE_CHANGED(s211, 0);
+ TEST_ACTIVE_CHANGED(s212, 0);
+ TEST_ACTIVE_CHANGED(s22, 0);
+ TEST_ACTIVE_CHANGED(s221, 0);
+ TEST_ACTIVE_CHANGED(s222, 0);
machine.postEvent(new QEvent(QEvent::User));
QTRY_VERIFY(machine.configuration().contains(s2));
QCOMPARE(machine.configuration().size(), 5);
@@ -4733,19 +5810,31 @@ void tst_QStateMachine::multiTargetTransitionInsideParallelStateGroup()
QVERIFY(machine.configuration().contains(s211));
QVERIFY(machine.configuration().contains(s22));
QVERIFY(machine.configuration().contains(s221));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
+ TEST_ACTIVE_CHANGED(s21, 1);
+ TEST_ACTIVE_CHANGED(s211, 1);
+ TEST_ACTIVE_CHANGED(s212, 0);
+ TEST_ACTIVE_CHANGED(s22, 1);
+ TEST_ACTIVE_CHANGED(s221, 1);
+ TEST_ACTIVE_CHANGED(s222, 0);
}
void tst_QStateMachine::signalTransitionNormalizeSignature()
{
QStateMachine machine;
QState *s0 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s0);
machine.setInitialState(s0);
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
SignalEmitter emitter;
TestSignalTransition *t0 = new TestSignalTransition(&emitter, SIGNAL(signalWithNoArg()), s1);
s0->addTransition(t0);
machine.start();
+ TEST_ACTIVE_CHANGED(s0, 1);
+ TEST_ACTIVE_CHANGED(s1, 0);
QTRY_VERIFY(machine.configuration().contains(s0));
emitter.emitSignalWithNoArg();
QTRY_VERIFY(machine.configuration().contains(s1));
@@ -4756,44 +5845,60 @@ void tst_QStateMachine::signalTransitionNormalizeSignature()
QCOMPARE(t0->transitionSenderReceived(), (QObject*)&emitter);
QCOMPARE(t0->transitionSignalIndexReceived(), emitter.metaObject()->indexOfSignal("signalWithNoArg()"));
QCOMPARE(t0->transitionArgumentsReceived().size(), 0);
+ TEST_ACTIVE_CHANGED(s0, 2);
+ TEST_ACTIVE_CHANGED(s1, 1);
}
void tst_QStateMachine::createSignalTransitionWhenRunning()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
QTRY_VERIFY(machine.configuration().contains(s1));
-
// Create by addTransition()
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
SignalEmitter emitter;
QAbstractTransition *t1 = s1->addTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
QCOMPARE(t1->sourceState(), s1);
emitter.emitSignalWithNoArg();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 1);
QTRY_VERIFY(machine.configuration().contains(s2));
// Create by constructor that takes sender, signal, source (parent) state
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QSignalTransition *t2 = new QSignalTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
QCOMPARE(t2->sourceState(), s2);
t2->setTargetState(s3);
emitter.emitSignalWithNoArg();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 1);
QTRY_VERIFY(machine.configuration().contains(s3));
// Create by constructor that takes source (parent) state
QState *s4 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s4);
QSignalTransition *t3 = new QSignalTransition(s3);
QCOMPARE(t3->sourceState(), s3);
t3->setSenderObject(&emitter);
t3->setSignal(SIGNAL(signalWithNoArg()));
t3->setTargetState(s4);
emitter.emitSignalWithNoArg();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 1);
QTRY_VERIFY(machine.configuration().contains(s4));
// Create by constructor without parent, then set the parent
QState *s5 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s5);
QSignalTransition *t4 = new QSignalTransition();
t4->setSenderObject(&emitter);
t4->setParent(s4);
@@ -4801,6 +5906,11 @@ void tst_QStateMachine::createSignalTransitionWhenRunning()
t4->setSignal(SIGNAL(signalWithNoArg()));
t4->setTargetState(s5);
emitter.emitSignalWithNoArg();
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 2);
+ TEST_ACTIVE_CHANGED(s5, 1);
QTRY_VERIFY(machine.configuration().contains(s5));
}
@@ -4808,12 +5918,15 @@ void tst_QStateMachine::createEventTransitionWhenRunning()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
QTRY_VERIFY(machine.configuration().contains(s1));
// Create by constructor that takes event source, type, source (parent) state
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
QObject object;
QEventTransition *t1 = new QEventTransition(&object, QEvent::Timer, s1);
QCOMPARE(t1->sourceState(), s1);
@@ -4824,6 +5937,7 @@ void tst_QStateMachine::createEventTransitionWhenRunning()
// Create by constructor that takes source (parent) state
QState *s3 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s3);
QEventTransition *t2 = new QEventTransition(s2);
QCOMPARE(t2->sourceState(), s2);
t2->setEventSource(&object);
@@ -4833,6 +5947,7 @@ void tst_QStateMachine::createEventTransitionWhenRunning()
// Create by constructor without parent, then set the parent
QState *s4 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s4);
QEventTransition *t3 = new QEventTransition();
t3->setEventSource(&object);
t3->setParent(s3);
@@ -4840,6 +5955,10 @@ void tst_QStateMachine::createEventTransitionWhenRunning()
t3->setEventType(QEvent::Timer);
t3->setTargetState(s4);
QTRY_VERIFY(machine.configuration().contains(s4));
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ TEST_ACTIVE_CHANGED(s3, 2);
+ TEST_ACTIVE_CHANGED(s4, 1);
}
class SignalEmitterThread : public QThread
@@ -4869,10 +5988,12 @@ void tst_QStateMachine::signalTransitionSenderInDifferentThread()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
SignalEmitterThread thread;
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
s1->addTransition(&thread, SIGNAL(signal1()), s2);
QFinalState *s3 = new QFinalState(&machine);
@@ -4882,29 +6003,41 @@ void tst_QStateMachine::signalTransitionSenderInDifferentThread()
QTRY_VERIFY(thread.isRunning());
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 1);
+ TEST_ACTIVE_CHANGED(s2, 0);
QTRY_VERIFY(machine.configuration().contains(s1));
QMetaObject::invokeMethod(&thread, "emitSignals");
// thread emits both signal1() and signal2(), so we should end in s3
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
+ QTRY_VERIFY(!machine.isRunning());
QTRY_VERIFY(machine.configuration().contains(s3));
// Run the machine again; transitions should still be registered
machine.start();
+ TEST_ACTIVE_CHANGED(s1, 3);
+ TEST_ACTIVE_CHANGED(s2, 2);
QTRY_VERIFY(machine.configuration().contains(s1));
QMetaObject::invokeMethod(&thread, "emitSignals");
QTRY_VERIFY(machine.configuration().contains(s3));
thread.quit();
QTRY_VERIFY(thread.wait());
+ TEST_ACTIVE_CHANGED(s1, 4);
+ TEST_ACTIVE_CHANGED(s2, 4);
+ QVERIFY(!machine.isRunning());
}
void tst_QStateMachine::signalTransitionSenderInDifferentThread2()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
QState *s2 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s2);
SignalEmitter emitter;
// At the time of the transition creation, the machine and the emitter
// are both in the same thread.
@@ -4921,18 +6054,24 @@ void tst_QStateMachine::signalTransitionSenderInDifferentThread2()
thread.start();
QTRY_VERIFY(thread.isRunning());
- QSignalSpy startedSpy(&machine, SIGNAL(started()));
- QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged);
+ QVERIFY(runningSpy.isValid());
+ QSignalSpy startedSpy(&machine, &QStateMachine::started);
+ QSignalSpy finishedSpy(&machine, &QStateMachine::finished);
machine.start();
QTRY_COMPARE(startedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(true);
emitter.emitSignalWithNoArg();
// The second emission should not get "lost".
emitter.emitSignalWithDefaultArg();
QTRY_COMPARE(finishedSpy.count(), 1);
+ TEST_RUNNING_CHANGED(false);
thread.quit();
QTRY_VERIFY(thread.wait());
+ TEST_ACTIVE_CHANGED(s1, 2);
+ TEST_ACTIVE_CHANGED(s2, 2);
}
class SignalTransitionMutatorThread : public QThread
@@ -4958,6 +6097,7 @@ void tst_QStateMachine::signalTransitionRegistrationThreadSafety()
{
QStateMachine machine;
QState *s1 = new QState(&machine);
+ DEFINE_ACTIVE_SPY(s1);
machine.setInitialState(s1);
machine.start();
QTRY_VERIFY(machine.configuration().contains(s1));
@@ -4982,6 +6122,8 @@ void tst_QStateMachine::signalTransitionRegistrationThreadSafety()
thread.quit();
QTRY_VERIFY(thread.wait());
+ TEST_ACTIVE_CHANGED(s1, 1);
+ QVERIFY(machine.isRunning());
}
void tst_QStateMachine::childModeConstructor()
diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
index b2b0eace34..5c9f26b70e 100644
--- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -87,8 +87,8 @@ void tst_QFutureWatcher::startFinish()
{
QFutureWatcher<void> futureWatcher;
- QSignalSpy startedSpy(&futureWatcher, SIGNAL(started()));
- QSignalSpy finishedSpy(&futureWatcher, SIGNAL(finished()));
+ QSignalSpy startedSpy(&futureWatcher, &QFutureWatcher<void>::started);
+ QSignalSpy finishedSpy(&futureWatcher, &QFutureWatcher<void>::finished);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -322,7 +322,7 @@ void tst_QFutureWatcher::futureSignals()
a.reportStarted();
f.setFuture(a.future());
- QSignalSpy progressSpy(&f, SIGNAL(progressValueChanged(int)));
+ QSignalSpy progressSpy(&f, &QFutureWatcher<void>::progressValueChanged);
QVERIFY(progressSpy.isValid());
const int progress = 1;
a.setProgressValue(progress);
@@ -331,8 +331,8 @@ void tst_QFutureWatcher::futureSignals()
QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0);
QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1);
- QSignalSpy finishedSpy(&f, SIGNAL(finished()));
- QSignalSpy resultReadySpy(&f, SIGNAL(resultReadyAt(int)));
+ QSignalSpy finishedSpy(&f, &QFutureWatcher<void>::finished);
+ QSignalSpy resultReadySpy(&f, &QFutureWatcher<void>::resultReadyAt);
QVERIFY(finishedSpy.isValid());
QVERIFY(resultReadySpy.isValid());
@@ -374,10 +374,10 @@ void tst_QFutureWatcher::watchFinishedFuture()
#endif
connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
- QSignalSpy startedSpy(&watcher, SIGNAL(started()));
- QSignalSpy finishedSpy(&watcher, SIGNAL(finished()));
- QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
- QSignalSpy canceledSpy(&watcher, SIGNAL(canceled()));
+ QSignalSpy startedSpy(&watcher, &QFutureWatcher<int>::started);
+ QSignalSpy finishedSpy(&watcher, &QFutureWatcher<int>::finished);
+ QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt);
+ QSignalSpy canceledSpy(&watcher, &QFutureWatcher<int>::canceled);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -408,10 +408,10 @@ void tst_QFutureWatcher::watchCanceledFuture()
#endif
connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
- QSignalSpy startedSpy(&watcher, SIGNAL(started()));
- QSignalSpy finishedSpy(&watcher, SIGNAL(finished()));
- QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
- QSignalSpy canceledSpy(&watcher, SIGNAL(canceled()));
+ QSignalSpy startedSpy(&watcher, &QFutureWatcher<int>::started);
+ QSignalSpy finishedSpy(&watcher, &QFutureWatcher<int>::finished);
+ QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt);
+ QSignalSpy canceledSpy(&watcher, &QFutureWatcher<int>::canceled);
QVERIFY(startedSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -439,8 +439,8 @@ void tst_QFutureWatcher::disconnectRunningFuture()
SignalSlotObject object;
connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
- QSignalSpy finishedSpy(watcher, SIGNAL(finished()));
- QSignalSpy resultReadySpy(watcher, SIGNAL(resultReadyAt(int)));
+ QSignalSpy finishedSpy(watcher, &QFutureWatcher<int>::finished);
+ QSignalSpy resultReadySpy(watcher, &QFutureWatcher<int>::resultReadyAt);
QVERIFY(finishedSpy.isValid());
QVERIFY(resultReadySpy.isValid());
@@ -634,7 +634,7 @@ void tst_QFutureWatcher::changeFuture()
SignalSlotObject object;
connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
- QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+ QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt);
QVERIFY(resultReadySpy.isValid());
watcher.setFuture(a); // Watch 'a' which will genere a resultReady event.
@@ -666,7 +666,7 @@ void tst_QFutureWatcher::cancelEvents()
SignalSlotObject object;
connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
- QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+ QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt);
QVERIFY(resultReadySpy.isValid());
watcher.setFuture(a);
@@ -694,7 +694,7 @@ void tst_QFutureWatcher::pauseEvents()
SignalSlotObject object;
connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
- QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+ QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt);
QVERIFY(resultReadySpy.isValid());
watcher.setFuture(a);
@@ -720,7 +720,7 @@ void tst_QFutureWatcher::pauseEvents()
SignalSlotObject object;
connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int)));
- QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int)));
+ QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt);
QVERIFY(resultReadySpy.isValid());
watcher.setFuture(a);
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index 0e53139414..a8c052119c 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -53,13 +53,11 @@
#ifdef Q_OS_UNIX
#include <pthread.h>
#endif
-#if defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
#include <windows.h>
-#elif defined(Q_OS_WINRT)
-#include <thread>
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN32)
#include <process.h>
-#include <windows.h>
+#endif
#endif
class tst_QThread : public QObject
@@ -328,9 +326,6 @@ void tst_QThread::isRunning()
void tst_QThread::setPriority()
{
-#if defined(Q_OS_WINRT)
- QSKIP("Thread priority is not supported on WinRT");
-#endif
Simple_Thread thread;
// cannot change the priority, since the thread is not running
@@ -465,10 +460,6 @@ void tst_QThread::start()
QVERIFY(!thread.isFinished());
QVERIFY(!thread.isRunning());
QMutexLocker locker(&thread.mutex);
-#ifdef Q_OS_WINRT
- if (priorities[i] != QThread::NormalPriority && priorities[i] != QThread::InheritPriority)
- QTest::ignoreMessage(QtWarningMsg, "QThread::start: Failed to set thread priority (not implemented)");
-#endif
thread.start(priorities[i]);
QVERIFY(thread.isRunning());
QVERIFY(!thread.isFinished());
@@ -482,7 +473,7 @@ void tst_QThread::start()
void tst_QThread::terminate()
{
#if defined(Q_OS_WINRT)
- QSKIP("Terminate is not supported on WinRT");
+ QSKIP("Thread termination is not supported on WinRT.");
#endif
Terminate_Thread thread;
{
@@ -548,7 +539,7 @@ void tst_QThread::finished()
void tst_QThread::terminated()
{
#if defined(Q_OS_WINRT)
- QSKIP("Terminate is not supported on WinRT");
+ QSKIP("Thread termination is not supported on WinRT.");
#endif
SignalRecorder recorder;
Terminate_Thread thread;
@@ -645,8 +636,6 @@ void noop(void*) { }
#if defined Q_OS_UNIX
typedef pthread_t ThreadHandle;
-#elif defined Q_OS_WINRT
- typedef std::thread ThreadHandle;
#elif defined Q_OS_WIN
typedef HANDLE ThreadHandle;
#endif
@@ -689,7 +678,7 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data)
const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this);
Q_UNUSED(state);
#elif defined(Q_OS_WINRT)
- nativeThreadHandle = std::thread(NativeThreadWrapper::runWin, this);
+ // creating a new worker from within the GUI thread is not supported
#elif defined(Q_OS_WINCE)
nativeThreadHandle = CreateThread(NULL, 0 , (LPTHREAD_START_ROUTINE)NativeThreadWrapper::runWin , this, 0, NULL);
#elif defined Q_OS_WIN
@@ -710,7 +699,7 @@ void NativeThreadWrapper::join()
#if defined Q_OS_UNIX
pthread_join(nativeThreadHandle, 0);
#elif defined Q_OS_WINRT
- nativeThreadHandle.join();
+ // not supported
#elif defined Q_OS_WIN
WaitForSingleObject(nativeThreadHandle, INFINITE);
CloseHandle(nativeThreadHandle);
@@ -766,6 +755,9 @@ void testNativeThreadAdoption(void *)
}
void tst_QThread::nativeThreadAdoption()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
threadAdoptedOk = false;
mainThread = QThread::currentThread();
NativeThreadWrapper nativeThread;
@@ -789,6 +781,9 @@ void adoptedThreadAffinityFunction(void *arg)
void tst_QThread::adoptedThreadAffinity()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
QThread *affinity[2] = { 0, 0 };
NativeThreadWrapper thread;
@@ -801,10 +796,9 @@ void tst_QThread::adoptedThreadAffinity()
void tst_QThread::adoptedThreadSetPriority()
{
-#if defined(Q_OS_WINRT)
- QSKIP("Thread priority is not supported on WinRT");
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
#endif
-
NativeThreadWrapper nativeThread;
nativeThread.setWaitForStop();
nativeThread.startAndWait();
@@ -832,6 +826,9 @@ void tst_QThread::adoptedThreadSetPriority()
void tst_QThread::adoptedThreadExit()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
NativeThreadWrapper nativeThread;
nativeThread.setWaitForStop();
@@ -861,6 +858,9 @@ void adoptedThreadExecFunction(void *)
void tst_QThread::adoptedThreadExec()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
NativeThreadWrapper nativeThread;
nativeThread.start(adoptedThreadExecFunction);
nativeThread.join();
@@ -871,6 +871,9 @@ void tst_QThread::adoptedThreadExec()
*/
void tst_QThread::adoptedThreadFinished()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
NativeThreadWrapper nativeThread;
nativeThread.setWaitForStop();
nativeThread.startAndWait();
@@ -889,6 +892,9 @@ void tst_QThread::adoptedThreadFinished()
void tst_QThread::adoptedThreadExecFinished()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
NativeThreadWrapper nativeThread;
nativeThread.setWaitForStop();
nativeThread.startAndWait(adoptedThreadExecFunction);
@@ -899,14 +905,14 @@ void tst_QThread::adoptedThreadExecFinished()
nativeThread.join();
QTestEventLoop::instance().enterLoop(5);
-#if defined(Q_OS_WINRT)
- QEXPECT_FAIL("", "QTBUG-31397: Known not to work on WinRT", Abort);
-#endif
QVERIFY(!QTestEventLoop::instance().timeout());
}
void tst_QThread::adoptMultipleThreads()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
#if defined(Q_OS_WIN)
// Windows CE is not capable of handling that many threads. On the emulator it is dead with 26 threads already.
# if defined(Q_OS_WINCE)
@@ -947,6 +953,9 @@ void tst_QThread::adoptMultipleThreads()
void tst_QThread::adoptMultipleThreadsOverlap()
{
+#ifdef Q_OS_WINRT
+ QSKIP("Native thread adoption is not supported on WinRT.");
+#endif
#if defined(Q_OS_WIN)
// Windows CE is not capable of handling that many threads. On the emulator it is dead with 26 threads already.
# if defined(Q_OS_WINCE)
diff --git a/tests/auto/other/collections/.gitignore b/tests/auto/corelib/tools/collections/.gitignore
index dcd9d49ec0..dcd9d49ec0 100644
--- a/tests/auto/other/collections/.gitignore
+++ b/tests/auto/corelib/tools/collections/.gitignore
diff --git a/tests/auto/other/collections/collections.pro b/tests/auto/corelib/tools/collections/collections.pro
index 51ea667f58..51ea667f58 100644
--- a/tests/auto/other/collections/collections.pro
+++ b/tests/auto/corelib/tools/collections/collections.pro
diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index 17ed9c8a45..33aa1c4888 100644
--- a/tests/auto/other/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -1238,8 +1238,6 @@ void tst_Collections::byteArray()
QVERIFY(hello + "World" == helloWorld);
QVERIFY("hello" + World == helloWorld);
-
- QByteArray l;
QVERIFY('h' + ello == hello);
QVERIFY(Wor + 'l' + 'd' == "World");
QVERIFY(hello + World == "helloWorld");
@@ -1969,8 +1967,6 @@ void tst_Collections::qstring()
QVERIFY(hello + "World" == helloWorld);
QVERIFY("hello" + World == helloWorld);
-
- QString l;
QVERIFY('h' + ello == hello);
QVERIFY(Wor + 'l' + 'd' == "World");
QVERIFY(hello + World == "helloWorld");
@@ -2441,8 +2437,7 @@ void testContainer()
}
/*
- Verify that the 'sharable' flag is true while no mutable
- iterator is active.
+ Verify that the 'sharable' flag is true in populated containers.
*/
{
Container c1;
@@ -2457,95 +2452,6 @@ void testContainer()
QVERIFY(!c2.isDetached());
}
- /*
- Verify that the 'sharable' flag is set to false by the
- mutable iterator.
- */
- {
- Container c1;
- populate(c1);
- QVERIFY(c1.size() == 4);
- QVERIFY(c1.isDetached());
-
- ContainerMutableIterator i(c1);
- i.next();
-
- Container c2 = c1;
- QVERIFY(c1.size() == 4);
- QVERIFY(c2.size() == 4);
- QVERIFY(c1.isDetached());
- QVERIFY(c2.isDetached());
-
- i.remove();
- QVERIFY(c1.size() == 3);
- QVERIFY(c2.size() == 4);
- }
-
- /*
- Verify that the 'sharable' flag is reset to true by the
- mutable iterator's destructor.
- */
- {
- Container c1;
- populate(c1);
- QVERIFY(c1.size() == 4);
- QVERIFY(c1.isDetached());
-
- {
- ContainerMutableIterator i(c1);
- i.next();
- }
-
- Container c2 = c1;
- QVERIFY(c1.size() == 4);
- QVERIFY(c2.size() == 4);
- QVERIFY(!c1.isDetached());
- QVERIFY(!c2.isDetached());
- }
-
- /*
- Verify that the 'sharable' flag only affects the original
- object, not the copies.
- */
- {
- Container c1;
- populate(c1);
- QVERIFY(c1.size() == 4);
- QVERIFY(c1.isDetached());
-
- Container c2 = c1;
- QVERIFY(isSharable(c2));
-
- ContainerMutableIterator i(c1);
- QVERIFY(!isSharable(c1));
- QVERIFY(isSharable(c2));
-
- Container c3 = c1;
- QVERIFY(!isSharable(c1));
- QVERIFY(isSharable(c2));
- QVERIFY(isSharable(c3));
- QVERIFY(c1.isDetached());
- QVERIFY(c2.isDetached());
- QVERIFY(c3.isDetached());
-
- Container c4;
- c4 = c1;
- QVERIFY(!isSharable(c1));
- QVERIFY(isSharable(c2));
- QVERIFY(isSharable(c4));
- QVERIFY(c1.isDetached());
- QVERIFY(c2.isDetached());
- QVERIFY(c4.isDetached());
-
- c3 = c2;
- QVERIFY(!isSharable(c1));
- QVERIFY(isSharable(c2));
- QVERIFY(isSharable(c3));
- QVERIFY(c1.isDetached());
- QVERIFY(!c2.isDetached());
- QVERIFY(!c3.isDetached());
- }
-
/* test that the move operators work properly */
{
Container c1 = Container(newInstance<Container>());
@@ -3231,18 +3137,20 @@ void tst_Collections::qtimerList()
QFAIL("QList preallocates too much memory");
}
+#define QVERIFY_TYPE(Type) QVERIFY(sizeof(Type))
+
template <typename Container>
void testContainerTypedefs(Container container)
{
Q_UNUSED(container)
- { typedef typename Container::value_type Foo; }
- { typedef typename Container::iterator Foo; }
- { typedef typename Container::const_iterator Foo; }
- { typedef typename Container::reference Foo; }
- { typedef typename Container::const_reference Foo; }
- { typedef typename Container::pointer Foo; }
- { typedef typename Container::difference_type Foo; }
- { typedef typename Container::size_type Foo; }
+ { QVERIFY_TYPE(typename Container::value_type); }
+ { QVERIFY_TYPE(typename Container::iterator); }
+ { QVERIFY_TYPE(typename Container::const_iterator); }
+ { QVERIFY_TYPE(typename Container::reference); }
+ { QVERIFY_TYPE(typename Container::const_reference); }
+ { QVERIFY_TYPE(typename Container::pointer); }
+ { QVERIFY_TYPE(typename Container::difference_type); }
+ { QVERIFY_TYPE(typename Container::size_type); }
}
template <typename Container>
@@ -3251,34 +3159,34 @@ void testPairAssociativeContainerTypedefs(Container container)
Q_UNUSED(container)
// TODO: Not sure how to define value_type for our associative containers
-// { typedef typename Container::value_type Foo; }
-// { typedef typename Container::const_iterator Foo; }
-// { typedef typename Container::reference Foo; }
-// { typedef typename Container::const_reference Foo; }
-// { typedef typename Container::pointer Foo; }
-
- { typedef typename Container::difference_type Foo; }
- { typedef typename Container::size_type Foo; }
- { typedef typename Container::iterator Foo; }
- { typedef typename Container::key_type Foo; }
- { typedef typename Container::mapped_type Foo; }
+// { QVERIFY_TYPE(typename Container::value_type); }
+// { QVERIFY_TYPE(typename Container::const_iterator); }
+// { QVERIFY_TYPE(typename Container::reference); }
+// { QVERIFY_TYPE(typename Container::const_reference); }
+// { QVERIFY_TYPE(typename Container::pointer); }
+
+ { QVERIFY_TYPE(typename Container::difference_type); }
+ { QVERIFY_TYPE(typename Container::size_type); }
+ { QVERIFY_TYPE(typename Container::iterator); }
+ { QVERIFY_TYPE(typename Container::key_type); }
+ { QVERIFY_TYPE(typename Container::mapped_type); }
// TODO
-// { typedef typename Container::key_compare Foo; }
-// { typedef typename Container::value_comare Foo; }
+// { QVERIFY_TYPE(typename Container::key_compare); }
+// { QVERIFY_TYPE(typename Container::value_comare); }
}
template <typename Container>
void testSetContainerTypedefs(Container container)
{
Q_UNUSED(container)
- { typedef typename Container::iterator Foo; }
- { typedef typename Container::const_iterator Foo; }
- { typedef typename Container::reference Foo; }
- { typedef typename Container::const_reference Foo; }
- { typedef typename Container::pointer Foo; }
- { typedef typename Container::difference_type Foo; }
- { typedef typename Container::size_type Foo; }
- { typedef typename Container::key_type Foo; }
+ { QVERIFY_TYPE(typename Container::iterator); }
+ { QVERIFY_TYPE(typename Container::const_iterator); }
+ { QVERIFY_TYPE(typename Container::reference); }
+ { QVERIFY_TYPE(typename Container::const_reference); }
+ { QVERIFY_TYPE(typename Container::pointer); }
+ { QVERIFY_TYPE(typename Container::difference_type); }
+ { QVERIFY_TYPE(typename Container::size_type); }
+ { QVERIFY_TYPE(typename Container::key_type); }
}
/*
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index cdcbd19ae8..52e1850c87 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -151,8 +151,12 @@ private slots:
#if defined(Q_COMPILER_LAMBDA)
void literals();
#endif
+ void toUpperLower_data();
+ void toUpperLower();
void macTypes();
+
+ void stdString();
};
static const struct StaticByteArrays {
@@ -1997,6 +2001,31 @@ void tst_QByteArray::literals()
}
#endif
+void tst_QByteArray::toUpperLower_data()
+{
+ QTest::addColumn<QByteArray>("input");
+ QTest::addColumn<QByteArray>("upper");
+ QTest::addColumn<QByteArray>("lower");
+
+ QTest::newRow("empty") << QByteArray() << QByteArray() << QByteArray();
+ QTest::newRow("ascii") << QByteArray("Hello World, this is a STRING")
+ << QByteArray("HELLO WORLD, THIS IS A STRING")
+ << QByteArray("hello world, this is a string");
+ QTest::newRow("latin1") << QByteArray("R\311sum\351")
+ << QByteArray("R\311SUM\311")
+ << QByteArray("r\351sum\351");
+ QTest::newRow("nul") << QByteArray("a\0B", 3) << QByteArray("A\0B", 3) << QByteArray("a\0b", 3);
+}
+
+void tst_QByteArray::toUpperLower()
+{
+ QFETCH(QByteArray, input);
+ QFETCH(QByteArray, upper);
+ QFETCH(QByteArray, lower);
+ QCOMPARE(input.toUpper(), upper);
+ QCOMPARE(input.toLower(), lower);
+}
+
void tst_QByteArray::macTypes()
{
#ifndef Q_OS_MAC
@@ -2007,6 +2036,23 @@ void tst_QByteArray::macTypes()
#endif
}
+void tst_QByteArray::stdString()
+{
+ std::string stdstr( "QByteArray" );
+
+ const QByteArray stlqt = QByteArray::fromStdString(stdstr);
+ QCOMPARE(stlqt.length(), int(stdstr.length()));
+ QCOMPARE(stlqt.data(), stdstr.c_str());
+ QCOMPARE(stlqt.toStdString(), stdstr);
+
+ std::string utf8str( "Nøt æscii" );
+ const QByteArray u8 = QByteArray::fromStdString(utf8str);
+ const QByteArray l1 = QString::fromUtf8(u8).toLatin1();
+ std::string l1str = l1.toStdString();
+ QVERIFY(l1str.length() < utf8str.length());
+}
+
+
const char globalChar = '1';
QTEST_MAIN(tst_QByteArray)
diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
index 807dcf5cbe..97787e9cbd 100644
--- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
@@ -104,6 +104,7 @@ private slots:
void longMonthName() const;
void standaloneLongMonthName() const;
void roundtrip() const;
+ void qdebug() const;
private:
QDate defDate() const { return QDate(1900, 1, 1); }
QDate invalidDate() const { return QDate(); }
@@ -1476,5 +1477,13 @@ void tst_QDate::roundtrip() const
}
}
+void tst_QDate::qdebug() const
+{
+ QTest::ignoreMessage(QtDebugMsg, "QDate(\"\")");
+ qDebug() << QDate();
+ QTest::ignoreMessage(QtDebugMsg, "QDate(\"1983-08-07\")");
+ qDebug() << QDate(1983, 8, 7);
+}
+
QTEST_APPLESS_MAIN(tst_QDate)
#include "tst_qdate.moc"
diff --git a/tests/auto/corelib/tools/qregularexpression/.gitignore b/tests/auto/corelib/tools/qregularexpression/.gitignore
index c9249e090e..4650b4454e 100644
--- a/tests/auto/corelib/tools/qregularexpression/.gitignore
+++ b/tests/auto/corelib/tools/qregularexpression/.gitignore
@@ -1,2 +1,3 @@
tst_qregularexpression_alwaysoptimize
tst_qregularexpression_defaultoptimize
+tst_qregularexpression_forceoptimize
diff --git a/tests/auto/corelib/tools/qregularexpression/forceoptimize/forceoptimize.pro b/tests/auto/corelib/tools/qregularexpression/forceoptimize/forceoptimize.pro
new file mode 100644
index 0000000000..d34bc9b93d
--- /dev/null
+++ b/tests/auto/corelib/tools/qregularexpression/forceoptimize/forceoptimize.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase parallel_test
+TARGET = tst_qregularexpression_forceoptimize
+QT = core testlib
+HEADERS = ../tst_qregularexpression.h
+SOURCES = \
+ tst_qregularexpression_forceoptimize.cpp \
+ ../tst_qregularexpression.cpp
+DEFINES += forceOptimize=true
diff --git a/tests/auto/corelib/tools/qregularexpression/forceoptimize/tst_qregularexpression_forceoptimize.cpp b/tests/auto/corelib/tools/qregularexpression/forceoptimize/tst_qregularexpression_forceoptimize.cpp
new file mode 100644
index 0000000000..6244aacedf
--- /dev/null
+++ b/tests/auto/corelib/tools/qregularexpression/forceoptimize/tst_qregularexpression_forceoptimize.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include "../tst_qregularexpression.h"
+
+class tst_QRegularExpression_ForceOptimize : public tst_QRegularExpression
+{
+ Q_OBJECT
+};
+
+QTEST_APPLESS_MAIN(tst_QRegularExpression_ForceOptimize)
+
+#include "tst_qregularexpression_forceoptimize.moc"
diff --git a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro
index 0cae10112f..c030f04a27 100644
--- a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro
+++ b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS = defaultoptimize
+SUBDIRS = defaultoptimize forceoptimize
contains(QT_CONFIG,private_tests):SUBDIRS += alwaysoptimize
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index 909725f4b8..5fad1bb738 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -48,6 +48,10 @@
#include "tst_qregularexpression.h"
+#ifndef forceOptimize
+#define forceOptimize false
+#endif
+
struct Match
{
Match()
@@ -329,22 +333,30 @@ void tst_QRegularExpression::gettersSetters()
{
QRegularExpression re;
re.setPattern(pattern);
+ if (forceOptimize)
+ re.optimize();
QCOMPARE(re.pattern(), pattern);
QCOMPARE(re.patternOptions(), QRegularExpression::NoPatternOption);
}
{
QRegularExpression re;
re.setPatternOptions(patternOptions);
+ if (forceOptimize)
+ re.optimize();
QCOMPARE(re.pattern(), QString());
QCOMPARE(re.patternOptions(), patternOptions);
}
{
QRegularExpression re(pattern);
+ if (forceOptimize)
+ re.optimize();
QCOMPARE(re.pattern(), pattern);
QCOMPARE(re.patternOptions(), QRegularExpression::NoPatternOption);
}
{
QRegularExpression re(pattern, patternOptions);
+ if (forceOptimize)
+ re.optimize();
QCOMPARE(re.pattern(), pattern);
QCOMPARE(re.patternOptions(), patternOptions);
}
@@ -385,6 +397,8 @@ void tst_QRegularExpression::escape()
QFETCH(QString, escaped);
QCOMPARE(QRegularExpression::escape(string), escaped);
QRegularExpression re(escaped);
+ if (forceOptimize)
+ re.optimize();
QCOMPARE(re.isValid(), true);
}
@@ -415,6 +429,8 @@ void tst_QRegularExpression::validity()
QFETCH(QString, pattern);
QFETCH(bool, validity);
QRegularExpression re(pattern);
+ if (forceOptimize)
+ re.optimize();
QCOMPARE(re.isValid(), validity);
if (!validity)
QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object");
@@ -501,6 +517,9 @@ void tst_QRegularExpression::patternOptions()
QFETCH(QString, subject);
QFETCH(Match, match);
+ if (forceOptimize)
+ regexp.optimize();
+
QRegularExpressionMatch m = regexp.match(subject);
consistencyCheck(m);
QVERIFY(m == match);
@@ -717,6 +736,9 @@ void tst_QRegularExpression::normalMatch()
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
+ if (forceOptimize)
+ regexp.optimize();
+
{
QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NormalMatch, matchOptions);
consistencyCheck(m);
@@ -995,6 +1017,9 @@ void tst_QRegularExpression::partialMatch()
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
+ if (forceOptimize)
+ regexp.optimize();
+
{
QRegularExpressionMatch m = regexp.match(subject, offset, matchType, matchOptions);
consistencyCheck(m);
@@ -1286,6 +1311,10 @@ void tst_QRegularExpression::globalMatch()
QFETCH(QRegularExpression::MatchType, matchType);
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(QList<Match>, matchList);
+
+ if (forceOptimize)
+ regexp.optimize();
+
{
QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, matchType, matchOptions);
consistencyCheck(iterator);
@@ -1320,6 +1349,10 @@ void tst_QRegularExpression::serialize()
QFETCH(QString, pattern);
QFETCH(QRegularExpression::PatternOptions, patternOptions);
QRegularExpression outRe(pattern, patternOptions);
+
+ if (forceOptimize)
+ outRe.optimize();
+
QByteArray buffer;
{
QDataStream out(&buffer, QIODevice::WriteOnly);
@@ -1376,16 +1409,34 @@ void tst_QRegularExpression::operatoreq()
{
QRegularExpression re1(pattern);
QRegularExpression re2(pattern);
+
+ if (forceOptimize)
+ re1.optimize();
+ if (forceOptimize)
+ re2.optimize();
+
verifyEquality(re1, re2);
}
{
QRegularExpression re1(QString(), patternOptions);
QRegularExpression re2(QString(), patternOptions);
+
+ if (forceOptimize)
+ re1.optimize();
+ if (forceOptimize)
+ re2.optimize();
+
verifyEquality(re1, re2);
}
{
QRegularExpression re1(pattern, patternOptions);
QRegularExpression re2(pattern, patternOptions);
+
+ if (forceOptimize)
+ re1.optimize();
+ if (forceOptimize)
+ re2.optimize();
+
verifyEquality(re1, re2);
}
}
@@ -1414,6 +1465,10 @@ void tst_QRegularExpression::captureCount()
{
QFETCH(QString, pattern);
QRegularExpression re(pattern);
+
+ if (forceOptimize)
+ re.optimize();
+
QTEST(re.captureCount(), "captureCount");
if (!re.isValid())
QCOMPARE(re.captureCount(), -1);
@@ -1480,7 +1535,11 @@ void tst_QRegularExpression::captureNames()
QFETCH(QString, pattern);
QFETCH(StringToIntMap, namedCapturesIndexMap);
- const QRegularExpression re(pattern);
+ QRegularExpression re(pattern);
+
+ if (forceOptimize)
+ re.optimize();
+
QStringList namedCaptureGroups = re.namedCaptureGroups();
int namedCaptureGroupsCount = namedCaptureGroups.size();
@@ -1515,6 +1574,10 @@ void tst_QRegularExpression::pcreJitStackUsage()
QFETCH(QString, subject);
QRegularExpression re(pattern);
+
+ if (forceOptimize)
+ re.optimize();
+
QVERIFY(re.isValid());
QRegularExpressionMatch match = re.match(subject);
consistencyCheck(match);
@@ -1541,6 +1604,10 @@ void tst_QRegularExpression::regularExpressionMatch()
QFETCH(QString, subject);
QRegularExpression re(pattern);
+
+ if (forceOptimize)
+ re.optimize();
+
QVERIFY(re.isValid());
QRegularExpressionMatch match = re.match(subject);
consistencyCheck(match);
@@ -1580,5 +1647,7 @@ void tst_QRegularExpression::JOptionUsage()
QRegularExpression re(pattern);
if (isValid && JOptionUsed)
QTest::ignoreMessage(QtWarningMsg, qPrintable(warningMessage.arg(pattern)));
+ if (forceOptimize)
+ re.optimize();
QCOMPARE(re.isValid(), isValid);
}
diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
index 285cc3042a..579d6cfe95 100644
--- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
+++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
@@ -54,6 +54,13 @@ private slots:
void sizeWhenEmpty();
void sizeWhenReservedAndChopped();
void sizeWhenReserved();
+ void free();
+ void reserveAndRead();
+ void chop();
+ void ungetChar();
+ void indexOf();
+ void appendAndRead();
+ void readLine();
};
void tst_QRingBuffer::sizeWhenReserved()
@@ -179,6 +186,134 @@ void tst_QRingBuffer::readPointerAtPositionWriteRead()
QVERIFY(outData.buffer().startsWith(inData.buffer()));
}
+void tst_QRingBuffer::free()
+{
+ QRingBuffer ringBuffer;
+ // make three byte arrays with different sizes
+ ringBuffer.reserve(4096);
+ ringBuffer.reserve(2048);
+ ringBuffer.append(QByteArray("01234", 5));
+
+ ringBuffer.free(1);
+ QCOMPARE(ringBuffer.size(), 4095 + 2048 + 5);
+ ringBuffer.free(4096);
+ QCOMPARE(ringBuffer.size(), 2047 + 5);
+ ringBuffer.free(48);
+ ringBuffer.free(2000);
+ QCOMPARE(ringBuffer.size(), 4);
+ QVERIFY(memcmp(ringBuffer.readPointer(), "1234", 4) == 0);
+}
+
+void tst_QRingBuffer::reserveAndRead()
+{
+ QRingBuffer ringBuffer;
+ // fill buffer with an arithmetic progression
+ for (int i = 1; i < 256; ++i) {
+ QByteArray ba(i, char(i));
+ char *ringPos = ringBuffer.reserve(i);
+ QVERIFY(ringPos);
+ memcpy(ringPos, ba.constData(), i);
+ }
+
+ // readback and check stored data
+ 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);
+ }
+ QVERIFY(ringBuffer.size() == 0);
+}
+
+void tst_QRingBuffer::chop()
+{
+ QRingBuffer ringBuffer;
+ // make three byte arrays with different sizes
+ ringBuffer.append(QByteArray("01234", 5));
+ ringBuffer.reserve(2048);
+ ringBuffer.reserve(4096);
+
+ ringBuffer.chop(1);
+ QCOMPARE(ringBuffer.size(), 5 + 2048 + 4095);
+ ringBuffer.chop(4096);
+ QCOMPARE(ringBuffer.size(), 5 + 2047);
+ ringBuffer.chop(48);
+ ringBuffer.chop(2000);
+ QCOMPARE(ringBuffer.size(), 4);
+ QVERIFY(memcmp(ringBuffer.readPointer(), "0123", 4) == 0);
+}
+
+void tst_QRingBuffer::ungetChar()
+{
+ QRingBuffer ringBuffer(16);
+ for (int i = 1; i < 32; ++i)
+ ringBuffer.putChar(char(i));
+
+ for (int i = 1; i < 31; ++i) {
+ int c = ringBuffer.getChar();
+ QVERIFY(c == 1);
+ ringBuffer.getChar();
+ ringBuffer.ungetChar(char(c)); // unget first char
+ }
+ QCOMPARE(ringBuffer.size(), 1);
+}
+
+void tst_QRingBuffer::indexOf()
+{
+ QRingBuffer ringBuffer(16);
+ for (int i = 1; i < 256; ++i)
+ 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
+ }
+}
+
+void tst_QRingBuffer::appendAndRead()
+{
+ QRingBuffer ringBuffer;
+ QByteArray ba1("Hello world!");
+ QByteArray ba2("Test string.");
+ QByteArray ba3("0123456789");
+ ringBuffer.append(ba1);
+ ringBuffer.append(ba2);
+ ringBuffer.append(ba3);
+
+ QVERIFY(ringBuffer.read() == ba1);
+ QVERIFY(ringBuffer.read() == ba2);
+ QVERIFY(ringBuffer.read() == ba3);
+}
+
+void tst_QRingBuffer::readLine()
+{
+ QRingBuffer ringBuffer;
+ QByteArray ba1("Hello world!\n", 13);
+ QByteArray ba2("\n", 1);
+ QByteArray ba3("Test string.", 12);
+ QByteArray ba4("0123456789", 10);
+ ringBuffer.append(ba1);
+ ringBuffer.append(ba2);
+ ringBuffer.append(ba3 + ba4 + ba2);
+
+ char stringBuf[102];
+ stringBuf[101] = 0; // non-crash terminator
+ QVERIFY(ringBuffer.readLine(stringBuf, sizeof(stringBuf) - 2) == ba1.size());
+ QVERIFY(QByteArray(stringBuf, strlen(stringBuf)) == ba1);
+
+ // check first empty string reading
+ stringBuf[0] = 0xFF;
+ QCOMPARE(ringBuffer.readLine(stringBuf, sizeof(stringBuf) - 2), ba2.size());
+ QVERIFY(stringBuf[0] == ba2[0]);
+
+ QVERIFY(ringBuffer.readLine(stringBuf, sizeof(stringBuf) - 2) == (ba3.size() + ba4.size()
+ + ba2.size()));
+ QVERIFY(QByteArray(stringBuf, strlen(stringBuf)) == (ba3 + ba4 + ba2));
+ QVERIFY(ringBuffer.size() == 0);
+}
QTEST_APPLESS_MAIN(tst_QRingBuffer)
#include "tst_qringbuffer.moc"
diff --git a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp
index af82897179..86438caed6 100644
--- a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp
+++ b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -67,14 +67,17 @@ void tst_QScopedValueRollback::leavingScope()
{
int i = 0;
bool b = false;
+ bool b2 = false;
QString s("This is useful");
//test rollback on going out of scope
{
QScopedValueRollback<int> ri(i);
QScopedValueRollback<bool> rb(b);
+ QScopedValueRollback<bool> rb2(b2, true);
QScopedValueRollback<QString> rs(s);
QCOMPARE(b, false);
+ QCOMPARE(b2, true);
QCOMPARE(i, 0);
QCOMPARE(s, QString("This is useful"));
b = true;
@@ -85,6 +88,7 @@ void tst_QScopedValueRollback::leavingScope()
QCOMPARE(s, QString("Useless"));
}
QCOMPARE(b, false);
+ QCOMPARE(b2, false);
QCOMPARE(i, 0);
QCOMPARE(s, QString("This is useful"));
}
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index 5b1a2cf076..ac37b9af2a 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -74,6 +74,7 @@ private slots:
void useOfForwardDeclared();
void memoryManagement();
void dropLastReferenceOfForwardDeclared();
+ void lock();
void downCast();
void functionCallDownCast();
void upCast();
@@ -111,6 +112,7 @@ private slots:
void invalidConstructs();
void qvariantCast();
+ void sharedFromThis();
public slots:
void cleanup() { safetyCheck(); }
@@ -391,12 +393,56 @@ void tst_QSharedPointer::swap()
QVERIFY(p2 != control);
QVERIFY(p2.isNull());
QVERIFY(*p1 == 42);
+
+ QWeakPointer<int> w1, w2 = control;
+
+ QVERIFY(w1.isNull());
+ QVERIFY(!w2.isNull());
+ QVERIFY(w2.lock() == control);
+ QVERIFY(!w1.lock());
+
+ w1.swap(w2);
+ QVERIFY(w2.isNull());
+ QVERIFY(!w1.isNull());
+ QVERIFY(w1.lock() == control);
+ QVERIFY(!w2.lock());
+
+ qSwap(w1, w2);
+ QVERIFY(w1.isNull());
+ QVERIFY(w2.lock() == control);
+
+ p1.reset();
+ p2.reset();
+ control.reset();
+
+ QVERIFY(w1.isNull());
+ QVERIFY(w2.isNull());
}
void tst_QSharedPointer::useOfForwardDeclared()
{
// this just a compile test: use the forward-declared class
QSharedPointer<ForwardDeclared> sp;
+
+ // copying should work, too:
+ QSharedPointer<ForwardDeclared> sp2 = sp;
+
+ // and assignment:
+ QSharedPointer<ForwardDeclared> sp3;
+ sp3 = sp;
+
+ // move assignment:
+ QSharedPointer<ForwardDeclared> sp4;
+ sp4 = qMove(sp);
+
+ // and move constuction:
+ QSharedPointer<ForwardDeclared> sp5 = qMove(sp2);
+
+ // swapping:
+ sp4.swap(sp3);
+ qSwap(sp4, sp3);
+
+ // and, of course, destruction
}
@@ -474,6 +520,22 @@ void tst_QSharedPointer::dropLastReferenceOfForwardDeclared()
QCOMPARE(forwardDeclaredDestructorRunCount, 1);
}
+void tst_QSharedPointer::lock()
+{
+ QSharedPointer<int> sp = QSharedPointer<int>::create();
+ QVERIFY(sp);
+ QWeakPointer<int> wp = sp;
+ QVERIFY(sp == wp);
+ QVERIFY(sp == wp.lock());
+ QVERIFY(sp == wp.toStrongRef());
+
+ sp.reset();
+ QVERIFY(!wp);
+ QVERIFY(sp != wp); // this is why op(shared_ptr, weak_ptr) is a bad idea (apart from MT races)...
+ QVERIFY(sp == wp.lock());
+ QVERIFY(sp == wp.toStrongRef());
+}
+
class DerivedData: public Data
{
public:
@@ -846,6 +908,7 @@ void tst_QSharedPointer::objectCast()
ptr.clear();
QVERIFY(ptr.isNull());
QVERIFY(weakptr.toStrongRef().isNull());
+ QVERIFY(weakptr.lock().isNull());
// verify that the object casts fail without crash
QSharedPointer<OtherObject> otherptr = qSharedPointerObjectCast<OtherObject>(weakptr);
@@ -2079,6 +2142,228 @@ void tst_QSharedPointer::qvariantCast()
}
}
+class SomeClass : public QEnableSharedFromThis<SomeClass>
+{
+public:
+ SomeClass()
+ {
+ }
+
+ QSharedPointer<SomeClass> getSharedPtr()
+ {
+ return sharedFromThis();
+ }
+
+ QSharedPointer<const SomeClass> getSharedPtr() const
+ {
+ return sharedFromThis();
+ }
+
+ Data data;
+};
+
+void tst_QSharedPointer::sharedFromThis()
+{
+ const int generations = Data::generationCounter;
+ const int destructions = Data::destructorCounter;
+
+ {
+ SomeClass sc;
+ QSharedPointer<SomeClass> scp = sc.sharedFromThis();
+ QVERIFY(scp.isNull());
+ QCOMPARE(Data::generationCounter, generations + 1);
+ QCOMPARE(Data::destructorCounter, destructions);
+
+ QSharedPointer<const SomeClass> const_scp = sc.sharedFromThis();
+ QVERIFY(const_scp.isNull());
+ QCOMPARE(Data::generationCounter, generations + 1);
+ QCOMPARE(Data::destructorCounter, destructions);
+ }
+
+ QCOMPARE(Data::generationCounter, generations + 1);
+ QCOMPARE(Data::destructorCounter, destructions + 1);
+
+ {
+ const SomeClass sc;
+ QSharedPointer<const SomeClass> const_scp = sc.sharedFromThis();
+ QVERIFY(const_scp.isNull());
+ QCOMPARE(Data::generationCounter, generations + 2);
+ QCOMPARE(Data::destructorCounter, destructions + 1);
+ }
+
+ QCOMPARE(Data::generationCounter, generations + 2);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ {
+ SomeClass *sc = new SomeClass;
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ QSharedPointer<SomeClass> scp;
+ QVERIFY(scp.isNull());
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ scp = sc->sharedFromThis();
+ QVERIFY(scp.isNull());
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ scp = QSharedPointer<SomeClass>(sc);
+ QVERIFY(!scp.isNull());
+ QCOMPARE(scp.data(), sc);
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ QSharedPointer<SomeClass> scp2;
+ QVERIFY(scp2.isNull());
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ scp2 = sc->sharedFromThis();
+ QVERIFY(!scp2.isNull());
+ QVERIFY(scp == scp2);
+ QCOMPARE(scp2.data(), sc);
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ QSharedPointer<const SomeClass> scp3;
+ QVERIFY(scp3.isNull());
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ scp3 = sc->sharedFromThis();
+ QVERIFY(!scp3.isNull());
+ QVERIFY(scp == scp3);
+ QVERIFY(scp2 == scp3);
+ QCOMPARE(scp3.data(), sc);
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ QSharedPointer<SomeClass> scp4;
+ QVERIFY(scp4.isNull());
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ scp4 = sc->getSharedPtr();
+ QVERIFY(!scp4.isNull());
+ QVERIFY(scp == scp4);
+ QVERIFY(scp2 == scp4);
+ QVERIFY(scp3 == scp4);
+ QCOMPARE(scp4.data(), sc);
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ QSharedPointer<const SomeClass> scp5;
+ QVERIFY(scp5.isNull());
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+
+ scp5 = const_cast<const SomeClass *>(sc)->getSharedPtr();
+ QVERIFY(!scp4.isNull());
+ QVERIFY(scp == scp5);
+ QVERIFY(scp2 == scp5);
+ QVERIFY(scp3 == scp5);
+ QVERIFY(scp4 == scp5);
+ QCOMPARE(scp5.data(), sc);
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 2);
+ }
+
+ QCOMPARE(Data::generationCounter, generations + 3);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+
+ QSharedPointer<SomeClass> scp;
+
+ QVERIFY(scp.isNull());
+
+ {
+ QSharedPointer<SomeClass> scp2(new SomeClass());
+ QVERIFY(!scp2.isNull());
+
+ scp = scp2->sharedFromThis();
+ QVERIFY(!scp.isNull());
+
+ QVERIFY(scp == scp2);
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ }
+
+
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ QVERIFY(!scp.isNull());
+
+ {
+ QSharedPointer<const SomeClass> scp2;
+ scp2 = scp->sharedFromThis();
+ QVERIFY(!scp2.isNull());
+
+ QVERIFY(scp == scp2);
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ }
+
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ QVERIFY(!scp.isNull());
+
+ {
+ QSharedPointer<SomeClass> scp2;
+ scp2 = scp->getSharedPtr();
+ QVERIFY(!scp2.isNull());
+
+ QVERIFY(scp == scp2);
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ }
+
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ QVERIFY(!scp.isNull());
+
+ {
+ QSharedPointer<const SomeClass> scp2;
+ scp2 = qSharedPointerConstCast<const SomeClass>(scp)->getSharedPtr();
+ QVERIFY(!scp2.isNull());
+
+ QVERIFY(scp == scp2);
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ }
+
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ QVERIFY(!scp.isNull());
+
+ {
+ QSharedPointer<SomeClass> scp2;
+ scp2 = scp->sharedFromThis();
+ QVERIFY(!scp2.isNull());
+
+ QVERIFY(scp == scp2);
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+
+ scp2.clear();
+
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ QVERIFY(!scp.isNull());
+ QVERIFY(scp2.isNull());
+ }
+
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 3);
+ QVERIFY(!scp.isNull());
+
+ scp.clear();
+
+ QCOMPARE(Data::generationCounter, generations + 4);
+ QCOMPARE(Data::destructorCounter, destructions + 4);
+
+}
+
namespace ReentrancyWhileDestructing {
struct IB
{
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 95d377b176..2b2b436015 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -76,6 +76,10 @@ class tst_QString : public QObject
{
Q_OBJECT
+ template<typename List, class RegExp>
+ void split_regexp(const QString &string, const QString &pattern, QStringList result);
+ template<typename List>
+ void split(const QString &string, const QString &separator, QStringList result);
public:
tst_QString();
public slots:
@@ -221,6 +225,14 @@ private slots:
void split();
void split_regexp_data();
void split_regexp();
+ void split_regularexpression_data();
+ void split_regularexpression();
+ void splitRef_data();
+ void splitRef();
+ void splitRef_regexp_data();
+ void splitRef_regexp();
+ void splitRef_regularexpression_data();
+ void splitRef_regularexpression();
void fromUtf16_data();
void fromUtf16();
void fromUtf16_char16_data();
@@ -4170,11 +4182,17 @@ void tst_QString::arg()
QCOMPARE( s4.arg(Q_INT64_C(9223372036854775807)), // LLONG_MAX
QString("[9223372036854775807]") );
+ QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\" , 0");
QCOMPARE( QString().arg(0), QString() );
+ QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\" , 0");
QCOMPARE( QString("").arg(0), QString("") );
+ QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \" \" , 0");
QCOMPARE( QString(" ").arg(0), QString(" ") );
+ QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%\" , 0");
QCOMPARE( QString("%").arg(0), QString("%") );
+ QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%\" , 0");
QCOMPARE( QString("%%").arg(0), QString("%%") );
+ QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%%\" , 0");
QCOMPARE( QString("%%%").arg(0), QString("%%%") );
QCOMPARE( QString("%%%1%%%2").arg("foo").arg("bar"), QString("%%foo%%bar") );
@@ -4983,16 +5001,49 @@ void tst_QString::split_data()
QTest::newRow("sep-empty") << "abc" << "" << (QStringList() << "" << "a" << "b" << "c" << "");
}
-void tst_QString::split()
+template<class> struct StringSplitWrapper;
+template<> struct StringSplitWrapper<QString>
{
- QFETCH(QString, str);
- QFETCH(QString, sep);
- QFETCH(QStringList, result);
+ const QString &string;
+
+ QStringList split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.split(sep, behavior, cs); }
+ QStringList split(QChar sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.split(sep, behavior, cs); }
+ QStringList split(const QRegExp &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts) const { return string.split(sep, behavior); }
+ QStringList split(const QRegularExpression &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts) const { return string.split(sep, behavior); }
+};
+
+template<> struct StringSplitWrapper<QStringRef>
+{
+ const QString &string;
+ QVector<QStringRef> split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
+ QVector<QStringRef> split(QChar sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
+ QVector<QStringRef> split(const QRegExp &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts) const { return string.splitRef(sep, behavior); }
+ QVector<QStringRef> split(const QRegularExpression &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts) const { return string.splitRef(sep, behavior); }
+};
+static bool operator ==(const QStringList &left, const QVector<QStringRef> &right)
+{
+ if (left.size() != right.size())
+ return false;
+
+ QStringList::const_iterator iLeft = left.constBegin();
+ QVector<QStringRef>::const_iterator iRight = right.constBegin();
+ for (; iLeft != left.end(); ++iLeft, ++iRight) {
+ if (*iLeft != *iRight)
+ return false;
+ }
+ return true;
+}
+static inline bool operator ==(const QVector<QStringRef> &left, const QStringList &right) { return right == left; }
+
+template<class List>
+void tst_QString::split(const QString &string, const QString &sep, QStringList result)
+{
QRegExp rx = QRegExp(QRegExp::escape(sep));
QRegularExpression re(QRegularExpression::escape(sep));
- QStringList list;
+ List list;
+ StringSplitWrapper<typename List::value_type> str = {string};
list = str.split(sep);
QVERIFY(list == result);
@@ -5029,6 +5080,27 @@ void tst_QString::split()
}
}
+void tst_QString::split()
+{
+ QFETCH(QString, str);
+ QFETCH(QString, sep);
+ QFETCH(QStringList, result);
+ split<QStringList>(str, sep, result);
+}
+
+void tst_QString::splitRef_data()
+{
+ split_data();
+}
+
+void tst_QString::splitRef()
+{
+ QFETCH(QString, str);
+ QFETCH(QString, sep);
+ QFETCH(QStringList, result);
+ split<QVector<QStringRef> >(str, sep, result);
+}
+
void tst_QString::split_regexp_data()
{
QTest::addColumn<QString>("string");
@@ -5048,24 +5120,66 @@ void tst_QString::split_regexp_data()
<< (QStringList() << "" << "Now" << ": " << "this" << " " << "sentence" << " " << "fragment" << ".");
}
+template<class List, class RegExp>
+void tst_QString::split_regexp(const QString &_string, const QString &pattern, QStringList result)
+{
+ List list;
+ StringSplitWrapper<typename List::value_type> string = {_string};
+
+ list = string.split(RegExp(pattern));
+ QVERIFY(list == result);
+
+ result.removeAll(QString());
+
+ list = string.split(RegExp(pattern), QString::SkipEmptyParts);
+ QVERIFY(list == result);
+}
+
void tst_QString::split_regexp()
{
QFETCH(QString, string);
QFETCH(QString, pattern);
QFETCH(QStringList, result);
+ split_regexp<QStringList, QRegExp>(string, pattern, result);
+}
- QStringList list;
- list = string.split(QRegExp(pattern));
- QCOMPARE(list, result);
- list = string.split(QRegularExpression(pattern));
- QCOMPARE(list, result);
+void tst_QString::split_regularexpression_data()
+{
+ split_regexp_data();
+}
- result.removeAll(QString());
+void tst_QString::split_regularexpression()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, pattern);
+ QFETCH(QStringList, result);
+ split_regexp<QStringList, QRegularExpression>(string, pattern, result);
+}
- list = string.split(QRegExp(pattern), QString::SkipEmptyParts);
- QCOMPARE(list, result);
- list = string.split(QRegularExpression(pattern), QString::SkipEmptyParts);
- QCOMPARE(list, result);
+void tst_QString::splitRef_regularexpression_data()
+{
+ split_regexp_data();
+}
+
+void tst_QString::splitRef_regularexpression()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, pattern);
+ QFETCH(QStringList, result);
+ split_regexp<QVector<QStringRef>, QRegularExpression>(string, pattern, result);
+}
+
+void tst_QString::splitRef_regexp_data()
+{
+ split_regexp_data();
+}
+
+void tst_QString::splitRef_regexp()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, pattern);
+ QFETCH(QStringList, result);
+ split_regexp<QVector<QStringRef>, QRegExp>(string, pattern, result);
}
void tst_QString::fromUtf16_data()
diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
index 246560e47f..91501a0106 100644
--- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
+++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
@@ -66,6 +66,7 @@ private slots:
void lastIndexOf_regExp();
void streamingOperator();
+ void assignmentOperator();
void join() const;
void join_data() const;
void joinEmptiness() const;
@@ -296,9 +297,11 @@ void tst_QStringList::removeDuplicates_data()
QTest::addColumn<QString>("before");
QTest::addColumn<QString>("after");
QTest::addColumn<int>("count");
+ QTest::addColumn<bool>("detached");
- QTest::newRow("empty-1") << "Hello,Hello" << "Hello" << 1;
- QTest::newRow("empty-2") << "Hello,World" << "Hello,World" << 0;
+ QTest::newRow("empty-1") << "Hello,Hello" << "Hello" << 1 << true;
+ QTest::newRow("empty-2") << "Hello,World" << "Hello,World" << 0 << false;
+ QTest::newRow("middle") << "Hello,World,Hello" << "Hello,World" << 1 << true;
}
void tst_QStringList::removeDuplicates()
@@ -306,13 +309,16 @@ void tst_QStringList::removeDuplicates()
QFETCH(QString, before);
QFETCH(QString, after);
QFETCH(int, count);
+ QFETCH(bool, detached);
QStringList lbefore = before.split(',');
+ const QStringList oldlbefore = lbefore;
QStringList lafter = after.split(',');
int removed = lbefore.removeDuplicates();
QCOMPARE(removed, count);
QCOMPARE(lbefore, lafter);
+ QCOMPARE(detached, !oldlbefore.isSharedWith(lbefore));
}
void tst_QStringList::streamingOperator()
@@ -321,8 +327,13 @@ void tst_QStringList::streamingOperator()
list << "hei";
list << list << "hopp" << list;
+ QList<QString> slist = list;
+ list << slist;
+
QCOMPARE(list, QStringList()
<< "hei" << "hei" << "hopp"
+ << "hei" << "hei" << "hopp"
+ << "hei" << "hei" << "hopp"
<< "hei" << "hei" << "hopp");
QStringList list2;
@@ -334,6 +345,21 @@ void tst_QStringList::streamingOperator()
QCOMPARE(list2 << list3, QStringList() << "adam" << "eva");
}
+void tst_QStringList::assignmentOperator()
+{
+ // compile-only test
+
+ QStringList adam;
+ adam << "adam";
+ QList<QString> eva;
+ eva << "eva";
+ QStringList result;
+ QStringList &ref1 = (result = adam);
+ QStringList &ref2 = (result = eva);
+ Q_UNUSED(ref1);
+ Q_UNUSED(ref2);
+}
+
void tst_QStringList::join() const
{
QFETCH(QStringList, input);
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index e6629301f9..6b833681d6 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -102,7 +102,7 @@ void tst_QTimeLine::range()
// Verify that you can change the range in the timeLine
timeLine.setFrameRange(10, 20);
- QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+ QSignalSpy spy(&timeLine, &QTimeLine::frameChanged);
QVERIFY(spy.isValid());
timeLine.start();
#ifdef Q_OS_WINCE
@@ -131,7 +131,7 @@ void tst_QTimeLine::currentTime()
{
QTimeLine timeLine(2000);
timeLine.setUpdateInterval((timeLine.duration()/2) / 33);
- QSignalSpy spy(&timeLine, SIGNAL(valueChanged(qreal)));
+ QSignalSpy spy(&timeLine, &QTimeLine::valueChanged);
QVERIFY(spy.isValid());
timeLine.setFrameRange(10, 20);
QCOMPARE(timeLine.currentTime(), 0);
@@ -202,7 +202,7 @@ void tst_QTimeLine::frameRate()
// Default speed
timeLine.setUpdateInterval(1000 / 33);
- QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+ QSignalSpy spy(&timeLine, &QTimeLine::frameChanged);
QVERIFY(spy.isValid());
timeLine.start();
QTest::qWait(timeLine.duration()*2);
@@ -225,7 +225,7 @@ void tst_QTimeLine::value()
QVERIFY(timeLine.currentValue() == 0.0);
// Default speed
- QSignalSpy spy(&timeLine, SIGNAL(valueChanged(qreal)));
+ QSignalSpy spy(&timeLine, &QTimeLine::valueChanged);
QVERIFY(spy.isValid());
timeLine.start();
QTest::qWait(timeLine.duration()/3);
@@ -256,7 +256,7 @@ void tst_QTimeLine::currentFrame()
QCOMPARE(timeLine.currentFrame(), 10);
// Default speed
- QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+ QSignalSpy spy(&timeLine, &QTimeLine::frameChanged);
QVERIFY(spy.isValid());
timeLine.start();
QTest::qWait(timeLine.duration()/3);
@@ -288,7 +288,7 @@ void tst_QTimeLine::loopCount()
QCOMPARE(timeLine.loopCount(), 0);
// Default speed infiniti looping
- QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+ QSignalSpy spy(&timeLine, &QTimeLine::frameChanged);
QVERIFY(spy.isValid());
timeLine.start();
QTest::qWait(timeLine.duration());
@@ -306,8 +306,8 @@ void tst_QTimeLine::loopCount()
timeLine.setFrameRange(0, 2);
timeLine.setLoopCount(4);
- QSignalSpy finishedSpy(&timeLine, SIGNAL(finished()));
- QSignalSpy frameChangedSpy(&timeLine, SIGNAL(frameChanged(int)));
+ QSignalSpy finishedSpy(&timeLine, &QTimeLine::finished);
+ QSignalSpy frameChangedSpy(&timeLine, &QTimeLine::frameChanged);
QVERIFY(finishedSpy.isValid());
QVERIFY(frameChangedSpy.isValid());
QEventLoop loop;
@@ -461,7 +461,7 @@ void tst_QTimeLine::frameChanged()
timeLine.setCurveShape(QTimeLine::LinearCurve);
timeLine.setFrameRange(0,9);
timeLine.setUpdateInterval(800);
- QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
+ QSignalSpy spy(&timeLine, &QTimeLine::frameChanged);
QVERIFY(spy.isValid());
// Test what happens when duration expires before all frames are emitted.
@@ -492,7 +492,7 @@ void tst_QTimeLine::stopped()
QTimeLine timeLine;
timeLine.setFrameRange(0, 9);
qRegisterMetaType<QTimeLine::State>("QTimeLine::State");
- QSignalSpy spy(&timeLine, SIGNAL(stateChanged(QTimeLine::State)));
+ QSignalSpy spy(&timeLine, &QTimeLine::stateChanged);
QVERIFY(spy.isValid());
timeLine.start();
QTest::qWait(timeLine.duration()*2);
@@ -510,7 +510,7 @@ void tst_QTimeLine::finished()
{
QTimeLine timeLine;
timeLine.setFrameRange(0,9);
- QSignalSpy spy(&timeLine, SIGNAL(finished()));
+ QSignalSpy spy(&timeLine, &QTimeLine::finished);
QVERIFY(spy.isValid());
timeLine.start();
QTest::qWait(timeLine.duration()*2);
@@ -543,7 +543,7 @@ void tst_QTimeLine::multipleTimeLines()
// Stopping a timer shouldn't affect the other timers
QTimeLine timeLine(200);
timeLine.setFrameRange(0,99);
- QSignalSpy spy(&timeLine, SIGNAL(finished()));
+ QSignalSpy spy(&timeLine, &QTimeLine::finished);
QVERIFY(spy.isValid());
QTimeLine timeLineKiller;
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index d81bfc33fb..5bdac00f4e 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -60,6 +60,8 @@ private slots:
void availableTimeZoneIds();
void stressTest();
void windowsId();
+ void isValidId_data();
+ void isValidId();
// Backend tests
void utcTest();
void icuTest();
@@ -521,6 +523,65 @@ void tst_QTimeZone::windowsId()
QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyCountry), list);
}
+void tst_QTimeZone::isValidId_data()
+{
+#ifdef QT_BUILD_INTERNAL
+ QTest::addColumn<QByteArray>("input");
+ QTest::addColumn<bool>("valid");
+
+#define TESTSET(name, section, valid) \
+ QTest::newRow(name " front") << QByteArray(section "/xyz/xyz") << valid; \
+ QTest::newRow(name " middle") << QByteArray("xyz/" section "/xyz") << valid; \
+ QTest::newRow(name " back") << QByteArray("xyz/xyz/" section) << valid
+
+ TESTSET("empty", "", false);
+ TESTSET("minimal", "m", true);
+ TESTSET("maximal", "12345678901234", true);
+ TESTSET("too long", "123456789012345", false);
+
+ TESTSET("bad hyphen", "-hyphen", false);
+ TESTSET("good hyphen", "hy-phen", true);
+
+ TESTSET("valid char _", "_", true);
+ TESTSET("valid char .", ".", true);
+ TESTSET("valid char :", ":", true);
+ TESTSET("valid char +", "+", true);
+ TESTSET("valid char A", "A", true);
+ TESTSET("valid char Z", "Z", true);
+ TESTSET("valid char a", "a", true);
+ TESTSET("valid char z", "z", true);
+ TESTSET("valid char 0", "0", true);
+ TESTSET("valid char 9", "9", true);
+
+ TESTSET("invalid char ^", "^", false);
+ TESTSET("invalid char \"", "\"", false);
+ TESTSET("invalid char $", "$", false);
+ TESTSET("invalid char %", "%", false);
+ TESTSET("invalid char &", "&", false);
+ TESTSET("invalid char (", "(", false);
+ TESTSET("invalid char )", ")", false);
+ TESTSET("invalid char =", "=", false);
+ TESTSET("invalid char ?", "?", false);
+ TESTSET("invalid char Ăź", "Ăź", false);
+ TESTSET("invalid char \\x01", "\x01", false);
+ TESTSET("invalid char ' '", " ", false);
+
+#undef TESTSET
+#endif // QT_BUILD_INTERNAL
+}
+
+void tst_QTimeZone::isValidId()
+{
+#ifdef QT_BUILD_INTERNAL
+ QFETCH(QByteArray, input);
+ QFETCH(bool, valid);
+
+ QCOMPARE(QTimeZonePrivate::isValidId(input), valid);
+#else
+ QSKIP("This test requires a Qt -developer-build.");
+#endif
+}
+
void tst_QTimeZone::utcTest()
{
#ifdef QT_BUILD_INTERNAL
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index f1efbf0812..e06c75afec 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -178,6 +178,9 @@ private slots:
void copyConstructorInt() const;
void copyConstructorMovable() const;
void copyConstructorCustom() const;
+ void assignmentInt() const;
+ void assignmentMovable() const;
+ void assignmentCustom() const;
void addInt() const;
void addMovable() const;
void addCustom() const;
@@ -225,7 +228,9 @@ private slots:
void fromListCustom() const;
void fromStdVector() const;
void indexOf() const;
- void insert() const;
+ void insertInt() const;
+ void insertMovable() const;
+ void insertCustom() const;
void isEmpty() const;
void last() const;
void lastIndexOf() const;
@@ -296,6 +301,7 @@ private:
template<typename T> void eraseReserved() const;
template<typename T> void fill() const;
template<typename T> void fromList() const;
+ template<typename T> void insert() const;
template<typename T> void prepend() const;
template<typename T> void remove() const;
template<typename T> void size() const;
@@ -441,6 +447,52 @@ void tst_QVector::copyConstructorCustom() const
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
+template <class T>
+static inline void testAssignment()
+{
+ QVector<T> v1(5);
+ QCOMPARE(v1.size(), 5);
+ QVERIFY(v1.isDetached());
+
+ QVector<T> v2(7);
+ QCOMPARE(v2.size(), 7);
+ QVERIFY(v2.isDetached());
+
+ QVERIFY(!v1.isSharedWith(v2));
+
+ v1 = v2;
+
+ QVERIFY(!v1.isDetached());
+ QVERIFY(!v2.isDetached());
+ QVERIFY(v1.isSharedWith(v2));
+
+ const void *const data1 = v1.constData();
+ const void *const data2 = v2.constData();
+
+ QCOMPARE(data1, data2);
+
+ v1.clear();
+
+ QVERIFY(v2.isDetached());
+ QVERIFY(!v1.isSharedWith(v2));
+ QCOMPARE((void *)v2.constData(), data2);
+}
+
+void tst_QVector::assignmentInt() const
+{
+ testAssignment<int>();
+}
+
+void tst_QVector::assignmentMovable() const
+{
+ testAssignment<Movable>();
+}
+
+void tst_QVector::assignmentCustom() const
+{
+ testAssignment<Custom>();
+}
+
template<typename T>
void tst_QVector::add() const
{
@@ -1231,32 +1283,87 @@ void tst_QVector::indexOf() const
QVERIFY(myvec.indexOf("A", 4) == -1);
}
+template <typename T>
void tst_QVector::insert() const
{
- QVector<QString> myvec;
- myvec << "A" << "B" << "C";
+ QVector<T> myvec;
+ const T
+ tA = SimpleValue<T>::at(0),
+ tB = SimpleValue<T>::at(1),
+ tC = SimpleValue<T>::at(2),
+ tX = SimpleValue<T>::at(3),
+ tZ = SimpleValue<T>::at(4),
+ tT = SimpleValue<T>::at(5),
+ ti = SimpleValue<T>::at(6);
+ myvec << tA << tB << tC;
+ QVector<T> myvec2 = myvec;
// first position
- QCOMPARE(myvec.at(0), QLatin1String("A"));
- myvec.insert(0, QLatin1String("X"));
- QCOMPARE(myvec.at(0), QLatin1String("X"));
- QCOMPARE(myvec.at(1), QLatin1String("A"));
+ QCOMPARE(myvec.at(0), tA);
+ myvec.insert(0, tX);
+ QCOMPARE(myvec.at(0), tX);
+ QCOMPARE(myvec.at(1), tA);
+
+ QCOMPARE(myvec2.at(0), tA);
+ myvec2.insert(myvec2.begin(), tX);
+ QCOMPARE(myvec2.at(0), tX);
+ QCOMPARE(myvec2.at(1), tA);
// middle
- myvec.insert(1, QLatin1String("Z"));
- QCOMPARE(myvec.at(0), QLatin1String("X"));
- QCOMPARE(myvec.at(1), QLatin1String("Z"));
- QCOMPARE(myvec.at(2), QLatin1String("A"));
+ myvec.insert(1, tZ);
+ QCOMPARE(myvec.at(0), tX);
+ QCOMPARE(myvec.at(1), tZ);
+ QCOMPARE(myvec.at(2), tA);
+
+ myvec2.insert(myvec2.begin() + 1, tZ);
+ QCOMPARE(myvec2.at(0), tX);
+ QCOMPARE(myvec2.at(1), tZ);
+ QCOMPARE(myvec2.at(2), tA);
// end
- myvec.insert(5, QLatin1String("T"));
- QCOMPARE(myvec.at(5), QLatin1String("T"));
- QCOMPARE(myvec.at(4), QLatin1String("C"));
+ myvec.insert(5, tT);
+ QCOMPARE(myvec.at(5), tT);
+ QCOMPARE(myvec.at(4), tC);
+
+ myvec2.insert(myvec2.end(), tT);
+ QCOMPARE(myvec2.at(5), tT);
+ QCOMPARE(myvec2.at(4), tC);
// insert a lot of garbage in the middle
- myvec.insert(2, 2, QLatin1String("infinity"));
- QCOMPARE(myvec, QVector<QString>() << "X" << "Z" << "infinity" << "infinity"
- << "A" << "B" << "C" << "T");
+ myvec.insert(2, 2, ti);
+ QCOMPARE(myvec, QVector<T>() << tX << tZ << ti << ti
+ << tA << tB << tC << tT);
+
+ myvec2.insert(myvec2.begin() + 2, 2, ti);
+ QCOMPARE(myvec2, myvec);
+
+ // insert from references to the same container:
+ myvec.insert(0, 1, myvec[5]); // inserts tB
+ myvec2.insert(0, 1, myvec2[5]); // inserts tB
+ QCOMPARE(myvec, QVector<T>() << tB << tX << tZ << ti << ti
+ << tA << tB << tC << tT);
+ QCOMPARE(myvec2, myvec);
+
+ myvec.insert(0, 1, const_cast<const QVector<T>&>(myvec)[0]); // inserts tB
+ myvec2.insert(0, 1, const_cast<const QVector<T>&>(myvec2)[0]); // inserts tB
+ QCOMPARE(myvec, QVector<T>() << tB << tB << tX << tZ << ti << ti
+ << tA << tB << tC << tT);
+ QCOMPARE(myvec2, myvec);
+}
+
+void tst_QVector::insertInt() const
+{
+ insert<int>();
+}
+
+void tst_QVector::insertMovable() const
+{
+ insert<Movable>();
+}
+
+void tst_QVector::insertCustom() const
+{
+ insert<Custom>();
}
void tst_QVector::isEmpty() const
@@ -1321,6 +1428,8 @@ void tst_QVector::mid() const
list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty";
QCOMPARE(list.mid(3, 3), QVector<QString>() << "bak" << "buck" << "hello");
+ QCOMPARE(list.mid(6, 10), QVector<QString>() << "kitty");
+ QCOMPARE(list.mid(-1, 20), list);
QCOMPARE(list.mid(4), QVector<QString>() << "buck" << "hello" << "kitty");
}
@@ -1386,13 +1495,28 @@ void tst_QVector::remove() const
T val1 = SimpleValue<T>::at(1);
T val2 = SimpleValue<T>::at(2);
T val3 = SimpleValue<T>::at(3);
+ T val4 = SimpleValue<T>::at(4);
+ myvec << val1 << val2 << val3;
+ myvec << val1 << val2 << val3;
myvec << val1 << val2 << val3;
// remove middle
myvec.remove(1);
- QCOMPARE(myvec, QVector<T>() << val1 << val3);
+ QCOMPARE(myvec, QVector<T>() << val1 << val3 << val1 << val2 << val3 << val1 << val2 << val3);
+
+ // removeOne()
+ QVERIFY(!myvec.removeOne(val4));
+ QVERIFY(myvec.removeOne(val2));
+ QCOMPARE(myvec, QVector<T>() << val1 << val3 << val1 << val3 << val1 << val2 << val3);
+
+ // removeAll()
+ QCOMPARE(myvec.removeAll(val4), 0);
+ QCOMPARE(myvec.removeAll(val1), 3);
+ QCOMPARE(myvec, QVector<T>() << val3 << val3 << val2 << val3);
+ QCOMPARE(myvec.removeAll(val2), 1);
+ QCOMPARE(myvec, QVector<T>() << val3 << val3 << val3);
// remove rest
- myvec.remove(0, 2);
+ myvec.remove(0, 3);
QCOMPARE(myvec, QVector<T>());
}
@@ -2184,7 +2308,7 @@ void tst_QVector::setSharable() const
if (isCapacityReserved)
QVERIFY2(copy.capacity() >= capacity,
qPrintable(QString("Capacity is %1, expected at least %2.")
- .arg(vector.capacity())
+ .arg(copy.capacity())
.arg(capacity)));
QCOMPARE(copy, vector);
}
diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro
index 1ef8e77071..352cf88d44 100644
--- a/tests/auto/corelib/tools/tools.pro
+++ b/tests/auto/corelib/tools/tools.pro
@@ -1,5 +1,6 @@
TEMPLATE=subdirs
SUBDIRS=\
+ collections \
qalgorithms \
qarraydata \
qarraydata_strictiterators \
diff --git a/tests/auto/corelib/xml/qxmlstream/data/009.ref b/tests/auto/corelib/xml/qxmlstream/data/009.ref
index 1de530df1c..12b994eac4 100644
--- a/tests/auto/corelib/xml/qxmlstream/data/009.ref
+++ b/tests/auto/corelib/xml/qxmlstream/data/009.ref
@@ -24,4 +24,4 @@ Invalid( name="bar" qualifiedName="bar"
Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" )
)
-ERROR: Attribute redefined.
+ERROR: Attribute 'b:attr' redefined.
diff --git a/tests/auto/corelib/xml/qxmlstream/data/010.ref b/tests/auto/corelib/xml/qxmlstream/data/010.ref
index 217f4963a1..07def503a5 100644
--- a/tests/auto/corelib/xml/qxmlstream/data/010.ref
+++ b/tests/auto/corelib/xml/qxmlstream/data/010.ref
@@ -24,4 +24,4 @@ Invalid( name="bar" qualifiedName="bar"
Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" )
)
-ERROR: Attribute redefined.
+ERROR: Attribute 'b:attr' redefined.
diff --git a/tests/auto/corelib/xml/qxmlstream/data/011.ref b/tests/auto/corelib/xml/qxmlstream/data/011.ref
index e3945324eb..faa6e75429 100644
--- a/tests/auto/corelib/xml/qxmlstream/data/011.ref
+++ b/tests/auto/corelib/xml/qxmlstream/data/011.ref
@@ -27,4 +27,4 @@ Invalid( name="bar" qualifiedName="bar"
Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" )
)
-ERROR: Attribute redefined.
+ERROR: Attribute 'b:attr' redefined.
diff --git a/tests/auto/corelib/xml/qxmlstream/data/012.ref b/tests/auto/corelib/xml/qxmlstream/data/012.ref
index 7a688b103d..834db97ba6 100644
--- a/tests/auto/corelib/xml/qxmlstream/data/012.ref
+++ b/tests/auto/corelib/xml/qxmlstream/data/012.ref
@@ -24,4 +24,4 @@ Invalid( name="bar" qualifiedName="bar"
Attribute( name="attr" namespaceUri="urn:xyzzy" qualifiedName="b:attr" prefix="b" value="2" )
)
-ERROR: Attribute redefined.
+ERROR: Attribute 'b:attr' redefined.
diff --git a/tests/auto/corelib/xml/qxmlstream/data/035.ref b/tests/auto/corelib/xml/qxmlstream/data/035.ref
index e172fc90e1..cab0158a51 100644
--- a/tests/auto/corelib/xml/qxmlstream/data/035.ref
+++ b/tests/auto/corelib/xml/qxmlstream/data/035.ref
@@ -13,4 +13,4 @@ Invalid( name="bar" qualifiedName="bar"
Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="a:attr" prefix="a" value="2" )
)
-ERROR: Attribute redefined.
+ERROR: Attribute 'a:attr' redefined.
diff --git a/tests/auto/corelib/xml/qxmlstream/data/036.ref b/tests/auto/corelib/xml/qxmlstream/data/036.ref
index 158e7361f9..50939ed7e7 100644
--- a/tests/auto/corelib/xml/qxmlstream/data/036.ref
+++ b/tests/auto/corelib/xml/qxmlstream/data/036.ref
@@ -13,4 +13,4 @@ Invalid( name="bar" qualifiedName="bar"
Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" )
)
-ERROR: Attribute redefined.
+ERROR: Attribute 'b:attr' redefined.
diff --git a/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur b/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur
new file mode 100644
index 0000000000..0a649aa7f7
--- /dev/null
+++ b/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur
Binary files differ
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
index cd9d4b448e..71adbabb84 100644
--- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
+++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
@@ -111,9 +111,17 @@ void tst_QIcoImageFormat::cleanupTestCase()
void tst_QIcoImageFormat::format()
{
- QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico");
- QByteArray fmt = reader.format();
- QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
+ {
+ QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico");
+ QByteArray fmt = reader.format();
+ QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
+ }
+
+ {
+ QImageReader reader(m_IconPath + "/valid/yellow.cur", "ico");
+ QByteArray fmt = reader.format();
+ QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
+ }
}
void tst_QIcoImageFormat::canRead_data()
@@ -133,6 +141,7 @@ void tst_QIcoImageFormat::canRead_data()
QTest::newRow("103x16px, 24BPP") << "valid/trolltechlogo_tiny.ico" << 1;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 1;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 1;
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::canRead()
@@ -203,7 +212,7 @@ void tst_QIcoImageFormat::imageCount_data()
QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 4;
-
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::imageCount()
@@ -231,6 +240,7 @@ void tst_QIcoImageFormat::jumpToNextImage_data()
QTest::newRow("16px16c, 32px32c, 32px256c 2") << "valid/WORLDH.ico" << 3;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 4;
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::jumpToNextImage()
@@ -281,6 +291,7 @@ void tst_QIcoImageFormat::nextImageDelay_data()
QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1;
QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
QTest::newRow("PNG compression") << "valid/Qt.ico" << 4;
+ QTest::newRow("CUR file") << "valid/yellow.cur" << 1;
}
void tst_QIcoImageFormat::nextImageDelay()
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 6c496ba6d4..f922deb815 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -62,6 +62,7 @@ public:
tst_QImage();
private slots:
+ void initTestCase();
void swap();
void create();
void createInvalidXPM();
@@ -173,12 +174,27 @@ private slots:
void scaled_QTBUG35972();
+ void convertToPixelFormat();
+ void convertToImageFormat_data();
+ void convertToImageFormat();
+
+ void invertPixelsRGB_data();
+ void invertPixelsRGB();
+
void cleanupFunctions();
+
+private:
+ const QString m_prefix;
};
tst_QImage::tst_QImage()
+ : m_prefix(QFINDTESTDATA("images/"))
+{
+}
+void tst_QImage::initTestCase()
{
+ QVERIFY(!m_prefix.isEmpty());
}
void tst_QImage::swap()
@@ -287,21 +303,17 @@ void tst_QImage::formatHandlersInput_data()
QTest::addColumn<QString>("testFormat");
QTest::addColumn<QString>("testFile");
- const QString prefix = QFINDTESTDATA("images/");
- if (prefix.isEmpty())
- QFAIL("can not find images directory!");
-
// add a new line here when a file is added
- QTest::newRow("ICO") << "ICO" << prefix + "image.ico";
- QTest::newRow("PNG") << "PNG" << prefix + "image.png";
- QTest::newRow("GIF") << "GIF" << prefix + "image.gif";
- QTest::newRow("BMP") << "BMP" << prefix + "image.bmp";
- QTest::newRow("JPEG") << "JPEG" << prefix + "image.jpg";
- QTest::newRow("PBM") << "PBM" << prefix + "image.pbm";
- QTest::newRow("PGM") << "PGM" << prefix + "image.pgm";
- QTest::newRow("PPM") << "PPM" << prefix + "image.ppm";
- QTest::newRow("XBM") << "XBM" << prefix + "image.xbm";
- QTest::newRow("XPM") << "XPM" << prefix + "image.xpm";
+ QTest::newRow("ICO") << "ICO" << m_prefix + "image.ico";
+ QTest::newRow("PNG") << "PNG" << m_prefix + "image.png";
+ QTest::newRow("GIF") << "GIF" << m_prefix + "image.gif";
+ QTest::newRow("BMP") << "BMP" << m_prefix + "image.bmp";
+ QTest::newRow("JPEG") << "JPEG" << m_prefix + "image.jpg";
+ QTest::newRow("PBM") << "PBM" << m_prefix + "image.pbm";
+ QTest::newRow("PGM") << "PGM" << m_prefix + "image.pgm";
+ QTest::newRow("PPM") << "PPM" << m_prefix + "image.ppm";
+ QTest::newRow("XBM") << "XBM" << m_prefix + "image.xbm";
+ QTest::newRow("XPM") << "XPM" << m_prefix + "image.xpm";
}
void tst_QImage::formatHandlersInput()
@@ -762,6 +774,13 @@ void tst_QImage::convertToFormat_data()
<< int(QImage::Format_ARGB32_Premultiplied) << 0x7f7f7f7fu;
QTest::newRow("semiblack rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f000000u
<< int(QImage::Format_ARGB32_Premultiplied) << 0x7f000000u;
+
+ QTest::newRow("red rgb30 -> argb32") << int(QImage::Format_RGB30) << 0xffff0000
+ << int(QImage::Format_ARGB32) << 0xffff0000;
+ QTest::newRow("green rgb30 -> argb32") << int(QImage::Format_RGB30) << 0xff00ff00
+ << int(QImage::Format_ARGB32) << 0xff00ff00;
+ QTest::newRow("blue rgb30 -> argb32") << int(QImage::Format_RGB30) << 0xff0000ff
+ << int(QImage::Format_ARGB32) << 0xff0000ff;
}
@@ -1074,10 +1093,7 @@ void tst_QImage::copy()
void tst_QImage::load()
{
- const QString prefix = QFINDTESTDATA("images/");
- if (prefix.isEmpty())
- QFAIL("can not find images directory!");
- const QString filePath = prefix + QLatin1String("image.jpg");
+ const QString filePath = m_prefix + QLatin1String("image.jpg");
QImage dest(filePath);
QVERIFY(!dest.isNull());
@@ -1089,10 +1105,7 @@ void tst_QImage::load()
void tst_QImage::loadFromData()
{
- const QString prefix = QFINDTESTDATA("images/");
- if (prefix.isEmpty())
- QFAIL("can not find images directory!");
- const QString filePath = prefix + QLatin1String("image.jpg");
+ const QString filePath = m_prefix + QLatin1String("image.jpg");
QImage original(filePath);
QVERIFY(!original.isNull());
@@ -1118,10 +1131,7 @@ void tst_QImage::loadFromData()
#if !defined(QT_NO_DATASTREAM)
void tst_QImage::loadFromDataStream()
{
- const QString prefix = QFINDTESTDATA("images/");
- if (prefix.isEmpty())
- QFAIL("can not find images directory!");
- const QString filePath = prefix + QLatin1String("image.jpg");
+ const QString filePath = m_prefix + QLatin1String("image.jpg");
QImage original(filePath);
QVERIFY(!original.isNull());
@@ -1214,6 +1224,18 @@ void tst_QImage::setPixel_data()
QTest::newRow("RGBA8888 blue") << int(QImage::Format_RGBA8888)
<< 0xff0000ffu << 0xffff0000u;
#endif
+ QTest::newRow("A2BGR30_Premultiplied red") << int(QImage::Format_A2BGR30_Premultiplied)
+ << 0xffff0000u << 0xc00003ffu;
+ QTest::newRow("A2BGR30_Premultiplied green") << int(QImage::Format_A2BGR30_Premultiplied)
+ << 0xff00ff00u << 0xc00ffc00u;
+ QTest::newRow("A2BGR30_Premultiplied blue") << int(QImage::Format_A2BGR30_Premultiplied)
+ << 0xff0000ffu << 0xfff00000u;
+ QTest::newRow("RGB30 red") << int(QImage::Format_RGB30)
+ << 0xffff0000u << 0xfff00000u;
+ QTest::newRow("RGB30 green") << int(QImage::Format_RGB30)
+ << 0xff00ff00u << 0xc00ffc00u;
+ QTest::newRow("RGB30 blue") << int(QImage::Format_RGB30)
+ << 0xff0000ffu << 0xc00003ffu;
}
void tst_QImage::setPixel()
@@ -1240,6 +1262,8 @@ void tst_QImage::setPixel()
case int(QImage::Format_RGBX8888):
case int(QImage::Format_RGBA8888):
case int(QImage::Format_RGBA8888_Premultiplied):
+ case int(QImage::Format_A2BGR30_Premultiplied):
+ case int(QImage::Format_RGB30):
{
for (int y = 0; y < h; ++y) {
const quint32 *row = (const quint32*)(img.scanLine(y));
@@ -1959,6 +1983,8 @@ void tst_QImage::fillColor_data()
"ARGB4444pm",
"RGBx8888",
"RGBA8888pm",
+ "BGR30",
+ "A2RGB30pm",
0
};
@@ -1978,6 +2004,8 @@ void tst_QImage::fillColor_data()
QImage::Format_ARGB4444_Premultiplied,
QImage::Format_RGBX8888,
QImage::Format_RGBA8888_Premultiplied,
+ QImage::Format_BGR30,
+ QImage::Format_A2RGB30_Premultiplied,
};
for (int i=0; names[i] != 0; ++i) {
@@ -1996,6 +2024,7 @@ void tst_QImage::fillColor_data()
QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << Qt::transparent << 0x00000000u;
QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << Qt::transparent << 0x00000000u;
QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << Qt::transparent << 0x00000000u;
+ QTest::newRow("A2RGB30pm, transparent") << QImage::Format_A2RGB30_Premultiplied << Qt::transparent << 0x00000000u;
}
void tst_QImage::fillColor()
@@ -2112,6 +2141,8 @@ void tst_QImage::rgbSwapped_data()
QTest::newRow("Format_RGB444") << QImage::Format_RGB444;
QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888;
QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("Format_A2BGR30_Premultiplied") << QImage::Format_A2BGR30_Premultiplied;
+ QTest::newRow("Format_RGB30") << QImage::Format_RGB30;
}
void tst_QImage::rgbSwapped()
@@ -2180,6 +2211,8 @@ void tst_QImage::mirrored_data()
QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false << 16 << 16;
QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false << 16 << 16;
QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_A2BGR30_Premultiplied, vertical") << QImage::Format_A2BGR30_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_RGB30, vertical") << QImage::Format_RGB30 << true << false << 16 << 16;
QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false << 16 << 16;
QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false << 16 << 16;
QTest::newRow("Format_MonoLSB, vertical") << QImage::Format_MonoLSB << true << false << 16 << 16;
@@ -2279,6 +2312,7 @@ void tst_QImage::inplaceRgbSwapped_data()
QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("Format_RGBA8888") << QImage::Format_RGBA8888;
+ QTest::newRow("Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied;
QTest::newRow("Format_RGB888") << QImage::Format_RGB888;
QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8;
@@ -2523,6 +2557,81 @@ void tst_QImage::scaled_QTBUG35972()
QCOMPARE(pixels[i], 0xffffffff);
}
+void tst_QImage::convertToPixelFormat()
+{
+ QPixelFormat rgb565 = QPixelFormatRgb(5,6,5,0,QPixelFormat::IgnoresAlpha, QPixelFormat::AtBeginning, QPixelFormat::NotPremultiplied, QPixelFormat::UnsignedShort);
+ QPixelFormat rgb565ImageFormat = QImage::toPixelFormat(QImage::Format_RGB16);
+ QCOMPARE(rgb565, rgb565ImageFormat);
+}
+
+void tst_QImage::convertToImageFormat_data()
+{
+ QTest::addColumn<QImage::Format>("image_format");
+ QTest::newRow("Convert Format_Invalid") << QImage::Format_Invalid;
+ QTest::newRow("Convert Format_Mono") << QImage::Format_Mono;
+ //This ends up being a QImage::Format_Mono since we cant specify LSB in QPixelFormat
+ //QTest::newRow("Convert Format_MonoLSB") << QImage::Format_MonoLSB;
+ QTest::newRow("Convert Format_Indexed8") << QImage::Format_Indexed8;
+ QTest::newRow("Convert Format_RGB32") << QImage::Format_RGB32;
+ QTest::newRow("Convert Format_ARGB32") << QImage::Format_ARGB32;
+ QTest::newRow("Convert Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Convert Format_RGB16") << QImage::Format_RGB16;
+ QTest::newRow("Convert Format_ARGB8565_Premultiplied") << QImage::Format_ARGB8565_Premultiplied;
+ QTest::newRow("Convert Format_RGB666") << QImage::Format_RGB666;
+ QTest::newRow("Convert Format_ARGB6666_Premultiplied") << QImage::Format_ARGB6666_Premultiplied;
+ QTest::newRow("Convert Format_RGB555") << QImage::Format_RGB555;
+ QTest::newRow("Convert Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied;
+ QTest::newRow("Convert Format_RGB888") << QImage::Format_RGB888;
+ QTest::newRow("Convert Format_RGB444") << QImage::Format_RGB444;
+ QTest::newRow("Convert Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied;
+ QTest::newRow("Convert Format_RGBX8888") << QImage::Format_RGBX8888;
+ QTest::newRow("Convert Format_RGBA8888") << QImage::Format_RGBA8888;
+ QTest::newRow("Convert Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied;
+}
+
+void tst_QImage::convertToImageFormat()
+{
+ QFETCH(QImage::Format, image_format);
+
+ QPixelFormat pixel_format = QImage::toPixelFormat(image_format);
+ QImage::Format format = QImage::toImageFormat(pixel_format);
+ QCOMPARE(format, image_format);
+}
+
+void tst_QImage::invertPixelsRGB_data()
+{
+ QTest::addColumn<QImage::Format>("image_format");
+
+ QTest::newRow("invertPixels RGB16") << QImage::Format_RGB16;
+ QTest::newRow("invertPixels RGB32") << QImage::Format_RGB32;
+ QTest::newRow("invertPixels BGR30") << QImage::Format_BGR30;
+ QTest::newRow("invertPixels RGB444") << QImage::Format_RGB444;
+ QTest::newRow("invertPixels RGB555") << QImage::Format_RGB555;
+ QTest::newRow("invertPixels RGB888") << QImage::Format_RGB888;
+
+ QTest::newRow("invertPixels ARGB32") << QImage::Format_ARGB32;
+ QTest::newRow("invertPixels ARGB32pm") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("invertPixels RGBA8888") << QImage::Format_RGBA8888;
+ QTest::newRow("invertPixels RGBA8888pm") << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("invertPixels RGBA4444pm") << QImage::Format_ARGB4444_Premultiplied;
+}
+
+void tst_QImage::invertPixelsRGB()
+{
+ QFETCH(QImage::Format, image_format);
+
+ QImage image(1, 1, image_format);
+ image.fill(QColor::fromRgb(32, 64, 96));
+ image.invertPixels();
+
+ QCOMPARE(image.format(), image_format);
+
+ uint pixel = image.pixel(0, 0);
+ QCOMPARE(qRed(pixel) >> 4, (255 - 32) >> 4);
+ QCOMPARE(qGreen(pixel) >> 4, (255 - 64) >> 4);
+ QCOMPARE(qBlue(pixel) >> 4, (255 - 96) >> 4);
+}
+
static void cleanupFunction(void* info)
{
bool *called = static_cast<bool*>(info);
diff --git a/tests/auto/gui/image/qpicture/tst_qpicture.cpp b/tests/auto/gui/image/qpicture/tst_qpicture.cpp
index 2e766c5bf5..986431941f 100644
--- a/tests/auto/gui/image/qpicture/tst_qpicture.cpp
+++ b/tests/auto/gui/image/qpicture/tst_qpicture.cpp
@@ -45,6 +45,7 @@
#include <qpicture.h>
#include <qpainter.h>
#include <qimage.h>
+#include <qpaintengine.h>
#ifndef QT_NO_WIDGETS
#include <qdesktopwidget.h>
#include <qapplication.h>
@@ -64,7 +65,7 @@ private slots:
void paintingActive();
void boundingRect();
void swap();
- void operator_lt_lt();
+ void serialization();
#ifndef QT_NO_WIDGETS
void save_restore();
@@ -169,36 +170,94 @@ void tst_QPicture::swap()
QCOMPARE(p2.boundingRect(), QRect(0,0,5,5));
}
-// operator<< and operator>>
-void tst_QPicture::operator_lt_lt()
+Q_DECLARE_METATYPE(QDataStream::Version)
+Q_DECLARE_METATYPE(QPicture)
+
+void ensureSerializesCorrectly(const QPicture &picture, QDataStream::Version version)
+ {
+ QDataStream stream;
+
+ QBuffer buffer;
+ buffer.open(QIODevice::WriteOnly);
+ stream.setDevice(&buffer);
+ stream.setVersion(version);
+ stream << picture;
+ buffer.close();
+
+ buffer.open(QIODevice::ReadOnly);
+ QPicture readpicture;
+ stream >> readpicture;
+ QVERIFY2(memcmp(picture.data(), readpicture.data(), picture.size()) == 0,
+ qPrintable(QString::fromLatin1("Picture data does not compare equal for QDataStream version %1").arg(version)));
+}
+
+class PaintEngine : public QPaintEngine
{
- // streaming of null pictures
- {
- QPicture pic1, pic2;
- QByteArray ba( 100, 0 );
- QDataStream str1( &ba, QIODevice::WriteOnly );
- str1 << pic1;
- QDataStream str2( &ba, QIODevice::ReadOnly );
- str2 >> pic2;
- QVERIFY( pic2.isNull() );
+public:
+ PaintEngine() : QPaintEngine() {}
+ bool begin(QPaintDevice *) { return true; }
+ bool end() { return true; }
+ void updateState(const QPaintEngineState &) {}
+ void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {}
+ Type type() const { return Raster; }
+
+ QFont font() { return state->font(); }
+};
+
+class Picture : public QPicture
+{
+public:
+ Picture() : QPicture() {}
+ QPaintEngine *paintEngine() const { return (QPaintEngine*)&mPaintEngine; }
+private:
+ PaintEngine mPaintEngine;
+};
+
+void tst_QPicture::serialization()
+{
+ QDataStream stream;
+ const int thisVersion = stream.version();
+
+ for (int version = QDataStream::Qt_1_0; version <= thisVersion; ++version) {
+ const QDataStream::Version versionEnum = static_cast<QDataStream::Version>(version);
+
+ {
+ // streaming of null pictures
+ ensureSerializesCorrectly(QPicture(), versionEnum);
+ }
+ {
+ // picture with a simple line, checking bitwise equality
+ QPicture picture;
+ QPainter painter(&picture);
+ painter.drawLine(10, 20, 30, 40);
+ ensureSerializesCorrectly(picture, versionEnum);
+ }
}
- // picture with a simple line, checking bitwise equality
{
- QPicture pic1, pic2;
- QPainter p( &pic1 );
- p.drawLine( 10, 20, 30, 40 );
- p.end();
- QByteArray ba( 10 * pic1.size(), 0 );
- QDataStream str1( &ba, QIODevice::WriteOnly );
- str1 << pic1;
- QDataStream str2( &ba, QIODevice::ReadOnly );
- str2 >> pic2;
- QCOMPARE( pic1.size(), pic2.size() );
- QVERIFY( memcmp( pic1.data(), pic2.data(), pic1.size() ) == 0 );
+ // Test features that were added after Qt 4.5, as that was hard-coded as the major
+ // version for a while, which was incorrect. In this case, we'll test font hints.
+ QPicture picture;
+ QPainter painter;
+ QFont font;
+ font.setStyleName("Blah");
+ font.setHintingPreference(QFont::PreferFullHinting);
+ painter.begin(&picture);
+ painter.setFont(font);
+ painter.drawText(20, 20, "Hello");
+ painter.end();
+
+ Picture customPicture;
+ painter.begin(&customPicture);
+ picture.play(&painter);
+ const QFont actualFont = ((PaintEngine*)customPicture.paintEngine())->font();
+ painter.end();
+ QCOMPARE(actualFont.styleName(), QStringLiteral("Blah"));
+ QCOMPARE(actualFont.hintingPreference(), QFont::PreferFullHinting);
}
}
+
#ifndef QT_NO_WIDGETS
static QPointF scalePoint(const QPointF &point, QPaintDevice *sourceDevice, QPaintDevice *destDevice)
{
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index b9d0adcd21..0c5d9f23b9 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -78,6 +78,7 @@ public:
public slots:
void init();
void cleanup();
+ void initTestCase();
void cleanupTestCase();
private slots:
@@ -171,6 +172,11 @@ private slots:
void detachOnLoad_QTBUG29639();
void copyOnNonAlignedBoundary();
+
+private:
+ const QString m_prefix;
+ const QString m_convertFromImage;
+ const QString m_loadFromData;
};
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
@@ -207,6 +213,9 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
tst_QPixmap::tst_QPixmap()
+ : m_prefix(QFINDTESTDATA("images/"))
+ , m_convertFromImage(QFINDTESTDATA("convertFromImage"))
+ , m_loadFromData(QFINDTESTDATA("loadFromData"))
{
}
@@ -222,6 +231,13 @@ void tst_QPixmap::cleanup()
{
}
+void tst_QPixmap::initTestCase()
+{
+ QVERIFY(!m_prefix.isEmpty());
+ QVERIFY(!m_convertFromImage.isEmpty());
+ QVERIFY(!m_loadFromData.isEmpty());
+}
+
void tst_QPixmap::cleanupTestCase()
{
QFile::remove(QLatin1String("temp_image.png"));
@@ -312,22 +328,21 @@ void tst_QPixmap::convertFromImage_data()
{
QTest::addColumn<QImage>("img1");
QTest::addColumn<QImage>("img2");
- const QString prefix = QFINDTESTDATA("convertFromImage");
{
QImage img1;
QImage img2;
- QVERIFY(img1.load(prefix + "/task31722_0/img1.png"));
- QVERIFY(img2.load(prefix + "/task31722_0/img2.png"));
- QVERIFY(img1.load(prefix + "/task31722_0/img1.png"));
- QVERIFY(img2.load(prefix + "/task31722_0/img2.png"));
+ QVERIFY(img1.load(m_convertFromImage + "/task31722_0/img1.png"));
+ QVERIFY(img2.load(m_convertFromImage + "/task31722_0/img2.png"));
+ QVERIFY(img1.load(m_convertFromImage + "/task31722_0/img1.png"));
+ QVERIFY(img2.load(m_convertFromImage + "/task31722_0/img2.png"));
QTest::newRow("Task 31722 0") << img1 << img2;
}
{
QImage img1;
QImage img2;
- QVERIFY(img1.load(prefix + "/task31722_1/img1.png"));
- QVERIFY(img2.load(prefix + "/task31722_1/img2.png"));
+ QVERIFY(img1.load(m_convertFromImage + "/task31722_1/img1.png"));
+ QVERIFY(img2.load(m_convertFromImage + "/task31722_1/img2.png"));
QTest::newRow("Task 31722 1") << img1 << img2;
}
}
@@ -346,11 +361,10 @@ void tst_QPixmap::convertFromImage()
void tst_QPixmap::convertFromImageShouldDetach()
{
- const QString prefix = QFINDTESTDATA("convertFromImage");
QImage img1;
QImage img2;
- QVERIFY(img1.load(prefix + "/task31722_0/img1.png"));
- QVERIFY(img2.load(prefix + "/task31722_0/img2.png"));
+ QVERIFY(img1.load(m_convertFromImage + "/task31722_0/img1.png"));
+ QVERIFY(img2.load(m_convertFromImage + "/task31722_0/img2.png"));
QPixmap pix = QPixmap::fromImage(img1);
QPixmap pix1 = pix;
pix.convertFromImage(img2);
@@ -1202,10 +1216,7 @@ void tst_QPixmap::transformed2()
void tst_QPixmap::load()
{
- const QString prefix = QFINDTESTDATA("images/");
- if (prefix.isEmpty())
- QFAIL("can not find images directory!");
- const QString filePath = prefix + QLatin1String("designer.png");
+ const QString filePath = m_prefix + QLatin1String("designer.png");
QPixmap dest(filePath);
QVERIFY(!dest.isNull());
@@ -1217,10 +1228,7 @@ void tst_QPixmap::load()
void tst_QPixmap::loadFromData()
{
- const QString prefix = QFINDTESTDATA("images/");
- if (prefix.isEmpty())
- QFAIL("can not find images directory!");
- const QString filePath = prefix + QLatin1String("designer.png");
+ const QString filePath = m_prefix + QLatin1String("designer.png");
QPixmap original(filePath);
QVERIFY(!original.isNull());
@@ -1246,10 +1254,7 @@ void tst_QPixmap::loadFromData()
#if !defined(QT_NO_DATASTREAM)
void tst_QPixmap::loadFromDataStream()
{
- const QString prefix = QFINDTESTDATA("images/");
- if (prefix.isEmpty())
- QFAIL("can not find images directory!");
- const QString filePath = prefix + QLatin1String("designer.png");
+ const QString filePath = m_prefix + QLatin1String("designer.png");
QPixmap original(filePath);
QVERIFY(!original.isNull());
@@ -1344,17 +1349,15 @@ void tst_QPixmap::loadFromDataImage_data()
{
QTest::addColumn<QString>("imagePath");
- const QString prefix = QFINDTESTDATA("loadFromData");
-
- QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png";
+ QTest::newRow("designer_argb32.png") << m_loadFromData + "/designer_argb32.png";
// When no extension is provided we try all extensions that has been registered by image providers
- QTest::newRow("designer_argb32") << prefix + "/designer_argb32.png";
- QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png";
- QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png";
- QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png";
- QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif";
- QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif";
- QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg";
+ QTest::newRow("designer_argb32") << m_loadFromData + "/designer_argb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.png") << m_loadFromData + "/designer_indexed8_no_alpha.png";
+ QTest::newRow("designer_indexed8_with_alpha.png") << m_loadFromData + "/designer_indexed8_with_alpha.png";
+ QTest::newRow("designer_rgb32.png") << m_loadFromData + "/designer_rgb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.gif") << m_loadFromData + "/designer_indexed8_no_alpha.gif";
+ QTest::newRow("designer_indexed8_with_alpha.gif") << m_loadFromData + "/designer_indexed8_with_alpha.gif";
+ QTest::newRow("designer_rgb32.jpg") << m_loadFromData + "/designer_rgb32.jpg";
}
void tst_QPixmap::loadFromDataImage()
@@ -1378,17 +1381,15 @@ void tst_QPixmap::fromImageReader_data()
{
QTest::addColumn<QString>("imagePath");
- const QString prefix = QFINDTESTDATA("loadFromData");
-
- QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png";
- QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png";
- QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png";
- QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png";
- QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif";
- QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif";
- QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg";
- QTest::newRow("designer_indexed8_with_alpha_animated") << prefix + "/designer_indexed8_with_alpha_animated.gif";
- QTest::newRow("designer_indexed8_no_alpha_animated") << prefix + "/designer_indexed8_no_alpha_animated.gif";
+ QTest::newRow("designer_argb32.png") << m_loadFromData + "/designer_argb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.png") << m_loadFromData + "/designer_indexed8_no_alpha.png";
+ QTest::newRow("designer_indexed8_with_alpha.png") << m_loadFromData + "/designer_indexed8_with_alpha.png";
+ QTest::newRow("designer_rgb32.png") << m_loadFromData + "/designer_rgb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.gif") << m_loadFromData + "/designer_indexed8_no_alpha.gif";
+ QTest::newRow("designer_indexed8_with_alpha.gif") << m_loadFromData + "/designer_indexed8_with_alpha.gif";
+ QTest::newRow("designer_rgb32.jpg") << m_loadFromData + "/designer_rgb32.jpg";
+ QTest::newRow("designer_indexed8_with_alpha_animated") << m_loadFromData + "/designer_indexed8_with_alpha_animated.gif";
+ QTest::newRow("designer_indexed8_no_alpha_animated") << m_loadFromData + "/designer_indexed8_no_alpha_animated.gif";
}
void tst_QPixmap::fromImageReader()
@@ -1416,8 +1417,7 @@ void tst_QPixmap::fromImageReaderAnimatedGif()
{
QFETCH(QString, imagePath);
- const QString prefix = QFINDTESTDATA("loadFromData");
- const QString path = prefix + imagePath;
+ const QString path = m_loadFromData + imagePath;
QImageReader referenceReader(path);
QImageReader pixmapReader(path);
@@ -1533,14 +1533,12 @@ void tst_QPixmap::scaled_QTBUG19157()
void tst_QPixmap::detachOnLoad_QTBUG29639()
{
- const QString prefix = QFINDTESTDATA("convertFromImage");
-
QPixmap a;
- a.load(prefix + "/task31722_0/img1.png");
- a.load(prefix + "/task31722_0/img2.png");
+ a.load(m_convertFromImage + "/task31722_0/img1.png");
+ a.load(m_convertFromImage + "/task31722_0/img2.png");
QPixmap b;
- b.load(prefix + "/task31722_0/img1.png");
+ b.load(m_convertFromImage + "/task31722_0/img1.png");
QVERIFY(a.toImage() != b.toImage());
}
diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro
index e4d9ce9d27..bbcdd91ea3 100644
--- a/tests/auto/gui/kernel/kernel.pro
+++ b/tests/auto/gui/kernel/kernel.pro
@@ -20,6 +20,7 @@ SUBDIRS=\
qtouchevent \
qwindow \
qguiapplication \
+ qpixelformat \
!qtHaveModule(widgets): SUBDIRS -= \
qmouseevent_modal \
diff --git a/tests/auto/gui/kernel/qclipboard/paster/main.cpp b/tests/auto/gui/kernel/qclipboard/paster/main.cpp
index 0dd7dd87af..3fd4267598 100644
--- a/tests/auto/gui/kernel/qclipboard/paster/main.cpp
+++ b/tests/auto/gui/kernel/qclipboard/paster/main.cpp
@@ -40,20 +40,59 @@
****************************************************************************/
#include <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
+#include <QtGui/QImage>
+#include <QtGui/QColor>
#include <QtCore/QStringList>
+#include <QtCore/QCommandLineParser>
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
- QString expected = QStringLiteral("testString.!");
-#ifndef Q_OS_WINCE
- const QStringList arguments = app.arguments();
- if (arguments.size() > 1)
- expected = arguments.at(1);
+ QCommandLineParser parser;
+ parser.addHelpOption();
+ QCommandLineOption textOption(QStringLiteral("text"),
+ QStringLiteral("Text to compare"),
+ QStringLiteral("text"));
+ parser.addOption(textOption);
+ QCommandLineOption imageOption(QStringLiteral("image"),
+ QStringLiteral("Perform image check"));
+ parser.addOption(imageOption);
+ parser.process(QCoreApplication::arguments());
+
+ if (parser.isSet(imageOption)) {
+#ifndef QT_NO_CLIPBOARD
+ const QImage actual = QGuiApplication::clipboard()->image();
+#else
+ const QImage actual;
#endif
- QString actual;
+ // Perform hard-coded checks on copied image (size, pixel 0,0: transparent,
+ // pixel 1,0: blue). Note: Windows sets RGB of transparent to 0xFF when converting
+ // to DIB5.
+ if (actual.size() != QSize(100, 100))
+ return 1;
+ const QRgb pixel00 = actual.pixel(QPoint(0, 0));
+ if (qAlpha(pixel00))
+ return 2;
+ const QRgb pixel01 = actual.pixel(QPoint(1, 0));
+ if (pixel01 != QColor(Qt::blue).rgba())
+ return 3;
+ return 0;
+ }
+
+#ifndef Q_OS_WINCE
+ QString expected;
+ if (parser.isSet(textOption))
+ expected = parser.value(textOption);
+#else // !Q_OS_WINCE
+ const QString expected = QStringLiteral("testString.!");
+#endif // Q_OS_WINCE
+ if (!expected.isEmpty()) {
#ifndef QT_NO_CLIPBOARD
- actual = QGuiApplication::clipboard()->text();
+ const QString actual = QGuiApplication::clipboard()->text();
+#else
+ const QString actual;
#endif
- return actual == expected ? 0 : 1;
+ return actual == expected ? 0 : 1;
+ }
+ return -2;
}
diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
index cf786c1dca..b677ee1ea4 100644
--- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -46,6 +46,8 @@
#include <QtCore/QDir>
#include <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
+#include <QtGui/QImage>
+#include <QtGui/QColor>
#include "../../../shared/platformclipboard.h"
class tst_QClipboard : public QObject
@@ -59,6 +61,7 @@ private slots:
void init();
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX)
void copy_exit_paste();
+ void copyImage();
#endif
void capabilityFunctions();
void modes();
@@ -134,6 +137,29 @@ void tst_QClipboard::modes()
}
}
+// A predicate to be used with a QSignalSpy / QTRY_VERIFY to ensure all delayed
+// notifications are eaten. It waits at least one cycle and returns true when
+// no new signals arrive.
+class EatSignalSpyNotificationsPredicate
+{
+public:
+ explicit EatSignalSpyNotificationsPredicate(QSignalSpy &spy) : m_spy(spy) { reset(); }
+
+ operator bool() const
+ {
+ if (m_timer.elapsed() && !m_spy.count())
+ return true;
+ m_spy.clear();
+ return false;
+ }
+
+ inline void reset() { m_timer.start(); }
+
+private:
+ QSignalSpy &m_spy;
+ QElapsedTimer m_timer;
+};
+
/*
Test that the appropriate signals are emitted when the clipboard
contents is changed by calling the qt functions.
@@ -149,6 +175,13 @@ void tst_QClipboard::testSignals()
QSignalSpy changedSpy(clipboard, SIGNAL(changed(QClipboard::Mode)));
QSignalSpy dataChangedSpy(clipboard, SIGNAL(dataChanged()));
+ // Clipboard notifications are asynchronous with the new AddClipboardFormatListener
+ // in Windows Vista (5.4). Eat away all signals to ensure they don't interfere
+ // with the QTRY_COMPARE below.
+ EatSignalSpyNotificationsPredicate noLeftOverDataChanges(dataChangedSpy);
+ EatSignalSpyNotificationsPredicate noLeftOverChanges(changedSpy);
+ QTRY_VERIFY(noLeftOverChanges && noLeftOverDataChanges);
+
QSignalSpy searchChangedSpy(clipboard, SIGNAL(findBufferChanged()));
QSignalSpy selectionChangedSpy(clipboard, SIGNAL(selectionChanged()));
@@ -156,7 +189,7 @@ void tst_QClipboard::testSignals()
// Test the default mode signal.
clipboard->setText(text);
- QCOMPARE(dataChangedSpy.count(), 1);
+ QTRY_COMPARE(dataChangedSpy.count(), 1);
QCOMPARE(searchChangedSpy.count(), 0);
QCOMPARE(selectionChangedSpy.count(), 0);
QCOMPARE(changedSpy.count(), 1);
@@ -248,18 +281,42 @@ void tst_QClipboard::copy_exit_paste()
// ### It's still possible to test copy/paste - just keep the apps running
if (!PlatformClipboard::isAvailable())
QSKIP("Native clipboard not working in this setup");
- const QStringList stringArgument(QStringLiteral("Test string."));
+ const QString stringArgument(QStringLiteral("Test string."));
QByteArray errorMessage;
- QVERIFY2(runHelper(QStringLiteral("copier/copier"), stringArgument, &errorMessage),
+ QVERIFY2(runHelper(QStringLiteral("copier/copier"), QStringList(stringArgument), &errorMessage),
errorMessage.constData());
#ifdef Q_OS_MAC
// The Pasteboard needs a moment to breathe (at least on older Macs).
QTest::qWait(100);
#endif // Q_OS_MAC
- QVERIFY2(runHelper(QStringLiteral("paster/paster"), stringArgument, &errorMessage),
+ QVERIFY2(runHelper(QStringLiteral("paster/paster"),
+ QStringList() << QStringLiteral("--text") << stringArgument,
+ &errorMessage),
errorMessage.constData());
#endif // QT_NO_PROCESS
}
+
+void tst_QClipboard::copyImage()
+{
+#ifndef QT_NO_PROCESS
+ if (!PlatformClipboard::isAvailable())
+ QSKIP("Native clipboard not working in this setup");
+ QImage image(100, 100, QImage::Format_ARGB32);
+ image.fill(QColor(Qt::transparent));
+ image.setPixel(QPoint(1, 0), QColor(Qt::blue).rgba());
+ QGuiApplication::clipboard()->setImage(image);
+#ifdef Q_OS_OSX
+ // The Pasteboard needs a moment to breathe (at least on older Macs).
+ QTest::qWait(100);
+#endif // Q_OS_OSX
+ // paster will perform hard-coded checks on the copied image.
+ QByteArray errorMessage;
+ QVERIFY2(runHelper(QStringLiteral("paster/paster"),
+ QStringList(QStringLiteral("--image")), &errorMessage),
+ errorMessage.constData());
+#endif // QT_NO_PROCESS
+}
+
#endif // Q_OS_WIN || Q_OS_MAC || Q_OS_QNX
void tst_QClipboard::setMimeData()
@@ -296,6 +353,11 @@ void tst_QClipboard::setMimeData()
QSignalSpy spySelection(QGuiApplication::clipboard(), SIGNAL(selectionChanged()));
QSignalSpy spyData(QGuiApplication::clipboard(), SIGNAL(dataChanged()));
+ // Clipboard notifications are asynchronous with the new AddClipboardFormatListener
+ // in Windows Vista (5.4). Eat away all signals to ensure they don't interfere
+ // with the QTRY_COMPARE below.
+ EatSignalSpyNotificationsPredicate noLeftOverDataChanges(spyData);
+ QTRY_VERIFY(noLeftOverDataChanges);
QSignalSpy spyFindBuffer(QGuiApplication::clipboard(), SIGNAL(findBufferChanged()));
QGuiApplication::clipboard()->clear(QClipboard::Clipboard);
@@ -312,7 +374,7 @@ void tst_QClipboard::setMimeData()
else
QCOMPARE(spyFindBuffer.count(), 0);
- QCOMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.count(), 1);
// an other crash test
data = new QMimeData;
@@ -326,7 +388,8 @@ void tst_QClipboard::setMimeData()
newData->setText("bar");
spySelection.clear();
- spyData.clear();
+ noLeftOverDataChanges.reset();
+ QTRY_VERIFY(noLeftOverDataChanges);
spyFindBuffer.clear();
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Clipboard);
@@ -343,7 +406,7 @@ void tst_QClipboard::setMimeData()
else
QCOMPARE(spyFindBuffer.count(), 0);
- QCOMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.count(), 1);
}
void tst_QClipboard::clearBeforeSetText()
diff --git a/tests/auto/gui/kernel/qguiapplication/icons/appicon.png b/tests/auto/gui/kernel/qguiapplication/icons/appicon.png
new file mode 100644
index 0000000000..b5d3ecbddf
--- /dev/null
+++ b/tests/auto/gui/kernel/qguiapplication/icons/appicon.png
Binary files differ
diff --git a/tests/auto/gui/kernel/qguiapplication/icons/usericon.png b/tests/auto/gui/kernel/qguiapplication/icons/usericon.png
new file mode 100644
index 0000000000..8d703640c1
--- /dev/null
+++ b/tests/auto/gui/kernel/qguiapplication/icons/usericon.png
Binary files differ
diff --git a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
index cd363bab31..895c2a0307 100644
--- a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
+++ b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
@@ -7,3 +7,5 @@ INCLUDEPATH += $$CORE_TEST_PATH
TARGET = tst_qguiapplication
QT += gui-private
SOURCES += tst_qguiapplication.cpp
+
+RESOURCES = tst_qguiapplication.qrc
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index e551d99959..232231b005 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -45,6 +45,7 @@
#include <QtGui/QWindow>
#include <QtGui/QScreen>
#include <QtGui/QCursor>
+#include <QtGui/QPalette>
#include <qpa/qwindowsysteminterface.h>
#include <qgenericplugin.h>
@@ -63,19 +64,28 @@ class tst_QGuiApplication: public tst_QCoreApplication
Q_OBJECT
private slots:
+ void cleanup();
void displayName();
void firstWindowTitle();
+ void windowIcon();
void focusObject();
void allWindows();
void topLevelWindows();
void abortQuitOnShow();
void changeFocusWindow();
void keyboardModifiers();
+ void palette();
void modalWindow();
void quitOnLastWindowClosed();
void genericPluginsAndWindowSystemEvents();
+ void layoutDirection();
};
+void tst_QGuiApplication::cleanup()
+{
+ QVERIFY(QGuiApplication::allWindows().isEmpty());
+}
+
void tst_QGuiApplication::displayName()
{
int argc = 1;
@@ -99,6 +109,24 @@ void tst_QGuiApplication::firstWindowTitle()
QCOMPARE(window.title(), QString("User Title"));
}
+void tst_QGuiApplication::windowIcon()
+{
+ int argc = 3;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication"), const_cast<char*>("-qwindowicon"), const_cast<char*>(":/icons/usericon.png") };
+ QGuiApplication app(argc, argv);
+ QIcon appIcon(":/icons/appicon.png");
+ app.setWindowIcon(appIcon);
+
+ QWindow window;
+ window.show();
+
+ QIcon userIcon(":/icons/usericon.png");
+ // Comparing icons is hard. cacheKey() differs because the icon was independently loaded.
+ // So we use availableSizes, after making sure that the app and user icons do have different sizes.
+ QVERIFY(userIcon.availableSizes() != appIcon.availableSizes());
+ QCOMPARE(window.icon().availableSizes(), userIcon.availableSizes());
+}
+
class DummyWindow : public QWindow
{
public:
@@ -414,6 +442,31 @@ void tst_QGuiApplication::keyboardModifiers()
window->close();
}
+void tst_QGuiApplication::palette()
+{
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+ QGuiApplication app(argc, argv);
+ QSignalSpy signalSpy(&app, SIGNAL(paletteChanged(QPalette)));
+
+ QPalette oldPalette = QGuiApplication::palette();
+ QPalette newPalette = QPalette(Qt::red);
+
+ QGuiApplication::setPalette(newPalette);
+ QCOMPARE(QGuiApplication::palette(), newPalette);
+ QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.at(0).at(0), QVariant(newPalette));
+
+ QGuiApplication::setPalette(oldPalette);
+ QCOMPARE(QGuiApplication::palette(), oldPalette);
+ QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.at(1).at(0), QVariant(oldPalette));
+
+ QGuiApplication::setPalette(oldPalette);
+ QCOMPARE(QGuiApplication::palette(), oldPalette);
+ QCOMPARE(signalSpy.count(), 2);
+}
+
class BlockableWindow : public QWindow
{
Q_OBJECT
@@ -829,4 +882,30 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents()
QCOMPARE(testReceiver.customEvents, 1);
}
+Q_DECLARE_METATYPE(Qt::LayoutDirection)
+void tst_QGuiApplication::layoutDirection()
+{
+ qRegisterMetaType<Qt::LayoutDirection>();
+
+ Qt::LayoutDirection oldDirection = QGuiApplication::layoutDirection();
+ Qt::LayoutDirection newDirection = oldDirection == Qt::LeftToRight ? Qt::RightToLeft : Qt::LeftToRight;
+
+ QGuiApplication::setLayoutDirection(newDirection);
+ QCOMPARE(QGuiApplication::layoutDirection(), newDirection);
+
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+ QGuiApplication app(argc, argv);
+ QSignalSpy signalSpy(&app, SIGNAL(layoutDirectionChanged(Qt::LayoutDirection)));
+
+ QGuiApplication::setLayoutDirection(oldDirection);
+ QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
+ QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.at(0).at(0).toInt(), static_cast<int>(oldDirection));
+
+ QGuiApplication::setLayoutDirection(oldDirection);
+ QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
+ QCOMPARE(signalSpy.count(), 1);
+}
+
QTEST_APPLESS_MAIN(tst_QGuiApplication)
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc
new file mode 100644
index 0000000000..b26fba37b9
--- /dev/null
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>icons/usericon.png</file>
+ <file>icons/appicon.png</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
index 431db86330..dc139cfa94 100644
--- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
+++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
@@ -145,18 +145,16 @@ void tst_QGuiVariant::constructor_invalid()
QFETCH(uint, typeId);
{
- MessageHandlerInvalidType msg;
+ 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);
- QVERIFY(msg.ok);
}
{
- MessageHandlerInvalidType msg;
+ 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);
- QVERIFY(msg.ok);
}
}
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index f9da7de0d6..b2c0ff979c 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
@@ -46,47 +46,13 @@
class tst_QPalette : public QObject
{
-Q_OBJECT
-
-public:
- tst_QPalette();
- virtual ~tst_QPalette();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
+ Q_OBJECT
+private Q_SLOTS:
void roleValues_data();
void roleValues();
+ void moveSemantics();
};
-tst_QPalette::tst_QPalette()
-{
-}
-
-tst_QPalette::~tst_QPalette()
-{
-}
-
-void tst_QPalette::initTestCase()
-{
-}
-
-void tst_QPalette::cleanupTestCase()
-{
-}
-
-void tst_QPalette::init()
-{
-}
-
-void tst_QPalette::cleanup()
-{
-}
-
void tst_QPalette::roleValues_data()
{
QTest::addColumn<int>("role");
@@ -124,5 +90,26 @@ void tst_QPalette::roleValues()
QCOMPARE(role, value);
}
+void tst_QPalette::moveSemantics()
+{
+#ifdef Q_COMPILER_RVALUE_REFS
+ QPalette src(Qt::red), dst;
+ const QPalette control = src;
+ QVERIFY(src != dst);
+ QCOMPARE(src, control);
+ QVERIFY(!dst.isCopyOf(src));
+ QVERIFY(!dst.isCopyOf(control));
+ dst = qMove(src); // move assignment
+ QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too
+ QVERIFY(dst.isCopyOf(control));
+ QCOMPARE(dst, control);
+ src = control; // check moved-from 'src' can still be assigned to (doesn't crash)
+ QVERIFY(src.isCopyOf(dst));
+ QVERIFY(src.isCopyOf(control));
+#else
+ QSKIP("Compiler doesn't support C++11 move semantics");
+#endif
+}
+
QTEST_MAIN(tst_QPalette)
#include "tst_qpalette.moc"
diff --git a/tests/auto/gui/kernel/qpixelformat/qpixelformat.pro b/tests/auto/gui/kernel/qpixelformat/qpixelformat.pro
new file mode 100644
index 0000000000..970e5c7c2d
--- /dev/null
+++ b/tests/auto/gui/kernel/qpixelformat/qpixelformat.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qpixelformat
+
+QT += gui testlib
+
+SOURCES += tst_qpixelformat.cpp
diff --git a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
new file mode 100644
index 0000000000..c3b19a3b44
--- /dev/null
+++ b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+
+#include <QtGui/qpixelformat.h>
+
+class tst_QPixelFormat : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testOperators();
+ void testQVectorOfFormats();
+ void testRGB();
+ void testCMYK();
+ void testHSLandHSV();
+ void testYUV_data();
+ void testYUV();
+ void testEnums();
+};
+
+void tst_QPixelFormat::testOperators()
+{
+ QPixelFormat first = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied);
+ QPixelFormat second = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied);
+ QVERIFY(first == second);
+
+ QPixelFormat third = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtEnd, QPixelFormat::NotPremultiplied);
+ QVERIFY(first != third);
+}
+
+void tst_QPixelFormat::testQVectorOfFormats()
+{
+ QVector<QPixelFormat> reallocedVector;
+ QVector<QPixelFormat> reservedVector;
+ reservedVector.reserve(QImage::NImageFormats);
+ for (int i = 0; i < QImage::NImageFormats; i++) {
+ if (i == 0 || i == 2) // skip invalid and monolsb
+ continue;
+ QImage::Format image_format = static_cast<QImage::Format>(i);
+ QPixelFormat format = QImage::toPixelFormat(image_format);
+ reallocedVector.append(format);
+ reservedVector.append(format);
+ }
+
+ for (int i = 0; i < reallocedVector.size(); i++) {
+ QCOMPARE(reallocedVector.at(i), reservedVector.at(i));
+ }
+}
+
+void tst_QPixelFormat::testRGB()
+{
+ QPixelFormat argb8888 = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha,QPixelFormat::AtBeginning, QPixelFormat::Premultiplied);
+ QCOMPARE(argb8888.redSize(), uchar(8));
+ QCOMPARE(argb8888.greenSize(), uchar(8));
+ QCOMPARE(argb8888.blueSize(), uchar(8));
+ QCOMPARE(argb8888.alphaSize(), uchar(8));
+
+ QPixelFormat rgb565 = QPixelFormatRgb(5,6,5,0,QPixelFormat::IgnoresAlpha,QPixelFormat::AtBeginning, QPixelFormat::NotPremultiplied);
+ QCOMPARE(rgb565.redSize(), uchar(5));
+ QCOMPARE(rgb565.greenSize(), uchar(6));
+ QCOMPARE(rgb565.blueSize(), uchar(5));
+ QCOMPARE(rgb565.alphaSize(), uchar(0));
+ QCOMPARE(rgb565.bitsPerPixel(), uchar(16));
+
+ QPixelFormat rgba1235 = QPixelFormatRgb(1,2,3,5,QPixelFormat::IgnoresAlpha, QPixelFormat::AtEnd, QPixelFormat::Premultiplied);
+ QCOMPARE(rgba1235.redSize(), uchar(1));
+ QCOMPARE(rgba1235.greenSize(), uchar(2));
+ QCOMPARE(rgba1235.blueSize(), uchar(3));
+ QCOMPARE(rgba1235.alphaSize(), uchar(5));
+ QCOMPARE(rgba1235.bitsPerPixel(), uchar(1 + 2 + 3 + 5));
+}
+
+void tst_QPixelFormat::testCMYK()
+{
+ QPixelFormat cmyk6 = QPixelFormatCmyk(6);
+ QCOMPARE(cmyk6.cyanSize(), uchar(6));
+ QCOMPARE(cmyk6.magentaSize(), uchar(6));
+ QCOMPARE(cmyk6.yellowSize(), uchar(6));
+ QCOMPARE(cmyk6.blackSize(), uchar(6));
+ QCOMPARE(cmyk6.bitsPerPixel(), uchar(6*4));
+
+ QPixelFormat cmykWithAlpha = QPixelFormatCmyk(8,8);
+ QCOMPARE(cmykWithAlpha.bitsPerPixel(), uchar(8*5));
+}
+void tst_QPixelFormat::testHSLandHSV()
+{
+ QPixelFormat hsl = QPixelFormatHsl(3,5);
+
+ QCOMPARE(hsl.hueSize(), uchar(3));
+ QCOMPARE(hsl.saturationSize(), uchar(3));
+ QCOMPARE(hsl.lightnessSize(), uchar(3));
+ QCOMPARE(hsl.bitsPerPixel(), uchar(3 * 3 + 5));
+
+ QPixelFormat hsv = QPixelFormatHsv(5,7);
+
+ QCOMPARE(hsv.hueSize(), uchar(5));
+ QCOMPARE(hsv.saturationSize(), uchar(5));
+ QCOMPARE(hsv.brightnessSize(), uchar(5));
+ QCOMPARE(hsv.bitsPerPixel(), uchar(5 * 3 + 7));
+}
+
+Q_DECLARE_METATYPE(QPixelFormat::YUVLayout)
+void tst_QPixelFormat::testYUV_data()
+{
+ QTest::addColumn<QPixelFormat::YUVLayout>("yuv_layout");
+ QTest::newRow("YUV Layout YUV444") << QPixelFormat::YUV444;
+ QTest::newRow("YUV Layout YUV422") << QPixelFormat::YUV422;
+ QTest::newRow("YUV Layout YUV411") << QPixelFormat::YUV411;
+ QTest::newRow("YUV Layout YUV420P") << QPixelFormat::YUV420P;
+ QTest::newRow("YUV Layout YUV420SP") << QPixelFormat::YUV420SP;
+ QTest::newRow("YUV Layout YV12") << QPixelFormat::YV12;
+ QTest::newRow("YUV Layout UYVY") << QPixelFormat::UYVY;
+ QTest::newRow("YUV Layout YUYV") << QPixelFormat::YUYV;
+ QTest::newRow("YUV Layout NV12") << QPixelFormat::NV12;
+ QTest::newRow("YUV Layout NV21") << QPixelFormat::NV21;
+ QTest::newRow("YUV Layout IMC1") << QPixelFormat::IMC1;
+ QTest::newRow("YUV Layout IMC2") << QPixelFormat::IMC2;
+ QTest::newRow("YUV Layout IMC3") << QPixelFormat::IMC3;
+ QTest::newRow("YUV Layout IMC4") << QPixelFormat::IMC4;
+ QTest::newRow("YUV Layout Y8") << QPixelFormat::Y8;
+ QTest::newRow("YUV Layout Y16") << QPixelFormat::Y16;
+}
+
+void tst_QPixelFormat::testYUV()
+{
+ QFETCH(QPixelFormat::YUVLayout, yuv_layout);
+
+ QPixelFormat format = QPixelFormatYuv(yuv_layout, 0);
+
+ switch (yuv_layout) {
+ case QPixelFormat::YUV444:
+ QCOMPARE(format.bitsPerPixel(), uchar(24));
+ break;
+ case QPixelFormat::YUV422:
+ QCOMPARE(format.bitsPerPixel(), uchar(16));
+ break;
+ case QPixelFormat::YUV411:
+ case QPixelFormat::YUV420P:
+ case QPixelFormat::YUV420SP:
+ case QPixelFormat::YV12:
+ QCOMPARE(format.bitsPerPixel(), uchar(12));
+ break;
+ case QPixelFormat::UYVY:
+ case QPixelFormat::YUYV:
+ QCOMPARE(format.bitsPerPixel(), uchar(16));
+ break;
+ case QPixelFormat::NV12:
+ case QPixelFormat::NV21:
+ QCOMPARE(format.bitsPerPixel(), uchar(12));
+ break;
+ case QPixelFormat::IMC1:
+ case QPixelFormat::IMC2:
+ case QPixelFormat::IMC3:
+ case QPixelFormat::IMC4:
+ QCOMPARE(format.bitsPerPixel(), uchar(12));
+ break;
+ case QPixelFormat::Y8:
+ QCOMPARE(format.bitsPerPixel(), uchar(8));
+ break;
+ case QPixelFormat::Y16:
+ QCOMPARE(format.bitsPerPixel(), uchar(16));
+ break;
+ default:
+ QVERIFY(!"the value stored for the yuvLayout is wrong!");
+ }
+
+}
+
+void tst_QPixelFormat::testEnums()
+{
+ QPixelFormat allSet = QPixelFormat(QPixelFormat::BGR,1,2,3,4,5,6,
+ QPixelFormat::UsesAlpha,
+ QPixelFormat::AtEnd,
+ QPixelFormat::Premultiplied,
+ QPixelFormat::FloatingPoint,
+ QPixelFormat::BigEndian,
+ (1 << 6) - 1);
+
+ QCOMPARE(allSet.alphaUsage(), QPixelFormat::UsesAlpha);
+ QCOMPARE(allSet.alphaPosition(), QPixelFormat::AtEnd);
+ QCOMPARE(allSet.premultiplied(), QPixelFormat::Premultiplied);
+ QCOMPARE(allSet.byteOrder(), QPixelFormat::BigEndian);
+ QCOMPARE(allSet.typeInterpretation(), QPixelFormat::FloatingPoint);
+ QCOMPARE(allSet.byteOrder(), QPixelFormat::BigEndian);
+ QCOMPARE(allSet.subEnum(), uchar(63));
+
+ QPixelFormat nonSet = QPixelFormat(QPixelFormat::RGB,6,5,4,3,2,1,
+ QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AtBeginning,
+ QPixelFormat::NotPremultiplied,
+ QPixelFormat::UnsignedInteger,
+ QPixelFormat::LittleEndian);
+
+ QCOMPARE(nonSet.alphaUsage(), QPixelFormat::IgnoresAlpha);
+ QCOMPARE(nonSet.alphaPosition(), QPixelFormat::AtBeginning);
+ QCOMPARE(nonSet.premultiplied(), QPixelFormat::NotPremultiplied);
+ QCOMPARE(nonSet.byteOrder(), QPixelFormat::LittleEndian);
+ QCOMPARE(nonSet.typeInterpretation(), QPixelFormat::UnsignedInteger);
+ QCOMPARE(nonSet.byteOrder(), QPixelFormat::LittleEndian);
+ QCOMPARE(nonSet.subEnum(), uchar(0));
+}
+
+#include <tst_qpixelformat.moc>
+QTEST_MAIN(tst_QPixelFormat);
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 868288e36e..02f3959802 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -67,6 +67,7 @@ private slots:
void mapGlobal();
void positioning_data();
void positioning();
+ void positioningDuringMinimized();
void isExposed();
void isActive();
void testInputEvents();
@@ -93,18 +94,36 @@ private slots:
void modalWithChildWindow();
void modalWindowModallity();
void modalWindowPosition();
-
- void initTestCase()
- {
- touchDevice = new QTouchDevice;
- touchDevice->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
- }
+ void initTestCase();
+ void cleanup();
private:
+ QPoint m_availableTopLeft;
+ QSize m_testWindowSize;
QTouchDevice *touchDevice;
};
+void tst_QWindow::initTestCase()
+{
+ // Size of reference window, 200 for < 2000, scale up for larger screens
+ // to avoid Windows warnings about minimum size for decorated windows.
+ int width = 200;
+ const QScreen *screen = QGuiApplication::primaryScreen();
+ m_availableTopLeft = screen->availableGeometry().topLeft();
+ const int screenWidth = screen->geometry().width();
+ if (screenWidth > 2000)
+ width = 100 * ((screenWidth + 500) / 1000);
+ m_testWindowSize = QSize(width, width);
+ touchDevice = new QTouchDevice;
+ touchDevice->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(touchDevice);
+}
+
+void tst_QWindow::cleanup()
+{
+ QVERIFY(QGuiApplication::allWindows().isEmpty());
+}
+
void tst_QWindow::mapGlobal()
{
QWindow a;
@@ -168,7 +187,7 @@ void tst_QWindow::eventOrderOnShow()
{
// Some platforms enforce minimum widths for windows, which can cause extra resize
// events, so set the width to suitably large value to avoid those.
- QRect geometry(80, 80, 300, 40);
+ QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
Window window;
window.setGeometry(geometry);
@@ -187,7 +206,7 @@ void tst_QWindow::resizeEventAfterResize()
{
// Some platforms enforce minimum widths for windows, which can cause extra resize
// events, so set the width to suitably large value to avoid those.
- QRect geometry(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 20), QSize(300, 40));
+ QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize * 2);
Window window;
window.setGeometry(geometry);
@@ -197,7 +216,7 @@ void tst_QWindow::resizeEventAfterResize()
// QTBUG-32706
// Make sure we get a resizeEvent after calling resize
- window.resize(400, 100);
+ window.resize(m_testWindowSize);
#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
// so we only expect one resize event
@@ -233,15 +252,14 @@ void tst_QWindow::positioning()
// Some platforms enforce minimum widths for windows, which can cause extra resize
// events, so set the width to suitably large value to avoid those.
- const QSize size = QSize(300, 40);
- const QRect geometry(QPoint(80, 80), size);
+ const QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
QFETCH(int, windowflags);
QFETCH(int, resizecount);
Window window((Qt::WindowFlags)windowflags);
- window.setGeometry(QRect(QPoint(20, 20), size));
- window.setFramePosition(QPoint(40, 40)); // Move window around before show, size must not change.
- QCOMPARE(window.geometry().size(), size);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(20, 20), m_testWindowSize));
+ window.setFramePosition(m_availableTopLeft + QPoint(40, 40)); // Move window around before show, size must not change.
+ QCOMPARE(window.geometry().size(), m_testWindowSize);
window.setGeometry(geometry);
QCOMPARE(window.geometry(), geometry);
// explicitly use non-fullscreen show. show() can be fullscreen on some platforms
@@ -306,9 +324,30 @@ 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))
+ QSKIP("Not supported on this platform");
+ Window window;
+ window.setTitle(QStringLiteral("positioningDuringMinimized"));
+ const QRect initialGeometry(m_availableTopLeft + QPoint(100, 100), m_testWindowSize);
+ window.setGeometry(initialGeometry);
+ window.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QCOMPARE(window.geometry(), initialGeometry);
+ window.setWindowState(Qt::WindowMinimized);
+ QCOMPARE(window.geometry(), initialGeometry);
+ const QRect newGeometry(initialGeometry.topLeft() + QPoint(50, 50), initialGeometry.size() + QSize(50, 50));
+ window.setGeometry(newGeometry);
+ QTRY_COMPARE(window.geometry(), newGeometry);
+ window.setWindowState(Qt::WindowNoState);
+ QTRY_COMPARE(window.geometry(), newGeometry);
+}
+
void tst_QWindow::isExposed()
{
- QRect geometry(80, 80, 40, 40);
+ QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
Window window;
window.setGeometry(geometry);
@@ -332,7 +371,7 @@ void tst_QWindow::isActive()
Window window;
// Some platforms enforce minimum widths for windows, which can cause extra resize
// events, so set the width to suitably large value to avoid those.
- window.setGeometry(80, 80, 300, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QCoreApplication::processEvents();
@@ -372,7 +411,7 @@ void tst_QWindow::isActive()
Window dialog;
dialog.setTransientParent(&window);
- dialog.setGeometry(110, 110, 300, 30);
+ dialog.setGeometry(QRect(m_availableTopLeft + QPoint(110, 100), m_testWindowSize));
dialog.show();
dialog.requestActivate();
@@ -508,7 +547,7 @@ public:
void tst_QWindow::testInputEvents()
{
InputTestWindow window;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -546,7 +585,7 @@ 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(2000, 500); // not inside the window
+ 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);
QCoreApplication::processEvents();
@@ -568,7 +607,7 @@ void tst_QWindow::touchToMouseTranslation()
QSKIP("Mouse events are synthesized by the system on this platform.");
InputTestWindow window;
window.ignoreTouch = true;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -644,7 +683,7 @@ void tst_QWindow::mouseToTouchTranslation()
InputTestWindow window;
window.ignoreMouse = true;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -693,7 +732,7 @@ void tst_QWindow::mouseToTouchLoop()
InputTestWindow window;
window.ignoreMouse = true;
window.ignoreTouch = true;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -708,7 +747,7 @@ void tst_QWindow::mouseToTouchLoop()
void tst_QWindow::touchCancel()
{
InputTestWindow window;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -770,7 +809,7 @@ void tst_QWindow::touchCancelWithTouchToMouse()
QSKIP("Mouse events are synthesized by the system on this platform.");
InputTestWindow window;
window.ignoreTouch = true;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -811,7 +850,7 @@ void tst_QWindow::touchCancelWithTouchToMouse()
void tst_QWindow::touchInterruptedByPopup()
{
InputTestWindow window;
- window.setGeometry(80, 80, 200, 200);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -832,8 +871,7 @@ void tst_QWindow::touchInterruptedByPopup()
InputTestWindow popup;
popup.setFlags(Qt::Popup);
popup.setModality(Qt::WindowModal);
- popup.setWidth(160);
- popup.setHeight(160);
+ popup.resize(m_testWindowSize / 2);
popup.setTransientParent(&window);
popup.show();
QVERIFY(QTest::qWaitForWindowExposed(&popup));
@@ -863,7 +901,7 @@ void tst_QWindow::orientation()
qRegisterMetaType<Qt::ScreenOrientation>("Qt::ScreenOrientation");
QWindow window;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.create();
window.reportContentOrientationChange(Qt::PortraitOrientation);
@@ -974,7 +1012,7 @@ void tst_QWindow::mouseEventSequence()
int doubleClickInterval = qGuiApp->styleHints()->mouseDoubleClickInterval();
InputTestWindow window;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -1096,7 +1134,7 @@ void tst_QWindow::inputReentrancy()
InputTestWindow window;
window.spinLoopWhenPressed = true;
- window.setGeometry(80, 80, 40, 40);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
@@ -1165,7 +1203,7 @@ void tst_QWindow::tabletEvents()
{
#ifndef QT_NO_TABLETEVENT
TabletTestWindow window;
- window.setGeometry(10, 10, 100, 100);
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(10, 10), m_testWindowSize));
qGuiApp->installEventFilter(&window);
QPoint local(10, 10);
@@ -1195,18 +1233,18 @@ void tst_QWindow::tabletEvents()
void tst_QWindow::windowModality_QTBUG27039()
{
QWindow parent;
- parent.setGeometry(10, 10, 100, 100);
+ parent.setGeometry(QRect(m_availableTopLeft + QPoint(10, 10), m_testWindowSize));
parent.show();
InputTestWindow modalA;
modalA.setTransientParent(&parent);
- modalA.setGeometry(10, 10, 20, 20);
+ modalA.setGeometry(QRect(m_availableTopLeft + QPoint(20, 10), m_testWindowSize));
modalA.setModality(Qt::ApplicationModal);
modalA.show();
InputTestWindow modalB;
modalB.setTransientParent(&parent);
- modalB.setGeometry(30, 10, 20, 20);
+ modalA.setGeometry(QRect(m_availableTopLeft + QPoint(30, 10), m_testWindowSize));
modalB.setModality(Qt::ApplicationModal);
modalB.show();
@@ -1296,40 +1334,43 @@ void tst_QWindow::initialSize()
}
{
Window w;
- w.setWidth(200);
+ w.setWidth(m_testWindowSize.width());
w.show();
#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
// so we only expect one resize event
QTRY_COMPARE(w.width(), qGuiApp->primaryScreen()->availableGeometry().width());
#else
- QTRY_COMPARE(w.width(), 200);
+ QTRY_COMPARE(w.width(), m_testWindowSize.width());
#endif
QTRY_VERIFY(w.height() > 0);
}
{
Window w;
- w.resize(200, 42);
+ const QSize testSize(m_testWindowSize.width(), 42);
+ w.resize(testSize);
w.show();
+
#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
// so we only expect one resize event
- QTRY_COMPARE(w.width(), qGuiApp->primaryScreen()->availableGeometry().width());
- QTRY_COMPARE(w.height(), qGuiApp->primaryScreen()->availableGeometry().height());
+ const QSize expectedSize = QGuiApplication::primaryScreen()->availableGeometry().size();
#else
- QTRY_COMPARE(w.width(), 200);
- QTRY_COMPARE(w.height(), 42);
+ const QSize expectedSize = testSize;
#endif
+ QTRY_COMPARE(w.size(), expectedSize);
}
}
void tst_QWindow::modalDialog()
{
QWindow normalWindow;
- normalWindow.resize(400, 400);
+ normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80));
+ normalWindow.resize(m_testWindowSize);
normalWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&normalWindow));
QWindow dialog;
- dialog.resize(200,200);
+ dialog.setFramePosition(m_availableTopLeft + QPoint(200, 200));
+ dialog.resize(m_testWindowSize);
dialog.setModality(Qt::ApplicationModal);
dialog.setFlags(Qt::Dialog);
dialog.show();
@@ -1345,12 +1386,14 @@ void tst_QWindow::modalDialog()
void tst_QWindow::modalDialogClosingOneOfTwoModal()
{
QWindow normalWindow;
- normalWindow.resize(400, 400);
+ normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80));
+ normalWindow.resize(m_testWindowSize);
normalWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&normalWindow));
QWindow first_dialog;
- first_dialog.resize(200,200);
+ first_dialog.setFramePosition(m_availableTopLeft + QPoint(200, 200));
+ first_dialog.resize(m_testWindowSize);
first_dialog.setModality(Qt::ApplicationModal);
first_dialog.setFlags(Qt::Dialog);
first_dialog.show();
@@ -1358,7 +1401,8 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal()
{
QWindow second_dialog;
- second_dialog.resize(200,200);
+ second_dialog.setFramePosition(m_availableTopLeft + QPoint(300, 300));
+ second_dialog.resize(m_testWindowSize);
second_dialog.setModality(Qt::ApplicationModal);
second_dialog.setFlags(Qt::Dialog);
second_dialog.show();
@@ -1377,12 +1421,14 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal()
void tst_QWindow::modalWithChildWindow()
{
QWindow normalWindow;
- normalWindow.resize(400, 400);
+ normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80));
+ normalWindow.resize(m_testWindowSize);
normalWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&normalWindow));
QWindow tlw_dialog;
- tlw_dialog.resize(400,200);
+ tlw_dialog.setFramePosition(m_availableTopLeft + QPoint(200, 200));
+ tlw_dialog.resize(m_testWindowSize);
tlw_dialog.setModality(Qt::ApplicationModal);
tlw_dialog.setFlags(Qt::Dialog);
tlw_dialog.create();
@@ -1406,18 +1452,21 @@ void tst_QWindow::modalWithChildWindow()
void tst_QWindow::modalWindowModallity()
{
QWindow normal_window;
- normal_window.resize(400, 400);
+ normal_window.setFramePosition(m_availableTopLeft + QPoint(80, 80));
+ normal_window.resize(m_testWindowSize);
normal_window.show();
QVERIFY(QTest::qWaitForWindowExposed(&normal_window));
QWindow parent_to_modal;
- parent_to_modal.resize(400, 400);
+ parent_to_modal.setFramePosition(normal_window.geometry().topRight() + QPoint(100, 0));
+ parent_to_modal.resize(m_testWindowSize);
parent_to_modal.show();
QVERIFY(QTest::qWaitForWindowExposed(&parent_to_modal));
QTRY_COMPARE(QGuiApplication::focusWindow(), &parent_to_modal);
QWindow modal_dialog;
- modal_dialog.resize(400,200);
+ modal_dialog.resize(m_testWindowSize);
+ modal_dialog.setFramePosition(normal_window.geometry().bottomLeft() + QPoint(0, 100));
modal_dialog.setModality(Qt::WindowModal);
modal_dialog.setFlags(Qt::Dialog);
modal_dialog.setTransientParent(&parent_to_modal);
@@ -1433,7 +1482,7 @@ void tst_QWindow::modalWindowModallity()
void tst_QWindow::modalWindowPosition()
{
QWindow window;
- window.setGeometry(QRect(100, 100, 400, 400));
+ window.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWindowSize));
// Allow for any potential resizing due to constraints
QRect origGeo = window.geometry();
window.setModality(Qt::WindowModal);
diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index 98f1c1c8f9..e492a8f7bf 100644
--- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -147,6 +147,7 @@ private slots:
void ortho();
void frustum();
void perspective();
+ void viewport();
void flipCoordinates();
void convertGeneric();
@@ -2794,6 +2795,40 @@ void tst_QMatrixNxN::perspective()
QVERIFY(m5.isIdentity());
}
+// Test viewport transformations
+void tst_QMatrixNxN::viewport()
+{
+ // Uses default depth range of 0->1
+ QMatrix4x4 m1;
+ m1.viewport(0.0f, 0.0f, 1024.0f, 768.0f);
+
+ // Lower left
+ QVector4D p1 = m1 * QVector4D(-1.0f, -1.0f, 0.0f, 1.0f);
+ QVERIFY(qFuzzyIsNull(p1.x()));
+ QVERIFY(qFuzzyIsNull(p1.y()));
+ QVERIFY(qFuzzyCompare(p1.z(), 0.5f));
+
+ // Lower right
+ QVector4D p2 = m1 * QVector4D(1.0f, -1.0f, 0.0f, 1.0f);
+ QVERIFY(qFuzzyCompare(p2.x(), 1024.0f));
+ QVERIFY(qFuzzyIsNull(p2.y()));
+
+ // Upper right
+ QVector4D p3 = m1 * QVector4D(1.0f, 1.0f, 0.0f, 1.0f);
+ QVERIFY(qFuzzyCompare(p3.x(), 1024.0f));
+ QVERIFY(qFuzzyCompare(p3.y(), 768.0f));
+
+ // Upper left
+ QVector4D p4 = m1 * QVector4D(-1.0f, 1.0f, 0.0f, 1.0f);
+ QVERIFY(qFuzzyIsNull(p4.x()));
+ QVERIFY(qFuzzyCompare(p4.y(), 768.0f));
+
+ // Center
+ QVector4D p5 = m1 * QVector4D(0.0f, 0.0f, 0.0f, 1.0f);
+ QVERIFY(qFuzzyCompare(p5.x(), 1024.0f / 2.0f));
+ QVERIFY(qFuzzyCompare(p5.y(), 768.0f / 2.0f));
+}
+
// Test left-handed vs right-handed coordinate flipping.
void tst_QMatrixNxN::flipCoordinates()
{
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 1b1f5575b1..2e1d55ced4 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -530,10 +530,19 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData);
void tst_QColor::setNamedColor()
{
for (int i = 0; i < rgbTblSize; ++i) {
- QColor color;
- color.setNamedColor(QLatin1String(rgbTbl[i].name));
QColor expected;
expected.setRgba(rgbTbl[i].value);
+
+ QColor color;
+ color.setNamedColor(QLatin1String(rgbTbl[i].name));
+ QCOMPARE(color, expected);
+
+ // name should be case insensitive
+ color.setNamedColor(QString(rgbTbl[i].name).toUpper());
+ QCOMPARE(color, expected);
+
+ // spaces should be ignored
+ color.setNamedColor(QString(rgbTbl[i].name).insert(1, ' '));
QCOMPARE(color, expected);
}
}
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index e4340451ce..5af5b1a269 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -282,6 +282,8 @@ private slots:
void QTBUG17053_zeroDashPattern();
+ void QTBUG38781_NoBrushAndQBitmap();
+
void drawTextOutsideGuiThread();
void drawTextWithComplexBrush();
@@ -1134,6 +1136,8 @@ void tst_QPainter::fillRect2_data()
QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("rgba8888") << QImage::Format_RGBA8888;
QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("a2rgb30pm") << QImage::Format_A2RGB30_Premultiplied;
+ QTest::newRow("a2bgr30pm") << QImage::Format_A2BGR30_Premultiplied;
}
void tst_QPainter::fillRect2()
@@ -1526,6 +1530,8 @@ void tst_QPainter::qimageFormats_data()
QTest::newRow("Qimage::Format_RGB555") << QImage::Format_RGB555;
QTest::newRow("Qimage::Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied;
QTest::newRow("Qimage::Format_RGB888") << QImage::Format_RGB888;
+ QTest::newRow("Qimage::Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied;
+ QTest::newRow("Qimage::Format_RGB30") << QImage::Format_RGB30;
}
/*
@@ -2342,6 +2348,26 @@ void tst_QPainter::setOpacity_data()
QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGB32
<< QImage::Format_RGBX8888;
+
+ 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("RGB32 on A2BGR30P") << QImage::Format_ARGB32_Premultiplied
+ << QImage::Format_A2BGR30_Premultiplied;
+
+ QTest::newRow("A2RGB30P on A2BGR30P") << QImage::Format_A2RGB30_Premultiplied
+ << QImage::Format_A2BGR30_Premultiplied;
+
+ QTest::newRow("ARGB32P on BGR30") << QImage::Format_ARGB32_Premultiplied
+ << QImage::Format_BGR30;
+
+ QTest::newRow("ARGB32P on RGB30") << QImage::Format_A2RGB30_Premultiplied
+ << QImage::Format_RGB30;
+
}
void tst_QPainter::setOpacity()
@@ -2430,7 +2456,9 @@ 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_ARGB8555_Premultiplied ||
+ dest.format() == QImage::Format_A2BGR30_Premultiplied ||
+ dest.format() == QImage::Format_A2RGB30_Premultiplied ) {
// Test skipped due to rounding errors...
continue;
}
@@ -4473,6 +4501,26 @@ void tst_QPainter::QTBUG17053_zeroDashPattern()
QCOMPARE(image, original);
}
+void tst_QPainter::QTBUG38781_NoBrushAndQBitmap()
+{
+ QBitmap bitmap(10, 10);
+ bitmap.fill(Qt::color0);
+ QPainter p(&bitmap);
+ p.setPen(Qt::color1);
+ p.drawLine(0, 1, 9, 1); // at horizontal line at y=1
+ p.setBrush(Qt::NoBrush);
+ p.drawRect(0, 0, 9, 9); // a rect all around
+
+ QRgb white = qRgb(0xff, 0xff, 0xff);
+ QRgb black = qRgb(0, 0, 0);
+ QImage image = bitmap.toImage();
+ QCOMPARE(image.pixel(0, 0), black);
+ QCOMPARE(image.pixel(5, 5), white);
+
+ // Check that the rect didn't overwrite the line
+ QCOMPARE(image.pixel(5, 1), black);
+}
+
class TextDrawerThread : public QThread
{
public:
diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp
index 07c996d026..a373c51710 100644
--- a/tests/auto/gui/painting/qpen/tst_qpen.cpp
+++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp
@@ -57,6 +57,8 @@ public:
private slots:
void getSetCheck();
void swap();
+ void move();
+ void move_assign();
void operator_eq_eq();
void operator_eq_eq_data();
@@ -101,6 +103,57 @@ void tst_QPen::swap()
QCOMPARE(p2.color(), QColor(Qt::black));
}
+void tst_QPen::move()
+{
+ QPen p1(Qt::black);
+
+ // check that moving does the right thing:
+ QPen p2 = qMove(p1); // could be move or copy construction, so don't check p1's state
+ QCOMPARE(p2.color(), QColor(Qt::black));
+
+ // this, executed ehre, would crash:
+ // QVERIFY(p1.style() != Qt::NoPen);
+
+ // check that moved-from QPen p1 can still be safely copied:
+ const QPen p3 = p1;
+
+ // check that moved-from QPen p1 can still be safely assigned to:
+ const QPen p4(Qt::yellow);
+ p1 = p4;
+ QCOMPARE(p1.color(), QColor(Qt::yellow));
+
+ // check that moved-from QPens p2, p3 can still be safely destroyed:
+ QPen p5 = qMove(p2);
+
+ // intentionally no more statements beyond this point
+}
+
+void tst_QPen::move_assign()
+{
+ QPen p1(Qt::black), p2(Qt::white);
+
+ // check that moving does the right thing:
+ p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state
+ QCOMPARE(p2.color(), QColor(Qt::black));
+
+ // check that move-assigned-from QPen p1 can still be used, albeit
+ // with undocumented state (it's p2's original state):
+ QVERIFY(p1.style() != Qt::NoPen);
+
+ // check that moved-from QPen p1 can still be safely copied:
+ const QPen p3 = p1;
+
+ // check that moved-from QPen p1 can still be safely assigned to:
+ const QPen p4(Qt::yellow);
+ p1 = p4;
+ QCOMPARE(p1.color(), QColor(Qt::yellow));
+
+ // check that moved-from QPens p2, p3 can still be safely destroyed:
+ QPen p5;
+ p5 = qMove(p2);
+
+ // intentionally no more statements beyond this point
+}
tst_QPen::tst_QPen()
diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro
index 12429bbeed..85297de1e1 100644
--- a/tests/auto/gui/qopengl/qopengl.pro
+++ b/tests/auto/gui/qopengl/qopengl.pro
@@ -10,3 +10,5 @@ QT += gui-private core-private testlib
SOURCES += tst_qopengl.cpp
win32-msvc2010:contains(QT_CONFIG, angle):CONFIG += insignificant_test # QTBUG-31611
+
+linux:contains(QT_CONFIG, xcb-glx):contains(QT_CONFIG, xcb-xlib):!contains(QT_CONFIG, opengles2): DEFINES += USE_GLX
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 63fe8b9693..6d83defdeb 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -43,6 +43,8 @@
#include <QtGui/private/qopenglcontext_p.h>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QOpenGLFunctions>
+#include <QtGui/QOpenGLFunctions_4_2_Core>
+#include <QtGui/QOpenGLVertexArrayObject>
#include <QtGui/QOpenGLPaintDevice>
#include <QtGui/QPainter>
#include <QtGui/QScreen>
@@ -51,12 +53,25 @@
#include <QtGui/QGenericMatrix>
#include <QtGui/QMatrix4x4>
#include <QtGui/private/qopengltextureblitter_p.h>
-
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
#include <QtTest/QtTest>
#include <QSignalSpy>
+#ifdef USE_GLX
+// Must be included last due to the X11 types
+#include <QtPlatformHeaders/QGLXNativeContext>
+#endif
+
+#if defined(Q_OS_WIN32) && !defined(QT_OPENGL_ES_2)
+#include <QtPlatformHeaders/QWGLNativeContext>
+#endif
+
+Q_DECLARE_METATYPE(QImage::Format)
+
class tst_QOpenGL : public QObject
{
Q_OBJECT
@@ -74,6 +89,8 @@ private slots:
void fboTextureOwnership();
void fboRendering_data();
void fboRendering();
+ void fboRenderingRGB30_data();
+ void fboRenderingRGB30();
void fboHandleNulledAfterContextDestroyed();
void openGLPaintDevice_data();
void openGLPaintDevice();
@@ -85,6 +102,16 @@ private slots:
void textureblitterPartOriginTopLeftSourceRectTransform();
void textureblitterFullTargetRectTransform();
void textureblitterPartTargetRectTransform();
+
+#ifdef USE_GLX
+ void glxContextWrap();
+#endif
+
+#if defined(Q_OS_WIN32) && !defined(QT_OPENGL_ES_2)
+ void wglContextWrap();
+#endif
+
+ void vaoCreate();
};
struct SharedResourceTracker
@@ -448,9 +475,9 @@ void tst_QOpenGL::fboSimpleRendering()
QVERIFY(fbo->bind());
- glClearColor(1.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glFinish();
+ ctx.functions()->glClearColor(1.0, 0.0, 0.0, 1.0);
+ ctx.functions()->glClear(GL_COLOR_BUFFER_BIT);
+ ctx.functions()->glFinish();
const QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
QCOMPARE(fb.size(), size);
@@ -494,9 +521,9 @@ void tst_QOpenGL::fboTextureOwnership()
fbo->bind();
QVERIFY(fbo->texture() != 0 && fbo->texture() != texture);
- glClearColor(1.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glFinish();
+ ctx.functions()->glClearColor(1.0, 0.0, 0.0, 1.0);
+ ctx.functions()->glClear(GL_COLOR_BUFFER_BIT);
+ ctx.functions()->glFinish();
QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
QImage reference(fb.size(), QImage::Format_RGB32);
@@ -504,7 +531,7 @@ void tst_QOpenGL::fboTextureOwnership()
QFUZZY_COMPARE_IMAGES(fb, reference);
- glDeleteTextures(1, &texture);
+ ctx.functions()->glDeleteTextures(1, &texture);
delete fbo;
}
@@ -539,7 +566,7 @@ void tst_QOpenGL::fboRendering()
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
- // Uncomplicate things by using NPOT:
+ // Uncomplicate things by using POT:
const QSize size(256, 128);
QOpenGLFramebufferObject fbo(size, fboFormat);
@@ -563,6 +590,111 @@ void tst_QOpenGL::fboRendering()
qt_opengl_check_test_pattern(fb);
}
+void tst_QOpenGL::fboRenderingRGB30_data()
+{
+ common_data();
+}
+
+#ifndef GL_RGB10_A2
+#define GL_RGB10_A2 0x8059
+#endif
+
+#ifndef GL_FRAMEBUFFER_RENDERABLE
+#define GL_FRAMEBUFFER_RENDERABLE 0x8289
+#endif
+
+#ifndef GL_FULL_SUPPORT
+#define GL_FULL_SUPPORT 0x82B7
+#endif
+
+void tst_QOpenGL::fboRenderingRGB30()
+{
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
+ QSKIP("QTBUG-22617");
+#endif
+
+ QFETCH(int, surfaceClass);
+ QScopedPointer<QSurface> surface(createSurface(surfaceClass));
+
+ QOpenGLContext ctx;
+ QVERIFY(ctx.create());
+
+ QVERIFY(ctx.makeCurrent(surface.data()));
+
+ if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QOpenGLFramebufferObject not supported on this platform");
+
+ if (ctx.format().majorVersion() < 3)
+ 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);
+ fboFormat.setInternalTextureFormat(GL_RGB10_A2);
+
+ // Uncomplicate things by using POT:
+ const QSize size(256, 128);
+ QOpenGLFramebufferObject fbo(size, fboFormat);
+
+ if (fbo.attachment() != QOpenGLFramebufferObject::CombinedDepthStencil)
+ QSKIP("FBOs missing combined depth~stencil support");
+
+ QVERIFY(fbo.bind());
+
+ QPainter fboPainter;
+ QOpenGLPaintDevice device(fbo.width(), fbo.height());
+ bool painterBegun = fboPainter.begin(&device);
+ QVERIFY(painterBegun);
+
+ qt_opengl_draw_test_pattern(&fboPainter, fbo.width(), fbo.height());
+
+ fboPainter.end();
+
+ QImage fb = fbo.toImage();
+ QCOMPARE(fb.format(), QImage::Format_A2BGR30_Premultiplied);
+ QCOMPARE(fb.size(), size);
+
+ qt_opengl_check_test_pattern(fb);
+
+ // Check rendering can handle color values below 1/256.
+ fboPainter.begin(&device);
+ fboPainter.fillRect(QRect(0, 0, 256, 128), QColor::fromRgbF(1.0/512, 1.0/512, 1.0/512));
+ fboPainter.end();
+ fb = fbo.toImage();
+ uint pixel = ((uint*)fb.bits())[0];
+ QVERIFY((pixel & 0x3f) > 0);
+ QVERIFY(((pixel >> 10) & 0x3f) > 0);
+ QVERIFY(((pixel >> 20) & 0x3f) > 0);
+
+ pixel = (3U << 30) | (2U << 20) | (2U << 10) | 2U;
+ fb.fill(pixel);
+
+ fboPainter.begin(&device);
+ fboPainter.setCompositionMode(QPainter::CompositionMode_Source);
+ fboPainter.drawImage(0, 0, fb);
+ fboPainter.end();
+ fb = fbo.toImage();
+ pixel = ((uint*)fb.bits())[0];
+ QVERIFY((pixel & 0x3f) > 0);
+ QVERIFY(((pixel >> 10) & 0x3f) > 0);
+ QVERIFY(((pixel >> 20) & 0x3f) > 0);
+}
+
void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
{
QWindow window;
@@ -591,7 +723,14 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
void tst_QOpenGL::openGLPaintDevice_data()
{
- common_data();
+ QTest::addColumn<int>("surfaceClass");
+ QTest::addColumn<QImage::Format>("imageFormat");
+
+ QTest::newRow("Using QWindow - RGB32") << int(QSurface::Window) << QImage::Format_RGB32;
+ QTest::newRow("Using QOffscreenSurface - RGB32") << int(QSurface::Offscreen) << QImage::Format_RGB32;
+ QTest::newRow("Using QOffscreenSurface - RGBx8888") << int(QSurface::Offscreen) << QImage::Format_RGBX8888;
+ QTest::newRow("Using QOffscreenSurface - RGB888") << int(QSurface::Offscreen) << QImage::Format_RGB888;
+ QTest::newRow("Using QOffscreenSurface - RGB16") << int(QSurface::Offscreen) << QImage::Format_RGB16;
}
void tst_QOpenGL::openGLPaintDevice()
@@ -601,6 +740,7 @@ void tst_QOpenGL::openGLPaintDevice()
#endif
QFETCH(int, surfaceClass);
+ QFETCH(QImage::Format, imageFormat);
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
@@ -613,7 +753,7 @@ void tst_QOpenGL::openGLPaintDevice()
const QSize size(128, 128);
- QImage image(size, QImage::Format_RGB32);
+ QImage image(size, imageFormat);
QPainter p(&image);
p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red);
p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green);
@@ -632,7 +772,7 @@ void tst_QOpenGL::openGLPaintDevice()
p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white);
p.end();
- QImage actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ QImage actual = fbo.toImage().convertToFormat(imageFormat);
QCOMPARE(image.size(), actual.size());
QCOMPARE(image, actual);
@@ -641,7 +781,7 @@ void tst_QOpenGL::openGLPaintDevice()
p.drawImage(0, 0, image);
p.end();
- actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ actual = fbo.toImage().convertToFormat(imageFormat);
QCOMPARE(image.size(), actual.size());
QCOMPARE(image, actual);
@@ -650,7 +790,7 @@ void tst_QOpenGL::openGLPaintDevice()
p.fillRect(0, 0, image.width(), image.height(), QBrush(image));
p.end();
- actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ actual = fbo.toImage().convertToFormat(imageFormat);
QCOMPARE(image.size(), actual.size());
QCOMPARE(image, actual);
}
@@ -970,6 +1110,121 @@ void tst_QOpenGL::textureblitterPartTargetRectTransform()
QCOMPARE(targetBottomRight, expectedBottomRight);
}
+#ifdef USE_GLX
+void tst_QOpenGL::glxContextWrap()
+{
+ QWindow *window = new QWindow;
+ window->setSurfaceType(QWindow::OpenGLSurface);
+ window->setGeometry(0, 0, 10, 10);
+ window->show();
+ QTest::qWaitForWindowExposed(window);
+
+ QPlatformNativeInterface *nativeIf = QGuiApplicationPrivate::instance()->platformIntegration()->nativeInterface();
+ QVERIFY(nativeIf);
+
+ // Fetch a GLXContext.
+ QOpenGLContext *ctx0 = new QOpenGLContext;
+ ctx0->setFormat(window->format());
+ QVERIFY(ctx0->create());
+ QVariant v = ctx0->nativeHandle();
+ QVERIFY(!v.isNull());
+ QVERIFY(v.canConvert<QGLXNativeContext>());
+ GLXContext context = v.value<QGLXNativeContext>().context();
+ QVERIFY(context);
+
+ // Then create another QOpenGLContext wrapping it.
+ QOpenGLContext *ctx = new QOpenGLContext;
+ ctx->setNativeHandle(QVariant::fromValue<QGLXNativeContext>(QGLXNativeContext(context)));
+ QVERIFY(ctx->create());
+ QVERIFY(ctx->nativeHandle().value<QGLXNativeContext>().context() == context);
+ QVERIFY(nativeIf->nativeResourceForContext(QByteArrayLiteral("glxcontext"), ctx) == (void *) context);
+
+ QVERIFY(ctx->makeCurrent(window));
+ ctx->doneCurrent();
+
+ delete ctx;
+ delete ctx0;
+
+ delete window;
+}
+#endif // USE_GLX
+
+#if defined(Q_OS_WIN32) && !defined(QT_OPENGL_ES_2)
+void tst_QOpenGL::wglContextWrap()
+{
+ QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
+ QVERIFY(ctx->create());
+ if (ctx->isOpenGLES())
+ QSKIP("Not applicable to EGL");
+
+ QScopedPointer<QWindow> window(new QWindow);
+ window->setSurfaceType(QWindow::OpenGLSurface);
+ window->setGeometry(0, 0, 256, 256);
+ window->show();
+ QTest::qWaitForWindowExposed(window.data());
+
+ QVariant v = ctx->nativeHandle();
+ QVERIFY(!v.isNull());
+ QVERIFY(v.canConvert<QWGLNativeContext>());
+ QWGLNativeContext nativeContext = v.value<QWGLNativeContext>();
+ QVERIFY(nativeContext.context());
+
+ // Now do a makeCurrent() do make sure the pixel format on the native
+ // window (the HWND we are going to retrieve below) is set.
+ QVERIFY(ctx->makeCurrent(window.data()));
+ ctx->doneCurrent();
+
+ HWND wnd = (HWND) qGuiApp->platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("handle"), window.data());
+ QVERIFY(wnd);
+
+ QScopedPointer<QOpenGLContext> adopted(new QOpenGLContext);
+ adopted->setNativeHandle(QVariant::fromValue<QWGLNativeContext>(QWGLNativeContext(nativeContext.context(), wnd)));
+ QVERIFY(adopted->create());
+
+ // This tests two things: that a regular, non-adopted QOpenGLContext is
+ // able to return a QSurfaceFormat containing the real values after
+ // create(), and that the adopted context got the correct pixel format from
+ // window and was able to update its format accordingly.
+ QCOMPARE(adopted->format().version(), ctx->format().version());
+ QCOMPARE(adopted->format().profile(), ctx->format().profile());
+ QVERIFY(ctx->format().redBufferSize() > 0);
+ QCOMPARE(adopted->format().redBufferSize(), ctx->format().redBufferSize());
+ QVERIFY(ctx->format().greenBufferSize() > 0);
+ QCOMPARE(adopted->format().greenBufferSize(), ctx->format().greenBufferSize());
+ QVERIFY(ctx->format().blueBufferSize() > 0);
+ QCOMPARE(adopted->format().blueBufferSize(), ctx->format().blueBufferSize());
+ QVERIFY(ctx->format().depthBufferSize() > 0);
+ QCOMPARE(adopted->format().depthBufferSize(), ctx->format().depthBufferSize());
+ QVERIFY(ctx->format().stencilBufferSize() > 0);
+ QCOMPARE(adopted->format().stencilBufferSize(), ctx->format().stencilBufferSize());
+
+ // This must work since we are using the exact same window.
+ QVERIFY(adopted->makeCurrent(window.data()));
+ adopted->doneCurrent();
+}
+#endif // Q_OS_WIN32 && !QT_OPENGL_ES_2
+
+void tst_QOpenGL::vaoCreate()
+{
+ QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
+ QOpenGLContext *ctx = new QOpenGLContext;
+ ctx->create();
+ ctx->makeCurrent(surface.data());
+
+ QOpenGLVertexArrayObject vao;
+ bool success = vao.create();
+ if (ctx->isOpenGLES()) {
+ if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object")))
+ QVERIFY(success);
+ } else {
+ if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object")))
+ QVERIFY(success);
+ }
+
+ vao.destroy();
+ ctx->doneCurrent();
+}
+
QTEST_MAIN(tst_QOpenGL)
#include "tst_qopengl.moc"
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 995f7a0378..d838c7375d 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -76,7 +76,8 @@ private slots:
void isCopyOf();
void italicOblique();
void insertAndRemoveSubstitutions();
- void serializeSpacing();
+ void serialize_data();
+ void serialize();
void lastResortFont();
void styleName();
void defaultFamily_data();
@@ -534,44 +535,115 @@ void tst_QFont::insertAndRemoveSubstitutions()
QVERIFY(QFont::substitutes("bogusfontfamily").isEmpty());
}
+Q_DECLARE_METATYPE(QDataStream::Version)
-static QFont copyFont(const QFont &font1) // copy using a QDataStream
+void tst_QFont::serialize_data()
{
- QBuffer buffer;
- buffer.open(QIODevice::WriteOnly);
- QDataStream ds(&buffer);
- ds << font1;
- buffer.close();
-
- buffer.open(QIODevice::ReadOnly);
- QFont font2;
- ds >> font2;
- return font2;
-}
+ QTest::addColumn<QFont>("font");
+ // The version in which the tested feature was added.
+ QTest::addColumn<QDataStream::Version>("minimumStreamVersion");
-void tst_QFont::serializeSpacing()
-{
- QFont font;
- QCOMPARE(font.letterSpacing(), 0.);
- QCOMPARE(font.wordSpacing(), 0.);
+ QFont basicFont;
+ // Versions <= Qt 2.1 had broken point size serialization,
+ // so we set an integer point size.
+ basicFont.setPointSize(9);
+
+ QFont font = basicFont;
+ QTest::newRow("defaultConstructed") << font << QDataStream::Qt_1_0;
font.setLetterSpacing(QFont::AbsoluteSpacing, 105);
- QCOMPARE(font.letterSpacing(), 105.);
- QCOMPARE(font.letterSpacingType(), QFont::AbsoluteSpacing);
- QCOMPARE(font.wordSpacing(), 0.);
- QFont font2 = copyFont(font);
- QCOMPARE(font2.letterSpacing(), 105.);
- QCOMPARE(font2.letterSpacingType(), QFont::AbsoluteSpacing);
- QCOMPARE(font2.wordSpacing(), 0.);
+ QTest::newRow("letterSpacing") << font << QDataStream::Qt_4_5;
+ font = basicFont;
font.setWordSpacing(50.0);
- QCOMPARE(font.letterSpacing(), 105.);
- QCOMPARE(font.wordSpacing(), 50.);
+ QTest::newRow("wordSpacing") << font << QDataStream::Qt_4_5;
+
+ font = basicFont;
+ font.setPointSize(20);
+ QTest::newRow("pointSize") << font << QDataStream::Qt_1_0;
+
+ font = basicFont;
+ font.setPixelSize(32);
+ QTest::newRow("pixelSize") << font << QDataStream::Qt_3_0;
+
+ font = basicFont;
+ font.setStyleHint(QFont::Monospace);
+ QTest::newRow("styleHint") << font << QDataStream::Qt_1_0;
+
+ font = basicFont;
+ font.setStretch(4000);
+ QTest::newRow("stretch") << font << QDataStream::Qt_4_3;
+
+ font = basicFont;
+ font.setWeight(99);
+ QTest::newRow("weight") << font << QDataStream::Qt_1_0;
+
+ font = basicFont;
+ font.setUnderline(true);
+ QTest::newRow("underline") << font << QDataStream::Qt_1_0;
+
+ font = basicFont;
+ font.setStrikeOut(true);
+ QTest::newRow("strikeOut") << font << QDataStream::Qt_1_0;
+
+ font = basicFont;
+ font.setFixedPitch(true);
+ // This fails for versions less than this, as ignorePitch is set to false
+ // whenever setFixedPitch() is called, but ignorePitch is considered an
+ // extended bit, which were apparently not available until 4.4.
+ QTest::newRow("fixedPitch") << font << QDataStream::Qt_4_4;
+
+ font = basicFont;
+ font.setLetterSpacing(QFont::AbsoluteSpacing, 10);
+ // Fails for 4.4 because letterSpacing wasn't read until 4.5.
+ QTest::newRow("letterSpacing") << font << QDataStream::Qt_4_5;
+
+ font = basicFont;
+ font.setRawMode(true);
+ QTest::newRow("rawMode") << font << QDataStream::Qt_1_0;
+
+ font = basicFont;
+ font.setKerning(false);
+ QTest::newRow("kerning") << font << QDataStream::Qt_4_0;
+
+ font = basicFont;
+ font.setStyleStrategy(QFont::NoFontMerging);
+ // This wasn't read properly until 5.4.
+ QTest::newRow("styleStrategy") << font << QDataStream::Qt_5_4;
+
+ font = basicFont;
+ font.setHintingPreference(QFont::PreferFullHinting);
+ // This wasn't read until 5.4.
+ QTest::newRow("hintingPreference") << font << QDataStream::Qt_5_4;
+
+ font = basicFont;
+ font.setStyleName("Regular Black Condensed");
+ // This wasn't read until 5.4.
+ QTest::newRow("styleName") << font << QDataStream::Qt_5_4;
+}
- QFont font3 = copyFont(font);
- QCOMPARE(font3.letterSpacing(), 105.);
- QCOMPARE(font3.letterSpacingType(), QFont::AbsoluteSpacing);
- QCOMPARE(font3.wordSpacing(), 50.);
+void tst_QFont::serialize()
+{
+ QFETCH(QFont, font);
+ QFETCH(QDataStream::Version, minimumStreamVersion);
+
+ QDataStream stream;
+ const int thisVersion = stream.version();
+
+ for (int version = minimumStreamVersion; version <= thisVersion; ++version) {
+ QBuffer buffer;
+ buffer.open(QIODevice::WriteOnly);
+ stream.setDevice(&buffer);
+ stream.setVersion(version);
+ stream << font;
+ buffer.close();
+
+ buffer.open(QIODevice::ReadOnly);
+ QFont readFont;
+ stream >> readFont;
+ QVERIFY2(readFont == font, qPrintable(QString::fromLatin1("Fonts do not compare equal for QDataStream version ") +
+ QString::fromLatin1("%1:\nactual: %2\nexpected: %3").arg(version).arg(readFont.toString()).arg(font.toString())));
+ }
}
// QFont::lastResortFont() may abort with qFatal() on QWS/QPA
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
index a39277b093..a4e1490b01 100644
--- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
@@ -314,16 +314,24 @@ void tst_QRawFont::advances()
bool supportsSubPixelPositions = font_d->fontEngine->supportsSubPixelPositions();
QVector<QPointF> advances = font.advancesForGlyphIndexes(glyphIndices);
- for (int i=0; i<glyphIndices.size(); ++i) {
-#ifdef Q_OS_WIN
- // In Windows, freetype engine returns advance of 9 when full hinting is used (default) for
- // some of the glyphs.
- if (font_d->fontEngine->type() == QFontEngine::Freetype
- && (hintingPreference == QFont::PreferFullHinting || hintingPreference == QFont::PreferDefaultHinting)
- && (i == 0 || i == 5)) {
- QEXPECT_FAIL("", "Advance for some glyphs is not the expected with Windows Freetype engine (9 instead of 8)", Continue);
- }
+
+ // On Windows and QNX, freetype engine returns advance of 9 for some of the glyphs
+ // when full hinting is used (default on Windows).
+ bool mayFail = false;
+#if defined (Q_OS_WIN)
+ mayFail = font_d->fontEngine->type() == QFontEngine::Freetype
+ && (hintingPreference == QFont::PreferFullHinting
+ || hintingPreference == QFont::PreferDefaultHinting);
+#elif defined(Q_OS_QNX)
+ mayFail = font_d->fontEngine->type() == QFontEngine::Freetype
+ && hintingPreference == QFont::PreferFullHinting;
#endif
+
+ for (int i = 0; i < glyphIndices.size(); ++i) {
+ if (mayFail && (i == 0 || i == 5)) {
+ QEXPECT_FAIL("", "FreeType engine reports unexpected advance "
+ "for some glyphs (9 instead of 8)", Continue);
+ }
QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0));
if (supportsSubPixelPositions)
QVERIFY(advances.at(i).x() > 8.0);
@@ -341,16 +349,11 @@ void tst_QRawFont::advances()
QVERIFY(font.advancesForGlyphIndexes(glyphIndices.constData(), advances.data(), numGlyphs));
- for (int i=0; i<glyphIndices.size(); ++i) {
-#ifdef Q_OS_WIN
- // In Windows, freetype engine returns advance of 9 when full hinting is used (default) for
- // some of the glyphs.
- if (font_d->fontEngine->type() == QFontEngine::Freetype
- && (hintingPreference == QFont::PreferFullHinting || hintingPreference == QFont::PreferDefaultHinting)
- && (i == 0 || i == 5)) {
- QEXPECT_FAIL("", "Advance for some glyphs is not the expected with Windows Freetype engine (9 instead of 8)", Continue);
+ for (int i = 0; i < glyphIndices.size(); ++i) {
+ if (mayFail && (i == 0 || i == 5)) {
+ QEXPECT_FAIL("", "FreeType engine reports unexpected advance "
+ "for some glyphs (9 instead of 8)", Continue);
}
-#endif
QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0));
if (supportsSubPixelPositions)
QVERIFY(advances.at(i).x() > 8.0);
diff --git a/tests/auto/network/access/spdy/tst_spdy.cpp b/tests/auto/network/access/spdy/tst_spdy.cpp
index 3f69549bbd..c0b119d437 100644
--- a/tests/auto/network/access/spdy/tst_spdy.cpp
+++ b/tests/auto/network/access/spdy/tst_spdy.cpp
@@ -85,6 +85,7 @@ private:
QNetworkAccessManager m_manager;
int m_multipleRequestsCount;
int m_multipleRepliesFinishedCount;
+ const QString m_rfc3252FilePath;
protected Q_SLOTS:
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *authenticator);
@@ -92,6 +93,7 @@ protected Q_SLOTS:
};
tst_Spdy::tst_Spdy()
+ : m_rfc3252FilePath(QFINDTESTDATA("../qnetworkreply/rfc3252.txt"))
{
#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
qRegisterMetaType<QNetworkReply *>(); // for QSignalSpy
@@ -110,6 +112,7 @@ tst_Spdy::~tst_Spdy()
void tst_Spdy::initTestCase()
{
+ QVERIFY(!m_rfc3252FilePath.isEmpty());
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
}
@@ -215,7 +218,7 @@ void tst_Spdy::download_data()
QTest::newRow("mediumfile") << QUrl("https://" + QtNetworkSettings::serverName()
+ "/qtest/rfc3252.txt")
- << QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
+ << m_rfc3252FilePath
<< QNetworkProxy();
QHostInfo hostInfo = QHostInfo::fromName(QtNetworkSettings::serverName());
@@ -223,23 +226,23 @@ void tst_Spdy::download_data()
QTest::newRow("mediumfile-http-proxy") << QUrl("https://" + QtNetworkSettings::serverName()
+ "/qtest/rfc3252.txt")
- << QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
+ << m_rfc3252FilePath
<< QNetworkProxy(QNetworkProxy::HttpProxy, proxyserver, 3128);
QTest::newRow("mediumfile-http-proxy-auth") << QUrl("https://" + QtNetworkSettings::serverName()
+ "/qtest/rfc3252.txt")
- << QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
+ << m_rfc3252FilePath
<< QNetworkProxy(QNetworkProxy::HttpProxy,
proxyserver, 3129);
QTest::newRow("mediumfile-socks-proxy") << QUrl("https://" + QtNetworkSettings::serverName()
+ "/qtest/rfc3252.txt")
- << QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
+ << m_rfc3252FilePath
<< QNetworkProxy(QNetworkProxy::Socks5Proxy, proxyserver, 1080);
QTest::newRow("mediumfile-socks-proxy-auth") << QUrl("https://" + QtNetworkSettings::serverName()
+ "/qtest/rfc3252.txt")
- << QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
+ << m_rfc3252FilePath
<< QNetworkProxy(QNetworkProxy::Socks5Proxy,
proxyserver, 1081);
@@ -408,7 +411,7 @@ void tst_Spdy::upload_data()
// 2. test uploading of files
- QFile *file = new QFile(QFINDTESTDATA("../qnetworkreply/rfc3252.txt"));
+ QFile *file = new QFile(m_rfc3252FilePath);
file->open(QIODevice::ReadOnly);
QTest::newRow("file-26K") << md5Url << QByteArray() << QByteArray("POST")
<< static_cast<QObject *>(file)
diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/README b/tests/auto/network/ssl/qsslcertificate/pkcs12/README
new file mode 100644
index 0000000000..1828d089c1
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/README
@@ -0,0 +1,8 @@
+The PKCS#12 bundle was created by running the following on
+in the qsslsocket/certs directory:
+
+openssl pkcs12 -export -in leaf.crt -inkey leaf.key \
+ -out leaf.p12 \
+ -certfile inter.crt -CAfile ca.crt
+
+No password was provided.
diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/inter.crt b/tests/auto/network/ssl/qsslcertificate/pkcs12/inter.crt
new file mode 100644
index 0000000000..4e1d67c3e0
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/inter.crt
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDvDCCAnSgAwIBAgIQO+uZxerYC10Ll11PBnVL4TANBgkqhkiG9w0BAQUFADA8
+MQswCQYDVQQGEwJHQjEZMBcGA1UEChMQV2VzdHBvaW50IENBIEtleTESMBAGA1UE
+ChMJV2VzdHBvaW50MB4XDTEzMDIxNjE2NTMwOFoXDTIzMDIxNjE2NTMwOFowMjEL
+MAkGA1UEBhMCR0IxIzAhBgNVBAoTGldlc3Rwb2ludCBJbnRlcm1lZGlhdGUgS2V5
+MIIBUjANBgkqhkiG9w0BAQEFAAOCAT8AMIIBOgKCATEAsR4tRskg2IFfQFMfGBJ1
+eqlrNejANw0oM6k5HlEB8uFA9qeyAzmflwQUPoJ55KRQ/gVHTOBdWrtgGgPMiekF
+1Q36Ry1elwbAl4a+LZ6qsc9ASipvk8HirKpt1v5L9hG+aI4yDxyvjNztFtg5R4P5
+zqsh/WwhCgsYmEVfcSDbhUjqoqxGRLaZxPKO+IMCNFrjZqi0yxc8f6Un4G5SQzHA
+4szi/ezcITnAFYWxHG2yaed4hawpxNS1WXabk2rzCi0pWeIcHuIczaCfZ7ElRcqV
+VNNXbGTtUDlfIsh6FAVI5kTUDcPV27uf6BmHuFOu/R9Tjni25+vBFvohwQh7ZwCX
+5COXnfkJLPkJQQEFVQv8nS27ht/vmyoKjERUeiuMd+hFcN5zl7bS5A2JCgi7erlP
+ZQIDAQABo2QwYjAPBgNVHRMBAf8EBTADAQH/MA8GA1UdDwEB/wQFAwMHBgAwHQYD
+VR0OBBYEFGn5shQ0SeTcc3x/cNu6TkoV0bPmMB8GA1UdIwQYMBaAFJQnOLW5hBTG
+pvc2vfcs4sJpRRPJMA0GCSqGSIb3DQEBBQUAA4IBMQAVDS0enQQ1FL0d92xOFfwx
+mjcNPz9oO7jMyEVxAs2eR2QD+xZ3Xj4gAiUEp40aGieDcLv+dg+cmuBFWF61IYSR
+UyuoakVm08VDcLAwUzU+xtSvJiSSROb0GsAnVsYZj4TYlvKDplqfapOYaiIkwF+c
+iE4n7G0hQW9fzqO+n3FGtBD8YUjghRqLggeRVJ2+8S3Bm8cfx8xPpRIO3ksA6opn
+CORRGuzetDHihbks59mkoY3GqKFgBOyrC3kG07nv5wtKjdKDtmD/kS/SAc4fIXKy
+Uruq2uXNf/1BUgF5gFGRyj22yB2D0763fJJpl5nqcLrL5RmnVObQKZGhE2VsRTV0
+untj+AmiJivhiAjjkHfw3XDf8tuL7D4pTmEkGgl5xl23fyeTIuygDCLT8fRD3ZqQ
+-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.crt b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.crt
new file mode 100644
index 0000000000..4a7dc40540
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.crt
@@ -0,0 +1,23 @@
+-----BEGIN CERTIFICATE-----
+MIID3zCCApegAwIBAgIQEKCtd1j2bq5Gk6ND+VmKnjANBgkqhkiG9w0BAQUFADAy
+MQswCQYDVQQGEwJHQjEjMCEGA1UEChMaV2VzdHBvaW50IEludGVybWVkaWF0ZSBL
+ZXkwHhcNMTMwMjE2MTY1MzA4WhcNMjMwMjE2MTY1MzA4WjA1MQswCQYDVQQGEwJH
+QjESMBAGA1UEChMJV2VzdHBvaW50MRIwEAYDVQQDEwkxMjcuMC4wLjEwggFSMA0G
+CSqGSIb3DQEBAQUAA4IBPwAwggE6AoIBMQC7EIWIzb7XCfmQQ1KFdZ5E9f49eNK/
+KvsXYfq/iV29K1cz2hUyvfdKgyU5F/+BOPQKQ5zdWn1CraZosFv/ibuO3mhRpMfB
+SfNn3rfdrE7WtA0wgT2YNIN0L4aCe+C15j2ESdmyMaFLUaUIS47JS66UtaYxp5ia
+mJFO1hSNaoI0pGHyPFTTtfOza9z/01qkBbHB4htzauqs/fX5ZrnyCDSrfpVipXke
+zkPKg4MkkytEkjRKw6tSXLpWIgF3ee2N/jBdefqlw8YPW08K0wmwF5qGuX6PZ8vB
+sOZeWeCfVr136BopkbfP3TkGWw2BrD8xSzOUez9HVc0v4SZ/7pe5w3L4V/mzYQLt
+O+1AHevCjX8+M58HYGBaWCAjxYUPGcGKcj0LLtgZgL6wY88N7RtfeOY3AgMBAAGj
+gY0wgYowFAYDVR0RBA0wC4IJMTI3LjAuMC4xMAwGA1UdEwEB/wQCMAAwEwYDVR0l
+BAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/BAUDAwcoADAdBgNVHQ4EFgQUKKuyJSrT
+Y+dnm1do7l0sVMX96SYwHwYDVR0jBBgwFoAUafmyFDRJ5NxzfH9w27pOShXRs+Yw
+DQYJKoZIhvcNAQEFBQADggExAHELijlIFdcncP3B+vxEp0SGKl0arIaCXahivb2F
+VxeM3WajN6O+oDRLFltzMeDKA9RVkao7fgITzXQgCGzeNhKv0vc9iDyvR9/67vuS
+W8xEEJrYowtw3VK5H1y0ewqZaxJhvKUjm4TBRWe8FGKD3s64lEsfbjOaI5VPidVc
+DXmdAlXsj0Hk+v4Ej8mshPQAnVSyJ3D0ZMgTjk8Di28N0qROFIYJaTObK1rCb1nQ
+GaCcmbZU6JnkYvVZ+iUe5U0GXFbb+LRNTUT8/fw1zADeHnv/G+WWVrfND+sov5Oc
+33fkNE6z+n6ayABVnGLuCYhbzD38sv0dnxeh8vbykNBPzYdzPg6nw3Czv2vlhKpJ
+8Yj/maoXuAyTXVf30K1/fAWyU45noq57MjQpU6UxIX1D7qw=
+-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.key b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.key
new file mode 100644
index 0000000000..54327925d8
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.key
@@ -0,0 +1,32 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIFfAIBAAKCATEAuxCFiM2+1wn5kENShXWeRPX+PXjSvyr7F2H6v4ldvStXM9oV
+Mr33SoMlORf/gTj0CkOc3Vp9Qq2maLBb/4m7jt5oUaTHwUnzZ9633axO1rQNMIE9
+mDSDdC+GgnvgteY9hEnZsjGhS1GlCEuOyUuulLWmMaeYmpiRTtYUjWqCNKRh8jxU
+07Xzs2vc/9NapAWxweIbc2rqrP31+Wa58gg0q36VYqV5Hs5DyoODJJMrRJI0SsOr
+Uly6ViIBd3ntjf4wXXn6pcPGD1tPCtMJsBeahrl+j2fLwbDmXlngn1a9d+gaKZG3
+z905BlsNgaw/MUszlHs/R1XNL+Emf+6XucNy+Ff5s2EC7TvtQB3rwo1/PjOfB2Bg
+WlggI8WFDxnBinI9Cy7YGYC+sGPPDe0bX3jmNwIDAQABAoIBMQCczBNyAStGqjjC
+oHuKHHWmTh9mPWFBFfDTv6/jXmvxRWPZtaHxH2Qp09Wejqv/D9MWy2ev7spx2oZS
+2Ai1ICjTbz83uAwryyW4Wen6aBTJSLCJiLstWk8ZU0DHHLjVH4FO4mwUPh95t5zC
+YDr2JXbXdY8xrc5vPxUFZNJjWvR61ZK37bQYpTn5mZ7r3KfsNk2yOylRTDwa9XFo
+ZZ+B82NKdrrz0UvGOnXZa5qd1ap7V+67FIAS2Mt8AMzSCG8TW0JXRUk89ISgAd8r
+NQTPtX9XCnMZSbBzDKdznXfHS9ZlJcSrpsbQCPcvMVNrdBfCF0eNnsRJffJGdaXI
+MsN6PvbcXWD08lXNGyeLjon03RdJnTAamNM3YQEIcjFmu5Y0o0CCJkZSCJPKJGMG
+0d/1tN/5AoGZANOcOgQZ9Wiu0ej3YoQ3aSHu3y8ZBJH4B3ViX8i+2x/6UnG7KNaa
+4Ygid1upnX6hk4CW5WZcoxGFacrFRpInKh5Ng8lEIHGp0VSzOBVDR0L5sAxutFuX
+6N9C0CuH80vD101mOloNnfT5KHZMI5RXqP6sDGUFlwak2XybDL1qOAza3gZAy25H
+vS/ll1BneBavikR5j+zxoTztAoGZAOJOJ5RyOrqpNuhiWZylah5LIFT9N1lCF4Hl
+ZbFIjUZ4jcApJ7JxkMXNQ4RU/3AiKCC1xr5ib7dd/qyjKXhdMo4SnLoKhapx5R9G
+3XOsQMahiCD/Zcymv9tmk8MxxzbLxhZYhEPzIP/NFkua3CHiX+d1e6fkzFLF/EiX
+ZGQOgRcFKrlzUeBputRQRXAkKJH+kMClgAWvy28zAoGYKyaMXhG9DV+4xjzMBhIW
+iijfsgbz+6AMRU+OIK1qmZa+ARsdNMXYf54noLVxvETOg0ZB+SGizwvZitO3lE4Q
+NKWx3fTaeNMcMJ1rLkrN2UZ5M8/PT24muoAxWu8aGbURzmKuO3bTYwT7z0OvbayC
+dYw36tG8/knXX6Vub6GdVGG9LKFB2nceiQnUVT0EK/wXwebYBoUvT/ECgZgF9qdG
+Wyg/CPyAbS8NWLKOL86fTrjpqjsyWhgu7smCROT/XlZEdoepHrqbvx2oF85U5lVh
+aPimrVxrsjUCjfoqEkV9BY/2KOAvzc9CIBTo5xLOQ8yr8uz1XCOiriogwIfsyNJb
+dAm3k/D1dxQ79FowoEDs8LONrtfyFcM4e8VdFO7GSkqrDj41IBRkWx+SkVHBMdtI
+yxQiTwKBmQCWym2iDCJg1ZZq4/lVwRudMhVmHoD0yoCAwADYHjjAi8QBplM0vfdd
+CESKsnBhlcrPGB279BKVJyZHehKZG+/dfnFs+to14l6A3IqU2d6+pu3EyFNX34HS
+xo+64QxMeF0akWnSaIPfUJfk36phjCvLBr4eLXN1i4jW3RdGFwF1THXt29VSSGmU
+q/hM51H0bsQ13AIVUSdNHA==
+-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.p12 b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.p12
new file mode 100644
index 0000000000..cb89aadb73
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.p12
Binary files differ
diff --git a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro
index 09cb22defe..69cd241f84 100644
--- a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro
+++ b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro
@@ -6,5 +6,6 @@ SOURCES += tst_qsslcertificate.cpp
QT = core network testlib
TARGET = tst_qsslcertificate
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
-TESTDATA += certificates/* more-certificates/* verify-certs/*
+TESTDATA += certificates/* more-certificates/* verify-certs/* pkcs12/*
diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
index 4f62076870..83462568f5 100644
--- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
@@ -105,6 +105,7 @@ private slots:
void largeSerialNumber();
void largeExpirationDate();
void blacklistedCertificates();
+ void selfsignedCertificates();
void toText();
void multipleCommonNames();
void subjectAndIssuerAttributes();
@@ -113,6 +114,7 @@ private slots:
void threadSafeConstMethods();
void version_data();
void version();
+ void pkcs12();
// helper for verbose test failure messages
QString toString(const QList<QSslError>&);
@@ -890,6 +892,13 @@ void tst_QSslCertificate::blacklistedCertificates()
}
}
+void tst_QSslCertificate::selfsignedCertificates()
+{
+ QVERIFY(QSslCertificate::fromPath(testDataDir + "/certificates/cert-ss.pem").first().isSelfSigned());
+ QVERIFY(!QSslCertificate::fromPath(testDataDir + "/certificates/cert.pem").first().isSelfSigned());
+ QVERIFY(!QSslCertificate().isSelfSigned());
+}
+
void tst_QSslCertificate::toText()
{
QList<QSslCertificate> certList =
@@ -1221,6 +1230,48 @@ void tst_QSslCertificate::version()
QCOMPARE(certificate.version(), result);
}
+void tst_QSslCertificate::pkcs12()
+{
+ if (!QSslSocket::supportsSsl()) {
+ qWarning("SSL not supported, skipping test");
+ return;
+ }
+
+ QFile f(QLatin1String(SRCDIR "pkcs12/leaf.p12"));
+ bool ok = f.open(QIODevice::ReadOnly);
+ QVERIFY(ok);
+
+ QSslKey key;
+ QSslCertificate cert;
+ QList<QSslCertificate> caCerts;
+
+ ok = QSslCertificate::importPKCS12(&f, &key, &cert, &caCerts);
+ QVERIFY(ok);
+ f.close();
+
+ QList<QSslCertificate> leafCert = QSslCertificate::fromPath(QLatin1String( SRCDIR "pkcs12/leaf.crt"));
+ QVERIFY(!leafCert.isEmpty());
+
+ QCOMPARE(cert, leafCert.first());
+
+ QFile f2(QLatin1String(SRCDIR "pkcs12/leaf.key"));
+ ok = f2.open(QIODevice::ReadOnly);
+ QVERIFY(ok);
+
+ QSslKey leafKey(&f2, QSsl::Rsa);
+ f2.close();
+
+ QVERIFY(!leafKey.isNull());
+ QCOMPARE(key, leafKey);
+
+ QList<QSslCertificate> caCert = QSslCertificate::fromPath(QLatin1String(SRCDIR "pkcs12/inter.crt"));
+ QVERIFY(!caCert.isEmpty());
+
+ QVERIFY(!caCerts.isEmpty());
+ QCOMPARE(caCerts.first(), caCert.first());
+ QCOMPARE(caCerts, caCert);
+}
+
#endif // QT_NO_SSL
QTEST_MAIN(tst_QSslCertificate)
diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp
index ba2528d3cf..71243339aa 100644
--- a/tests/auto/opengl/qgl/tst_qgl.cpp
+++ b/tests/auto/opengl/qgl/tst_qgl.cpp
@@ -1090,9 +1090,10 @@ void tst_QGL::glFBOSimpleRendering()
fbo->bind();
- glClearColor(1.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glFinish();
+ QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
+ funcs->glClearColor(1.0, 0.0, 0.0, 1.0);
+ funcs->glClear(GL_COLOR_BUFFER_BIT);
+ funcs->glFinish();
QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
QImage reference(fb.size(), QImage::Format_RGB32);
@@ -1390,11 +1391,11 @@ class RenderPixmapWidget : public QGLWidget
protected:
void initializeGL() {
// Set some gl state:
- glClearColor(1.0, 0.0, 0.0, 1.0);
+ QOpenGLContext::currentContext()->functions()->glClearColor(1.0, 0.0, 0.0, 1.0);
}
void paintGL() {
- glClear(GL_COLOR_BUFFER_BIT);
+ QOpenGLContext::currentContext()->functions()->glClear(GL_COLOR_BUFFER_BIT);
}
};
@@ -1683,11 +1684,12 @@ protected:
void paintEvent(QPaintEvent*)
{
// clear the stencil with junk
- glStencilMask(0xFFFF);
- glClearStencil(0xFFFF);
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_SCISSOR_TEST);
- glClear(GL_STENCIL_BUFFER_BIT);
+ QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
+ funcs->glStencilMask(0xFFFF);
+ funcs->glClearStencil(0xFFFF);
+ funcs->glDisable(GL_STENCIL_TEST);
+ funcs->glDisable(GL_SCISSOR_TEST);
+ funcs->glClear(GL_STENCIL_BUFFER_BIT);
QPainter painter(this);
paint(&painter);
@@ -2029,26 +2031,27 @@ void tst_QGL::qglContextDefaultBindTexture()
QVERIFY(QImagePixmapCleanupHooks::isImageCached(*boundImage));
QVERIFY(QImagePixmapCleanupHooks::isPixmapCached(*boundPixmap));
+ QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
// Make sure the texture IDs returned are valid:
- QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_TRUE);
- QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_TRUE);
+ QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE);
+ QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), 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)glIsTexture(boundImageTextureId), GL_TRUE);
+ QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE);
QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+1);
delete boundPixmap;
boundPixmap = 0;
- QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_TRUE);
+ QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE);
QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount);
// Finally, make sure QGLContext::deleteTexture deletes the texture IDs:
ctx->deleteTexture(boundImageTextureId);
ctx->deleteTexture(boundPixmapTextureId);
- QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_FALSE);
- QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_FALSE);
+ QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_FALSE);
+ QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_FALSE);
}
#endif
diff --git a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp
index 2f09d84772..a465afef21 100644
--- a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp
+++ b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp
@@ -62,7 +62,7 @@ bool tst_QGLFunctions::hasExtension(const char *name)
{
QString extensions =
QString::fromLatin1
- (reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
+ (reinterpret_cast<const char *>(QOpenGLContext::currentContext()->functions()->glGetString(GL_EXTENSIONS)));
return extensions.split(QLatin1Char(' ')).contains
(QString::fromLatin1(name));
}
@@ -194,46 +194,46 @@ void tst_QGLFunctions::features()
// Verify that the multitexture functions appear to resolve and work.
void tst_QGLFunctions::multitexture()
{
- QGLFunctions funcs;
+ QOpenGLFunctions funcs;
QGLWidget glw;
if (!glw.isValid())
QSKIP("Could not create a GL context");
glw.makeCurrent();
- funcs.initializeGLFunctions();
+ funcs.initializeOpenGLFunctions();
- if (!funcs.hasOpenGLFeature(QGLFunctions::Multitexture))
+ if (!funcs.hasOpenGLFeature(QOpenGLFunctions::Multitexture))
QSKIP("Multitexture functions are not supported");
funcs.glActiveTexture(GL_TEXTURE1);
GLint active = 0;
- glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
+ funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
QVERIFY(active == GL_TEXTURE1);
funcs.glActiveTexture(GL_TEXTURE0);
active = 0;
- glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
+ funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
QVERIFY(active == GL_TEXTURE0);
}
// Verify that the glBlendColor() function appears to resolve and work.
void tst_QGLFunctions::blendColor()
{
- QGLFunctions funcs;
+ QOpenGLFunctions funcs;
QGLWidget glw;
if (!glw.isValid())
QSKIP("Could not create a GL context");
glw.makeCurrent();
- funcs.initializeGLFunctions();
+ funcs.initializeOpenGLFunctions();
- if (!funcs.hasOpenGLFeature(QGLFunctions::BlendColor))
+ if (!funcs.hasOpenGLFeature(QOpenGLFunctions::BlendColor))
QSKIP("glBlendColor() is not supported");
funcs.glBlendColor(0.0f, 1.0f, 0.0f, 1.0f);
GLfloat colors[4] = {0.5f, 0.5f, 0.5f, 0.5f};
- glGetFloatv(GL_BLEND_COLOR, colors);
+ funcs.glGetFloatv(GL_BLEND_COLOR, colors);
QCOMPARE(colors[0], 0.0f);
QCOMPARE(colors[1], 1.0f);
diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
index 70e3a3b62a..25057ba2a0 100644
--- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
@@ -48,6 +48,10 @@
#include <QtOpenGL/QtOpenGL>
#include "tst_qglthreads.h"
+#ifndef QT_OPENGL_ES_2
+#include <QtGui/QOpenGLFunctions_1_0>
+#endif
+
#define RUNNING_TIME 5000
tst_QGLThreads::tst_QGLThreads(QObject *parent)
@@ -339,8 +343,9 @@ static inline float qrandom() { return (rand() % 100) / 100.f; }
void renderAScene(int w, int h)
{
+ QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
+
if (QOpenGLContext::currentContext()->isOpenGLES()) {
- QGLFunctions funcs(QGLContext::currentContext());
Q_UNUSED(w);
Q_UNUSED(h);
QGLShaderProgram program;
@@ -349,7 +354,7 @@ void renderAScene(int w, int h)
program.bindAttributeLocation("pos", 0);
program.bind();
- funcs.glEnableVertexAttribArray(0);
+ funcs->glEnableVertexAttribArray(0);
for (int i=0; i<1000; ++i) {
GLfloat pos[] = {
@@ -361,30 +366,33 @@ void renderAScene(int w, int h)
(rand() % 100) / 100.f
};
- funcs.glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, pos);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ funcs->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, pos);
+ funcs->glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
} else {
#ifndef QT_OPENGL_ES_2
- glViewport(0, 0, w, h);
+ QOpenGLFunctions_1_0 *gl1funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_0>();
+ gl1funcs->initializeOpenGLFunctions();
+
+ gl1funcs->glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(0, w, h, 0, 1, 100);
- glTranslated(0, 0, -1);
+ gl1funcs->glMatrixMode(GL_PROJECTION);
+ gl1funcs->glLoadIdentity();
+ gl1funcs->glFrustum(0, w, h, 0, 1, 100);
+ gl1funcs->glTranslated(0, 0, -1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ gl1funcs->glMatrixMode(GL_MODELVIEW);
+ gl1funcs->glLoadIdentity();
for (int i=0;i<1000; ++i) {
- glBegin(GL_TRIANGLES);
- glColor3f(qrandom(), qrandom(), qrandom());
- glVertex2f(qrandom() * w, qrandom() * h);
- glColor3f(qrandom(), qrandom(), qrandom());
- glVertex2f(qrandom() * w, qrandom() * h);
- glColor3f(qrandom(), qrandom(), qrandom());
- glVertex2f(qrandom() * w, qrandom() * h);
- glEnd();
+ gl1funcs->glBegin(GL_TRIANGLES);
+ gl1funcs->glColor3f(qrandom(), qrandom(), qrandom());
+ gl1funcs->glVertex2f(qrandom() * w, qrandom() * h);
+ gl1funcs->glColor3f(qrandom(), qrandom(), qrandom());
+ gl1funcs->glVertex2f(qrandom() * w, qrandom() * h);
+ gl1funcs->glColor3f(qrandom(), qrandom(), qrandom());
+ gl1funcs->glVertex2f(qrandom() * w, qrandom() * h);
+ gl1funcs->glEnd();
}
#endif
}
@@ -434,8 +442,9 @@ public:
QSize s = m_widget->newSize;
m_widget->mutex.unlock();
+ QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
if (s != m_size) {
- glViewport(0, 0, s.width(), s.height());
+ funcs->glViewport(0, 0, s.width(), s.height());
}
if (QGLContext::currentContext() != m_widget->context()) {
@@ -443,7 +452,7 @@ public:
break;
}
- glClear(GL_COLOR_BUFFER_BIT);
+ funcs->glClear(GL_COLOR_BUFFER_BIT);
int w = m_widget->width();
int h = m_widget->height();
@@ -451,7 +460,7 @@ public:
renderAScene(w, h);
int color;
- glReadPixels(w / 2, h / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &color);
+ funcs->glReadPixels(w / 2, h / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &color);
m_widget->swapBuffers();
}
diff --git a/tests/auto/other/compiler/compiler.pro b/tests/auto/other/compiler/compiler.pro
index 8ebcf60bc0..213429050f 100644
--- a/tests/auto/other/compiler/compiler.pro
+++ b/tests/auto/other/compiler/compiler.pro
@@ -1,9 +1,9 @@
CONFIG += testcase
TARGET = tst_compiler
-SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp
+SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp othersource.cpp
HEADERS += baseclass.h derivedclass.h
QT = core testlib
-
+contains(QT_CONFIG, c++11): CONFIG += c++14 c++11
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/other/compiler/othersource.cpp b/tests/auto/other/compiler/othersource.cpp
new file mode 100644
index 0000000000..6ff7c4d8a9
--- /dev/null
+++ b/tests/auto/other/compiler/othersource.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Intel Corporation.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+
+#ifdef Q_COMPILER_EXTERN_TEMPLATES
+template <typename T> T externTemplate();
+template<> int externTemplate<int>()
+{
+ return 42;
+}
+#endif
+
diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp
index a239e2c888..9ed5c64c4f 100644
--- a/tests/auto/other/compiler/tst_compiler.cpp
+++ b/tests/auto/other/compiler/tst_compiler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Intel Corporation
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -48,12 +49,17 @@
#include "baseclass.h"
#include "derivedclass.h"
+#ifdef Q_COMPILER_ATOMICS
+# include <atomic>
+#endif
+
QT_USE_NAMESPACE
class tst_Compiler : public QObject
{
Q_OBJECT
private slots:
+ /* C++98 & C++03 base functionality */
void template_methods();
void template_constructors();
void template_subclasses();
@@ -71,6 +77,57 @@ private slots:
void charSignedness() const;
void privateStaticTemplateMember() const;
void staticConstUnionWithInitializerList() const;
+ void templateFriends();
+
+ /* C++11 features */
+ void cxx11_alignas();
+ void cxx11_alignof();
+ void cxx11_alignas_alignof();
+ void cxx11_atomics();
+ void cxx11_attributes();
+ void cxx11_auto_function();
+ void cxx11_auto_type();
+ void cxx11_class_enum();
+ void cxx11_constexpr();
+ void cxx11_decltype();
+ void cxx11_default_members();
+ void cxx11_delete_members();
+ void cxx11_delegating_constructors();
+ void cxx11_explicit_conversions();
+ void cxx11_explicit_overrides();
+ void cxx11_extern_templates();
+ void cxx11_inheriting_constructors();
+ void cxx11_initializer_lists();
+ void cxx11_lambda();
+ void cxx11_nonstatic_member_init();
+ void cxx11_noexcept();
+ void cxx11_nullptr();
+ void cxx11_range_for();
+ void cxx11_raw_strings();
+ void cxx11_ref_qualifiers();
+ void cxx11_rvalue_refs();
+ void cxx11_static_assert();
+ void cxx11_template_alias();
+ void cxx11_thread_local();
+ void cxx11_udl();
+ void cxx11_unicode_strings();
+ void cxx11_uniform_init();
+ void cxx11_unrestricted_unions();
+ void cxx11_variadic_macros();
+ void cxx11_variadic_templates();
+
+ /* C++14 compiler features */
+ void cxx14_binary_literals();
+ void cxx14_init_captures();
+ void cxx14_generic_lambdas();
+ void cxx14_constexpr();
+ void cxx14_decltype_auto();
+ void cxx14_return_type_deduction();
+ void cxx14_aggregate_nsdmi();
+ void cxx14_variable_templates();
+
+ /* Future / Technical specification compiler features */
+ void runtimeArrays();
};
#if defined(Q_CC_HPACC)
@@ -556,5 +613,706 @@ void tst_Compiler::staticConstUnionWithInitializerList() const
QVERIFY(qIsInf(d));
}
+#ifndef Q_NO_TEMPLATE_FRIENDS
+template <typename T> class TemplateFriends
+{
+ T value;
+public:
+ TemplateFriends(T value) : value(value) {}
+
+ template <typename X> void copy(TemplateFriends<X> other)
+ { value = other.value; }
+
+ template <typename X> friend class TemplateFriends;
+};
+
+void tst_Compiler::templateFriends()
+{
+ TemplateFriends<int> ti(42);
+ TemplateFriends<long> tl(0);
+ tl.copy(ti);
+}
+#else
+void tst_Compiler::templateFriends()
+{
+ QSKIP("Compiler does not support template friends");
+}
+#endif
+
+void tst_Compiler::cxx11_alignas()
+{
+#ifndef Q_COMPILER_ALIGNAS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ alignas(double) char c;
+ QVERIFY(Q_ALIGNOF(c) == Q_ALIGNOF(double));
+#endif
+}
+
+void tst_Compiler::cxx11_alignof()
+{
+#ifndef Q_COMPILER_ALIGNOF
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ size_t alignchar = alignof(char);
+ size_t aligndouble = alignof(double);
+ QVERIFY(alignchar >= 1);
+ QVERIFY(alignchar <= aligndouble);
+#endif
+}
+
+void tst_Compiler::cxx11_alignas_alignof()
+{
+#if !defined(Q_COMPILER_ALIGNAS) && !defined(Q_COMPILER_ALIGNOF)
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ alignas(alignof(double)) char c;
+ Q_UNUSED(c);
+#endif
+}
+
+void tst_Compiler::cxx11_atomics()
+{
+#ifndef Q_COMPILER_ATOMICS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ std::atomic<int> i;
+ i.store(42, std::memory_order_seq_cst);
+ QCOMPARE(i.load(std::memory_order_acquire), 42);
+
+ std::atomic<short> s;
+ s.store(42);
+ QCOMPARE(s.load(), short(42));
+
+ std::atomic_flag flag;
+ flag.clear();
+ QVERIFY(!flag.test_and_set());
+ QVERIFY(flag.test_and_set());
+#endif
+}
+
+void tst_Compiler::cxx11_attributes()
+{
+#ifndef Q_COMPILER_ATTRIBUTES
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct [[deprecated]] C {};
+ [[gnu::unused]] struct D {} d;
+ [[noreturn]] void f();
+ struct D e [[gnu::used, gnu::unused]];
+ [[gnu::aligned(8)]] int i;
+
+[[gnu::unused]] end:
+ ;
+
+ Q_UNUSED(d);
+ Q_UNUSED(e);
+ Q_UNUSED(i);
+#endif
+}
+
+#ifdef Q_COMPILER_AUTO_FUNCTION
+auto autoFunction() -> unsigned
+{
+ return 1;
+}
+#endif
+
+void tst_Compiler::cxx11_auto_function()
+{
+#ifndef Q_COMPILER_AUTO_FUNCTION
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ QCOMPARE(autoFunction(), 1u);
+#endif
+}
+
+void tst_Compiler::cxx11_auto_type()
+{
+#ifndef Q_COMPILER_AUTO_TYPE
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ auto i = 1;
+ auto x = qrand();
+ auto l = 1L;
+ auto s = QStringLiteral("Hello World");
+
+ QCOMPARE(i, 1);
+ Q_UNUSED(x);
+ QCOMPARE(l, 1L);
+ QCOMPARE(s.toLower(), QString("hello world"));
+#endif
+}
+
+void tst_Compiler::cxx11_class_enum()
+{
+#ifndef Q_COMPILER_CLASS_ENUM
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ enum class X { EnumValue };
+ X x = X::EnumValue;
+ QCOMPARE(x, X::EnumValue);
+
+ enum class Y : short { Val = 2 };
+ enum Z : long { ValLong = LONG_MAX };
+#endif
+}
+
+#ifdef Q_COMPILER_CONSTEXPR
+constexpr int constexprValue()
+{
+ return 42;
+}
+#endif
+
+void tst_Compiler::cxx11_constexpr()
+{
+#ifndef Q_COMPILER_CONSTEXPR
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ static constexpr QBasicAtomicInt atomic = Q_BASIC_ATOMIC_INITIALIZER(1);
+ static constexpr int i = constexprValue();
+ QCOMPARE(i, constexprValue());
+ QCOMPARE(atomic.load(), 1);
+#endif
+}
+
+void tst_Compiler::cxx11_decltype()
+{
+#ifndef Q_COMPILER_DECLTYPE
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ decltype(qrand()) i = 0;
+ QCOMPARE(i, 0);
+#endif
+}
+
+void tst_Compiler::cxx11_default_members()
+{
+#ifndef Q_COMPILER_DEFAULT_MEMBERS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct DefaultMembers
+ {
+ DefaultMembers() = default;
+ DefaultMembers(int) {}
+ };
+ DefaultMembers dm;
+ Q_UNUSED(dm);
+#endif
+}
+
+void tst_Compiler::cxx11_delete_members()
+{
+#ifndef Q_COMPILER_DELETE_MEMBERS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct DeleteMembers
+ {
+ DeleteMembers() = delete;
+ DeleteMembers(const DeleteMembers &) = delete;
+ ~DeleteMembers() = delete;
+ };
+#endif
+}
+
+void tst_Compiler::cxx11_delegating_constructors()
+{
+#ifndef Q_COMPILER_DELEGATING_CONSTRUCTORS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct DC {
+ DC(int i) : i(i) {}
+ DC() : DC(0) {}
+ int i;
+ };
+
+ DC dc;
+ QCOMPARE(dc.i, 0);
+#endif
+}
+
+void tst_Compiler::cxx11_explicit_conversions()
+{
+#ifndef Q_COMPILER_EXPLICIT_CONVERSIONS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct EC {
+ explicit operator int() const { return 0; }
+ operator long long() const { return 1; }
+ };
+ EC ec;
+
+ int i(ec);
+ QCOMPARE(i, 0);
+
+ int i2 = ec;
+ QCOMPARE(i2, 1);
+#endif
+}
+
+void tst_Compiler::cxx11_explicit_overrides()
+{
+#ifndef Q_COMPILER_EXPLICIT_OVERRIDES
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct Base {
+ virtual ~Base() {}
+ virtual void f() {}
+ };
+ struct Derived final : public Base {
+ virtual void f() final override {}
+ };
+#endif
+}
+
+#ifdef Q_COMPILER_EXTERN_TEMPLATES
+template <typename T> T externTemplate() { return T(0); }
+extern template int externTemplate<int>();
+#endif
+
+void tst_Compiler::cxx11_extern_templates()
+{
+#ifndef Q_COMPILER_EXTERN_TEMPLATES
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ QCOMPARE(externTemplate<int>(), 42);
+#endif
+}
+
+void tst_Compiler::cxx11_inheriting_constructors()
+{
+#ifndef Q_COMPILER_INHERITING_CONSTRUCTORS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct Base {
+ int i;
+ Base() : i(0) {}
+ Base(int i) : i(i) {}
+ };
+ struct Derived : public Base {
+ using Base::Base;
+ };
+
+ Derived d(1);
+ QCOMPARE(d.i, 1);
+#endif
+}
+
+void tst_Compiler::cxx11_initializer_lists()
+{
+#ifndef Q_COMPILER_INITIALIZER_LISTS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ QList<int> l = { 1, 2, 3, 4, 5 };
+ QCOMPARE(l.length(), 5);
+ QCOMPARE(l.at(0), 1);
+ QCOMPARE(l.at(4), 5);
+#endif
+}
+
+struct CallFunctor
+{
+ template <typename Functor> static int f(Functor f)
+ { return f();}
+};
+
+void tst_Compiler::cxx11_lambda()
+{
+#ifndef Q_COMPILER_LAMBDA
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ QCOMPARE(CallFunctor::f([]() { return 42; }), 42);
+#endif
+}
+
+void tst_Compiler::cxx11_nonstatic_member_init()
+{
+#ifndef Q_COMPILER_NONSTATIC_MEMBER_INIT
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ struct S {
+ int i = 42;
+ long l = 47;
+ char c;
+ S() : l(-47), c(0) {}
+ };
+ S s;
+
+ QCOMPARE(s.i, 42);
+ QCOMPARE(s.l, -47L);
+ QCOMPARE(s.c, '\0');
+#endif
+}
+
+void tst_Compiler::cxx11_noexcept()
+{
+#ifndef Q_COMPILER_NOEXCEPT
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ extern void noexcept_f() noexcept;
+ extern void g() noexcept(noexcept(noexcept_f()));
+ QCOMPARE(noexcept(cxx11_noexcept()), false);
+ QCOMPARE(noexcept(noexcept_f), true);
+ QCOMPARE(noexcept(g), true);
+#endif
+}
+
+void tst_Compiler::cxx11_nullptr()
+{
+#ifndef Q_COMPILER_NULLPTR
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ void *v = nullptr;
+ char *c = nullptr;
+ const char *cc = nullptr;
+ volatile char *vc = nullptr;
+ std::nullptr_t np = nullptr;
+ v = np;
+
+ Q_UNUSED(v);
+ Q_UNUSED(c);
+ Q_UNUSED(cc);
+ Q_UNUSED(vc);
+#endif
+}
+
+void tst_Compiler::cxx11_range_for()
+{
+#ifndef Q_COMPILER_RANGE_FOR
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ QList<int> l;
+ l << 1 << 2 << 3;
+ for (int i : l)
+ Q_UNUSED(i);
+
+ l.clear();
+ l << 1;
+ for (int i : l)
+ QCOMPARE(i, 1);
+
+ QList<long> ll;
+ l << 2;
+ for (int i : ll)
+ QCOMPARE(i, 2);
+#endif
+}
+
+void tst_Compiler::cxx11_raw_strings()
+{
+#ifndef Q_COMPILER_RAW_STRINGS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ static const char xml[] = R"(<?xml version="1.0" encoding="UTF-8" ?>)";
+ static const char raw[] = R"***(*"*)***";
+ QCOMPARE(strlen(raw), size_t(3));
+ QCOMPARE(raw[1], '"');
+ Q_UNUSED(xml);
+#endif
+}
+
+void tst_Compiler::cxx11_ref_qualifiers()
+{
+#ifndef Q_COMPILER_REF_QUALIFIERS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+# ifndef Q_COMPILER_RVALUE_REFS
+# error "Impossible condition: ref qualifiers are supported but not rvalue refs"
+# endif
+ // also applies to function pointers
+ QByteArray (QString:: *lvalueref)() const & = &QString::toLatin1;
+ QByteArray (QString:: *rvalueref)() && = &QString::toLatin1;
+
+ QString s("Hello");
+ QCOMPARE((s.*lvalueref)(), QByteArray("Hello"));
+ QCOMPARE((std::move(s).*rvalueref)(), QByteArray("Hello"));
+
+ // tests internal behavior:
+ QVERIFY(s.isEmpty());
+#endif
+}
+
+void tst_Compiler::cxx11_rvalue_refs()
+{
+#ifndef Q_COMPILER_RVALUE_REFS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ int i = 1;
+ i = std::move(i);
+
+ QString s = "Hello";
+ QString t = std::move(s);
+ QCOMPARE(t, QString("Hello"));
+
+ s = t;
+ t = std::move(s);
+ QCOMPARE(t, QString("Hello"));
+
+ QString &&r = std::move(s);
+ QCOMPARE(r, QString("Hello"));
+#endif
+}
+
+void tst_Compiler::cxx11_static_assert()
+{
+#ifndef Q_COMPILER_STATIC_ASSERT
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ static_assert(true, "Message");
+#endif
+}
+
+#ifdef Q_COMPILER_TEMPLATE_ALIAS
+template <typename T> using Map = QMap<QString, T>;
+#endif
+
+void tst_Compiler::cxx11_template_alias()
+{
+#ifndef Q_COMPILER_TEMPLATE_ALIAS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ Map<QVariant> m;
+ m.insert("Hello", "World");
+ QCOMPARE(m.value("Hello").toString(), QString("World"));
+
+ using X = int;
+ X i = 0;
+ Q_UNUSED(i);
+#endif
+}
+
+#ifdef Q_COMPILER_THREAD_LOCAL
+static thread_local int stl = 42;
+thread_local int gtl = 42;
+#endif
+
+void tst_Compiler::cxx11_thread_local()
+{
+#ifndef Q_COMPILER_THREAD_LOCAL
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ thread_local int v = 1;
+ QVERIFY(v);
+ QVERIFY(stl);
+ QVERIFY(gtl);
+
+ thread_local QString s = "Hello";
+ QVERIFY(!s.isEmpty());
+#endif
+}
+
+#ifdef Q_COMPILER_UDL
+QString operator"" _tstqstring(const char *str, size_t len)
+{
+ return QString::fromUtf8(str, len) + " UDL";
+}
+#endif
+
+void tst_Compiler::cxx11_udl()
+{
+#ifndef Q_COMPILER_UDL
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ QString s = "Hello World"_tstqstring;
+ QCOMPARE(s, QString("Hello World UDL"));
+#endif
+}
+
+void tst_Compiler::cxx11_unicode_strings()
+{
+#ifndef Q_COMPILER_UNICODE_STRINGS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ static const char16_t u[] = u"\u200BHello\u00A0World";
+ QCOMPARE(u[0], char16_t(0x200B));
+
+ static const char32_t U[] = U"\ufffe";
+ QCOMPARE(U[0], char32_t(0xfffe));
+
+ QCOMPARE(u"\U00010000"[0], char16_t(0xD800));
+ QCOMPARE(u"\U00010000"[1], char16_t(0xDC00));
+#endif
+}
+
+static void noop(QPair<int, int>) {}
+void tst_Compiler::cxx11_uniform_init()
+{
+#ifndef Q_COMPILER_UNIFORM_INIT
+ QSKIP("Compiler does not support C++11 feature");
+ noop(QPair<int,int>());
+#else
+ QString s{"Hello"};
+ int i{};
+ noop(QPair<int,int>{1,1});
+ noop({i,1});
+#endif
+}
+
+void tst_Compiler::cxx11_unrestricted_unions()
+{
+#ifndef Q_COMPILER_UNRESTRICTED_UNIONS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ union U {
+ QString s;
+ U() {}
+ U(const QString &s) : s(s) {}
+ ~U() {}
+ };
+ U u;
+ std::aligned_storage<sizeof(QString), Q_ALIGNOF(QString)> as;
+ Q_UNUSED(u);
+ Q_UNUSED(as);
+
+ U u2("hello");
+ u2.s.~QString();
+#endif
+}
+
+void tst_Compiler::cxx11_variadic_macros()
+{
+#ifndef Q_COMPILER_VARIADIC_MACROS
+ QSKIP("Compiler does not support C++11 feature");
+#else
+# define TEST_VARARG(x, ...) __VA_ARGS__
+ QCOMPARE(TEST_VARARG(0, 1), 1);
+#endif
+}
+
+#ifdef Q_COMPILER_VARIADIC_TEMPLATES
+template <typename... Args> struct VariadicTemplate {};
+#endif
+
+void tst_Compiler::cxx11_variadic_templates()
+{
+#ifndef Q_COMPILER_VARIADIC_TEMPLATES
+ QSKIP("Compiler does not support C++11 feature");
+#else
+ VariadicTemplate<> v0;
+ VariadicTemplate<int> v1;
+ VariadicTemplate<int, int, int, int,
+ int, int, int, int> v8;
+ Q_UNUSED(v0);
+ Q_UNUSED(v1);
+ Q_UNUSED(v8);
+#endif
+}
+
+void tst_Compiler::cxx14_binary_literals()
+{
+#if __cpp_binary_literals-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ int i = 0b11001001;
+ QCOMPARE(i, 0xC9);
+#endif
+}
+
+void tst_Compiler::cxx14_init_captures()
+{
+#if __cpp_init_captures-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ QCOMPARE([x = 42]() { return x; }(), 42);
+#endif
+}
+
+void tst_Compiler::cxx14_generic_lambdas()
+{
+#if __cpp_generic_lambdas-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ auto identity = [](auto x) { return x; };
+ QCOMPARE(identity(42), 42);
+ QCOMPARE(identity(42U), 42U);
+ QCOMPARE(identity(42L), 42L);
+#endif
+}
+
+#if __cpp_constexpr-0 >= 201304
+constexpr int relaxedConstexpr(int i)
+{
+ i *= 2;
+ i += 2;
+ return i;
+}
+#endif
+
+void tst_Compiler::cxx14_constexpr()
+{
+#if __cpp_constexpr-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ QCOMPARE(relaxedConstexpr(0), 2);
+ QCOMPARE(relaxedConstexpr(2), 6);
+#endif
+}
+
+void tst_Compiler::cxx14_decltype_auto()
+{
+#if __cpp_decltype_auto-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ QList<int> l;
+ l << 1;
+ decltype(auto) value = l[0];
+ value = 2;
+ QCOMPARE(l.at(0), 2);
+#endif
+}
+
+#if __cpp_return_type_deduction >= 201304
+auto returnTypeDeduction()
+{
+ return 1U;
+}
+#endif
+
+void tst_Compiler::cxx14_return_type_deduction()
+{
+#if __cpp_return_type_deduction-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ QCOMPARE(returnTypeDeduction(), 1U);
+#endif
+}
+
+void tst_Compiler::cxx14_aggregate_nsdmi()
+{
+#if __cpp_aggregate_nsdmi-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ struct S { int i, j = i; };
+ S s = { 1 };
+ QCOMPARE(s.j, 1);
+#endif
+}
+
+#if __cpp_variable_templates >= 201304
+template <typename T> constexpr T variableTemplate = T(42);
+#endif
+void tst_Compiler::cxx14_variable_templates()
+{
+#if __cpp_variable_templates-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ QCOMPARE(variableTemplate<int>, 42);
+ QCOMPARE(variableTemplate<long>, 42L);
+ QCOMPARE(variableTemplate<unsigned>, 42U);
+ QCOMPARE(variableTemplate<unsigned long long>, 42ULL);
+#endif
+}
+
+void tst_Compiler::runtimeArrays()
+{
+#if __cpp_runtime_arrays-0 < 201304
+ QSKIP("Compiler does not support this C++14 feature");
+#else
+ int i[qrand() & 0x1f];
+ Q_UNUSED(i);
+#endif
+}
+
QTEST_MAIN(tst_Compiler)
#include "tst_compiler.moc"
diff --git a/tests/auto/other/lancelot/scripts/text.qps b/tests/auto/other/lancelot/scripts/text.qps
index e7d47448ea..b3d8475411 100644
--- a/tests/auto/other/lancelot/scripts/text.qps
+++ b/tests/auto/other/lancelot/scripts/text.qps
@@ -11,7 +11,7 @@ save
setFont "sansserif" 12 normal
drawText 0 40 "sansserif 12pt, normal"
- setFont "sansserif" 10 bold
+ setFont "sansserif" 12 bold
drawText 0 60 "sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
@@ -27,7 +27,7 @@ save
setFont "sansserif" 12 normal
drawText 0 40 "alpha sansserif 12pt, normal"
- setFont "sansserif" 10 bold
+ setFont "sansserif" 12 bold
drawText 0 60 "alpha sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
@@ -45,7 +45,7 @@ save
setFont "sansserif" 12 normal
drawText 0 40 "scaled sansserif 12pt, normal"
- setFont "sansserif" 10 bold
+ setFont "sansserif" 12 bold
drawText 0 60 "scaled sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
@@ -63,7 +63,7 @@ save
setFont "sansserif" 12 normal
drawStaticText 0 40 "flipped sansserif 12pt, normal"
- setFont "sansserif" 10 bold
+ setFont "sansserif" 12 bold
drawStaticText 0 60 "flipped sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
@@ -82,7 +82,7 @@ save
setFont "sansserif" 12 normal
drawText 0 40 "scaled sansserif 12pt, normal"
- setFont "sansserif" 10 bold
+ setFont "sansserif" 12 bold
drawText 0 60 "scaled sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
@@ -102,7 +102,7 @@ save
setFont "sansserif" 12 normal
drawText 0 20 "gradient sansserif 12pt, normal"
- setFont "sansserif" 10 bold
+ setFont "sansserif" 12 bold
drawText 0 40 "gradient sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index 407237e519..745c8f2499 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -2,7 +2,6 @@ TEMPLATE=subdirs
SUBDIRS=\
# atwrapper \ # QTBUG-19452
baselineexample \
- collections \
compiler \
d3dcompiler \
gestures \
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 8b033efa4a..c9df497b07 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -243,6 +243,7 @@ private slots:
void statesStructTest();
void navigateHierarchy();
void sliderTest();
+ void textAttributes_data();
void textAttributes();
void hideShowTest();
@@ -250,6 +251,7 @@ private slots:
void applicationTest();
void mainWindowTest();
+ void subWindowTest();
void buttonTest();
void scrollBarTest();
void tabTest();
@@ -698,58 +700,118 @@ void tst_QAccessibility::accessibleName()
QTestAccessibility::clearEvents();
}
-void tst_QAccessibility::textAttributes()
+// note: color should probably always be part of the attributes
+void tst_QAccessibility::textAttributes_data()
{
- QTextEdit textEdit;
- int startOffset;
- int endOffset;
- QString attributes;
- QString text("<html><head></head><body>"
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<int>("offset");
+ QTest::addColumn<int>("startOffsetResult");
+ QTest::addColumn<int>("endOffsetResult");
+ QTest::addColumn<QStringList>("attributeResult");
+
+ static QStringList defaults = QString("font-style:normal;font-weight:normal;text-align:left;text-position:baseline;text-underline-style:none").split(';');
+ static QStringList bold = defaults;
+ bold[1] = QString::fromLatin1("font-weight:bold");
+
+ static QStringList italic = defaults;
+ italic[0] = QString::fromLatin1("font-style:italic");
+
+ static QStringList boldItalic = defaults;
+ boldItalic[0] = QString::fromLatin1("font-style:italic");
+ boldItalic[1] = QString::fromLatin1("font-weight:bold");
+
+ static QStringList monospace = defaults;
+ monospace.append(QLatin1String("font-family:\"monospace\""));
+
+ static QStringList font8pt = defaults;
+ font8pt.append(QLatin1String("font-size:8pt"));
+
+ static QStringList color = defaults;
+ color << QLatin1String("color:rgb(240,241,242)") << QLatin1String("background-color:rgb(20,240,30)");
+
+ static QStringList rightAlign = defaults;
+ rightAlign[2] = QStringLiteral("text-align:right");
+
+ QTest::newRow("defaults 1") << "hello" << 0 << 0 << 5 << defaults;
+ QTest::newRow("defaults 2") << "hello" << 1 << 0 << 5 << defaults;
+ QTest::newRow("defaults 3") << "hello" << 4 << 0 << 5 << defaults;
+ QTest::newRow("defaults 4") << "hello" << 5 << 0 << 5 << defaults;
+ QTest::newRow("offset -1 length") << "hello" << -1 << 0 << 5 << defaults;
+ QTest::newRow("offset -2 cursor pos") << "hello" << -2 << 0 << 5 << defaults;
+ QTest::newRow("offset -3") << "hello" << -3 << -1 << -1 << QStringList();
+ QTest::newRow("invalid offset 2") << "hello" << 6 << -1 << -1 << QStringList();
+ QTest::newRow("invalid offset 3") << "" << 1 << -1 << -1 << QStringList();
+
+ QString boldText = QLatin1String("<html><b>bold</b>text");
+ QTest::newRow("bold 0") << boldText << 0 << 0 << 4 << bold;
+ QTest::newRow("bold 2") << boldText << 2 << 0 << 4 << bold;
+ QTest::newRow("bold 3") << boldText << 3 << 0 << 4 << bold;
+ QTest::newRow("bold 4") << boldText << 4 << 4 << 8 << defaults;
+ QTest::newRow("bold 6") << boldText << 6 << 4 << 8 << defaults;
+
+ QString longText = QLatin1String("<html>"
"Hello, <b>this</b> is an <i><b>example</b> text</i>."
"<span style=\"font-family: monospace\">Multiple fonts are used.</span>"
"Multiple <span style=\"font-size: 8pt\">text sizes</span> are used."
- "Let's give some color to <span style=\"color:#f0f1f2; background-color:#14f01e\">Qt</span>."
- "</body></html>");
+ "Let's give some color to <span style=\"color:#f0f1f2; background-color:#14f01e\">Qt</span>.");
+
+ QTest::newRow("default 5") << longText << 6 << 0 << 7 << defaults;
+ QTest::newRow("default 6") << longText << 7 << 7 << 11 << bold;
+ QTest::newRow("bold 7") << longText << 10 << 7 << 11 << bold;
+ QTest::newRow("bold 8") << longText << 10 << 7 << 11 << bold;
+ QTest::newRow("bold italic") << longText << 18 << 18 << 25 << boldItalic;
+ QTest::newRow("monospace") << longText << 34 << 31 << 55 << monospace;
+ QTest::newRow("8pt") << longText << 65 << 64 << 74 << font8pt;
+ QTest::newRow("color") << longText << 110 << 109 << 111 << color;
+
+ QString rightAligned = QLatin1String("<html><p align=\"right\">right</p>");
+ QTest::newRow("right aligned 1") << rightAligned << 0 << 0 << 5 << rightAlign;
+ QTest::newRow("right aligned 2") << rightAligned << 1 << 0 << 5 << rightAlign;
+ QTest::newRow("right aligned 3") << rightAligned << 5 << 0 << 5 << rightAlign;
+
+ // left \n right \n left, make sure bold and alignment borders coincide
+ QString leftRightLeftAligned = QLatin1String("<html><p><b>left</b></p><p align=\"right\">right</p><p><b>left</b></p>");
+ QTest::newRow("left right left aligned 1") << leftRightLeftAligned << 1 << 0 << 4 << bold;
+ QTest::newRow("left right left aligned 3") << leftRightLeftAligned << 3 << 0 << 4 << bold;
+ QTest::newRow("left right left aligned 4") << leftRightLeftAligned << 4 << 4 << 5 << defaults;
+ QTest::newRow("left right left aligned 5") << leftRightLeftAligned << 5 << 5 << 10 << rightAlign;
+ QTest::newRow("left right left aligned 8") << leftRightLeftAligned << 8 << 5 << 10 << rightAlign;
+ QTest::newRow("left right left aligned 9") << leftRightLeftAligned << 9 << 5 << 10 << rightAlign;
+ QTest::newRow("left right left aligned 10") << leftRightLeftAligned << 10 << 10 << 11 << rightAlign;
+ QTest::newRow("left right left aligned 11") << leftRightLeftAligned << 11 << 11 << 15 << bold;
+ QTest::newRow("left right left aligned 15") << leftRightLeftAligned << 15 << 11 << 15 << bold;
+}
+
+void tst_QAccessibility::textAttributes()
+{
+ {
+ QFETCH(QString, text);
+ QFETCH(int, offset);
+ QFETCH(int, startOffsetResult);
+ QFETCH(int, endOffsetResult);
+ QFETCH(QStringList, attributeResult);
+ QTextEdit textEdit;
textEdit.setText(text);
+ if (textEdit.document()->characterCount() > 1)
+ textEdit.textCursor().setPosition(1);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit);
-
QAccessibleTextInterface *textInterface=interface->textInterface();
-
QVERIFY(textInterface);
- QCOMPARE(textInterface->characterCount(), 112);
+ QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().length());
- attributes = textInterface->attributes(10, &startOffset, &endOffset);
- QCOMPARE(startOffset, 7);
- QCOMPARE(endOffset, 11);
- attributes.prepend(';');
- QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;")));
-
- attributes = textInterface->attributes(18, &startOffset, &endOffset);
- QCOMPARE(startOffset, 18);
- QCOMPARE(endOffset, 25);
- attributes.prepend(';');
- QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;")));
- QVERIFY(attributes.contains(QLatin1String(";font-style:italic;")));
-
- attributes = textInterface->attributes(34, &startOffset, &endOffset);
- QCOMPARE(startOffset, 31);
- QCOMPARE(endOffset, 55);
- attributes.prepend(';');
- QVERIFY(attributes.contains(QLatin1String(";font-family:\"monospace\";")));
-
- attributes = textInterface->attributes(65, &startOffset, &endOffset);
- QCOMPARE(startOffset, 64);
- QCOMPARE(endOffset, 74);
- attributes.prepend(';');
- QVERIFY(attributes.contains(QLatin1String(";font-size:8pt;")));
-
- attributes = textInterface->attributes(110, &startOffset, &endOffset);
- QCOMPARE(startOffset, 109);
- QCOMPARE(endOffset, 111);
- attributes.prepend(';');
- QVERIFY(attributes.contains(QLatin1String(";background-color:rgb(20,240,30);")));
- QVERIFY(attributes.contains(QLatin1String(";color:rgb(240,241,242);")));
+ int startOffset = -1;
+ int endOffset = -1;
+ QString attributes = textInterface->attributes(offset, &startOffset, &endOffset);
+
+ QCOMPARE(startOffset, startOffsetResult);
+ QCOMPARE(endOffset, endOffsetResult);
+ QStringList attrList = attributes.split(QChar(';'), QString::SkipEmptyParts);
+ attributeResult.sort();
+ attrList.sort();
+ QCOMPARE(attrList, attributeResult);
+ }
+ QTestAccessibility::clearEvents();
}
void tst_QAccessibility::hideShowTest()
@@ -942,6 +1004,66 @@ void tst_QAccessibility::mainWindowTest()
}
}
+// Dialogs and other sub-windows must appear in the
+// accessibility hierarchy exactly once as top level objects
+void tst_QAccessibility::subWindowTest()
+{
+ {
+ QWidget mainWidget;
+ mainWidget.setGeometry(100, 100, 100, 100);
+ mainWidget.show();
+ QLabel label(QStringLiteral("Window Contents"), &mainWidget);
+ mainWidget.setLayout(new QHBoxLayout());
+ mainWidget.layout()->addWidget(&label);
+
+ QDialog d(&mainWidget);
+ d.show();
+
+ QAccessibleInterface *app = QAccessible::queryAccessibleInterface(qApp);
+ QVERIFY(app);
+ QCOMPARE(app->childCount(), 2);
+
+ QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(&mainWidget);
+ QVERIFY(windowIface);
+ QCOMPARE(windowIface->childCount(), 1);
+ QCOMPARE(app->child(0), windowIface);
+ QCOMPARE(windowIface->parent(), app);
+
+ QAccessibleInterface *dialogIface = QAccessible::queryAccessibleInterface(&d);
+ QVERIFY(dialogIface);
+ QCOMPARE(app->child(1), dialogIface);
+ QCOMPARE(dialogIface->parent(), app);
+ QCOMPARE(dialogIface->parent(), app);
+ }
+
+ {
+ QMainWindow mainWindow;
+ mainWindow.setGeometry(100, 100, 100, 100);
+ mainWindow.show();
+ QLabel label(QStringLiteral("Window Contents"), &mainWindow);
+ mainWindow.setCentralWidget(&label);
+
+ QDialog d(&mainWindow);
+ d.show();
+
+ QAccessibleInterface *app = QAccessible::queryAccessibleInterface(qApp);
+ QVERIFY(app);
+ QCOMPARE(app->childCount(), 2);
+
+ QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(&mainWindow);
+ QVERIFY(windowIface);
+ QCOMPARE(windowIface->childCount(), 1);
+ QCOMPARE(app->child(0), windowIface);
+
+ QAccessibleInterface *dialogIface = QAccessible::queryAccessibleInterface(&d);
+ QVERIFY(dialogIface);
+ QCOMPARE(app->child(1), dialogIface);
+ QCOMPARE(dialogIface->parent(), app);
+ QCOMPARE(windowIface->parent(), app);
+ }
+ QTestAccessibility::clearEvents();
+}
+
class CounterButton : public QPushButton {
Q_OBJECT
public:
@@ -1191,8 +1313,11 @@ void tst_QAccessibility::tabTest()
QVERIFY(leftButton->state().invisible);
const int lots = 5;
- for (int i = 0; i < lots; ++i)
+ for (int i = 0; i < lots; ++i) {
tabBar->addTab("Foo");
+ tabBar->setTabToolTip(i, QLatin1String("Cool tool tip"));
+ tabBar->setTabWhatsThis(i, QLatin1String("I don't know"));
+ }
QAccessibleInterface *child1 = interface->child(0);
QAccessibleInterface *child2 = interface->child(1);
@@ -1201,6 +1326,10 @@ void tst_QAccessibility::tabTest()
QVERIFY(child2);
QCOMPARE(child2->role(), QAccessible::PageTab);
+ QCOMPARE(child1->text(QAccessible::Name), QLatin1String("Foo"));
+ QCOMPARE(child1->text(QAccessible::Description), QLatin1String("Cool tool tip"));
+ QCOMPARE(child1->text(QAccessible::Help), QLatin1String("I don't know"));
+
QVERIFY((child1->state().invisible) == false);
tabBar->hide();
@@ -1652,6 +1781,11 @@ void tst_QAccessibility::textEditTest()
QTest::qWaitForWindowShown(&edit);
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&edit);
QCOMPARE(iface->text(QAccessible::Value), edit.toPlainText());
+ QVERIFY(iface->state().focusable);
+ QVERIFY(!iface->state().selectable);
+ QVERIFY(!iface->state().selected);
+ QVERIFY(iface->state().selectableText);
+
QAccessibleTextInterface *textIface = iface->textInterface();
QVERIFY(textIface);
@@ -1751,8 +1885,6 @@ void tst_QAccessibility::textEditTest()
QAccessibleTextRemoveEvent remove(&edit, 0, " ");
QVERIFY_EVENT(&remove);
- // FIXME the new text is not there yet
- QEXPECT_FAIL("", "Inserting should always contain the new text", Continue);
QAccessibleTextInsertEvent insert(&edit, 0, "Accessibility rocks");
QVERIFY_EVENT(&insert);
}
@@ -1929,7 +2061,8 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(iface->state().sizeable);
QVERIFY(iface->state().movable);
QVERIFY(iface->state().focusable);
- QVERIFY(iface->state().selectable);
+ QVERIFY(!iface->state().selectable);
+ QVERIFY(iface->state().selectableText);
QVERIFY(!iface->state().hasPopup);
QCOMPARE(bool(iface->state().focused), le->hasFocus());
@@ -1940,13 +2073,13 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(iface->text(QAccessible::Value), secret);
le->setEchoMode(QLineEdit::NoEcho);
QVERIFY(iface->state().passwordEdit);
- QVERIFY(iface->text(QAccessible::Value).isEmpty());
+ QCOMPARE(iface->text(QAccessible::Value), QString());
le->setEchoMode(QLineEdit::Password);
QVERIFY(iface->state().passwordEdit);
- QVERIFY(iface->text(QAccessible::Value).isEmpty());
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::PasswordEchoOnEdit);
QVERIFY(iface->state().passwordEdit);
- QVERIFY(iface->text(QAccessible::Value).isEmpty());
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::Normal);
QVERIFY(!(iface->state().passwordEdit));
QCOMPARE(iface->text(QAccessible::Value), secret);
@@ -1957,7 +2090,9 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(!(iface->state().sizeable));
QVERIFY(!(iface->state().movable));
QVERIFY(iface->state().focusable);
- QVERIFY(iface->state().selectable);
+ QVERIFY(!iface->state().selectable);
+ QVERIFY(!iface->state().selected);
+ QVERIFY(iface->state().selectableText);
QVERIFY(!iface->state().hasPopup);
QCOMPARE(bool(iface->state().focused), le->hasFocus());
diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
index 50bf342365..4ff90e85cc 100644
--- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -47,6 +47,7 @@
#include <QtWidgets/QListWidget>
#include <QtWidgets/QTreeWidget>
#include <QtWidgets/QTextEdit>
+#include <QtWidgets/QPushButton>
#include <QDBusArgument>
#include <QDBusConnection>
@@ -102,6 +103,7 @@ private slots:
void testTreeWidget();
void testTextEdit();
void testSlider();
+ void testFocus();
void cleanupTestCase();
@@ -421,14 +423,22 @@ void tst_QAccessibilityLinux::testTextEdit()
QCOMPARE(callResult.at(2).toInt(), 17);
// Check if at least CharacterExtents and RangeExtents give a consistent result
- QDBusReply<QRect> replyRect20 = textInterface->call(QDBus::Block, "GetCharacterExtents", 20, ATSPI_COORD_TYPE_SCREEN);
- QVERIFY(replyRect20.isValid());
- QRect r1 = replyRect20.value();
- QDBusReply<QRect> replyRect21 = textInterface->call(QDBus::Block, "GetCharacterExtents", 21, ATSPI_COORD_TYPE_SCREEN);
- QRect r2 = replyRect21.value();
- QDBusReply<QRect> reply = textInterface->call(QDBus::Block, "GetRangeExtents", 20, 21, ATSPI_COORD_TYPE_SCREEN);
- QRect rect = reply.value();
- QCOMPARE(rect, r1|r2);
+
+ QDBusMessage replyRect20 = textInterface->call(QDBus::Block, "GetCharacterExtents", 20, ATSPI_COORD_TYPE_SCREEN);
+ QCOMPARE(replyRect20.type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(replyRect20.signature(), QStringLiteral("iiii"));
+ callResult = replyRect20.arguments();
+ QRect r1 = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt());
+ QDBusMessage replyRect21 = textInterface->call(QDBus::Block, "GetCharacterExtents", 21, ATSPI_COORD_TYPE_SCREEN);
+ QCOMPARE(replyRect21.type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(replyRect21.signature(), QStringLiteral("iiii"));
+ callResult = replyRect21.arguments();
+ QRect r2 = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt());
+
+ QDBusMessage replyRange = textInterface->call(QDBus::Block, "GetRangeExtents", 20, 21, ATSPI_COORD_TYPE_SCREEN);
+ callResult = replyRange.arguments();
+ QRect rectRangeExtents = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt());
+ QCOMPARE(rectRangeExtents, r1|r2);
m_window->clearChildren();
delete textInterface;
@@ -457,6 +467,54 @@ void tst_QAccessibilityLinux::testSlider()
QCOMPARE(valueInterface->property("CurrentValue").toInt(), 4);
}
+quint64 getAtspiState(QDBusInterface *interface)
+{
+ QDBusMessage msg = interface->call(QDBus::Block, "GetState");
+ const QDBusArgument arg = msg.arguments().at(0).value<QDBusArgument>();
+ quint32 state1 = 0;
+ quint64 state2 = 0;
+ arg.beginArray();
+ arg >> state1;
+ arg >> state2;
+ arg.endArray();
+
+ state2 = state2 << 32;
+ return state2 | state1;
+}
+
+void tst_QAccessibilityLinux::testFocus()
+{
+ QLineEdit *lineEdit1 = new QLineEdit(m_window);
+ lineEdit1->setText("lineEdit 1");
+ QLineEdit *lineEdit2 = new QLineEdit(m_window);
+ lineEdit2->setText("lineEdit 2");
+
+ m_window->addWidget(lineEdit1);
+ m_window->addWidget(lineEdit2);
+ lineEdit1->setFocus();
+
+ QStringList children = getChildren(mainWindow);
+ QCOMPARE(children.length(), 2);
+ QDBusInterface *accessibleInterfaceLineEdit1 = getInterface(children.at(0), "org.a11y.atspi.Accessible");
+ QVERIFY(accessibleInterfaceLineEdit1->isValid());
+ QDBusInterface *accessibleInterfaceLineEdit2 = getInterface(children.at(1), "org.a11y.atspi.Accessible");
+ QVERIFY(accessibleInterfaceLineEdit2->isValid());
+ QDBusInterface *componentInterfaceLineEdit1 = getInterface(children.at(0), "org.a11y.atspi.Component");
+ QVERIFY(componentInterfaceLineEdit1->isValid());
+ QDBusInterface *componentInterfaceLineEdit2 = getInterface(children.at(1), "org.a11y.atspi.Component");
+ QVERIFY(componentInterfaceLineEdit2->isValid());
+
+ quint64 focusedState = quint64(1) << ATSPI_STATE_FOCUSED;
+ QVERIFY(getAtspiState(accessibleInterfaceLineEdit1) & focusedState);
+ QVERIFY(!(getAtspiState(accessibleInterfaceLineEdit2) & focusedState));
+
+ QDBusMessage focusReply = componentInterfaceLineEdit2->call(QDBus::Block, "GrabFocus");
+ QVERIFY(focusReply.arguments().at(0).toBool());
+ QVERIFY(lineEdit2->hasFocus());
+ QVERIFY(!(getAtspiState(accessibleInterfaceLineEdit1) & focusedState));
+ QVERIFY(getAtspiState(accessibleInterfaceLineEdit2) & focusedState);
+}
+
QTEST_MAIN(tst_QAccessibilityLinux)
#include "tst_qaccessibilitylinux.moc"
diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
index 71a90e83f7..775156e728 100644
--- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
+++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
@@ -172,14 +172,18 @@ void tst_QObjectRace::moveToThreadRace()
class MyObject : public QObject
{ Q_OBJECT
+ bool ok;
+ public:
+ MyObject() : ok(true) {}
+ ~MyObject() { Q_ASSERT(ok); ok = false; }
public slots:
- void slot1() { emit signal1(); }
- void slot2() { emit signal2(); }
- void slot3() { emit signal3(); }
- void slot4() { emit signal4(); }
- void slot5() { emit signal5(); }
- void slot6() { emit signal6(); }
- void slot7() { emit signal7(); }
+ void slot1() { Q_ASSERT(ok); }
+ void slot2() { Q_ASSERT(ok); }
+ void slot3() { Q_ASSERT(ok); }
+ void slot4() { Q_ASSERT(ok); }
+ void slot5() { Q_ASSERT(ok); }
+ void slot6() { Q_ASSERT(ok); }
+ void slot7() { Q_ASSERT(ok); }
signals:
void signal1();
void signal2();
@@ -237,6 +241,10 @@ public:
disconnect(objects[((i+4)*41) % nAlive], _signalsPMF[(18*i)%7], objects[((i+5)*43) % nAlive], _slotsPMF[(19*i+2)%7] );
QMetaObject::Connection c = connect(objects[((i+5)*43) % nAlive], _signalsPMF[(9*i+1)%7], Functor());
+
+ for (int f = 0; f < 7; ++f)
+ emit (objects[i]->*_signalsPMF[f])();
+
disconnect(c);
disconnect(objects[i], _signalsPMF[(10*i+5)%7], 0, 0);
@@ -249,6 +257,9 @@ public:
delete objects[i];
}
+
+ //run the possible queued slots
+ qApp->processEvents();
}
};
diff --git a/tests/auto/other/qvariant_common/tst_qvariant_common.h b/tests/auto/other/qvariant_common/tst_qvariant_common.h
index 7a34d7b0c2..89c8bc777a 100644
--- a/tests/auto/other/qvariant_common/tst_qvariant_common.h
+++ b/tests/auto/other/qvariant_common/tst_qvariant_common.h
@@ -44,33 +44,6 @@
#include <QString>
-struct MessageHandlerInvalidType
-{
- MessageHandlerInvalidType()
- : oldMsgHandler(qInstallMessageHandler(handler))
- {
- ok = false;
- }
-
- ~MessageHandlerInvalidType()
- {
- qInstallMessageHandler(oldMsgHandler);
- }
-
- QtMessageHandler oldMsgHandler;
-
- static void handler(QtMsgType type, const QMessageLogContext & /*ctxt*/, const QString &msg)
- {
- Q_UNUSED(type);
- // uint(-1) can be platform dependent so we check only beginning of the message.
- ok = msg.startsWith("Trying to construct an instance of an invalid type, type id:");
- QVERIFY2(ok, (QString::fromLatin1("Message is not started correctly: '") + msg + '\'').toLatin1().constData());
- }
- static bool ok;
-};
-bool MessageHandlerInvalidType::ok;
-
-
class MessageHandler {
public:
MessageHandler(const int typeId, QtMessageHandler msgHandler = handler)
diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
index 47d6789327..40e1070fcc 100644
--- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
+++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
@@ -65,6 +65,19 @@ private slots:
void wait_signalEmittedLater();
void wait_signalEmittedTooLate();
void wait_signalEmittedMultipleTimes();
+
+ void spyFunctionPointerWithoutArgs();
+ void spyFunctionPointerWithBasicArgs();
+ void spyFunctionPointerWithPointers();
+ void spyFunctionPointerWithQtClasses();
+ void spyFunctionPointerWithBasicQtClasses();
+ void spyFunctionPointerWithQtTypedefs();
+
+ void waitFunctionPointer_signalEmitted();
+ void waitFunctionPointer_timeout();
+ void waitFunctionPointer_signalEmittedLater();
+ void waitFunctionPointer_signalEmittedTooLate();
+ void waitFunctionPointer_signalEmittedMultipleTimes();
};
class QtTestObject: public QObject
@@ -278,5 +291,160 @@ void tst_QSignalSpy::wait_signalEmittedMultipleTimes()
QCOMPARE(spy.count(), 3);
}
+void tst_QSignalSpy::spyFunctionPointerWithoutArgs()
+{
+ QtTestObject obj;
+
+ QSignalSpy spy(&obj, &QtTestObject::sig0);
+ QCOMPARE(spy.count(), 0);
+
+ emit obj.sig0();
+ QCOMPARE(spy.count(), 1);
+ emit obj.sig0();
+ QCOMPARE(spy.count(), 2);
+
+ QList<QVariant> args = spy.takeFirst();
+ QCOMPARE(args.count(), 0);
+}
+
+void tst_QSignalSpy::spyFunctionPointerWithBasicArgs()
+{
+ QtTestObject obj;
+ QSignalSpy spy(&obj, &QtTestObject::sig1);
+
+ emit obj.sig1(1, 2);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> args = spy.takeFirst();
+ QCOMPARE(args.count(), 2);
+ QCOMPARE(args.at(0).toInt(), 1);
+ QCOMPARE(args.at(1).toInt(), 2);
+
+ QSignalSpy spyl(&obj, &QtTestObject::sigLong);
+
+ emit obj.sigLong(1l, 2l);
+ args = spyl.takeFirst();
+ QCOMPARE(args.count(), 2);
+ QCOMPARE(qvariant_cast<long>(args.at(0)), 1l);
+ QCOMPARE(qvariant_cast<long>(args.at(1)), 2l);
+}
+
+
+void tst_QSignalSpy::spyFunctionPointerWithPointers()
+{
+ qRegisterMetaType<int *>("int*");
+
+ QtTestObject obj;
+ QSignalSpy spy(&obj, &QtTestObject::sig2);
+
+ int i1 = 1;
+ int i2 = 2;
+
+ emit obj.sig2(&i1, &i2);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> args = spy.takeFirst();
+ QCOMPARE(args.count(), 2);
+ QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1);
+ QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2);
+}
+
+void tst_QSignalSpy::spyFunctionPointerWithBasicQtClasses()
+{
+ QtTestObject2 obj;
+
+ QSignalSpy spy(&obj, &QtTestObject2::sig);
+ emit obj.sig(QString("bubu"));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.at(0).at(0).toString(), QString("bubu"));
+
+ QSignalSpy spy2(&obj, &QtTestObject2::sig5);
+ QVariant val(45);
+ emit obj.sig5(val);
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.at(0).count(), 1);
+ QCOMPARE(spy2.at(0).at(0), val);
+ QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val);
+}
+
+void tst_QSignalSpy::spyFunctionPointerWithQtClasses()
+{
+ QtTestObject2 obj;
+
+ QSignalSpy spy(&obj, &QtTestObject2::sig2);
+ QDateTime dt = QDateTime::currentDateTime();
+ emit obj.sig2(dt);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime");
+ QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt);
+ QCOMPARE(spy.at(0).at(0).toDateTime(), dt);
+
+ QSignalSpy spy2(&obj, &QtTestObject2::sig3);
+ emit obj.sig3(this);
+ QCOMPARE(*static_cast<QObject * const *>(spy2.value(0).value(0).constData()),
+ (QObject *)this);
+ QCOMPARE(qvariant_cast<QObject *>(spy2.value(0).value(0)), (QObject*)this);
+
+ QSignalSpy spy3(&obj, &QtTestObject2::sig4);
+ emit obj.sig4(QChar('A'));
+ QCOMPARE(qvariant_cast<QChar>(spy3.value(0).value(0)), QChar('A'));
+}
+
+void tst_QSignalSpy::spyFunctionPointerWithQtTypedefs()
+{
+ QtTestObject3 obj;
+
+ QSignalSpy spy2(&obj, &QtTestObject3::sig2);
+ emit obj.sig2(42, 43);
+ QCOMPARE(spy2.value(0).value(0).toInt(), 42);
+ QCOMPARE(spy2.value(0).value(1).toInt(), 43);
+}
+
+void tst_QSignalSpy::waitFunctionPointer_signalEmitted()
+{
+ QTimer::singleShot(0, this, SIGNAL(sigFoo()));
+ QSignalSpy spy(this, &tst_QSignalSpy::sigFoo);
+ QVERIFY(spy.wait(1));
+}
+
+void tst_QSignalSpy::waitFunctionPointer_timeout()
+{
+ QSignalSpy spy(this, &tst_QSignalSpy::sigFoo);
+ QVERIFY(!spy.wait(1));
+}
+
+void tst_QSignalSpy::waitFunctionPointer_signalEmittedLater()
+{
+ QTimer::singleShot(500, this, SIGNAL(sigFoo()));
+ QSignalSpy spy(this, &tst_QSignalSpy::sigFoo);
+ QVERIFY(spy.wait(1000));
+}
+
+void tst_QSignalSpy::waitFunctionPointer_signalEmittedTooLate()
+{
+ QTimer::singleShot(500, this, SIGNAL(sigFoo()));
+ QSignalSpy spy(this, &tst_QSignalSpy::sigFoo);
+ QVERIFY(!spy.wait(200));
+ QTest::qWait(400);
+ QCOMPARE(spy.count(), 1);
+}
+
+void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes()
+{
+ QTimer::singleShot(100, this, SIGNAL(sigFoo()));
+ QTimer::singleShot(800, this, SIGNAL(sigFoo()));
+ QSignalSpy spy(this, &tst_QSignalSpy::sigFoo);
+ QVERIFY(spy.wait());
+ QCOMPARE(spy.count(), 1); // we don't wait for the second signal...
+ QVERIFY(spy.wait());
+ QCOMPARE(spy.count(), 2);
+ QVERIFY(!spy.wait(1));
+ QTimer::singleShot(10, this, SIGNAL(sigFoo()));
+ QVERIFY(spy.wait());
+ QCOMPARE(spy.count(), 3);
+}
+
QTEST_MAIN(tst_QSignalSpy)
#include "tst_qsignalspy.moc"
diff --git a/tests/auto/testlib/selftests/expected_assert.lightxml b/tests/auto/testlib/selftests/expected_assert.lightxml
index d2d4ae5153..b40ff41da3 100644
--- a/tests/auto/testlib/selftests/expected_assert.lightxml
+++ b/tests/auto/testlib/selftests/expected_assert.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_assert.xml b/tests/auto/testlib/selftests/expected_assert.xml
index 9e5ea760ae..9770b3cd57 100644
--- a/tests/auto/testlib/selftests/expected_assert.xml
+++ b/tests/auto/testlib/selftests/expected_assert.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Assert">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_assert.xunitxml b/tests/auto/testlib/selftests/expected_assert.xunitxml
index 0aebe72745..96daa33dcf 100644
--- a/tests/auto/testlib/selftests/expected_assert.xunitxml
+++ b/tests/auto/testlib/selftests/expected_assert.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="testNumber1"/>
diff --git a/tests/auto/testlib/selftests/expected_badxml.lightxml b/tests/auto/testlib/selftests/expected_badxml.lightxml
index e4c79e3bb0..94f479a79a 100644
--- a/tests/auto/testlib/selftests/expected_badxml.lightxml
+++ b/tests/auto/testlib/selftests/expected_badxml.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_badxml.xml b/tests/auto/testlib/selftests/expected_badxml.xml
index 0811db0f3a..c1266bfeed 100644
--- a/tests/auto/testlib/selftests/expected_badxml.xml
+++ b/tests/auto/testlib/selftests/expected_badxml.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_BadXml">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_badxml.xunitxml b/tests/auto/testlib/selftests/expected_badxml.xunitxml
index a696da58c9..49048fdad6 100644
--- a/tests/auto/testlib/selftests/expected_badxml.xunitxml
+++ b/tests/auto/testlib/selftests/expected_badxml.xunitxml
@@ -3,6 +3,7 @@
<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="badDataTag">
diff --git a/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml b/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml
index 08872be733..6fe511462c 100644
--- a/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml
+++ b/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibcounting.xml b/tests/auto/testlib/selftests/expected_benchlibcounting.xml
index ee6fd98ef2..d945511eec 100644
--- a/tests/auto/testlib/selftests/expected_benchlibcounting.xml
+++ b/tests/auto/testlib/selftests/expected_benchlibcounting.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_BenchlibCounting">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml b/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml
index 83e429aa3a..05d1da9874 100644
--- a/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="passingBenchmark">
diff --git a/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml b/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml
index cba91a374f..0bc00569e9 100644
--- a/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml
+++ b/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml
index 7d28975ead..f543e2775c 100644
--- a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml
+++ b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_BenchlibEventCounter">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml
index 60dca28d4f..ce0a81110d 100644
--- a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="events">
diff --git a/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml b/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml
index 97422240d9..11296ad9c2 100644
--- a/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml
+++ b/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml
index 24c2e51084..3dd56b4af7 100644
--- a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml
+++ b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_BenchlibTickCounter">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml
index 28c8f11143..779d3bdcbc 100644
--- a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="threeBillionTicks">
diff --git a/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml b/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml
index b2e819b26d..c75a6c944d 100644
--- a/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml
+++ b/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibwalltime.xml b/tests/auto/testlib/selftests/expected_benchlibwalltime.xml
index 6ae355783a..a2f0edecc6 100644
--- a/tests/auto/testlib/selftests/expected_benchlibwalltime.xml
+++ b/tests/auto/testlib/selftests/expected_benchlibwalltime.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_BenchlibWalltime">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml b/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml
index e4ffca4d09..6a0510c4c9 100644
--- a/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml
+++ b/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="waitForOneThousand">
diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml
index 3a776ea7cb..4a376b5c8b 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.lightxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml
index 970544e4b6..aefb1b5f4c 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Cmptest">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
index 7874c6c52e..7502d3cc54 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="compare_boolfuncs"/>
diff --git a/tests/auto/testlib/selftests/expected_commandlinedata.lightxml b/tests/auto/testlib/selftests/expected_commandlinedata.lightxml
index c11017f022..894ae7ae23 100644
--- a/tests/auto/testlib/selftests/expected_commandlinedata.lightxml
+++ b/tests/auto/testlib/selftests/expected_commandlinedata.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_commandlinedata.xml b/tests/auto/testlib/selftests/expected_commandlinedata.xml
index 20dc0c6a7c..b2aa98f6a7 100644
--- a/tests/auto/testlib/selftests/expected_commandlinedata.xml
+++ b/tests/auto/testlib/selftests/expected_commandlinedata.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_DataTable">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml b/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml
index 45b833cf19..5072a7e6f4 100644
--- a/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="fiveTablePasses">
diff --git a/tests/auto/testlib/selftests/expected_counting.lightxml b/tests/auto/testlib/selftests/expected_counting.lightxml
index e5fe1ee3cf..836c35fb85 100644
--- a/tests/auto/testlib/selftests/expected_counting.lightxml
+++ b/tests/auto/testlib/selftests/expected_counting.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_counting.xml b/tests/auto/testlib/selftests/expected_counting.xml
index e015dddcc6..892fd762c6 100644
--- a/tests/auto/testlib/selftests/expected_counting.xml
+++ b/tests/auto/testlib/selftests/expected_counting.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Counting">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_counting.xunitxml b/tests/auto/testlib/selftests/expected_counting.xunitxml
index 72bf047ba8..cb3a7815af 100644
--- a/tests/auto/testlib/selftests/expected_counting.xunitxml
+++ b/tests/auto/testlib/selftests/expected_counting.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="testPassPass"/>
diff --git a/tests/auto/testlib/selftests/expected_datatable.lightxml b/tests/auto/testlib/selftests/expected_datatable.lightxml
index 6cc2d1c46f..c14a6a1940 100644
--- a/tests/auto/testlib/selftests/expected_datatable.lightxml
+++ b/tests/auto/testlib/selftests/expected_datatable.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_datatable.xml b/tests/auto/testlib/selftests/expected_datatable.xml
index 79963db0a4..297cb0d5de 100644
--- a/tests/auto/testlib/selftests/expected_datatable.xml
+++ b/tests/auto/testlib/selftests/expected_datatable.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_DataTable">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_datatable.xunitxml b/tests/auto/testlib/selftests/expected_datatable.xunitxml
index 6bac80e0a2..89fc7ee819 100644
--- a/tests/auto/testlib/selftests/expected_datatable.xunitxml
+++ b/tests/auto/testlib/selftests/expected_datatable.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="singleTestFunction1"/>
diff --git a/tests/auto/testlib/selftests/expected_datetime.lightxml b/tests/auto/testlib/selftests/expected_datetime.lightxml
index 02c60d04f9..48ad0933f7 100644
--- a/tests/auto/testlib/selftests/expected_datetime.lightxml
+++ b/tests/auto/testlib/selftests/expected_datetime.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_datetime.xml b/tests/auto/testlib/selftests/expected_datetime.xml
index 03aec4430e..30afde60ec 100644
--- a/tests/auto/testlib/selftests/expected_datetime.xml
+++ b/tests/auto/testlib/selftests/expected_datetime.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_DateTime">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_datetime.xunitxml b/tests/auto/testlib/selftests/expected_datetime.xunitxml
index 00bd43f904..901462b6bf 100644
--- a/tests/auto/testlib/selftests/expected_datetime.xunitxml
+++ b/tests/auto/testlib/selftests/expected_datetime.xunitxml
@@ -3,6 +3,7 @@
<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="dateTime">
diff --git a/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml b/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml
index 6c9675a2aa..2b802aabaf 100644
--- a/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml
+++ b/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
@@ -7,7 +8,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="throwException">
-<Incident type="fail" file="/home/frederik/dev/qt/qt&#x002D;src&#x002D;dev/qtbase/src/testlib/qtestcase.cpp" line="2229">
+<Incident type="fail" file="qtestcase.cpp" line="2235">
<Description><![CDATA[Caught unhandled exception]]></Description>
</Incident>
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_exceptionthrow.xml b/tests/auto/testlib/selftests/expected_exceptionthrow.xml
index 87d9d2d431..a265d5ba5f 100644
--- a/tests/auto/testlib/selftests/expected_exceptionthrow.xml
+++ b/tests/auto/testlib/selftests/expected_exceptionthrow.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Exception">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
@@ -9,7 +10,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="throwException">
-<Incident type="fail" file="/home/frederik/dev/qt/qt&#x002D;src&#x002D;dev/qtbase/src/testlib/qtestcase.cpp" line="2229">
+<Incident type="fail" file="qtestcase.cpp" line="2235">
<Description><![CDATA[Caught unhandled exception]]></Description>
</Incident>
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml b/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml
index ab0d379255..7d10bf6f04 100644
--- a/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml
+++ b/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml
@@ -3,6 +3,7 @@
<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="throwException">
diff --git a/tests/auto/testlib/selftests/expected_expectfail.lightxml b/tests/auto/testlib/selftests/expected_expectfail.lightxml
index e5fcca5875..cd5ab78fbe 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.lightxml
+++ b/tests/auto/testlib/selftests/expected_expectfail.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_expectfail.xml b/tests/auto/testlib/selftests/expected_expectfail.xml
index 14fee2129e..a98b97810c 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.xml
+++ b/tests/auto/testlib/selftests/expected_expectfail.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_ExpectFail">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_expectfail.xunitxml b/tests/auto/testlib/selftests/expected_expectfail.xunitxml
index 45c260c77f..47483d71bf 100644
--- a/tests/auto/testlib/selftests/expected_expectfail.xunitxml
+++ b/tests/auto/testlib/selftests/expected_expectfail.xunitxml
@@ -3,6 +3,7 @@
<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="xfail" name="xfailAndContinue">
diff --git a/tests/auto/testlib/selftests/expected_failcleanup.lightxml b/tests/auto/testlib/selftests/expected_failcleanup.lightxml
index cfc18ef5da..b2db64c4e2 100644
--- a/tests/auto/testlib/selftests/expected_failcleanup.lightxml
+++ b/tests/auto/testlib/selftests/expected_failcleanup.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xml b/tests/auto/testlib/selftests/expected_failcleanup.xml
index 3aa7aa265d..476e56c4f4 100644
--- a/tests/auto/testlib/selftests/expected_failcleanup.xml
+++ b/tests/auto/testlib/selftests/expected_failcleanup.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_FailCleanup">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml
index 6e35566be8..813e284ee0 100644
--- a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml
+++ b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="aTestFunction"/>
diff --git a/tests/auto/testlib/selftests/expected_failinit.lightxml b/tests/auto/testlib/selftests/expected_failinit.lightxml
index c0d193998d..5a940fc36b 100644
--- a/tests/auto/testlib/selftests/expected_failinit.lightxml
+++ b/tests/auto/testlib/selftests/expected_failinit.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_failinit.xml b/tests/auto/testlib/selftests/expected_failinit.xml
index 70ad613f3f..51e1a7fce4 100644
--- a/tests/auto/testlib/selftests/expected_failinit.xml
+++ b/tests/auto/testlib/selftests/expected_failinit.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_FailInit">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_failinit.xunitxml b/tests/auto/testlib/selftests/expected_failinit.xunitxml
index 3c2e31be29..3715725ea5 100644
--- a/tests/auto/testlib/selftests/expected_failinit.xunitxml
+++ b/tests/auto/testlib/selftests/expected_failinit.xunitxml
@@ -3,6 +3,7 @@
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
+ <property value="" name="QtBuild"/>
</properties>
<testcase result="fail" name="initTestCase">
<failure message="&apos;false&apos; returned FALSE. ()" result="fail"/>
diff --git a/tests/auto/testlib/selftests/expected_failinitdata.lightxml b/tests/auto/testlib/selftests/expected_failinitdata.lightxml
index 285471470f..f9da42c060 100644
--- a/tests/auto/testlib/selftests/expected_failinitdata.lightxml
+++ b/tests/auto/testlib/selftests/expected_failinitdata.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_failinitdata.xml b/tests/auto/testlib/selftests/expected_failinitdata.xml
index e86e102202..e843863bfc 100644
--- a/tests/auto/testlib/selftests/expected_failinitdata.xml
+++ b/tests/auto/testlib/selftests/expected_failinitdata.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_FailInitData">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_failinitdata.xunitxml b/tests/auto/testlib/selftests/expected_failinitdata.xunitxml
index f32ccd5e81..d245bc0dff 100644
--- a/tests/auto/testlib/selftests/expected_failinitdata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_failinitdata.xunitxml
@@ -3,6 +3,7 @@
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
+ <property value="" name="QtBuild"/>
</properties>
<testcase result="fail" name="initTestCase">
<failure message="&apos;false&apos; returned FALSE. ()" result="fail"/>
diff --git a/tests/auto/testlib/selftests/expected_fetchbogus.lightxml b/tests/auto/testlib/selftests/expected_fetchbogus.lightxml
index c5587cf031..c62a93eb49 100644
--- a/tests/auto/testlib/selftests/expected_fetchbogus.lightxml
+++ b/tests/auto/testlib/selftests/expected_fetchbogus.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_fetchbogus.xml b/tests/auto/testlib/selftests/expected_fetchbogus.xml
index 40295bdebc..c20de137a2 100644
--- a/tests/auto/testlib/selftests/expected_fetchbogus.xml
+++ b/tests/auto/testlib/selftests/expected_fetchbogus.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_FetchBogus">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml b/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml
index fe31b4b600..77ccbd896a 100644
--- a/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml
+++ b/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml
@@ -3,6 +3,7 @@
<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="fetchBogus">
diff --git a/tests/auto/testlib/selftests/expected_findtestdata.lightxml b/tests/auto/testlib/selftests/expected_findtestdata.lightxml
index 4c1c7298ed..e3c3cea7bc 100644
--- a/tests/auto/testlib/selftests/expected_findtestdata.lightxml
+++ b/tests/auto/testlib/selftests/expected_findtestdata.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_findtestdata.xml b/tests/auto/testlib/selftests/expected_findtestdata.xml
index b1f33abaf6..6abaa15103 100644
--- a/tests/auto/testlib/selftests/expected_findtestdata.xml
+++ b/tests/auto/testlib/selftests/expected_findtestdata.xml
@@ -2,6 +2,7 @@
<TestCase name="FindTestData">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_findtestdata.xunitxml b/tests/auto/testlib/selftests/expected_findtestdata.xunitxml
index 60283a1064..c1138da6cb 100644
--- a/tests/auto/testlib/selftests/expected_findtestdata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_findtestdata.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="paths">
diff --git a/tests/auto/testlib/selftests/expected_globaldata.lightxml b/tests/auto/testlib/selftests/expected_globaldata.lightxml
index fd128d2c61..7d4c43905c 100644
--- a/tests/auto/testlib/selftests/expected_globaldata.lightxml
+++ b/tests/auto/testlib/selftests/expected_globaldata.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_globaldata.xml b/tests/auto/testlib/selftests/expected_globaldata.xml
index 0867619fde..5e5d4d8922 100644
--- a/tests/auto/testlib/selftests/expected_globaldata.xml
+++ b/tests/auto/testlib/selftests/expected_globaldata.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_globaldata">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_globaldata.xunitxml b/tests/auto/testlib/selftests/expected_globaldata.xunitxml
index e8cd03a59c..bdd7e3f00a 100644
--- a/tests/auto/testlib/selftests/expected_globaldata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_globaldata.xunitxml
@@ -3,6 +3,7 @@
<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">
<!-- message="initTestCase initTestCase (null)" type="qdebug" -->
diff --git a/tests/auto/testlib/selftests/expected_longstring.lightxml b/tests/auto/testlib/selftests/expected_longstring.lightxml
index 45c6d3f78d..f8796bed4a 100644
--- a/tests/auto/testlib/selftests/expected_longstring.lightxml
+++ b/tests/auto/testlib/selftests/expected_longstring.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_longstring.xml b/tests/auto/testlib/selftests/expected_longstring.xml
index efc29d6def..6623b7cd88 100644
--- a/tests/auto/testlib/selftests/expected_longstring.xml
+++ b/tests/auto/testlib/selftests/expected_longstring.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_LongString">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_longstring.xunitxml b/tests/auto/testlib/selftests/expected_longstring.xunitxml
index 6486817dbb..269c06fe08 100644
--- a/tests/auto/testlib/selftests/expected_longstring.xunitxml
+++ b/tests/auto/testlib/selftests/expected_longstring.xunitxml
@@ -3,6 +3,7 @@
<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="failWithLongString">
diff --git a/tests/auto/testlib/selftests/expected_maxwarnings.lightxml b/tests/auto/testlib/selftests/expected_maxwarnings.lightxml
index ce6d828eb2..49db189352 100644
--- a/tests/auto/testlib/selftests/expected_maxwarnings.lightxml
+++ b/tests/auto/testlib/selftests/expected_maxwarnings.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_maxwarnings.xml b/tests/auto/testlib/selftests/expected_maxwarnings.xml
index 758af9d6d5..614b054fad 100644
--- a/tests/auto/testlib/selftests/expected_maxwarnings.xml
+++ b/tests/auto/testlib/selftests/expected_maxwarnings.xml
@@ -2,6 +2,7 @@
<TestCase name="MaxWarnings">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml b/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml
index b1b0215cef..329fae5f1d 100644
--- a/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml
+++ b/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="warn">
diff --git a/tests/auto/testlib/selftests/expected_singleskip.lightxml b/tests/auto/testlib/selftests/expected_singleskip.lightxml
index 685396a243..ce09c0a9ad 100644
--- a/tests/auto/testlib/selftests/expected_singleskip.lightxml
+++ b/tests/auto/testlib/selftests/expected_singleskip.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_singleskip.xml b/tests/auto/testlib/selftests/expected_singleskip.xml
index c10626ca41..0c5cdade3d 100644
--- a/tests/auto/testlib/selftests/expected_singleskip.xml
+++ b/tests/auto/testlib/selftests/expected_singleskip.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_SingleSkip">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_singleskip.xunitxml b/tests/auto/testlib/selftests/expected_singleskip.xunitxml
index 70968fa1c4..2b2da2f504 100644
--- a/tests/auto/testlib/selftests/expected_singleskip.xunitxml
+++ b/tests/auto/testlib/selftests/expected_singleskip.xunitxml
@@ -3,6 +3,7 @@
<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 name="myTest">
diff --git a/tests/auto/testlib/selftests/expected_skip.lightxml b/tests/auto/testlib/selftests/expected_skip.lightxml
index 408bc44871..ee83d263b5 100644
--- a/tests/auto/testlib/selftests/expected_skip.lightxml
+++ b/tests/auto/testlib/selftests/expected_skip.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skip.xml b/tests/auto/testlib/selftests/expected_skip.xml
index b220722b6c..2c830bc9fb 100644
--- a/tests/auto/testlib/selftests/expected_skip.xml
+++ b/tests/auto/testlib/selftests/expected_skip.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Skip">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skip.xunitxml b/tests/auto/testlib/selftests/expected_skip.xunitxml
index 956d51f531..63e582f96a 100644
--- a/tests/auto/testlib/selftests/expected_skip.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skip.xunitxml
@@ -3,6 +3,7 @@
<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 name="test">
diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.lightxml b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml
index 49c9d148f5..dbbc30c0db 100644
--- a/tests/auto/testlib/selftests/expected_skipcleanup.lightxml
+++ b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xml b/tests/auto/testlib/selftests/expected_skipcleanup.xml
index 0bf1fe53a3..7b787ebb3d 100644
--- a/tests/auto/testlib/selftests/expected_skipcleanup.xml
+++ b/tests/auto/testlib/selftests/expected_skipcleanup.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_SkipCleanup">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml
index b8f67e2d07..9934584ec5 100644
--- a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="aTestFunction"/>
diff --git a/tests/auto/testlib/selftests/expected_skipinit.lightxml b/tests/auto/testlib/selftests/expected_skipinit.lightxml
index e06c745205..3682068825 100644
--- a/tests/auto/testlib/selftests/expected_skipinit.lightxml
+++ b/tests/auto/testlib/selftests/expected_skipinit.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skipinit.xml b/tests/auto/testlib/selftests/expected_skipinit.xml
index 6a62b93614..9d6a38b82f 100644
--- a/tests/auto/testlib/selftests/expected_skipinit.xml
+++ b/tests/auto/testlib/selftests/expected_skipinit.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_SkipInit">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skipinit.xunitxml b/tests/auto/testlib/selftests/expected_skipinit.xunitxml
index f62df71d96..bab08c375c 100644
--- a/tests/auto/testlib/selftests/expected_skipinit.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skipinit.xunitxml
@@ -3,6 +3,7 @@
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
+ <property value="" name="QtBuild"/>
</properties>
<testcase name="initTestCase">
<!-- message="Skip inside initTestCase. This should skip all tests in the class." type="skip" -->
diff --git a/tests/auto/testlib/selftests/expected_skipinitdata.lightxml b/tests/auto/testlib/selftests/expected_skipinitdata.lightxml
index 41abd5dccd..26afcb4ab1 100644
--- a/tests/auto/testlib/selftests/expected_skipinitdata.lightxml
+++ b/tests/auto/testlib/selftests/expected_skipinitdata.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skipinitdata.xml b/tests/auto/testlib/selftests/expected_skipinitdata.xml
index 8efe12195e..9ab84f21a1 100644
--- a/tests/auto/testlib/selftests/expected_skipinitdata.xml
+++ b/tests/auto/testlib/selftests/expected_skipinitdata.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_SkipInitData">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml b/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml
index 699d50f7a7..e61d50b06b 100644
--- a/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml
+++ b/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml
@@ -3,6 +3,7 @@
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
+ <property value="" name="QtBuild"/>
</properties>
<testcase name="initTestCase">
<!-- message="Skip inside initTestCase_data. This should skip all tests in the class." type="skip" -->
diff --git a/tests/auto/testlib/selftests/expected_strcmp.lightxml b/tests/auto/testlib/selftests/expected_strcmp.lightxml
index f0d266d400..298e910be8 100644
--- a/tests/auto/testlib/selftests/expected_strcmp.lightxml
+++ b/tests/auto/testlib/selftests/expected_strcmp.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_strcmp.xml b/tests/auto/testlib/selftests/expected_strcmp.xml
index 20ffee0611..29208f9a87 100644
--- a/tests/auto/testlib/selftests/expected_strcmp.xml
+++ b/tests/auto/testlib/selftests/expected_strcmp.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_StrCmp">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_strcmp.xunitxml b/tests/auto/testlib/selftests/expected_strcmp.xunitxml
index dde9ff5299..14bef9ec47 100644
--- a/tests/auto/testlib/selftests/expected_strcmp.xunitxml
+++ b/tests/auto/testlib/selftests/expected_strcmp.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="compareCharStars"/>
diff --git a/tests/auto/testlib/selftests/expected_subtest.lightxml b/tests/auto/testlib/selftests/expected_subtest.lightxml
index 467fabb7ac..2e484aafef 100644
--- a/tests/auto/testlib/selftests/expected_subtest.lightxml
+++ b/tests/auto/testlib/selftests/expected_subtest.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_subtest.xml b/tests/auto/testlib/selftests/expected_subtest.xml
index 1107bcb070..f011489ec8 100644
--- a/tests/auto/testlib/selftests/expected_subtest.xml
+++ b/tests/auto/testlib/selftests/expected_subtest.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Subtest">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_subtest.xunitxml b/tests/auto/testlib/selftests/expected_subtest.xunitxml
index 753711f837..b49c006940 100644
--- a/tests/auto/testlib/selftests/expected_subtest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_subtest.xunitxml
@@ -3,6 +3,7 @@
<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">
<!-- message="initTestCase initTestCase (null)" type="qdebug" -->
diff --git a/tests/auto/testlib/selftests/expected_verbose1.lightxml b/tests/auto/testlib/selftests/expected_verbose1.lightxml
index 45dca139fa..6d7ce13ea0 100644
--- a/tests/auto/testlib/selftests/expected_verbose1.lightxml
+++ b/tests/auto/testlib/selftests/expected_verbose1.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_verbose1.xml b/tests/auto/testlib/selftests/expected_verbose1.xml
index 7a182183c1..b5ae1286cb 100644
--- a/tests/auto/testlib/selftests/expected_verbose1.xml
+++ b/tests/auto/testlib/selftests/expected_verbose1.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Counting">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_verbose1.xunitxml b/tests/auto/testlib/selftests/expected_verbose1.xunitxml
index 72bf047ba8..cb3a7815af 100644
--- a/tests/auto/testlib/selftests/expected_verbose1.xunitxml
+++ b/tests/auto/testlib/selftests/expected_verbose1.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="testPassPass"/>
diff --git a/tests/auto/testlib/selftests/expected_verbose2.lightxml b/tests/auto/testlib/selftests/expected_verbose2.lightxml
index 0ead76884c..85f9ec45af 100644
--- a/tests/auto/testlib/selftests/expected_verbose2.lightxml
+++ b/tests/auto/testlib/selftests/expected_verbose2.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_verbose2.xml b/tests/auto/testlib/selftests/expected_verbose2.xml
index 6d592f4a52..94fef3eed7 100644
--- a/tests/auto/testlib/selftests/expected_verbose2.xml
+++ b/tests/auto/testlib/selftests/expected_verbose2.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Counting">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_verbose2.xunitxml b/tests/auto/testlib/selftests/expected_verbose2.xunitxml
index 6dabbd34fc..6764a5564f 100644
--- a/tests/auto/testlib/selftests/expected_verbose2.xunitxml
+++ b/tests/auto/testlib/selftests/expected_verbose2.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="testPassPass">
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml
index fb8f61503e..d38363fb6e 100644
--- a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml
index a89528cfb8..8c57fe5c0f 100644
--- a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_VerifyExceptionThrown">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml
index f49746a9af..003a31a1cc 100644
--- a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="testCorrectStdTypes"/>
diff --git a/tests/auto/testlib/selftests/expected_warnings.lightxml b/tests/auto/testlib/selftests/expected_warnings.lightxml
index bbc96b7010..31b3d842aa 100644
--- a/tests/auto/testlib/selftests/expected_warnings.lightxml
+++ b/tests/auto/testlib/selftests/expected_warnings.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_warnings.xml b/tests/auto/testlib/selftests/expected_warnings.xml
index acb80e4f2a..a3821f84df 100644
--- a/tests/auto/testlib/selftests/expected_warnings.xml
+++ b/tests/auto/testlib/selftests/expected_warnings.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Warnings">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_warnings.xunitxml b/tests/auto/testlib/selftests/expected_warnings.xunitxml
index 7be47174c6..7ea66522c6 100644
--- a/tests/auto/testlib/selftests/expected_warnings.xunitxml
+++ b/tests/auto/testlib/selftests/expected_warnings.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="testWarnings">
diff --git a/tests/auto/testlib/selftests/expected_xunit.lightxml b/tests/auto/testlib/selftests/expected_xunit.lightxml
index 6660cf4e7a..95ab8f03f0 100644
--- a/tests/auto/testlib/selftests/expected_xunit.lightxml
+++ b/tests/auto/testlib/selftests/expected_xunit.lightxml
@@ -1,5 +1,6 @@
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_xunit.xml b/tests/auto/testlib/selftests/expected_xunit.xml
index af9fe1f502..f56ca947be 100644
--- a/tests/auto/testlib/selftests/expected_xunit.xml
+++ b/tests/auto/testlib/selftests/expected_xunit.xml
@@ -2,6 +2,7 @@
<TestCase name="tst_Xunit">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
diff --git a/tests/auto/testlib/selftests/expected_xunit.xunitxml b/tests/auto/testlib/selftests/expected_xunit.xunitxml
index 7d133da7a5..395b6efdd9 100644
--- a/tests/auto/testlib/selftests/expected_xunit.xunitxml
+++ b/tests/auto/testlib/selftests/expected_xunit.xunitxml
@@ -3,6 +3,7 @@
<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="pass" name="testFunc1">
diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py
index 1c09faf4db..8c1de0d8b4 100755
--- a/tests/auto/testlib/selftests/generate_expected_output.py
+++ b/tests/auto/testlib/selftests/generate_expected_output.py
@@ -56,8 +56,11 @@ isWindows = sys.platform == 'win32'
replacements = [
(qtver, r'@INSERT_QT_VERSION_HERE@'),
+ (r'Config: Using QtTest library.*', r'Config: Using QtTest library'), # Build string in text logs
(rootPath.encode('unicode-escape').decode('utf-8'), r''),
(r'( *)<Duration msecs="[\d\.]+"/>', r'\1<Duration msecs="0"/>'),
+ (r'( *)<QtBuild>[^<]+</QtBuild>', r'\1<QtBuild/>'), # Build element in xml, lightxml
+ (r'<property value="[^"]+" name="QtBuild"/>', r'<property value="" name="QtBuild"/>') # Build in xunitxml
]
extraArgs = {
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 9082561dc9..3e7262a7a0 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -169,12 +169,17 @@ QString tst_Selftests::logName(const QString &logger) const
return (logger.startsWith("stdout") ? "" : QString(tempDir.path() + "/test_output." + logger));
}
+static QString expectedFileNameFromTest(const QString &subdir, const QString &logger)
+{
+ return QStringLiteral("expected_") + subdir + QLatin1Char('.') + logFormat(logger);
+}
+
// Load the expected test output for the nominated test (subdir) and logger
// as an array of lines. If there is no expected output file, return an
// empty array.
-static QList<QByteArray> expectedResult(const QString &subdir, const QString &logger)
+static QList<QByteArray> expectedResult(const QString &fileName)
{
- QFile file(":/expected_" + subdir + "." + logFormat(logger));
+ QFile file(QStringLiteral(":/") + fileName);
if (!file.open(QIODevice::ReadOnly))
return QList<QByteArray>();
return splitLines(file.readAll());
@@ -621,7 +626,8 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
for (int n = 0; n < loggers.count(); ++n) {
QString logger = loggers[n];
QList<QByteArray> res = splitLines(actualOutputs[n]);
- QList<QByteArray> exp = expectedResult(subdir, logger);
+ 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 (n == 0 && subdir == QStringLiteral("float")) {
@@ -640,7 +646,7 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
QList<QByteArray> tmp;
int i = 1;
do {
- tmp = expectedResult(subdir + QString("_%1").arg(i++), logger);
+ tmp = expectedResult(expectedFileNameFromTest(subdir + QLatin1Char('_') + QString::number(i++), logger));
if (tmp.count())
expArr += tmp;
} while (tmp.count());
@@ -669,8 +675,8 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
qDebug() << ">>>>>>";
QVERIFY2(res.count() == exp.count(),
- qPrintable(QString::fromLatin1("Mismatch in line count: %1 != %2 (%3).")
- .arg(res.count()).arg(exp.count()).arg(loggers.at(n))));
+ qPrintable(QString::fromLatin1("Mismatch in line count: %1 != %2 (%3, %4).")
+ .arg(res.count()).arg(exp.count()).arg(loggers.at(n), expectedFileName)));
}
}
@@ -713,6 +719,12 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
if (line.endsWith(" : failure location"))
continue;
+ if (line.startsWith("Config: Using QtTest library") // Text build string
+ || line.startsWith(" <QtBuild") // XML, Light XML build string
+ || (line.startsWith(" <property value=") && line.endsWith("name=\"QtBuild\"/>"))) { // XUNIT-XML build string
+ continue;
+ }
+
const QString output(QString::fromLatin1(line));
const QString expected(QString::fromLatin1(exp.at(i)).replace("@INSERT_QT_VERSION_HERE@", QT_VERSION_STR));
@@ -742,8 +754,8 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
.arg(i).arg(loggers.at(n), output)));
} else {
QVERIFY2(output == expected,
- qPrintable(QString::fromLatin1("Mismatch at line %1 (%2): '%3' != '%4'")
- .arg(i).arg(loggers.at(n), output, expected)));
+ qPrintable(QString::fromLatin1("Mismatch at line %1 (%2, %3): '%4' != '%5'")
+ .arg(i + 1).arg(loggers.at(n), expectedFileName, output, expected)));
}
benchmark = line.startsWith("RESULT : ");
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 2e1504383f..97a2f366c5 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -174,6 +174,9 @@ class TestClassinfoWithEscapes: public QObject
Q_OBJECT
Q_CLASSINFO("escaped", "\"bar\"")
Q_CLASSINFO("\"escaped\"", "foo")
+ Q_CLASSINFO("cpp c*/omment", "f/*oo")
+ Q_CLASSINFO("endswith\\", "Or?\?/")
+ Q_CLASSINFO("newline\n inside\n", "Or \r")
public slots:
void slotWithAReallyLongName(int)
{ }
@@ -800,6 +803,14 @@ void tst_Moc::classinfoWithEscapes()
const QMetaObject *mobj = &TestClassinfoWithEscapes::staticMetaObject;
QCOMPARE(mobj->methodCount() - mobj->methodOffset(), 1);
+ QCOMPARE(mobj->classInfoCount(), 5);
+ QCOMPARE(mobj->classInfo(2).name(), "cpp c*/omment");
+ QCOMPARE(mobj->classInfo(2).value(), "f/*oo");
+ QCOMPARE(mobj->classInfo(3).name(), "endswith\\");
+ QCOMPARE(mobj->classInfo(3).value(), "Or?\?/");
+ QCOMPARE(mobj->classInfo(4).name(), "newline\n inside\n");
+ QCOMPARE(mobj->classInfo(4).value(), "Or \r");
+
QMetaMethod mm = mobj->method(mobj->methodOffset());
QCOMPARE(mm.methodSignature(), QByteArray("slotWithAReallyLongName(int)"));
}
@@ -1781,6 +1792,14 @@ void tst_Moc::warnings_data()
<< QString("IGNORE_ALL_STDOUT")
<< QString("standard input:1: Warning: Property declaration x has no READ accessor function or associated MEMBER variable. The property will be invalid.");
+ // This should output a warning
+ QTest::newRow("Duplicate property warning")
+ << QByteArray("class X : public QObject { Q_OBJECT Q_PROPERTY(int x READ x) Q_PROPERTY(int x READ y) };")
+ << QStringList()
+ << 0
+ << QString("IGNORE_ALL_STDOUT")
+ << QString("standard input:1: Warning: The property 'x' is defined multiple times in class X.");
+
// Passing "-nn" should NOT suppress the warning
QTest::newRow("Invalid property warning with -nn")
<< QByteArray("class X : public QObject { Q_OBJECT Q_PROPERTY(int x) };")
diff --git a/tests/auto/tools/qmake/testdata/functions/functions.pro b/tests/auto/tools/qmake/testdata/functions/functions.pro
index 84f97c2022..a0e88300d4 100644
--- a/tests/auto/tools/qmake/testdata/functions/functions.pro
+++ b/tests/auto/tools/qmake/testdata/functions/functions.pro
@@ -173,3 +173,12 @@ testReplace($$shell_quote($$in), $$out, "shell_quote")
testReplace($$reverse($$list(one two three)), three two one, "reverse")
testReplace($$cat(textfile), hi '"holla he"' 'hu!')
+
+MOD.a.depends =
+MOD.b.depends =
+MOD.b.priority = 1
+MOD.c.depends = a b
+testReplace($$resolve_depends($$list(c), "MOD."), c b a)
+MOD.a.priority = 1
+MOD.b.priority = 0
+testReplace($$resolve_depends($$list(c), "MOD."), c a b)
diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected
index 9334443ccc..ae470db336 100644
--- a/tests/auto/tools/rcc/data/images/images.expected
+++ b/tests/auto/tools/rcc/data/images/images.expected
@@ -1,13 +1,11 @@
/****************************************************************************
** Resource object code
**
-IGNORE: ** Created by: The Resource Compiler for Qt version 5.0.0
+IGNORE: ** Created by: The Resource Compiler for Qt version 5.3.1
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
-#include <QtCore/qglobal.h>
-
static const unsigned char qt_resource_data[] = {
IGNORE: // /dev/qt5/qtbase/tests/auto/tools/rcc/data/images/images/circle.png
0x0,0x0,0x0,0xa5,
@@ -94,32 +92,47 @@ static const unsigned char qt_resource_struct[] = {
};
-QT_BEGIN_NAMESPACE
+#ifdef QT_NAMESPACE
+# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
+# define QT_RCC_MANGLE_NAMESPACE0(x) x
+# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
+# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
+# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
+ QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
+#else
+# define QT_RCC_PREPEND_NAMESPACE(name) name
+# define QT_RCC_MANGLE_NAMESPACE(name) name
+#endif
-extern Q_CORE_EXPORT bool qRegisterResourceData
- (int, const unsigned char *, const unsigned char *, const unsigned char *);
+#ifdef QT_NAMESPACE
+namespace QT_NAMESPACE {
+#endif
-extern Q_CORE_EXPORT bool qUnregisterResourceData
- (int, const unsigned char *, const unsigned char *, const unsigned char *);
+bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
-QT_END_NAMESPACE
+bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
+#ifdef QT_NAMESPACE
+}
+#endif
-int QT_MANGLE_NAMESPACE(qInitResources)()
+int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
{
- QT_PREPEND_NAMESPACE(qRegisterResourceData)
+ QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
-Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources))
-
-int QT_MANGLE_NAMESPACE(qCleanupResources)()
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
{
- QT_PREPEND_NAMESPACE(qUnregisterResourceData)
+ QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
-Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources))
-
+namespace {
+ struct initializer {
+ initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); }
+ ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); }
+ } dummy;
+}
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 096658ae02..b9ca831e0c 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -114,8 +114,8 @@ public:
virtual ~tst_QFiledialog();
public slots:
+ void initTestCase();
void init();
- void cleanup();
private slots:
void currentChangedSignal();
@@ -171,7 +171,7 @@ private slots:
void tildeExpansion();
#endif // QT_BUILD_INTERNAL
#endif
- void getFileUrl();
+ void rejectModalDialogs();
private:
QByteArray userSettings;
@@ -185,28 +185,25 @@ tst_QFiledialog::~tst_QFiledialog()
{
}
+void tst_QFiledialog::initTestCase()
+{
+ QStandardPaths::setTestModeEnabled(true);
+}
+
void tst_QFiledialog::init()
{
- // Save the developers settings so they don't get mad when their sidebar folders are gone.
+ // clean up the sidebar between each test
QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
settings.beginGroup(QLatin1String("Qt"));
- userSettings = settings.value(QLatin1String("filedialog")).toByteArray();
settings.remove(QLatin1String("filedialog"));
- // populate it with some default settings
+ // populate the sidebar with some default settings
QNonNativeFileDialog fd;
#if defined(Q_OS_WINCE)
QTest::qWait(1000);
#endif
}
-void tst_QFiledialog::cleanup()
-{
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("Qt"));
- settings.setValue(QLatin1String("filedialog"), userSettings);
-}
-
class MyAbstractItemDelegate : public QAbstractItemDelegate
{
public:
@@ -252,7 +249,10 @@ void tst_QFiledialog::directoryEnteredSignal()
// sidebar
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
- sidebar->setCurrentIndex(sidebar->model()->index(1, 0));
+ QVERIFY(sidebar->model()->rowCount() >= 2);
+ QModelIndex secondItem = sidebar->model()->index(1, 0);
+ QVERIFY(secondItem.isValid());
+ sidebar->setCurrentIndex(secondItem);
QTest::keyPress(sidebar->viewport(), Qt::Key_Return);
QCOMPARE(spyDirectoryEntered.count(), 1);
spyDirectoryEntered.clear();
@@ -1451,7 +1451,7 @@ public slots:
}
};
-void tst_QFiledialog::getFileUrl()
+void tst_QFiledialog::rejectModalDialogs()
{
// QTBUG-38672 , static functions should return empty Urls
const QFileDialog::Options options = QFileDialog::DontUseNativeDialog;
@@ -1472,6 +1472,18 @@ void tst_QFiledialog::getFileUrl()
QVERIFY(url.isEmpty());
QVERIFY(!url.isValid());
+ // Same test with local files
+ QString file = QFileDialog::getOpenFileName(0, QStringLiteral("getOpenFileName"),
+ QString(), QString(), Q_NULLPTR, options);
+ QVERIFY(file.isEmpty());
+
+ file = QFileDialog::getExistingDirectory(0, QStringLiteral("getExistingDirectory"),
+ QString(), options | QFileDialog::ShowDirsOnly);
+ QVERIFY(file.isEmpty());
+
+ file = QFileDialog::getSaveFileName(0, QStringLiteral("getSaveFileName"),
+ QString(), QString(), Q_NULLPTR, options);
+ QVERIFY(file.isEmpty());
}
QTEST_MAIN(tst_QFiledialog)
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
index 060fa51293..86b9d7eee2 100644
--- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
+++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
@@ -42,34 +42,34 @@
#include <QtTest/QtTest>
-#include <qcoreapplication.h>
+#include <qapplication.h>
#include <qdebug.h>
+#include <qprogressbar.h>
#include <qprogressdialog.h>
+#include <qpushbutton.h>
#include <qlabel.h>
+#include <qpointer.h>
#include <qthread.h>
+#include <qtranslator.h>
class tst_QProgressDialog : public QObject
{
-Q_OBJECT
+ Q_OBJECT
-public:
- tst_QProgressDialog();
- virtual ~tst_QProgressDialog();
-
-private slots:
+private Q_SLOTS:
+ void cleanup();
void autoShow_data();
void autoShow();
void getSetCheck();
void task198202();
void QTBUG_31046();
+ void settingCustomWidgets();
+ void i18n();
};
-tst_QProgressDialog::tst_QProgressDialog()
-{
-}
-
-tst_QProgressDialog::~tst_QProgressDialog()
+void tst_QProgressDialog::cleanup()
{
+ QVERIFY(QApplication::topLevelWindows().empty());
}
void tst_QProgressDialog::autoShow_data()
@@ -190,5 +190,94 @@ void tst_QProgressDialog::QTBUG_31046()
QCOMPARE(50, dlg.value());
}
+void tst_QProgressDialog::settingCustomWidgets()
+{
+ QPointer<QLabel> l = new QLabel;
+ QPointer<QPushButton> btn = new QPushButton;
+ QPointer<QProgressBar> bar = new QProgressBar;
+ QVERIFY(!l->parent());
+ QVERIFY(!btn->parent());
+ QVERIFY(!bar->parent());
+
+ {
+ QProgressDialog dlg;
+
+ QVERIFY(!dlg.isAncestorOf(l));
+ dlg.setLabel(l);
+ QVERIFY(dlg.isAncestorOf(l));
+ QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setLabel: Attempt to set the same label again");
+ dlg.setLabel(l); // setting the same widget again should not crash
+ QVERIFY(l); // and not delete the (old == new) widget
+
+ QVERIFY(!dlg.isAncestorOf(btn));
+ dlg.setCancelButton(btn);
+ QVERIFY(dlg.isAncestorOf(btn));
+ QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setCancelButton: Attempt to set the same button again");
+ dlg.setCancelButton(btn); // setting the same widget again should not crash
+ QVERIFY(btn); // and not delete the (old == new) widget
+
+ QVERIFY(!dlg.isAncestorOf(bar));
+ dlg.setBar(bar);
+ QEXPECT_FAIL("", "QProgressBar doesn't adopt custom progress bar as children", Continue);
+ QVERIFY(dlg.isAncestorOf(bar));
+ QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Attempt to set the same progress bar again");
+ dlg.setBar(bar); // setting the same widget again should not crash
+ QVERIFY(bar); // and not delete the (old == new) widget
+ }
+
+ QVERIFY(!l);
+ QVERIFY(!btn);
+#if 0
+ QEXPECT_FAIL("", "QProgressBar doesn't clean up custom progress bars", Continue);
+ QVERIFY(!bar);
+#else
+ // make cleanup() pass
+ delete bar;
+#endif
+}
+
+class QTestTranslator : public QTranslator
+{
+ const QString m_str;
+public:
+ explicit QTestTranslator(QString str) : m_str(qMove(str)) {}
+
+ QString translate(const char *, const char *sourceText, const char *, int) const Q_DECL_OVERRIDE
+ { return m_str + sourceText + m_str; }
+
+ bool isEmpty() const Q_DECL_OVERRIDE { return false; }
+};
+
+template <typename Translator>
+class QTranslatorGuard {
+ Translator t;
+public:
+ template <typename Arg>
+ explicit QTranslatorGuard(Arg a) : t(qMove(a))
+ { qApp->installTranslator(&t); }
+ ~QTranslatorGuard()
+ { qApp->removeTranslator(&t); }
+};
+
+void tst_QProgressDialog::i18n()
+{
+ QProgressDialog dlg;
+ QPushButton *btn = dlg.findChild<QPushButton*>();
+ QVERIFY(btn);
+ const QString xxx = QStringLiteral("xxx");
+ {
+ QTranslatorGuard<QTestTranslator> guard(xxx);
+ {
+ QPushButton *btn = dlg.findChild<QPushButton*>();
+ QVERIFY(btn);
+ QTRY_COMPARE(btn->text(), QProgressDialog::tr("Cancel"));
+ QVERIFY(btn->text().startsWith(xxx));
+ }
+ }
+ QVERIFY(btn);
+ QTRY_COMPARE(btn->text(), QProgressDialog::tr("Cancel"));
+ QVERIFY(!btn->text().startsWith(xxx));
+}
+
QTEST_MAIN(tst_QProgressDialog)
#include "tst_qprogressdialog.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index e9aae1ec59..c89b05616d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -389,6 +389,8 @@ private slots:
void itemClipsChildrenToShape5();
void itemClipsTextChildToShape();
void itemClippingDiscovery();
+ void itemContainsChildrenInShape();
+ void itemContainsChildrenInShape2();
void ancestorFlags();
void untransformable();
void contextMenuEventPropagation();
@@ -5855,6 +5857,102 @@ void tst_QGraphicsItem::itemClippingDiscovery()
QCOMPARE(scene.itemAt(90, 90), (QGraphicsItem *)0);
}
+class ItemCountsBoundingRectCalls : public QGraphicsRectItem
+{
+public:
+ ItemCountsBoundingRectCalls(const QRectF & rect, QGraphicsItem *parent = 0)
+ : QGraphicsRectItem(rect, parent), boundingRectCalls(0) {}
+ QRectF boundingRect () const {
+ ++boundingRectCalls;
+ return QGraphicsRectItem::boundingRect();
+ }
+ mutable int boundingRectCalls;
+};
+
+void tst_QGraphicsItem::itemContainsChildrenInShape()
+{
+ ItemCountsBoundingRectCalls *parent = new ItemCountsBoundingRectCalls(QRectF(0,0, 10, 10));
+ ItemCountsBoundingRectCalls *childOutsideShape = new ItemCountsBoundingRectCalls(QRectF(0,0, 10, 10), parent);
+ childOutsideShape->setPos(20,0);
+
+ QGraphicsScene scene;
+ scene.setItemIndexMethod(QGraphicsScene::NoIndex);
+ scene.addItem(parent);
+
+ QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+
+ int oldParentBoundingRectCalls = parent->boundingRectCalls;
+ int oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
+
+ // First test that both items are searched if no optimization flags are set
+ QGraphicsItem* item = scene.itemAt(25,5);
+
+ QVERIFY(item == childOutsideShape);
+ QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
+ QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls);
+ QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+
+ oldParentBoundingRectCalls = parent->boundingRectCalls;
+ oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
+
+ // Repeat the test to make sure that no caching/indexing is in effect
+ item = scene.itemAt(25,5);
+
+ QVERIFY(item == childOutsideShape);
+ QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
+ QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls);
+ QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+
+ oldParentBoundingRectCalls = parent->boundingRectCalls;
+ oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
+
+ // Set the optimization flag and make sure that the child is not returned
+ // and that the child's boundingRect() method is never called.
+ parent->setFlag(QGraphicsItem::ItemContainsChildrenInShape);
+ item = scene.itemAt(25,5);
+
+ QVERIFY(!(item));
+ QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
+ QVERIFY(childOutsideShape->boundingRectCalls == oldChildBoundingRectCalls);
+ QVERIFY(parent->boundingRectCalls > childOutsideShape->boundingRectCalls);
+}
+
+void tst_QGraphicsItem::itemContainsChildrenInShape2()
+{
+ //The tested flag behaves almost identically to ItemClipsChildrenToShape
+ //in terms of optimizations but does not enforce the clip.
+ //This test makes sure there is no clip.
+ QGraphicsScene scene;
+ QGraphicsItem *rect = scene.addRect(0, 0, 50, 50, QPen(Qt::NoPen), QBrush(Qt::yellow));
+
+ QGraphicsItem *ellipse = scene.addEllipse(0, 0, 100, 100, QPen(Qt::NoPen), QBrush(Qt::green));
+ ellipse->setParentItem(rect);
+
+ QGraphicsItem *clippedEllipse = scene.addEllipse(0, 0, 50, 50, QPen(Qt::NoPen), QBrush(Qt::blue));
+ clippedEllipse->setParentItem(ellipse);
+
+ QGraphicsItem *clippedEllipse2 = scene.addEllipse(0, 0, 25, 25, QPen(Qt::NoPen), QBrush(Qt::red));
+ clippedEllipse2->setParentItem(clippedEllipse);
+
+ QVERIFY(!(ellipse->flags() & QGraphicsItem::ItemClipsChildrenToShape));
+ QVERIFY(!(ellipse->flags() & QGraphicsItem::ItemContainsChildrenInShape));
+ ellipse->setFlags(QGraphicsItem::ItemContainsChildrenInShape);
+ QVERIFY(!(ellipse->flags() & QGraphicsItem::ItemClipsChildrenToShape));
+ QVERIFY((ellipse->flags() & QGraphicsItem::ItemContainsChildrenInShape));
+
+ QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
+ image.fill(0);
+ QPainter painter(&image);
+ painter.setRenderHint(QPainter::Antialiasing);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(image.pixel(2, 2), QColor(Qt::yellow).rgba());
+ QCOMPARE(image.pixel(12, 12), QColor(Qt::red).rgba());
+ QCOMPARE(image.pixel(2, 25), QColor(Qt::blue).rgba());
+ QCOMPARE(image.pixel(2, 50), QColor(Qt::green).rgba());
+}
+
void tst_QGraphicsItem::ancestorFlags()
{
QGraphicsItem *level1 = new QGraphicsRectItem;
@@ -5975,11 +6073,27 @@ void tst_QGraphicsItem::ancestorFlags()
// Nobody handles child events
level21->setHandlesChildEvents(false);
- for (int i = 0; i < 2; ++i) {
- QGraphicsItem::GraphicsItemFlag flag = !i ? QGraphicsItem::ItemClipsChildrenToShape
- : QGraphicsItem::ItemIgnoresTransformations;
- int ancestorFlag = !i ? QGraphicsItemPrivate::AncestorClipsChildren
- : QGraphicsItemPrivate::AncestorIgnoresTransformations;
+ for (int i = 0; i < 3; ++i) {
+ QGraphicsItem::GraphicsItemFlag flag;
+ int ancestorFlag;
+
+ switch (i) {
+ case(0):
+ flag = QGraphicsItem::ItemClipsChildrenToShape;
+ ancestorFlag = QGraphicsItemPrivate::AncestorClipsChildren;
+ break;
+ case(1):
+ flag = QGraphicsItem::ItemIgnoresTransformations;
+ ancestorFlag = QGraphicsItemPrivate::AncestorIgnoresTransformations;
+ break;
+ case(2):
+ flag = QGraphicsItem::ItemContainsChildrenInShape;
+ ancestorFlag = QGraphicsItemPrivate::AncestorContainsChildren;
+ break;
+ default:
+ qFatal("Unknown ancestor flag, please fix!");
+ break;
+ }
QCOMPARE(int(level1->d_ptr->ancestorFlags), 0);
QCOMPARE(int(level21->d_ptr->ancestorFlags), 0);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 8f57eca0a7..5bb8634b82 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -282,6 +282,9 @@ void tst_QGraphicsProxyWidget::initTestCase()
#ifdef Q_OS_WINCE //disable magic for WindowsCE
qApp->setAutoMaximizeThreshold(-1);
#endif
+ // Disable menu animations to prevent the alpha widget from getting in the way
+ // in actionsContextMenu().
+ QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
}
// This will be called after the last test function is executed.
@@ -298,6 +301,7 @@ void tst_QGraphicsProxyWidget::init()
// This will be called after every test function.
void tst_QGraphicsProxyWidget::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QGraphicsProxyWidget::qgraphicsproxywidget_data()
@@ -840,10 +844,11 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
QTRY_VERIFY(view.isVisible());
QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
- QWidget *widget = new QWidget;
+ QScopedPointer<QWidget> widgetGuard(new QWidget);
+ QWidget *widget = widgetGuard.data();
widget->setFocusPolicy(Qt::WheelFocus);
if (hasWidget)
- proxy->setWidget(widget);
+ proxy->setWidget(widgetGuard.take());
proxy->show();
proxy->setFocus();
QVERIFY(proxy->hasFocus());
@@ -970,13 +975,14 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
QVERIFY(QTest::qWaitForWindowActive(&view));
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
- EventLogger *widget = new EventLogger;
+ QScopedPointer<EventLogger> widgetGuard(new EventLogger);
+ EventLogger *widget = widgetGuard.data();
widget->resize(50, 50);
widget->setAttribute(Qt::WA_Hover, hoverEnabled);
widget->setMouseTracking(true);
view.resize(100, 100);
if (hasWidget)
- proxy->setWidget(widget);
+ proxy->setWidget(widgetGuard.take());
proxy->setPos(50, 0);
scene.addItem(proxy);
QTest::qWait(30);
@@ -1001,9 +1007,6 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
QTRY_COMPARE(widget->hoverLeave, (hasWidget && hoverEnabled) ? 1 : 0);
// does not work on all platforms
//QCOMPARE(widget->moveCount, 0);
-
- if (!hasWidget)
- delete widget;
}
#endif
@@ -2447,6 +2450,13 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
void tst_QGraphicsProxyWidget::popup_basic()
{
+ QScopedPointer<QComboBox> box(new QComboBox);
+ QStyleOptionComboBox opt;
+ opt.initFrom(box.data());
+ opt.editable = box->isEditable();
+ if (box->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt))
+ QSKIP("Does not work due to SH_Combobox_Popup");
+
// ProxyWidget should automatically create proxy's when the widget creates a child
QGraphicsScene *scene = new QGraphicsScene;
QGraphicsView view(scene);
@@ -2455,12 +2465,11 @@ void tst_QGraphicsProxyWidget::popup_basic()
view.show();
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
- QComboBox *box = new QComboBox;
box->setGeometry(0, 0, 320, 40);
box->addItems(QStringList() << "monday" << "tuesday" << "wednesday"
<< "thursday" << "saturday" << "sunday");
QCOMPARE(proxy->childItems().count(), 0);
- proxy->setWidget(box);
+ proxy->setWidget(box.data());
proxy->show();
scene->addItem(proxy);
@@ -2480,12 +2489,7 @@ void tst_QGraphicsProxyWidget::popup_basic()
QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0];
QVERIFY(child->isWidget());
QVERIFY(child->widget());
- QStyleOptionComboBox opt;
- opt.initFrom(box);
- opt.editable = box->isEditable();
- if (box->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt))
- QSKIP("Does not work due to SH_Combobox_Popup");
- QCOMPARE(child->widget()->parent(), static_cast<QObject*>(box));
+ QCOMPARE(child->widget()->parent(), static_cast<QObject*>(box.data()));
QTRY_COMPARE(proxy->pos(), QPointF(box->pos()));
QCOMPARE(child->x(), qreal(box->x()));
@@ -2975,6 +2979,8 @@ void tst_QGraphicsProxyWidget::dontCrashWhenDie()
QApplication::processEvents();
delete w;
+ // This leaves an invisible proxy widget behind.
+ qDeleteAll(QApplication::topLevelWidgets());
}
void tst_QGraphicsProxyWidget::createProxyForChildWidget()
@@ -3472,7 +3478,8 @@ void tst_QGraphicsProxyWidget::clickFocus()
{
QGraphicsScene scene;
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- QGraphicsProxyWidget *proxy = scene.addWidget(new QLineEdit);
+ QLineEdit *le1 = new QLineEdit;
+ QGraphicsProxyWidget *proxy = scene.addWidget(le1);
QGraphicsView view(&scene);
@@ -3524,6 +3531,7 @@ void tst_QGraphicsProxyWidget::clickFocus()
scene.setFocusItem(0);
proxy->setWidget(new QLineEdit); // resets focusWidget
+ delete le1;
{
QPointF lineEditCenter = proxy->mapToScene(proxy->boundingRect().center());
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index dfc8465210..a4752126bc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -267,6 +267,7 @@ private slots:
void removeFullyTransparentItem();
void zeroScale();
void focusItemChangedSignal();
+ void minimumRenderSize();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -4678,6 +4679,78 @@ void tst_QGraphicsScene::focusItemChangedSignal()
}
+class ItemCountsPaintCalls : public QGraphicsRectItem
+{
+public:
+ ItemCountsPaintCalls(const QRectF & rect, QGraphicsItem *parent = 0)
+ : QGraphicsRectItem(rect, parent), repaints(0) {}
+ void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 )
+ {
+ QGraphicsRectItem::paint(painter, option, widget);
+ ++repaints;
+ }
+ int repaints;
+};
+
+void tst_QGraphicsScene::minimumRenderSize()
+{
+ Q_CHECK_PAINTEVENTS
+
+ ItemCountsPaintCalls *bigParent = new ItemCountsPaintCalls(QRectF(0,0,100,100));
+ ItemCountsPaintCalls *smallChild = new ItemCountsPaintCalls(QRectF(0,0,10,10), bigParent);
+ ItemCountsPaintCalls *smallerGrandChild = new ItemCountsPaintCalls(QRectF(0,0,1,1), smallChild);
+ QGraphicsScene scene;
+ scene.addItem(bigParent);
+
+ CustomView view;
+ view.setScene(&scene);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ qApp->processEvents();
+
+ // Initially, everything should be repainted the same number of times
+ int viewRepaints = 0;
+ QTRY_VERIFY(view.repaints > viewRepaints);
+ viewRepaints = view.repaints;
+
+ QVERIFY(viewRepaints == bigParent->repaints);
+ QVERIFY(viewRepaints == smallChild->repaints);
+ QVERIFY(viewRepaints == smallerGrandChild->repaints);
+
+ // Setting a minimum render size should cause a repaint
+ scene.setMinimumRenderSize(0.5);
+ qApp->processEvents();
+
+ QTRY_VERIFY(view.repaints > viewRepaints);
+ viewRepaints = view.repaints;
+
+ QVERIFY(viewRepaints == bigParent->repaints);
+ QVERIFY(viewRepaints == smallChild->repaints);
+ QVERIFY(viewRepaints == smallerGrandChild->repaints);
+
+ // Scaling should cause a repaint of big items only.
+ view.scale(0.1, 0.1);
+ qApp->processEvents();
+
+ QTRY_VERIFY(view.repaints > viewRepaints);
+ viewRepaints = view.repaints;
+
+ QVERIFY(viewRepaints == bigParent->repaints);
+ QVERIFY(viewRepaints == smallChild->repaints);
+ QVERIFY(smallChild->repaints > smallerGrandChild->repaints);
+
+ // Scaling further should cause even fewer items to be repainted
+ view.scale(0.1, 0.1); // Stacks with previous scale
+ qApp->processEvents();
+
+ QTRY_VERIFY(view.repaints > viewRepaints);
+ viewRepaints = view.repaints;
+
+ QVERIFY(viewRepaints == bigParent->repaints);
+ QVERIFY(bigParent->repaints > smallChild->repaints);
+ QVERIFY(smallChild->repaints > smallerGrandChild->repaints);
+}
+
void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache()
{
QGraphicsScene scene;
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index daca1d1516..237d4f8a29 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -248,6 +248,7 @@ private slots:
void testFocusPolicy_data();
void testFocusPolicy();
void QTBUG31411_noSelection();
+ void QTBUG39324_settingSameInstanceOfIndexWidget();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1830,5 +1831,22 @@ void tst_QAbstractItemView::QTBUG31411_noSelection()
QCOMPARE(selectionChangeSpy.count(), 0);
}
+void tst_QAbstractItemView::QTBUG39324_settingSameInstanceOfIndexWidget()
+{
+ QStringList list;
+ list << "FOO" << "bar";
+ QScopedPointer<QStringListModel> model(new QStringListModel(list));
+
+ QScopedPointer<QTableView> table(new QTableView());
+ table->setModel(model.data());
+
+ QModelIndex index = model->index(0,0);
+ QLineEdit *lineEdit = new QLineEdit();
+ table->setIndexWidget(index, lineEdit);
+ table->setIndexWidget(index, lineEdit);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ table->show();
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 38367fb4ee..33af273284 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -178,6 +178,8 @@ private slots:
void spansAfterColumnInsertion();
void spansAfterRowRemoval();
void spansAfterColumnRemoval();
+ void editSpanFromDirections_data();
+ void editSpanFromDirections();
void checkHeaderReset();
void checkHeaderMinSize();
@@ -1240,28 +1242,28 @@ void tst_QTableView::moveCursorStrikesBack_data()
<< IntList()
<< QRect(1, 2, 2, 3)
<< 2 << 0 << (IntList() << int(QtTestTableView::MoveNext))
- << 2 << 2;
+ << 2 << 1;
QTest::newRow("Span, anchor column disabled") << -1 << -1
<< IntList()
<< (IntList() << 1)
<< QRect(1, 2, 2, 3)
<< 2 << 0 << (IntList() << int(QtTestTableView::MoveNext))
- << 2 << 2;
+ << 2 << 1;
QTest::newRow("Span, anchor row hidden") << 2 << -1
<< IntList()
<< IntList()
<< QRect(1, 2, 2, 3)
<< 1 << 2 << (IntList() << int(QtTestTableView::MoveDown))
- << 3 << 2;
+ << 2 << 1;
QTest::newRow("Span, anchor row disabled") << -1 << -1
<< (IntList() << 2)
<< IntList()
<< QRect(1, 2, 2, 3)
<< 1 << 2 << (IntList() << int(QtTestTableView::MoveDown))
- << 3 << 2;
+ << 2 << 1;
QTest::newRow("Move through span right") << -1 << -1
<< IntList()
@@ -3278,6 +3280,159 @@ void tst_QTableView::spansAfterColumnRemoval()
VERIFY_SPANS_CONSISTENCY(&view);
}
+Q_DECLARE_METATYPE(Qt::Key)
+
+void tst_QTableView::editSpanFromDirections_data()
+{
+ QTest::addColumn<QList<Qt::Key> >("keyPresses");
+ QTest::addColumn<QSharedPointer<QStandardItemModel> >("model");
+ QTest::addColumn<int>("row");
+ QTest::addColumn<int>("column");
+ QTest::addColumn<int>("rowSpan");
+ QTest::addColumn<int>("columnSpan");
+ QTest::addColumn<QModelIndex>("expectedVisualCursorIndex");
+ QTest::addColumn<QModelIndex>("expectedEditedIndex");
+
+ /* x = the cell that should be edited
+ c = the cell that should actually be the current index
+ +---+---+
+ | | |
+ +---+---+
+ | | x |
+ +---+ +
+ | | c |
+ +---+---+
+ | | ^ |
+ +---+---+ */
+ QList<Qt::Key> keyPresses;
+ keyPresses << Qt::Key_Right << Qt::Key_PageDown << Qt::Key_Up;
+ QSharedPointer<QStandardItemModel> model(new QStandardItemModel(4, 2));
+ QTest::newRow("row span, bottom up")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(2, 1) << model->index(1, 1);
+
+ /* +---+---+
+ | | v |
+ +---+---+
+ | |x,c|
+ +---+ +
+ | | |
+ +---+---+
+ | | |
+ +---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_Right << Qt::Key_Down;
+ model.reset(new QStandardItemModel(4, 2));
+ QTest::newRow("row span, top down")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(1, 1) << model->index(1, 1);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ | |x,c| < |
+ +---+ +---+
+ | | | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_End << Qt::Key_Down << Qt::Key_Left;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("row span, right to left")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(1, 1) << model->index(1, 1);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ | | x | |
+ +---+ +---+
+ | > | c | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_PageDown << Qt::Key_Right;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("row span, left to right")
+ << keyPresses << model << 1 << 1 << 2 << 1 << model->index(2, 1) << model->index(1, 1);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ |x,c |
+ +---+---+---+
+ | ^ | | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_PageDown << Qt::Key_Up;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("col span, bottom up")
+ << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 0) << model->index(1, 0);
+
+ /* +---+---+---+
+ | | | |
+ +---+---+---+
+ | x c |
+ +---+---+---+
+ | | ^ | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_PageDown << Qt::Key_Right << Qt::Key_Up;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("col span, bottom up #2")
+ << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 1) << model->index(1, 0);
+
+ /* +---+---+---+
+ | | | v |
+ +---+---+---+
+ | x c |
+ +---+---+---+
+ | | | |
+ +---+---+---+ */
+ keyPresses.clear();
+ keyPresses << Qt::Key_End << Qt::Key_Down;
+ model.reset(new QStandardItemModel(3, 3));
+ QTest::newRow("col span, top down")
+ << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 2) << model->index(1, 0);
+}
+
+class TableViewWithCursorExposed : public QTableView
+{
+public:
+ TableViewWithCursorExposed() :
+ QTableView() {
+ }
+
+public:
+ QModelIndex visualCursorIndex() {
+ QTableViewPrivate *d = static_cast<QTableViewPrivate*>(qt_widget_private(this));
+ return d->model->index(d->visualCursor.y(), d->visualCursor.x());
+ }
+};
+
+void tst_QTableView::editSpanFromDirections()
+{
+ QFETCH(QList<Qt::Key>, keyPresses);
+ QFETCH(QSharedPointer<QStandardItemModel>, model);
+ QFETCH(int, row);
+ QFETCH(int, column);
+ QFETCH(int, rowSpan);
+ QFETCH(int, columnSpan);
+ QFETCH(QModelIndex, expectedVisualCursorIndex);
+ QFETCH(QModelIndex, expectedEditedIndex);
+
+ TableViewWithCursorExposed view;
+ view.setModel(model.data());
+ view.setSpan(row, column, rowSpan, columnSpan);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ foreach (Qt::Key key, keyPresses) {
+ QTest::keyClick(&view, key);
+ }
+ QCOMPARE(view.visualCursorIndex(), expectedVisualCursorIndex);
+ QCOMPARE(view.selectionModel()->currentIndex(), expectedEditedIndex);
+
+ QTest::keyClick(&view, Qt::Key_X);
+ QTest::keyClick(QApplication::focusWidget(), Qt::Key_Enter);
+ QTRY_COMPARE(view.model()->data(expectedEditedIndex).toString(), QLatin1String("x"));
+}
+
class Model : public QAbstractTableModel {
Q_OBJECT
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 9d7d3d1f34..6c1e67a049 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -260,6 +260,7 @@ void tst_QApplication::cleanup()
{
// TODO: Add cleanup code here.
// This will be executed immediately after each test is run.
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QApplication::staticSetup()
@@ -916,10 +917,10 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r)
#define QT_TST_QAPP_DEBUG
void tst_QApplication::libraryPaths()
{
- {
#ifndef Q_OS_WINCE
- QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
-#else
+ const QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
+ QVERIFY(!testDir.isEmpty());
+#else // !Q_OS_WINCE
// On Windows CE we need QApplication object to have valid
// current Path. Therefore we need to identify it ourselves
// here for the test.
@@ -927,8 +928,9 @@ void tst_QApplication::libraryPaths()
wchar_t module_name[MAX_PATH];
GetModuleFileName(0, module_name, MAX_PATH);
filePath = QString::fromWCharArray(module_name);
- QString testDir = filePath.path() + "/test";
-#endif
+ const QString testDir = filePath.path() + "/test";
+#endif // Q_OS_WINCE
+ {
QApplication::setLibraryPaths(QStringList() << testDir);
QCOMPARE(QApplication::libraryPaths(), (QStringList() << testDir));
@@ -964,8 +966,7 @@ void tst_QApplication::libraryPaths()
"\nexpected:\n - " + expected.join("\n - ")));
// setting the library paths overrides everything
- QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
- QApplication::setLibraryPaths(QStringList() << testDir);
+ QApplication::setLibraryPaths(QStringList() << testDir);
QVERIFY2(isPathListIncluded(QApplication::libraryPaths(), (QStringList() << testDir)),
qPrintable("actual:\n - " + QApplication::libraryPaths().join("\n - ") +
"\nexpected:\n - " + testDir));
@@ -987,7 +988,6 @@ void tst_QApplication::libraryPaths()
qDebug() << "After adding plugins path:" << QApplication::libraryPaths();
#endif
QCOMPARE(QApplication::libraryPaths().count(), count);
- QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
QApplication::addLibraryPath(testDir);
QCOMPARE(QApplication::libraryPaths().count(), count + 1);
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 4252fb673b..270de944c5 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -449,6 +449,8 @@ private:
QWidget *testWidget;
const QString m_platform;
+ QSize m_testWidgetSize;
+ QPoint m_availableTopLeft;
const bool m_windowsAnimationsEnabled;
};
@@ -644,9 +646,20 @@ void tst_QWidget::initTestCase()
#ifdef Q_OS_WINCE //disable magic for WindowsCE
qApp->setAutoMaximizeThreshold(-1);
#endif
+ // Size of reference widget, 200 for < 2000, scale up for larger screens
+ // to avoid Windows warnings about minimum size for decorated windows.
+ int width = 200;
+ const QScreen *screen = QGuiApplication::primaryScreen();
+ m_availableTopLeft = screen->availableGeometry().topLeft();
+ const int screenWidth = screen->geometry().width();
+ if (screenWidth > 2000)
+ width = 100 * ((screenWidth + 500) / 1000);
+ m_testWidgetSize = QSize(width, width);
// Create the test class
testWidget = new BezierViewer;
- testWidget->resize(200,200);
+ testWidget->setWindowTitle(QStringLiteral("BezierViewer"));
+ testWidget->move(m_availableTopLeft + QPoint(screenWidth / 3, 50));
+ testWidget->resize(m_testWidgetSize);
testWidget->show();
QVERIFY(QTest::qWaitForWindowExposed(testWidget));
}
@@ -667,6 +680,8 @@ void tst_QWidget::init()
void tst_QWidget::cleanup()
{
+ // Only 'testwidget', do not leak any other widgets.
+ QCOMPARE(QApplication::topLevelWidgets().size(), 1);
}
// Helper class...
@@ -1115,6 +1130,9 @@ void tst_QWidget::enabledPropagation()
void tst_QWidget::ignoreKeyEventsWhenDisabled_QTBUG27417()
{
QLineEdit lineEdit;
+ lineEdit.setWindowTitle(__FUNCTION__);
+ lineEdit.setMinimumWidth(m_testWidgetSize.width());
+ centerOnScreen(&lineEdit);
lineEdit.setDisabled(true);
lineEdit.show();
QTest::keyClick(&lineEdit, Qt::Key_A);
@@ -1124,6 +1142,9 @@ void tst_QWidget::ignoreKeyEventsWhenDisabled_QTBUG27417()
void tst_QWidget::properTabHandlingWhenDisabled_QTBUG27417()
{
QWidget widget;
+ widget.setWindowTitle(__FUNCTION__);
+ widget.setMinimumWidth(m_testWidgetSize.width());
+ centerOnScreen(&widget);
QVBoxLayout *layout = new QVBoxLayout();
QLineEdit *lineEdit = new QLineEdit();
layout->addWidget(lineEdit);
@@ -1211,7 +1232,7 @@ void tst_QWidget::isEnabledTo()
QVERIFY( grandChildWidget->isEnabledTo( childWidget ) );
QVERIFY( !grandChildWidget->isEnabledTo( testWidget ) );
- QMainWindow* childDialog = new QMainWindow(testWidget);
+ QScopedPointer<QMainWindow> childDialog(new QMainWindow(testWidget));
testWidget->setEnabled(false);
QVERIFY(!childDialog->isEnabled());
QVERIFY(childDialog->isEnabledTo(0));
@@ -1836,7 +1857,7 @@ void tst_QWidget::windowState()
QSKIP("X11: Many window managers do not support window state properly, which causes this test to fail.");
QPoint pos;
- QSize size(200, 200);
+ QSize size = m_testWidgetSize;
if (QGuiApplicationPrivate::platformIntegration()->defaultWindowState(Qt::Widget)
== Qt::WindowFullScreen) {
size = QGuiApplication::primaryScreen()->size();
@@ -2275,6 +2296,7 @@ void tst_QWidget::showMinimizedKeepsFocus()
QTRY_COMPARE(qApp->focusWidget(), child);
child->setParent(0);
+ QScopedPointer<QWidget> childGuard(child);
QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
}
@@ -2342,8 +2364,9 @@ void tst_QWidget::showMinimizedKeepsFocus()
void tst_QWidget::reparent()
{
QWidget parent;
- parent.setWindowTitle("Toplevel");
- parent.setGeometry(300, 300, 200, 150);
+ parent.setWindowTitle(QStringLiteral("Toplevel ") + __FUNCTION__);
+ const QPoint parentPosition = m_availableTopLeft + QPoint(300, 300);
+ parent.setGeometry(QRect(parentPosition, m_testWidgetSize));
QWidget child(0);
child.setObjectName("child");
@@ -2353,8 +2376,9 @@ void tst_QWidget::reparent()
child.setPalette(pal1);
QWidget childTLW(&child, Qt::Window);
- childTLW.setObjectName("childTLW");
- childTLW.setGeometry(100, 100, 50, 50);
+ childTLW.setObjectName(QStringLiteral("childTLW ") + __FUNCTION__);
+ childTLW.setWindowTitle(childTLW.objectName());
+ childTLW.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize));
QPalette pal2;
pal2.setColor(childTLW.backgroundRole(), Qt::yellow);
childTLW.setPalette(pal2);
@@ -2366,7 +2390,7 @@ void tst_QWidget::reparent()
#ifdef Q_OS_WINCE
parent.move(50, 50);
#else
- parent.move(300, 300);
+ parent.move(parentPosition);
#endif
QPoint childPos = parent.mapToGlobal(child.pos());
@@ -2446,7 +2470,8 @@ void tst_QWidget::normalGeometry()
QCOMPARE(parent.normalGeometry(), parent.geometry());
QCOMPARE(child->normalGeometry(), QRect());
- parent.setGeometry(100, 100, 200, 200);
+ const QRect testGeom = QRect(m_availableTopLeft + QPoint(100 ,100), m_testWidgetSize);
+ parent.setGeometry(testGeom);
parent.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&parent));
QApplication::processEvents();
@@ -3009,8 +3034,8 @@ void tst_QWidget::testContentsPropagation()
void tst_QWidget::saveRestoreGeometry()
{
- const QPoint position(100, 100);
- const QSize size(200, 200);
+ const QPoint position = m_availableTopLeft + QPoint(100, 100);
+ const QSize size = m_testWidgetSize;
QByteArray savedGeometry;
@@ -3232,19 +3257,21 @@ void tst_QWidget::widgetAt()
{
Q_CHECK_PAINTEVENTS
+ const QPoint referencePos = m_availableTopLeft + QPoint(100, 100);
QScopedPointer<QWidget> w1(new QWidget(0, Qt::X11BypassWindowManagerHint));
- w1->setGeometry(0, 0, 160, 150);
+ w1->setGeometry(QRect(referencePos, QSize(m_testWidgetSize.width(), 150)));
w1->setObjectName(QLatin1String("w1"));
w1->setWindowTitle(w1->objectName());
QScopedPointer<QWidget> w2(new QWidget(0, Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint));
- w2->setGeometry(50,50, 160, 100);
+ w2->setGeometry(QRect(referencePos + QPoint(50, 50), QSize(m_testWidgetSize.width(), 100)));
w2->setObjectName(QLatin1String("w2"));
w2->setWindowTitle(w2->objectName());
w1->showNormal();
QVERIFY(QTest::qWaitForWindowExposed(w1.data()));
qApp->processEvents();
+ const QPoint testPos = referencePos + QPoint(100, 100);
QWidget *wr;
- QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)));
+ QTRY_VERIFY((wr = QApplication::widgetAt((testPos))));
QCOMPARE(wr->objectName(), QString("w1"));
w2->showNormal();
@@ -3252,27 +3279,27 @@ void tst_QWidget::widgetAt()
qApp->processEvents();
qApp->processEvents();
qApp->processEvents();
- QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)));
+ QTRY_VERIFY((wr = QApplication::widgetAt(testPos)));
QCOMPARE(wr->objectName(), QString("w2"));
w2->lower();
qApp->processEvents();
- QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)) && wr->objectName() == QString("w1"));
+ QTRY_VERIFY((wr = QApplication::widgetAt(testPos)) && wr->objectName() == QString("w1"));
w2->raise();
qApp->processEvents();
- QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)) && wr->objectName() == QString("w2"));
+ QTRY_VERIFY((wr = QApplication::widgetAt(testPos)) && wr->objectName() == QString("w2"));
QWidget *w3 = new QWidget(w2.data());
w3->setGeometry(10,10,50,50);
w3->setObjectName("w3");
w3->showNormal();
qApp->processEvents();
- QTRY_VERIFY((wr = QApplication::widgetAt(100,100)) && wr->objectName() == QString("w3"));
+ QTRY_VERIFY((wr = QApplication::widgetAt(testPos)) && wr->objectName() == QString("w3"));
w3->setAttribute(Qt::WA_TransparentForMouseEvents);
qApp->processEvents();
- QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)) && wr->objectName() == QString("w2"));
+ QTRY_VERIFY((wr = QApplication::widgetAt(testPos)) && wr->objectName() == QString("w2"));
if (!QGuiApplicationPrivate::platformIntegration()
->hasCapability(QPlatformIntegration::WindowMasks)) {
@@ -3280,7 +3307,7 @@ void tst_QWidget::widgetAt()
}
QRegion rgn = QRect(QPoint(0,0), w2->size());
- QPoint point = w2->mapFromGlobal(QPoint(100,100));
+ QPoint point = w2->mapFromGlobal(testPos);
rgn -= QRect(point, QSize(1,1));
w2->setMask(rgn);
qApp->processEvents();
@@ -3291,16 +3318,16 @@ void tst_QWidget::widgetAt()
if (!QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive))
QEXPECT_FAIL("", "Window mask not implemented on Mac QTBUG-22326", Continue);
- QTRY_VERIFY((wr = QApplication::widgetAt(100,100)));
+ QTRY_VERIFY((wr = QApplication::widgetAt(testPos)));
QTRY_COMPARE(wr->objectName(), w1->objectName());
- QTRY_VERIFY((wr = QApplication::widgetAt(101,101)));
+ QTRY_VERIFY((wr = QApplication::widgetAt(testPos + QPoint(1, 1))));
QTRY_COMPARE(wr->objectName(), w2->objectName());
QBitmap bitmap(w2->size());
QPainter p(&bitmap);
p.fillRect(bitmap.rect(), Qt::color1);
p.setPen(Qt::color0);
- p.drawPoint(w2->mapFromGlobal(QPoint(100,100)));
+ p.drawPoint(w2->mapFromGlobal(testPos));
p.end();
w2->setMask(bitmap);
qApp->processEvents();
@@ -3310,8 +3337,8 @@ void tst_QWidget::widgetAt()
#endif
if (!QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive))
QEXPECT_FAIL("", "Window mask not implemented on Mac QTBUG-22326", Continue);
- QTRY_VERIFY(QApplication::widgetAt(100,100) == w1.data());
- QTRY_VERIFY(QApplication::widgetAt(101,101) == w2.data());
+ QTRY_VERIFY(QApplication::widgetAt(testPos) == w1.data());
+ QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data());
}
void tst_QWidget::task110173()
@@ -3957,7 +3984,8 @@ void tst_QWidget::persistentWinId()
void tst_QWidget::showNativeChild()
{
QWidget topLevel;
- topLevel.setGeometry(0, 0, 160, 160);
+ topLevel.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize));
+ topLevel.setWindowTitle(__FUNCTION__);
QWidget child(&topLevel);
child.winId();
topLevel.show();
@@ -4420,36 +4448,39 @@ void tst_QWidget::setWindowGeometry_data()
QTest::addColumn<int>("windowFlags");
QList<QList<QRect> > rects;
+ const int width = m_testWidgetSize.width();
+ const int height = m_testWidgetSize.height();
+ const QRect availableAdjusted = QApplication::desktop()->availableGeometry().adjusted(100, 100, -100, -100);
rects << (QList<QRect>()
- << QRect(100, 100, 200, 200)
- << QApplication::desktop()->availableGeometry().adjusted(100, 100, -100, -100)
- << QRect(130, 100, 0, 200)
- << QRect(100, 50, 200, 0)
- << QRect(130, 50, 0, 0))
+ << QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize)
+ << availableAdjusted
+ << QRect(m_availableTopLeft + QPoint(130, 100), QSize(0, height))
+ << QRect(m_availableTopLeft + QPoint(100, 50), QSize(width, 0))
+ << QRect(m_availableTopLeft + QPoint(130, 50), QSize(0, 0)))
<< (QList<QRect>()
- << QApplication::desktop()->availableGeometry().adjusted(100, 100, -100, -100)
- << QRect(130, 100, 0, 200)
- << QRect(100, 50, 200, 0)
- << QRect(130, 50, 0, 0)
- << QRect(100, 100, 200, 200))
+ << availableAdjusted
+ << QRect(m_availableTopLeft + QPoint(130, 100), QSize(0, height))
+ << QRect(m_availableTopLeft + QPoint(100, 50), QSize(width, 0))
+ << QRect(m_availableTopLeft + QPoint(130, 50), QSize(0, 0))
+ << QRect(m_availableTopLeft + QPoint(100, 100), QSize(width, height)))
<< (QList<QRect>()
- << QRect(130, 100, 0, 200)
- << QRect(100, 50, 200, 0)
- << QRect(130, 50, 0, 0)
- << QRect(100, 100, 200, 200)
- << QApplication::desktop()->availableGeometry().adjusted(100, 100, -100, -100))
+ << QRect(m_availableTopLeft + QPoint(130, 100), QSize(0, height))
+ << QRect(m_availableTopLeft + QPoint(100, 50), QSize(width, 0))
+ << QRect(m_availableTopLeft + QPoint(130, 50), QSize(0, 0))
+ << QRect(m_availableTopLeft + QPoint(100, 100), QSize(width, height))
+ << availableAdjusted)
<< (QList<QRect>()
- << QRect(100, 50, 200, 0)
- << QRect(130, 50, 0, 0)
- << QRect(100, 100, 200, 200)
- << QApplication::desktop()->availableGeometry().adjusted(100, 100, -100, -100)
- << QRect(130, 100, 0, 200))
+ << QRect(m_availableTopLeft + QPoint(100, 50), QSize(width, 0))
+ << QRect(m_availableTopLeft + QPoint(130, 50), QSize(0, 0))
+ << QRect(m_availableTopLeft + QPoint(100, 100), QSize(width, height))
+ << availableAdjusted
+ << QRect(m_availableTopLeft + QPoint(130, 100), QSize(0, height)))
<< (QList<QRect>()
- << QRect(130, 50, 0, 0)
- << QRect(100, 100, 200, 200)
- << QApplication::desktop()->availableGeometry().adjusted(100, 100, -100, -100)
- << QRect(130, 100, 0, 200)
- << QRect(100, 50, 200, 0));
+ << QRect(m_availableTopLeft + QPoint(130, 50), QSize(0, 0))
+ << QRect(m_availableTopLeft + QPoint(100, 100), QSize(width, height))
+ << availableAdjusted
+ << QRect(m_availableTopLeft + QPoint(130, 100), QSize(0, height))
+ << QRect(m_availableTopLeft + QPoint(100, 50), QSize(width, 0)));
QList<int> windowFlags;
windowFlags << 0 << Qt::FramelessWindowHint;
@@ -5202,6 +5233,7 @@ public:
void tst_QWidget::setFocus()
{
+ const QPoint windowPos = testWidget->geometry().topRight() + QPoint(50, 0);
{
// move focus to another window
testWidget->activateWindow();
@@ -5213,7 +5245,9 @@ void tst_QWidget::setFocus()
// window and children never shown, nobody gets focus
QWidget window;
- window.resize(200, 200);
+ window.setWindowTitle(QStringLiteral("#1 ") + __FUNCTION__);
+ window.resize(m_testWidgetSize);
+ window.move(windowPos);
QWidget child1(&window);
child1.setFocusPolicy(Qt::StrongFocus);
@@ -5235,7 +5269,9 @@ void tst_QWidget::setFocus()
{
// window and children show, but window not active, nobody gets focus
QWidget window;
- window.resize(200, 200);
+ window.setWindowTitle(QStringLiteral("#2 ") + __FUNCTION__);
+ window.resize(m_testWidgetSize);
+ window.move(windowPos);
QWidget child1(&window);
child1.setFocusPolicy(Qt::StrongFocus);
@@ -5267,7 +5303,9 @@ void tst_QWidget::setFocus()
{
// window and children show, but window *is* active, children get focus
QWidget window;
- window.resize(200, 200);
+ window.setWindowTitle(QStringLiteral("#3 ") + __FUNCTION__);
+ window.resize(m_testWidgetSize);
+ window.move(windowPos);
FocusWidget child1(&window);
child1.setFocusPolicy(Qt::StrongFocus);
@@ -5298,7 +5336,9 @@ void tst_QWidget::setFocus()
{
// window shown and active, children created, don't get focus, but get focus when shown
QWidget window;
- window.resize(200, 200);
+ window.setWindowTitle(QStringLiteral("#4 ") + __FUNCTION__);
+ window.resize(m_testWidgetSize);
+ window.move(windowPos);
window.show();
window.activateWindow();
@@ -5337,7 +5377,9 @@ void tst_QWidget::setFocus()
// window shown and active, children created, don't get focus,
// even after setFocus(), hide(), then show()
QWidget window;
- window.resize(200, 200);
+ window.setWindowTitle(QStringLiteral("#5 ") + __FUNCTION__);
+ window.resize(m_testWidgetSize);
+ window.move(windowPos);
window.show();
window.activateWindow();
@@ -5591,9 +5633,15 @@ void tst_QWidget::testWindowIconChangeEventPropagation()
typedef QSharedPointer<EventSpy<QWindow> > WindowEventSpyPtr;
// Create widget hierarchy.
QWidget topLevelWidget;
+ topLevelWidget.setWindowTitle(QStringLiteral("TopLevel ") + __FUNCTION__);
+ topLevelWidget.resize(m_testWidgetSize);
+ topLevelWidget.move(m_availableTopLeft + QPoint(100, 100));
QWidget topLevelChild(&topLevelWidget);
QDialog dialog(&topLevelWidget);
+ dialog.resize(m_testWidgetSize);
+ dialog.move(topLevelWidget.geometry().topRight() + QPoint(100, 0));
+ dialog.setWindowTitle(QStringLiteral("Dialog ") + __FUNCTION__);
QWidget dialogChild(&dialog);
QWidgetList widgets;
@@ -6295,6 +6343,7 @@ void tst_QWidget::renderInvisible()
QSKIP("QTBUG-26424");
QScopedPointer<QCalendarWidget> calendar(new QCalendarWidget);
+ calendar->move(m_availableTopLeft + QPoint(100, 100));
// disable anti-aliasing to eliminate potential differences when subpixel antialiasing
// is enabled on the screen
QFont f;
@@ -6305,6 +6354,8 @@ void tst_QWidget::renderInvisible()
// Create a dummy focus widget to get rid of focus rect in reference image.
QLineEdit dummyFocusWidget;
+ dummyFocusWidget.setMinimumWidth(m_testWidgetSize.width());
+ dummyFocusWidget.move(calendar->geometry().bottomLeft() + QPoint(0, 100));
dummyFocusWidget.show();
QVERIFY(QTest::qWaitForWindowExposed(&dummyFocusWidget));
qApp->processEvents();
@@ -6615,12 +6666,15 @@ void tst_QWidget::render_task211796()
{ // Please don't die in a resize recursion.
MyWidget widget;
- widget.resize(200, 200);
+ widget.resize(m_testWidgetSize);
+ centerOnScreen(&widget);
widget.show();
}
{ // Same check with a deeper hierarchy.
QWidget widget;
+ widget.resize(m_testWidgetSize);
+ centerOnScreen(&widget);
widget.show();
QWidget child(&widget);
MyWidget grandChild;
@@ -7305,7 +7359,7 @@ void tst_QWidget::alienWidgets()
qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
QWidget parent;
- parent.resize(200, 200);
+ parent.resize(m_testWidgetSize);
QWidget child(&parent);
QWidget grandChild(&child);
QWidget greatGrandChild(&grandChild);
@@ -7339,7 +7393,7 @@ void tst_QWidget::alienWidgets()
// Ensure that hide() on an ancestor of a widget with
// Qt::WA_DontCreateNativeAncestors still gets unmapped
QWidget window;
- window.resize(200, 200);
+ window.resize(m_testWidgetSize);
QWidget widget(&window);
QWidget child(&widget);
child.setAttribute(Qt::WA_NativeWindow);
@@ -7401,7 +7455,7 @@ void tst_QWidget::alienWidgets()
// Make sure we don't create native windows when setting Qt::WA_X11NetWmWindowType attributes
// on alien widgets (see task 194231).
QWidget dummy;
- dummy.resize(200, 200);
+ dummy.resize(m_testWidgetSize);
QVERIFY(dummy.winId());
QWidget widget(&dummy);
widget.setAttribute(Qt::WA_X11NetWmWindowTypeToolBar);
@@ -7410,7 +7464,7 @@ void tst_QWidget::alienWidgets()
{ // Make sure we create native ancestors when setting Qt::WA_PaintOnScreen before show().
QWidget topLevel;
- topLevel.resize(200, 200);
+ topLevel.resize(m_testWidgetSize);
QWidget child(&topLevel);
QWidget grandChild(&child);
PaintOnScreenWidget greatGrandChild(&grandChild);
@@ -7434,7 +7488,7 @@ void tst_QWidget::alienWidgets()
{ // Ensure that widgets reparented into Qt::WA_PaintOnScreen widgets become native.
QWidget topLevel;
- topLevel.resize(200, 200);
+ topLevel.resize(m_testWidgetSize);
QWidget *widget = new PaintOnScreenWidget(&topLevel);
widget->setAttribute(Qt::WA_PaintOnScreen);
QWidget *child = new QWidget;
@@ -7467,7 +7521,7 @@ void tst_QWidget::alienWidgets()
{ // Ensure that ancestors of a Qt::WA_PaintOnScreen widget stay native
// if they are re-created (typically in QWidgetPrivate::setParent_sys) (task 210822).
QWidget window;
- window.resize(200, 200);
+ window.resize(m_testWidgetSize);
QWidget child(&window);
QWidget grandChild;
@@ -7508,7 +7562,7 @@ void tst_QWidget::alienWidgets()
QWidget *toolBar = new QWidget(&mainWindow);
QWidget *dockWidget = new QWidget(&mainWindow);
QWidget *centralWidget = new QWidget(&mainWindow);
- centralWidget->setMinimumSize(QSize(200, 200));
+ centralWidget->setMinimumSize(m_testWidgetSize);
QWidget *button = new QWidget(centralWidget);
QWidget *mdiArea = new QWidget(centralWidget);
@@ -8255,12 +8309,16 @@ void tst_QWidget::paintOnScreenPossible()
void tst_QWidget::reparentStaticWidget()
{
QWidget window1;
+ window1.setWindowTitle(QStringLiteral("window1 ") + __FUNCTION__);
+ window1.resize(m_testWidgetSize);
+ window1.move(m_availableTopLeft + QPoint(100, 100));
QWidget *child = new QWidget(&window1);
child->setPalette(Qt::red);
child->setAutoFillBackground(true);
child->setAttribute(Qt::WA_StaticContents);
- child->resize(160, 160);
+ child->resize(window1.width() - 40, window1.height() - 40);
+ child->setWindowTitle(QStringLiteral("child ") + __FUNCTION__);
QWidget *grandChild = new QWidget(child);
grandChild->setPalette(Qt::blue);
@@ -8271,6 +8329,9 @@ void tst_QWidget::reparentStaticWidget()
QVERIFY(QTest::qWaitForWindowExposed(&window1));
QWidget window2;
+ window2.setWindowTitle(QStringLiteral("window2 ") + __FUNCTION__);
+ window2.resize(m_testWidgetSize);
+ window2.move(window1.geometry().topRight() + QPoint(100, 0));
window2.show();
QVERIFY(QTest::qWaitForWindowExposed(&window2));
QTest::qWait(20);
@@ -8312,6 +8373,10 @@ void tst_QWidget::reparentStaticWidget()
QTest::qWait(20);
QWidget paintOnScreen;
+ paintOnScreen.setWindowTitle(QStringLiteral("paintOnScreen ") + __FUNCTION__);
+ paintOnScreen.resize(m_testWidgetSize);
+ paintOnScreen.move(window1.geometry().bottomLeft() + QPoint(0, 50));
+
paintOnScreen.setAttribute(Qt::WA_PaintOnScreen);
paintOnScreen.show();
QVERIFY(QTest::qWaitForWindowExposed(&paintOnScreen));
@@ -8330,18 +8395,23 @@ void tst_QWidget::reparentStaticWidget()
void tst_QWidget::QTBUG6883_reparentStaticWidget2()
{
QMainWindow mw;
- QDockWidget *one = new QDockWidget("one", &mw);
+ mw.setWindowTitle(QStringLiteral("MainWindow ") + __FUNCTION__);
+ mw.move(m_availableTopLeft + QPoint(100, 100));
+
+ QDockWidget *one = new QDockWidget(QStringLiteral("Dock ") + __FUNCTION__, &mw);
mw.addDockWidget(Qt::LeftDockWidgetArea, one , Qt::Vertical);
QWidget *child = new QWidget();
child->setPalette(Qt::red);
child->setAutoFillBackground(true);
child->setAttribute(Qt::WA_StaticContents);
- child->resize(100, 100);
+ child->resize(m_testWidgetSize);
one->setWidget(child);
QToolBar *mainTools = mw.addToolBar("Main Tools");
- mainTools->addWidget(new QLineEdit);
+ QLineEdit *le = new QLineEdit;
+ le->setMinimumWidth(m_testWidgetSize.width());
+ mainTools->addWidget(le);
mw.show();
QVERIFY(QTest::qWaitForWindowExposed(&mw));
@@ -8962,7 +9032,7 @@ void tst_QWidget::updateOnDestroyedSignal()
QWidget widget;
QWidget *child = new QWidget(&widget);
- child->resize(200, 200);
+ child->resize(m_testWidgetSize);
child->setAutoFillBackground(true);
child->setPalette(Qt::red);
@@ -8980,6 +9050,7 @@ void tst_QWidget::toplevelLineEditFocus()
testWidget->hide();
QLineEdit w;
+ w.setMinimumWidth(m_testWidgetSize.width());
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
QTest::qWait(20);
@@ -9139,7 +9210,10 @@ void tst_QWidget::activateWindow()
// Create first mainwindow and set it active
QScopedPointer<QMainWindow> mainwindow(new QMainWindow);
QLabel* label = new QLabel(mainwindow.data());
+ label->setMinimumWidth(m_testWidgetSize.width());
+ mainwindow->setWindowTitle(QStringLiteral("#1 ") + __FUNCTION__);
mainwindow->setCentralWidget(label);
+ mainwindow->move(m_availableTopLeft + QPoint(100, 100));
mainwindow->setVisible(true);
mainwindow->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(mainwindow.data()));
@@ -9147,8 +9221,11 @@ void tst_QWidget::activateWindow()
// Create second mainwindow and set it active
QScopedPointer<QMainWindow> mainwindow2(new QMainWindow);
+ mainwindow2->setWindowTitle(QStringLiteral("#2 ") + __FUNCTION__);
QLabel* label2 = new QLabel(mainwindow2.data());
+ label2->setMinimumWidth(m_testWidgetSize.width());
mainwindow2->setCentralWidget(label2);
+ mainwindow2->move(mainwindow->geometry().bottomLeft() + QPoint(0, 50));
mainwindow2->setVisible(true);
mainwindow2->activateWindow();
qApp->processEvents();
@@ -9170,10 +9247,7 @@ void tst_QWidget::openModal_taskQTBUG_5804()
class Widget : public QWidget
{
public:
- Widget(QWidget *parent) : QWidget(parent)
- {
- resize(200, 200);
- }
+ Widget(QWidget *parent) : QWidget(parent) {}
~Widget()
{
QMessageBox msgbox;
@@ -9183,6 +9257,10 @@ void tst_QWidget::openModal_taskQTBUG_5804()
};
QScopedPointer<QWidget> win(new QWidget);
+ win->resize(m_testWidgetSize);
+ win->setWindowTitle(__FUNCTION__);
+ centerOnScreen(win.data());
+
new Widget(win.data());
win->show();
QVERIFY(QTest::qWaitForWindowExposed(win.data()));
@@ -9444,6 +9522,8 @@ void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion()
void tst_QWidget::nativeChildFocus()
{
QWidget w;
+ w.setMinimumWidth(m_testWidgetSize.width());
+ w.setWindowTitle(__FUNCTION__);
QLayout *layout = new QVBoxLayout;
w.setLayout(layout);
QLineEdit *p1 = new QLineEdit;
@@ -9452,6 +9532,7 @@ void tst_QWidget::nativeChildFocus()
layout->addWidget(p2);
p1->setObjectName("p1");
p2->setObjectName("p2");
+ centerOnScreen(&w);
w.show();
w.activateWindow();
p1->setFocus();
@@ -9588,8 +9669,9 @@ void tst_QWidget::grabMouse()
GrabLoggerWidget *grabber = new GrabLoggerWidget(&log, &w);
const QString grabberObjectName = QLatin1String("tst_qwidget_grabMouse_grabber");
grabber->setObjectName(grabberObjectName);
- grabber->setMinimumSize(100, 100);
+ grabber->setMinimumSize(m_testWidgetSize);
layout->addWidget(grabber);
+ centerOnScreen(&w);
w.show();
qApp->setActiveWindow(&w);
QVERIFY(QTest::qWaitForWindowActive(&w));
@@ -9616,9 +9698,12 @@ void tst_QWidget::grabKeyboard()
w.setWindowTitle(w.objectName());
QLayout *layout = new QVBoxLayout(&w);
QLineEdit *grabber = new QLineEdit(&w);
+ grabber->setMinimumWidth(m_testWidgetSize.width());
layout->addWidget(grabber);
QLineEdit *nonGrabber = new QLineEdit(&w);
+ nonGrabber->setMinimumWidth(m_testWidgetSize.width());
layout->addWidget(nonGrabber);
+ centerOnScreen(&w);
w.show();
qApp->setActiveWindow(&w);
QVERIFY(QTest::qWaitForWindowActive(&w));
@@ -10211,11 +10296,11 @@ public:
void tst_QWidget::keyboardModifiers()
{
- KeyboardWidget* w = new KeyboardWidget;
- QTest::mouseClick(w, Qt::LeftButton, Qt::ControlModifier);
- QCOMPARE(w->m_eventCounter, 1);
- QCOMPARE(int(w->m_modifiers), int(Qt::ControlModifier));
- QCOMPARE(int(w->m_appModifiers), int(Qt::ControlModifier));
+ KeyboardWidget w;
+ QTest::mouseClick(&w, Qt::LeftButton, Qt::ControlModifier);
+ QCOMPARE(w.m_eventCounter, 1);
+ QCOMPARE(int(w.m_modifiers), int(Qt::ControlModifier));
+ QCOMPARE(int(w.m_appModifiers), int(Qt::ControlModifier));
}
class DClickWidget : public QWidget
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 d6b7fc20ed..8084d50fbe 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -61,7 +61,7 @@ static inline void setFrameless(QWidget *w)
w->setWindowFlags(flags);
}
-class tst_QWidget_window : public QWidget
+class tst_QWidget_window : public QObject
{
Q_OBJECT
@@ -71,6 +71,7 @@ public:
public slots:
void initTestCase();
void cleanupTestCase();
+ void cleanup();
private slots:
void tst_min_max_size();
@@ -106,9 +107,13 @@ void tst_QWidget_window::cleanupTestCase()
{
}
+void tst_QWidget_window::cleanup()
+{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
/* Test if the maximum/minimum size constraints
- * are propagated from the wid src/widgets/kernel/qwidgetwindow_qpa_p.h
-get to the QWidgetWindow
+ * are propagated from the widget to the QWidgetWindow
* independently of whether they were set before or after
* window creation (QTBUG-26745). */
diff --git a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
index 286b887521..6264151c08 100644
--- a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
+++ b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
@@ -89,18 +89,16 @@ void tst_QWidgetsVariant::constructor_invalid()
QFETCH(uint, typeId);
{
- MessageHandlerInvalidType msg;
+ 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);
- QVERIFY(msg.ok);
}
{
- MessageHandlerInvalidType msg;
+ 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);
- QVERIFY(msg.ok);
}
}
diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
index a4d4e5d717..433fbc2bfe 100644
--- a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
@@ -46,6 +46,7 @@
#include <QStyleOptionGroupBox>
#include <QVBoxLayout>
#include <QRadioButton>
+#include <QDialog>
#include "qgroupbox.h"
@@ -71,6 +72,7 @@ private slots:
void setChecked_data();
void setChecked();
void enabledPropagation();
+ void enabledChildPropagation();
void sizeHint();
void toggled();
void clicked_data();
@@ -288,6 +290,23 @@ void tst_QGroupBox::enabledPropagation()
delete testWidget;
}
+void tst_QGroupBox::enabledChildPropagation()
+{
+ QGroupBox testWidget;
+ testWidget.setCheckable(true);
+ testWidget.setChecked(true);
+ // The value of isChecked() should be reflected in the isEnabled() of newly
+ // added child widgets, but not in top level widgets.
+ QWidget *childWidget = new QWidget(&testWidget);
+ QVERIFY(childWidget->isEnabled());
+ QDialog *dialog = new QDialog(&testWidget);
+ QVERIFY(dialog->isEnabled());
+ testWidget.setChecked(false);
+ childWidget = new QWidget(&testWidget);
+ QVERIFY(!childWidget->isEnabled());
+ dialog = new QDialog(&testWidget);
+ QVERIFY(dialog->isEnabled());
+}
void tst_QGroupBox::sizeHint()
{
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 36f14cb1ba..0094a1112b 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -4185,8 +4185,14 @@ void tst_QLineEdit::clearButton()
QTRY_COMPARE(filterModel->rowCount(), 2); // matches 'aa', 'ab'
QTest::keyClick(filterLineEdit, 'b');
QTRY_COMPARE(filterModel->rowCount(), 1); // matches 'ab'
- QTest::mouseClick(clearButton, Qt::LeftButton, 0, QRect(QPoint(0, 0), clearButton->size()).center());
+ QSignalSpy spyEdited(filterLineEdit, &QLineEdit::textEdited);
+ const QPoint clearButtonCenterPos = QRect(QPoint(0, 0), clearButton->size()).center();
+ QTest::mouseClick(clearButton, Qt::LeftButton, 0, clearButtonCenterPos);
+ QCOMPARE(spyEdited.count(), 1);
+ QTest::mouseClick(clearButton, Qt::LeftButton, 0, clearButtonCenterPos);
QTRY_COMPARE(filterModel->rowCount(), 3);
+ QCoreApplication::processEvents();
+ QCOMPARE(spyEdited.count(), 1);
filterLineEdit->setReadOnly(true); // QTBUG-34315
QVERIFY(!clearButton->isEnabled());
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 59021108a2..4f611cd06f 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -237,6 +237,8 @@ public:
tst_QMdiArea();
public slots:
void initTestCase();
+ void cleanup();
+
protected slots:
void activeChanged(QMdiSubWindow *child);
@@ -306,6 +308,11 @@ void tst_QMdiArea::initTestCase()
#endif
}
+void tst_QMdiArea::cleanup()
+{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
// Old QWorkspace tests
void tst_QMdiArea::activeChanged(QMdiSubWindow *child)
{
@@ -1271,6 +1278,7 @@ void tst_QMdiArea::removeSubWindow_2()
mdiArea.addSubWindow(subWindow);
QVERIFY(numberOfConnectedSignals(subWindow) >= 2);
subWindow->setParent(0);
+ QScopedPointer<MySubWindow> subWindowGuard(subWindow);
QCOMPARE(numberOfConnectedSignals(subWindow), 0);
}
@@ -2340,7 +2348,7 @@ void tst_QMdiArea::setViewMode()
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
QMdiSubWindow *activeSubWindow = mdiArea.activeSubWindow();
- const QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
+ QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
// Default.
QVERIFY(!activeSubWindow->isMaximized());
@@ -2410,9 +2418,12 @@ void tst_QMdiArea::setViewMode()
// Remove sub-windows and make sure the tab is removed.
foreach (QMdiSubWindow *subWindow, subWindows) {
- if (subWindow != activeSubWindow)
+ if (subWindow != activeSubWindow) {
mdiArea.removeSubWindow(subWindow);
+ delete subWindow;
+ }
}
+ subWindows.clear();
QCOMPARE(tabBar->count(), 1);
// Go back to default (QMdiArea::SubWindowView).
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index 87d87eb4bc..4b327c9ba8 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -58,6 +58,7 @@
#include <QStyle>
#include <QStyleOptionTitleBar>
#include <QPushButton>
+#include <QScreen>
#include <QSizeGrip>
#include "../../../qtest-config.h"
@@ -182,6 +183,7 @@ private slots:
void mouseDoubleClick();
void setSystemMenu();
void restoreFocus();
+ void restoreFocusOverCreation();
void changeFocusWithTab();
void closeEvent();
void setWindowTitle();
@@ -1126,6 +1128,7 @@ void tst_QMdiSubWindow::restoreFocus()
expectedFocusWindow->showMinimized();
qApp->processEvents();
QVERIFY(expectedFocusWindow->isMinimized());
+ qDebug() << expectedFocusWindow<< qApp->focusWidget();
QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(expectedFocusWindow));
// Minimized -> normal
@@ -1178,6 +1181,48 @@ void tst_QMdiSubWindow::restoreFocus()
QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(expectedFocusWindow));
}
+class MultiWidget : public QWidget {
+public:
+ explicit MultiWidget(QWidget *parent = 0) : QWidget(parent)
+ , m_lineEdit1(new QLineEdit(this)), m_lineEdit2(new QLineEdit(this))
+ {
+ QVBoxLayout *lt = new QVBoxLayout(this);
+ lt->addWidget(m_lineEdit1);
+ lt->addWidget(m_lineEdit2);
+ }
+
+ QLineEdit *m_lineEdit1;
+ QLineEdit *m_lineEdit2;
+};
+
+void tst_QMdiSubWindow::restoreFocusOverCreation()
+{
+ // QTBUG-38378, verify that the focus child of a subwindow
+ // is not "forgotten" when adding yet another subwindow.
+ QMdiArea mdiArea;
+ mdiArea.resize(800, 800);
+ mdiArea.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(400, 400));
+ mdiArea.setWindowTitle(QStringLiteral("restoreFocusOverCreation"));
+
+ MultiWidget *subWidget1 = new MultiWidget;
+ MultiWidget *subWidget2 = new MultiWidget;
+
+ QMdiSubWindow *subWindow1 = mdiArea.addSubWindow(subWidget1);
+ subWidget1->m_lineEdit2->setFocus();
+ subWindow1->show();
+ mdiArea.show();
+ QApplication::setActiveWindow(&mdiArea);
+ QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
+ QCOMPARE(QApplication::focusWidget(), subWidget1->m_lineEdit2);
+
+ QMdiSubWindow *subWindow2 = mdiArea.addSubWindow(subWidget2);
+ subWindow2->show();
+ QTRY_COMPARE(QApplication::focusWidget(), subWidget2->m_lineEdit1);
+
+ mdiArea.setActiveSubWindow(subWindow1);
+ QTRY_COMPARE(QApplication::focusWidget(), subWidget1->m_lineEdit2);
+}
+
void tst_QMdiSubWindow::changeFocusWithTab()
{
QWidget *widget = new QWidget;
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index b4be24f0e0..3b891152b1 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -55,6 +55,7 @@
#include <qmenu.h>
#include <qstyle.h>
+#include <QTimer>
#include <qdebug.h>
Q_DECLARE_METATYPE(Qt::Key);
@@ -132,6 +133,7 @@ private:
enum { num_builtins = 10 };
QAction *activated, *highlighted, *builtins[num_builtins];
QString statustip;
+ bool m_onStatusTipTimerExecuted;
};
// Testing get/set functions
@@ -158,6 +160,7 @@ void tst_QMenu::getSetCheck()
}
tst_QMenu::tst_QMenu()
+ : m_onStatusTipTimerExecuted(false)
{
QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
}
@@ -193,6 +196,7 @@ void tst_QMenu::init()
{
activated = highlighted = 0;
lastMenu = 0;
+ m_onStatusTipTimerExecuted = false;
}
void tst_QMenu::createActions()
@@ -492,8 +496,13 @@ void tst_QMenu::statusTip()
//because showMenu calls QMenu::exec, we need to use a singleshot
//to continue the test
- QTimer::singleShot(200,this, SLOT(onStatusTipTimer()));
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(&timer, &QTimer::timeout, this, &tst_QMenu::onStatusTipTimer);
+ timer.setInterval(200);
+ timer.start();
btn->showMenu();
+ QVERIFY(m_onStatusTipTimerExecuted);
QVERIFY(statustip.isEmpty());
}
@@ -513,6 +522,7 @@ void tst_QMenu::onStatusTipTimer()
QCOMPARE(st, QString("sub action"));
QVERIFY(menu->isVisible() == false);
+ m_onStatusTipTimerExecuted = true;
}
void tst_QMenu::widgetActionFocus()
diff --git a/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro b/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro
new file mode 100644
index 0000000000..bbc6e987af
--- /dev/null
+++ b/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+CONFIG += parallel_test
+TARGET = tst_qopenglwidget
+QT += gui-private core-private testlib widgets
+
+SOURCES += tst_qopenglwidget.cpp
+
+win32-msvc2010:contains(QT_CONFIG, angle):CONFIG += insignificant_test # QTBUG-31611
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
new file mode 100644
index 0000000000..14d06e7111
--- /dev/null
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -0,0 +1,266 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets/QOpenGLWidget>
+#include <QtGui/QOpenGLFunctions>
+#include <QtGui/QPainter>
+#include <QtTest/QtTest>
+#include <QSignalSpy>
+
+class tst_QOpenGLWidget : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void create();
+ void clearAndGrab();
+ void clearAndResizeAndGrab();
+ void createNonTopLevel();
+ void painter();
+ void reparentToAlreadyCreated();
+ void reparentToNotYetCreated();
+};
+
+void tst_QOpenGLWidget::create()
+{
+ QScopedPointer<QOpenGLWidget> w(new QOpenGLWidget);
+ QVERIFY(!w->isValid());
+ QSignalSpy frameSwappedSpy(w.data(), SIGNAL(frameSwapped()));
+ w->show();
+ QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(frameSwappedSpy.count() > 0);
+
+ QVERIFY(w->isValid());
+ QVERIFY(w->context());
+ QVERIFY(w->context()->format() == w->format());
+ QVERIFY(w->defaultFramebufferObject() != 0);
+}
+
+class ClearWidget : public QOpenGLWidget, protected QOpenGLFunctions
+{
+public:
+ ClearWidget(QWidget *parent, int expectedWidth, int expectedHeight)
+ : QOpenGLWidget(parent),
+ m_initCalled(false), m_paintCalled(false), m_resizeCalled(false),
+ m_resizeOk(false),
+ m_w(expectedWidth), m_h(expectedHeight) { }
+
+ void initializeGL() Q_DECL_OVERRIDE {
+ m_initCalled = true;
+ initializeOpenGLFunctions();
+ }
+ void paintGL() Q_DECL_OVERRIDE {
+ m_paintCalled = true;
+ glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+ void resizeGL(int w, int h) Q_DECL_OVERRIDE {
+ m_resizeCalled = true;
+ m_resizeOk = w == m_w && h == m_h;
+ }
+
+ bool m_initCalled;
+ bool m_paintCalled;
+ bool m_resizeCalled;
+ bool m_resizeOk;
+ int m_w;
+ int m_h;
+};
+
+void tst_QOpenGLWidget::clearAndGrab()
+{
+ QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
+ w->resize(800, 600);
+ w->show();
+ QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(w->m_initCalled);
+ QVERIFY(w->m_resizeCalled);
+ QVERIFY(w->m_resizeOk);
+ QVERIFY(w->m_paintCalled);
+
+ QImage image = w->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0));
+}
+
+void tst_QOpenGLWidget::clearAndResizeAndGrab()
+{
+ QScopedPointer<QOpenGLWidget> w(new ClearWidget(0, 640, 480));
+ w->resize(640, 480);
+ w->show();
+ QTest::qWaitForWindowExposed(w.data());
+
+ QImage image = w->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ w->resize(800, 600);
+ image = w->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), 800);
+ QCOMPARE(image.height(), 600);
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0));
+}
+
+void tst_QOpenGLWidget::createNonTopLevel()
+{
+ QWidget w;
+ ClearWidget *glw = new ClearWidget(&w, 600, 700);
+ QSignalSpy frameSwappedSpy(glw, SIGNAL(frameSwapped()));
+ w.resize(400, 400);
+ w.show();
+ QTest::qWaitForWindowExposed(&w);
+ QVERIFY(frameSwappedSpy.count() > 0);
+
+ QVERIFY(glw->m_resizeCalled);
+ glw->m_resizeCalled = false;
+ QVERIFY(!glw->m_resizeOk);
+ glw->resize(600, 700);
+
+ QVERIFY(glw->m_initCalled);
+ QVERIFY(glw->m_resizeCalled);
+ QVERIFY(glw->m_resizeOk);
+ QVERIFY(glw->m_paintCalled);
+
+ QImage image = glw->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), glw->width());
+ QCOMPARE(image.height(), glw->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0));
+
+ glw->doneCurrent();
+ QVERIFY(!QOpenGLContext::currentContext());
+ glw->makeCurrent();
+ QVERIFY(QOpenGLContext::currentContext() == glw->context() && glw->context());
+}
+
+class PainterWidget : public QOpenGLWidget, protected QOpenGLFunctions
+{
+public:
+ PainterWidget(QWidget *parent)
+ : QOpenGLWidget(parent), m_clear(false) { }
+
+ void initializeGL() Q_DECL_OVERRIDE {
+ initializeOpenGLFunctions();
+ }
+ void paintGL() Q_DECL_OVERRIDE {
+ QPainter p(this);
+ QCOMPARE(p.device()->width(), width());
+ QCOMPARE(p.device()->height(), height());
+ p.fillRect(QRect(QPoint(0, 0), QSize(width(), height())), Qt::blue);
+ if (m_clear) {
+ p.beginNativePainting();
+ glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ p.endNativePainting();
+ }
+ }
+ bool m_clear;
+};
+
+void tst_QOpenGLWidget::painter()
+{
+ QWidget w;
+ PainterWidget *glw = new PainterWidget(&w);
+ w.resize(640, 480);
+ glw->resize(320, 200);
+ w.show();
+ QTest::qWaitForWindowExposed(&w);
+
+ QImage image = glw->grabFramebuffer();
+ QCOMPARE(image.width(), glw->width());
+ QCOMPARE(image.height(), glw->height());
+ QVERIFY(image.pixel(20, 10) == qRgb(0, 0, 255));
+
+ glw->m_clear = true;
+ image = glw->grabFramebuffer();
+ QVERIFY(image.pixel(20, 10) == qRgb(0, 255, 0));
+}
+
+void tst_QOpenGLWidget::reparentToAlreadyCreated()
+{
+ QWidget w1;
+ PainterWidget *glw = new PainterWidget(&w1);
+ w1.resize(640, 480);
+ glw->resize(320, 200);
+ w1.show();
+ QTest::qWaitForWindowExposed(&w1);
+
+ QWidget w2;
+ w2.show();
+ QTest::qWaitForWindowExposed(&w2);
+
+ glw->setParent(&w2);
+ glw->show();
+
+ QImage image = glw->grabFramebuffer();
+ QCOMPARE(image.width(), 320);
+ QCOMPARE(image.height(), 200);
+ QVERIFY(image.pixel(20, 10) == qRgb(0, 0, 255));
+}
+
+void tst_QOpenGLWidget::reparentToNotYetCreated()
+{
+ QWidget w1;
+ PainterWidget *glw = new PainterWidget(&w1);
+ w1.resize(640, 480);
+ glw->resize(320, 200);
+ w1.show();
+ QTest::qWaitForWindowExposed(&w1);
+
+ QWidget w2;
+ glw->setParent(&w2);
+ w2.show();
+ QTest::qWaitForWindowExposed(&w2);
+
+ QImage image = glw->grabFramebuffer();
+ QCOMPARE(image.width(), 320);
+ QCOMPARE(image.height(), 200);
+ QVERIFY(image.pixel(20, 10) == qRgb(0, 0, 255));
+}
+
+QTEST_MAIN(tst_QOpenGLWidget)
+
+#include "tst_qopenglwidget.moc"
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 21034e8f1b..350ae23d8a 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -393,18 +393,31 @@ void tst_QSpinBox::valueChangedHelper(int value)
actualValues << value;
}
+class MySpinBox: public QSpinBox
+{
+public:
+ MySpinBox(QWidget *parent = 0) : QSpinBox(parent) {}
+
+ void changeEvent(QEvent *ev) {
+ eventsReceived.append(ev->type());
+ }
+ QList<QEvent::Type> eventsReceived;
+};
+
void tst_QSpinBox::setReadOnly()
{
- QSpinBox spin(0);
+ MySpinBox spin(0);
spin.show();
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1);
spin.setReadOnly(true);
+ QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange);
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1);
spin.stepBy(1);
QCOMPARE(spin.value(), 2);
spin.setReadOnly(false);
+ QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange << QEvent::ReadOnlyChange);
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 3);
}
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
index 06dd623368..fedf16271f 100644
--- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
+++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
@@ -99,6 +99,7 @@ private slots:
void taskQTBUG_10052_widgetLayoutWhenMoving();
void tabBarClicked();
+ void autoHide();
};
// Testing get/set functions
@@ -701,5 +702,32 @@ void tst_QTabBar::tabBarClicked()
}
}
+void tst_QTabBar::autoHide()
+{
+ QTabBar tabBar;
+ QVERIFY(!tabBar.autoHide());
+ QVERIFY(!tabBar.isVisible());
+ tabBar.show();
+ QVERIFY(tabBar.isVisible());
+ tabBar.addTab("0");
+ QVERIFY(tabBar.isVisible());
+ tabBar.removeTab(0);
+ QVERIFY(tabBar.isVisible());
+
+ tabBar.setAutoHide(true);
+ QVERIFY(!tabBar.isVisible());
+ tabBar.addTab("0");
+ QVERIFY(!tabBar.isVisible());
+ tabBar.addTab("1");
+ QVERIFY(tabBar.isVisible());
+ tabBar.removeTab(0);
+ QVERIFY(!tabBar.isVisible());
+ tabBar.removeTab(0);
+ QVERIFY(!tabBar.isVisible());
+
+ tabBar.setAutoHide(false);
+ QVERIFY(tabBar.isVisible());
+}
+
QTEST_MAIN(tst_QTabBar)
#include "tst_qtabbar.moc"
diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro
index 29d1f7746c..423b3952d4 100644
--- a/tests/auto/widgets/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets/widgets.pro
@@ -52,3 +52,5 @@ SUBDIRS=\
qmainwindow \
qtextedit \
qtoolbar \
+
+contains(QT_CONFIG, opengl): SUBDIRS += qopenglwidget
diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 4818be5389..3a605c89c8 100644
--- a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -70,16 +70,6 @@ private slots:
void isRegisteredCustom();
void isRegisteredNotRegistered();
- void constructCoreType_data();
- void constructCoreType();
- void constructCoreTypeStaticLess_data();
- void constructCoreTypeStaticLess();
- void constructCoreTypeCopy_data();
- void constructCoreTypeCopy();
-
- void constructCustomType_data();
- void constructCustomType();
-
void constructInPlace_data();
void constructInPlace();
void constructInPlaceCopy_data();
@@ -250,91 +240,15 @@ void tst_QMetaType::isRegisteredNotRegistered()
}
}
-void tst_QMetaType::constructCoreType_data()
+void tst_QMetaType::constructInPlace_data()
{
QTest::addColumn<int>("typeId");
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i)
if (i != QMetaType::Void)
QTest::newRow(QMetaType::typeName(i)) << i;
- // GUI types are tested in tst_QGuiMetaType.
-}
-
-// Tests how fast QMetaType can default-construct and destroy a Qt
-// core type. The purpose of this benchmark is to measure the overhead
-// of using type id-based creation compared to creating the type
-// directly (i.e. "T *t = new T(); delete t;").
-void tst_QMetaType::constructCoreType()
-{
- QFETCH(int, typeId);
- QBENCHMARK {
- for (int i = 0; i < 100000; ++i) {
- void *data = QMetaType::create(typeId, (void *)0);
- QMetaType::destroy(typeId, data);
- }
- }
-}
-
-void tst_QMetaType::constructCoreTypeStaticLess_data()
-{
- constructCoreType_data();
-}
-
-void tst_QMetaType::constructCoreTypeStaticLess()
-{
- QFETCH(int, typeId);
- QBENCHMARK {
- QMetaType type(typeId);
- for (int i = 0; i < 100000; ++i) {
- void *data = type.create((void *)0);
- type.destroy(data);
- }
- }
-}
-
-void tst_QMetaType::constructCoreTypeCopy_data()
-{
- constructCoreType_data();
-}
-
-// Tests how fast QMetaType can copy-construct and destroy a Qt core
-// type. The purpose of this benchmark is to measure the overhead of
-// using type id-based creation compared to creating the type directly
-// (i.e. "T *t = new T(other); delete t;").
-void tst_QMetaType::constructCoreTypeCopy()
-{
- QFETCH(int, typeId);
- QVariant other(typeId, (void *)0);
- const void *copy = other.constData();
- QBENCHMARK {
- for (int i = 0; i < 100000; ++i) {
- void *data = QMetaType::create(typeId, copy);
- QMetaType::destroy(typeId, data);
- }
- }
-}
-
-void tst_QMetaType::constructCustomType_data()
-{
- QTest::addColumn<int>("typeId");
- QTest::newRow("BigClass") << qMetaTypeId<BigClass>();
-}
-
-void tst_QMetaType::constructCustomType()
-{
- QFETCH(int, typeId);
- QBENCHMARK {
- for (int i = 0; i < 100000; ++i) {
- void *data = QMetaType::create(typeId, (void *)0);
- QMetaType::destroy(typeId, data);
- }
- }
-}
-
-void tst_QMetaType::constructInPlace_data()
-{
- constructCoreType_data();
QTest::newRow("custom") << qMetaTypeId<BigClass>();
+ // GUI types are tested in tst_QGuiMetaType.
}
void tst_QMetaType::constructInPlace()
diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp
index 1eb423c8e7..34815af646 100644
--- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp
+++ b/tests/benchmarks/corelib/tools/qdatetime/main.cpp
@@ -48,7 +48,11 @@ class tst_QDateTime : public QObject
{
Q_OBJECT
- enum {
+ enum
+#if defined(Q_COMPILER_CLASS_ENUM) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700)
+ : qint64
+#endif
+ {
SECS_PER_DAY = 86400,
MSECS_PER_DAY = 86400000,
JULIAN_DAY_1950 = 2433283,
diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro
index 74544519f3..d194d2b698 100644
--- a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro
+++ b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro
@@ -11,7 +11,7 @@ qtHaveModule(script):!pcre {
QT += script
}
-exists( /usr/include/boost/regex.hpp ){
+exists($$[QT_SYSROOT]/usr/include/boost/regex.hpp) {
DEFINES+=HAVE_BOOST
LIBS+=-lboost_regex
}
diff --git a/tests/benchmarks/corelib/tools/qringbuffer/main.cpp b/tests/benchmarks/corelib/tools/qringbuffer/main.cpp
new file mode 100644
index 0000000000..ebc87aa0cb
--- /dev/null
+++ b/tests/benchmarks/corelib/tools/qringbuffer/main.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qringbuffer_p.h>
+#include <QByteArray>
+
+#include <qtest.h>
+
+class tst_qringbuffer : public QObject
+{
+ Q_OBJECT
+private slots:
+ void reserveAndRead();
+ void free();
+};
+
+void tst_qringbuffer::reserveAndRead()
+{
+ QRingBuffer ringBuffer;
+ QBENCHMARK {
+ for (int i = 1; i < 256; ++i)
+ ringBuffer.reserve(i);
+
+ for (int i = 1; i < 256; ++i)
+ ringBuffer.read(0, i);
+ }
+}
+
+void tst_qringbuffer::free()
+{
+ QRingBuffer ringBuffer;
+ QBENCHMARK {
+ ringBuffer.reserve(4096);
+ ringBuffer.reserve(2048);
+ ringBuffer.append(QByteArray("01234", 5));
+
+ ringBuffer.free(1);
+ ringBuffer.free(4096);
+ ringBuffer.free(48);
+ ringBuffer.free(2000);
+ }
+}
+
+QTEST_MAIN(tst_qringbuffer)
+
+#include "main.moc"
diff --git a/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro b/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro
new file mode 100644
index 0000000000..21b50e10e5
--- /dev/null
+++ b/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = tst_bench_qringbuffer
+
+QT = core-private testlib
+CONFIG += release
+
+SOURCES += main.cpp
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp
index 6101cfe8fb..b94d9f5d66 100644
--- a/tests/benchmarks/corelib/tools/qstring/main.cpp
+++ b/tests/benchmarks/corelib/tools/qstring/main.cpp
@@ -2388,7 +2388,7 @@ int fromUtf8_sse2_trusted_no_bom(ushort *qch, const char *chars, int len)
}
#endif
-#ifdef __ARM_NEON__
+#if defined(__ARM_NEON__) && (defined(Q_PROCESSOR_ARM_V7) || defined(__ARM_ARCH_6T2__))
int fromUtf8_latin1_neon(ushort *dst, const char *chars, int len)
{
fromLatin1_neon_improved(dst, chars, len);
@@ -2521,7 +2521,7 @@ void tst_QString::fromUtf8Alternatives_data() const
QTest::newRow("sse2-optimized-for-ascii") << &fromUtf8_sse2_optimised_for_ascii;
QTest::newRow("sse2-trusted-no-bom") << &fromUtf8_sse2_trusted_no_bom;
#endif
-#ifdef __ARM_NEON__
+#if defined(__ARM_NEON__) && (defined(Q_PROCESSOR_ARM_V7) || defined(__ARM_ARCH_6T2__))
QTest::newRow("neon") << &fromUtf8_neon;
QTest::newRow("neon-trusted-no-bom") << &fromUtf8_neon_trusted;
#endif
@@ -2531,7 +2531,7 @@ void tst_QString::fromUtf8Alternatives_data() const
QTest::newRow("latin1-sse2-qt4.7") << &fromUtf8_latin1_qt47;
QTest::newRow("latin1-sse2-improved") << &fromUtf8_latin1_sse2_improved;
#endif
-#ifdef __ARM_NEON__
+#if defined(__ARM_NEON__) && (defined(Q_PROCESSOR_ARM_V7) || defined(__ARM_ARCH_6T2__))
QTest::newRow("latin1-neon-improved") << &fromUtf8_latin1_neon;
#endif
}
diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro
index 08570aadb9..00abd75839 100644
--- a/tests/benchmarks/corelib/tools/tools.pro
+++ b/tests/benchmarks/corelib/tools/tools.pro
@@ -11,6 +11,7 @@ SUBDIRS = \
qmap \
qrect \
qregexp \
+ qringbuffer \
qstring \
qstringbuilder \
qstringlist \
diff --git a/tests/benchmarks/gui/kernel/kernel.pro b/tests/benchmarks/gui/kernel/kernel.pro
index cd7235cff8..607e58b6c0 100644
--- a/tests/benchmarks/gui/kernel/kernel.pro
+++ b/tests/benchmarks/gui/kernel/kernel.pro
@@ -1,4 +1,6 @@
TEMPLATE = subdirs
qtHaveModule(widgets): SUBDIRS = \
qapplication \
- qwidget
+ qwidget \
+ qguimetatype \
+ qguivariant
diff --git a/tests/benchmarks/gui/kernel/qapplication/main.cpp b/tests/benchmarks/gui/kernel/qapplication/main.cpp
index c319b2bcc6..dcf3ca75b6 100644
--- a/tests/benchmarks/gui/kernel/qapplication/main.cpp
+++ b/tests/benchmarks/gui/kernel/qapplication/main.cpp
@@ -60,7 +60,7 @@ void tst_qapplication::ctor()
{
// simulate reasonable argc, argv
int argc = 1;
- char *argv[] = { "tst_qapplication" };
+ char *argv[] = { const_cast<char*>("tst_qapplication") };
QBENCHMARK {
QApplication app(argc, argv);
}
diff --git a/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp
index 8f987470f5..ec587707c3 100644
--- a/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp
+++ b/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp
@@ -46,77 +46,27 @@ class tst_QGuiMetaType : public QObject
{
Q_OBJECT
-public:
- tst_QGuiMetaType();
- virtual ~tst_QGuiMetaType();
-
private slots:
- void constructGuiType_data();
- void constructGuiType();
- void constructGuiTypeCopy_data();
- void constructGuiTypeCopy();
-
void constructInPlace_data();
void constructInPlace();
void constructInPlaceCopy_data();
void constructInPlaceCopy();
+private:
+ void constructableGuiTypes();
};
-tst_QGuiMetaType::tst_QGuiMetaType()
-{
-}
-
-tst_QGuiMetaType::~tst_QGuiMetaType()
-{
-}
-void tst_QGuiMetaType::constructGuiType_data()
+void tst_QGuiMetaType::constructableGuiTypes()
{
QTest::addColumn<int>("typeId");
for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i)
QTest::newRow(QMetaType::typeName(i)) << i;
}
-// Tests how fast QMetaType can default-construct and destroy a Qt GUI
-// type. The purpose of this benchmark is to measure the overhead of
-// using type id-based creation compared to creating the type directly
-// (i.e. "T *t = new T(); delete t;").
-void tst_QGuiMetaType::constructGuiType()
-{
- QFETCH(int, typeId);
- QBENCHMARK {
- for (int i = 0; i < 100000; ++i) {
- void *data = QMetaType::create(typeId, (void *)0);
- QMetaType::destroy(typeId, data);
- }
- }
-}
-
-void tst_QGuiMetaType::constructGuiTypeCopy_data()
-{
- constructGuiType_data();
-}
-
-// Tests how fast QMetaType can copy-construct and destroy a Qt GUI
-// type. The purpose of this benchmark is to measure the overhead of
-// using type id-based creation compared to creating the type directly
-// (i.e. "T *t = new T(other); delete t;").
-void tst_QGuiMetaType::constructGuiTypeCopy()
-{
- QFETCH(int, typeId);
- QVariant other(typeId, (void *)0);
- const void *copy = other.constData();
- QBENCHMARK {
- for (int i = 0; i < 100000; ++i) {
- void *data = QMetaType::create(typeId, copy);
- QMetaType::destroy(typeId, data);
- }
- }
-}
void tst_QGuiMetaType::constructInPlace_data()
{
- constructGuiType_data();
+ constructableGuiTypes();
}
void tst_QGuiMetaType::constructInPlace()
@@ -137,7 +87,7 @@ void tst_QGuiMetaType::constructInPlace()
void tst_QGuiMetaType::constructInPlaceCopy_data()
{
- constructGuiType_data();
+ constructableGuiTypes();
}
void tst_QGuiMetaType::constructInPlaceCopy()
diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
index 4b2781e9ea..a6f144ea8a 100644
--- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
@@ -1290,7 +1290,7 @@ void tst_QPainter::drawScaledAntialiasedRoundedRect_data()
{
QTest::addColumn<float>("scale");
- for (float i = 0; i < 3; i += .1)
+ for (float i = 0; i < 3; i += .1f)
QTest::newRow(QString(QLatin1String("scale=%1")).arg(i).toLatin1()) << i;
}
@@ -1471,7 +1471,7 @@ void tst_QPainter::drawScaledBorderPixmapRoundedRect_data()
QTest::addColumn<float>("scale");
QTest::addColumn<int>("imageType");
- for (float i = 0; i < 3; i += .1)
+ for (float i = 0; i < 3; i += .1f)
QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB32_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB32_Premultiplied;
//for (float i = 0; i < 3; i += .1)
// QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB8565_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB8565_Premultiplied;
diff --git a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp
index 823eb404e2..e17f8c6436 100644
--- a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp
+++ b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp
@@ -152,7 +152,7 @@ private slots:
QString makeString(int length)
{
const char chars[] = "abcd efgh ijkl mnop qrst uvwx yz!$. ABCD 1234";
- int len = strlen(chars);
+ const int len = int(strlen(chars));
QString ret;
for (int j = 0; j < length; j++) {
diff --git a/tests/benchmarks/gui/text/qfontmetrics/main.cpp b/tests/benchmarks/gui/text/qfontmetrics/main.cpp
index f7515abd89..7df8e9407a 100644
--- a/tests/benchmarks/gui/text/qfontmetrics/main.cpp
+++ b/tests/benchmarks/gui/text/qfontmetrics/main.cpp
@@ -66,6 +66,7 @@ private:
void tst_QFontMetrics::testQFontMetrics( const QFontMetrics &fm )
{
int fontHeight = fm.height();
+ Q_UNUSED(fontHeight)
}
void tst_QFontMetrics::fontmetrics_create()
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 3b8565a0ec..5ccfe5d2a4 100644
--- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -52,8 +52,10 @@
#ifdef QT_BUILD_INTERNAL
#include <QtNetwork/private/qhostinfo_p.h>
+#ifndef QT_NO_OPENSSL
#include <QtNetwork/private/qsslsocket_openssl_p.h>
#endif
+#endif
Q_DECLARE_METATYPE(QSharedPointer<char>)
diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm
index 9a39788b02..7b4d4dd8d5 100644
--- a/tests/manual/cocoa/qt_on_cocoa/main.mm
+++ b/tests/manual/cocoa/qt_on_cocoa/main.mm
@@ -43,7 +43,7 @@
#include <QtDeclarative>
#include <QtWidgets/QtWidgets>
-#include <private/qwidgetwindow_qpa_p.h>
+#include <private/qwidgetwindow_p.h>
#include <QtGui/qpa/qplatformnativeinterface.h>
#include <QtGui/QPixmap>
diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp
index 57624a0d37..71147e1319 100644
--- a/tests/manual/dialogs/filedialogpanel.cpp
+++ b/tests/manual/dialogs/filedialogpanel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -292,6 +292,11 @@ QString FileDialogPanel::filterString() const
return m_nameFilters->toPlainText().trimmed().replace(QLatin1String("\n"), QLatin1String(";;"));
}
+QUrl FileDialogPanel::currentDirectoryUrl() const
+{
+ return QUrl::fromUserInput(m_directory->text().trimmed());
+}
+
QFileDialog::Options FileDialogPanel::options() const
{
QFileDialog::Options result;
@@ -338,7 +343,7 @@ void FileDialogPanel::getOpenFileUrls()
QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QList<QUrl> files =
QFileDialog::getOpenFileUrls(this, tr("getOpenFileNames Qt %1").arg(QLatin1String(QT_VERSION_STR)),
- QUrl(m_directory->text()), filterString(), &selectedFilter, options(),
+ currentDirectoryUrl(), filterString(), &selectedFilter, options(),
allowedSchemes());
if (!files.isEmpty()) {
QString result;
@@ -371,7 +376,7 @@ void FileDialogPanel::getOpenFileUrl()
QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QUrl file =
QFileDialog::getOpenFileUrl(this, tr("getOpenFileUrl Qt %1").arg(QLatin1String(QT_VERSION_STR)),
- QUrl(m_directory->text()), filterString(), &selectedFilter, options(),
+ currentDirectoryUrl(), filterString(), &selectedFilter, options(),
allowedSchemes());
if (file.isValid()) {
QString result;
@@ -404,7 +409,7 @@ void FileDialogPanel::getSaveFileUrl()
QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QUrl file =
QFileDialog::getSaveFileUrl(this, tr("getSaveFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)),
- QUrl(m_directory->text()), filterString(), &selectedFilter, options(),
+ currentDirectoryUrl(), filterString(), &selectedFilter, options(),
allowedSchemes());
if (file.isValid()) {
QString result;
@@ -430,7 +435,7 @@ void FileDialogPanel::getExistingDirectoryUrl()
#if QT_VERSION >= 0x050000
const QUrl dir =
QFileDialog::getExistingDirectoryUrl(this, tr("getExistingDirectory Qt %1").arg(QLatin1String(QT_VERSION_STR)),
- QUrl(m_directory->text()), options() | QFileDialog::ShowDirsOnly,
+ currentDirectoryUrl(), options() | QFileDialog::ShowDirsOnly,
allowedSchemes());
if (!dir.isEmpty())
QMessageBox::information(this, tr("getExistingDirectory"), QLatin1String("Directory: ") + dir.toString(), QMessageBox::Ok);
diff --git a/tests/manual/dialogs/filedialogpanel.h b/tests/manual/dialogs/filedialogpanel.h
index 8a9d93da03..0486af7bd4 100644
--- a/tests/manual/dialogs/filedialogpanel.h
+++ b/tests/manual/dialogs/filedialogpanel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -86,6 +86,7 @@ private slots:
void useMimeTypeFilters(bool);
private:
+ QUrl currentDirectoryUrl() const;
QString filterString() const;
QFileDialog::Options options() const;
QStringList allowedSchemes() const;
diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp
index e316486fcf..2e6477df03 100644
--- a/tests/manual/dialogs/printdialogpanel.cpp
+++ b/tests/manual/dialogs/printdialogpanel.cpp
@@ -422,8 +422,9 @@ QSizeF PrintDialogPanel::customPageSize() const
// Apply the settings to the QPrinter
void PrintDialogPanel::applySettings(QPrinter *printer) const
{
- QString printerName = m_panel.m_printerCombo->currentData().toString();
- if (printerName == QStringLiteral("PdfFormat"))
+ const int currentIndex = m_panel.m_printerCombo->currentIndex();
+ QString printerName = m_panel.m_printerCombo->itemData(currentIndex).toString();
+ if (printerName == QLatin1String("PdfFormat"))
printer->setOutputFileName(m_panel.m_fileName->text());
else
printer->setPrinterName(printerName);
@@ -459,7 +460,7 @@ void PrintDialogPanel::retrieveSettings(const QPrinter *printer)
m_panel.m_printerCombo->setCurrentIndex(m_panel.m_printerCombo->findData(QVariant(printer->printerName())));
m_panel.m_fileName->setEnabled(false);
} else {
- m_panel.m_printerCombo->setCurrentIndex(m_panel.m_printerCombo->findData(QVariant(QStringLiteral("PdfFormat"))));
+ m_panel.m_printerCombo->setCurrentIndex(m_panel.m_printerCombo->findData(QVariant(QLatin1String("PdfFormat"))));
m_panel.m_fileName->setEnabled(true);
}
m_panel.m_fileName->setText(printer->outputFileName());
@@ -662,10 +663,11 @@ void PrintDialogPanel::layoutModeChanged()
void PrintDialogPanel::printerChanged()
{
- bool isPdf = (m_panel.m_printerCombo->currentData().toString() == QStringLiteral("PdfFormat"));
+ const int currentIndex = m_panel.m_printerCombo->currentIndex();
+ const bool isPdf = (m_panel.m_printerCombo->itemData(currentIndex).toString() == QLatin1String("PdfFormat"));
m_panel.m_fileName->setEnabled(isPdf);
if (isPdf && m_panel.m_fileName->text().isEmpty())
- m_panel.m_fileName->setText(QDir::homePath() + QDir::separator() + QStringLiteral("print.pdf"));
+ m_panel.m_fileName->setText(QDir::homePath() + QDir::separator() + QLatin1String("print.pdf"));
}
void PrintDialogPanel::showPrintDialog()
diff --git a/tests/manual/highdpi/highdpi.pro b/tests/manual/highdpi/highdpi.pro
index b827456f9b..7a2979c74c 100644
--- a/tests/manual/highdpi/highdpi.pro
+++ b/tests/manual/highdpi/highdpi.pro
@@ -2,7 +2,7 @@ TEMPLATE = app
TARGET = highdpi
INCLUDEPATH += .
QT += widgets
-
+CONFIG+=console
# Input
SOURCES += main.cpp
diff --git a/tests/manual/highdpi/main.cpp b/tests/manual/highdpi/main.cpp
index c40cbd7b42..290e550afb 100644
--- a/tests/manual/highdpi/main.cpp
+++ b/tests/manual/highdpi/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
- ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -39,9 +39,27 @@
**
****************************************************************************/
-#include <QtCore>
-#include <QtGui>
-#include <QtWidgets>
+#include <QMainWindow>
+#include <QLabel>
+#include <QHBoxLayout>
+#include <QApplication>
+#include <QAction>
+#include <QStyle>
+#include <QToolBar>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QScrollBar>
+#include <QSlider>
+#include <QSpinBox>
+#include <QTabBar>
+#include <QIcon>
+#include <QPainter>
+#include <QWindow>
+#include <QScreen>
+#include <QFile>
+#include <QTemporaryDir>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
class PixmapPainter : public QWidget
@@ -74,7 +92,7 @@ PixmapPainter::PixmapPainter()
qtIcon.addFile(":/qticon32@2x.png");
}
-void PixmapPainter::paintEvent(QPaintEvent *event)
+void PixmapPainter::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.fillRect(QRect(QPoint(0, 0), size()), QBrush(Qt::gray));
@@ -187,7 +205,7 @@ MainWindow::MainWindow()
class StandardIcons : public QWidget
{
public:
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *)
{
int x = 10;
int y = 10;
@@ -203,13 +221,13 @@ public:
y+=dy;
x = ((x + dx) % maxX);
}
- };
+ }
};
class Caching : public QWidget
{
public:
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *)
{
QSize layoutSize(75, 75);
@@ -232,7 +250,7 @@ public:
{
const qreal devicePixelRatio = this->windowHandle()->devicePixelRatio();
- QImage cache = QImage(layoutSize * devicePixelRatio, QImage::QImage::Format_ARGB32_Premultiplied);
+ QImage cache = QImage(layoutSize * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
cache.setDevicePixelRatio(devicePixelRatio);
QPainter cachedPainter(&cache);
@@ -282,7 +300,7 @@ public:
class Fonts : public QWidget
{
public:
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *)
{
QPainter painter(this);
int y = 40;
@@ -333,28 +351,22 @@ void apiTest()
class IconDrawing : public QWidget
{
public:
- QIcon *iconHighDPI;
- QIcon *iconNormalDpi;
-
IconDrawing()
{
- QFile::copy(":/qticon32.png", "/tmp/qticon32-2.png");
+ const QString tempPath = m_temporaryDir.path();
+ const QString path32 = tempPath + "/qticon32.png";
+ const QString path32_2 = tempPath + "/qticon32-2.png";
+ const QString path32_2x = tempPath + "/qticon32@2x.png";
- QFile::copy(":/qticon32.png", "/tmp/qticon32.png");
- QFile::copy(":/qticon32@2x.png", "/tmp/qticon32@2x.png");
+ QFile::copy(":/qticon32.png", path32_2);
+ QFile::copy(":/qticon32.png", path32);
+ QFile::copy(":/qticon32@2x.png", path32_2x);
- iconHighDPI = new QIcon("/tmp/qticon32.png"); // will auto-load @2x version.
- iconNormalDpi = new QIcon("/tmp/qticon32-2.png"); // does not have a 2x version.
- }
-
- ~IconDrawing()
- {
- delete iconHighDPI;
- delete iconNormalDpi;
-// Qile::
+ iconHighDPI.reset(new QIcon(path32)); // will auto-load @2x version.
+ iconNormalDpi.reset(new QIcon(path32_2)); // does not have a 2x version.
}
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *)
{
int x = 10;
int y = 10;
@@ -366,7 +378,7 @@ public:
int sizeIncrement = 5;
// Disable high-dpi icons
- qApp->setAttribute(Qt::AA_UseHighDpiPixmaps, false);
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, false);
// normal icon
for (int size = minSize; size < maxSize; size += sizeIncrement) {
@@ -392,7 +404,7 @@ public:
y+=dy;
// Enable high-dpi icons
- qApp->setAttribute(Qt::AA_UseHighDpiPixmaps, true);
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
// normal icon
for (int size = minSize; size < maxSize; size += sizeIncrement) {
@@ -417,7 +429,12 @@ public:
x = 10;
y+=dy;
- };
+ }
+
+private:
+ QTemporaryDir m_temporaryDir;
+ QScopedPointer<QIcon> iconHighDPI;
+ QScopedPointer<QIcon> iconNormalDpi;
};
// Icons on buttons
@@ -456,38 +473,93 @@ public:
int main(int argc, char **argv)
{
QApplication app(argc, argv);
- qApp->setAttribute(Qt::AA_UseHighDpiPixmaps);
-
- PixmapPainter pixmapPainter;
- pixmapPainter.show();
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+
+ 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);
+
+ parser.process(app);
+
+ QScopedPointer<PixmapPainter> pixmapPainter;
+ if (parser.isSet(pixmapPainterOption)) {
+ pixmapPainter.reset(new PixmapPainter);
+ pixmapPainter->show();
+ }
- Labels label;
- label.resize(200, 200);
-// label.show();
+ QScopedPointer<Labels> label;
+ if (parser.isSet(labelOption)) {
+ label.reset(new Labels);
+ label->resize(200, 200);
+ label->show();
+ }
- MainWindow mainWindow;
-// mainWindow.show();
+ QScopedPointer<MainWindow> mainWindow;
+ if (parser.isSet(mainWindowOption)) {
+ mainWindow.reset(new MainWindow);
+ mainWindow->show();
+ }
- StandardIcons icons;
- icons.resize(510, 510);
-// icons.show();
+ QScopedPointer<StandardIcons> icons;
+ if (parser.isSet(standardIconsOption)) {
+ icons.reset(new StandardIcons);
+ icons->resize(510, 510);
+ icons->show();
+ }
- Caching caching;
- caching.resize(300, 300);
-// caching.show();
+ QScopedPointer<Caching> caching;
+ if (parser.isSet(cachingOption)) {
+ caching.reset(new Caching);
+ caching->resize(300, 300);
+ caching->show();
+ }
- Style style;
-// style.show();
+ QScopedPointer<Style> style;
+ if (parser.isSet(styleOption)) {
+ style.reset(new Style);
+ style->show();
+ }
- Fonts fonts;
-// fonts.show();
+ QScopedPointer<Fonts> fonts;
+ if (parser.isSet(fontsOption)) {
+ fonts.reset(new Fonts);
+ fonts->show();
+ }
- IconDrawing iconDrawing;
-// iconDrawing.show();
+ QScopedPointer<IconDrawing> iconDrawing;
+ if (parser.isSet(iconDrawingOption)) {
+ iconDrawing.reset(new IconDrawing);
+ iconDrawing->show();
+ }
- Buttons buttons;
-// buttons.show();
+ QScopedPointer<Buttons> buttons;
+ if (parser.isSet(buttonsOption)) {
+ buttons.reset(new Buttons);
+ buttons->show();
+ }
+ if (QApplication::topLevelWidgets().isEmpty())
+ parser.showHelp(0);
return app.exec();
}
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index 9318824e6d..e593756a7d 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -47,7 +47,10 @@ unc
!contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions
-contains(QT_CONFIG, opengl):SUBDIRS += qopengltextureblitter
+contains(QT_CONFIG, opengl) {
+ SUBDIRS += qopengltextureblitter
+ contains(QT_CONFIG, egl): SUBDIRS += qopenglcontext
+}
win32 {
SUBDIRS -= network_remote_stresstest network_stresstest
diff --git a/tests/manual/qopenglcontext/main.cpp b/tests/manual/qopenglcontext/main.cpp
new file mode 100644
index 0000000000..dd3178f466
--- /dev/null
+++ b/tests/manual/qopenglcontext/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include "qopenglcontextwindow.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ QOpenGLContextWindow window;
+ window.resize(300, 300);
+ window.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/qopenglcontext/qopenglcontext.pro b/tests/manual/qopenglcontext/qopenglcontext.pro
new file mode 100644
index 0000000000..c5943809c6
--- /dev/null
+++ b/tests/manual/qopenglcontext/qopenglcontext.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+TARGET = qopenglcontext
+
+QT += gui-private platformsupport-private
+
+HEADERS += $$PWD/qopenglcontextwindow.h
+
+SOURCES += $$PWD/main.cpp \
+ $$PWD/qopenglcontextwindow.cpp
diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.cpp b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
new file mode 100644
index 0000000000..bf6fe30c00
--- /dev/null
+++ b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qopenglcontextwindow.h"
+#include <QtGui/QOpenGLFunctions>
+#include <QtGui/QOffscreenSurface>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QMatrix4x4>
+#include <qpa/qplatformnativeinterface.h>
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformHeaders/QEGLNativeContext>
+
+QOpenGLContextWindow::QOpenGLContextWindow()
+ : m_blitter(0)
+{
+ setSurfaceType(OpenGLSurface);
+
+ m_context = new QOpenGLContext(this);
+ m_context->setFormat(requestedFormat());
+ m_context->create();
+
+ m_image = QImage(QStringLiteral("qticon64.png")).convertToFormat(QImage::Format_RGBA8888);
+ Q_ASSERT(!m_image.isNull());
+
+ create(); // to make sure format() returns something real
+ createForeignContext();
+}
+
+QOpenGLContextWindow::~QOpenGLContextWindow()
+{
+ if (m_blitter) {
+ m_blitter->destroy(); // the dtor does not call this for some reason
+ delete m_blitter;
+ }
+}
+
+void QOpenGLContextWindow::render()
+{
+ if (!m_context->makeCurrent(this))
+ qFatal("makeCurrent() failed");
+
+ QOpenGLFunctions *f = m_context->functions();
+ f->glViewport(0, 0, dWidth(), dHeight());
+ f->glClearColor(0, 0, 0, 1);
+ f->glClear(GL_COLOR_BUFFER_BIT);
+
+ if (!m_blitter) {
+ m_blitter = new QOpenGLTextureBlitter;
+ m_blitter->create();
+ }
+
+ // Draw the image. If nothing gets shown, then something went wrong with the context
+ // adoption or sharing was not successfully enabled.
+ m_blitter->bind();
+ QRectF r(0, 0, dWidth(), dHeight());
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRectF(100, 100, 100, 100), r.toRect());
+ m_blitter->blit(m_textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
+ m_blitter->release();
+
+ m_context->swapBuffers(this);
+}
+
+void QOpenGLContextWindow::exposeEvent(QExposeEvent *)
+{
+ if (isExposed())
+ render();
+}
+
+void QOpenGLContextWindow::createForeignContext()
+{
+ // Here a context will be created manually. This context will share with m_context's
+ // underlying native context. This way the texture, that belongs to the context
+ // created here, will be accessible from m_context too.
+
+ EGLContext shareCtx = m_context->nativeHandle().value<QEGLNativeContext>().context();
+ Q_ASSERT(shareCtx != EGL_NO_CONTEXT);
+
+ EGLDisplay dpy = (EGLDisplay) qGuiApp->platformNativeInterface()->nativeResourceForWindow(
+ QByteArrayLiteral("egldisplay"), this);
+ Q_ASSERT(dpy != EGL_NO_DISPLAY);
+
+ QSurfaceFormat fmt = format();
+ EGLConfig config = q_configFromGLFormat(dpy, fmt);
+
+ QVector<EGLint> contextAttrs;
+ contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ contextAttrs.append(fmt.majorVersion());
+ contextAttrs.append(EGL_NONE);
+ switch (fmt.renderableType()) {
+#ifdef EGL_VERSION_1_4
+ case QSurfaceFormat::OpenGL:
+ eglBindAPI(EGL_OPENGL_API);
+ break;
+#endif // EGL_VERSION_1_4
+ default:
+ eglBindAPI(EGL_OPENGL_ES_API);
+ break;
+ }
+
+ EGLContext ctx = eglCreateContext(dpy, config, shareCtx, contextAttrs.constData());
+ Q_ASSERT(ctx != EGL_NO_CONTEXT);
+
+ // Wrap ctx into a QOpenGLContext.
+ QOpenGLContext *ctxWrap = new QOpenGLContext;
+ ctxWrap->setNativeHandle(QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx, dpy)));
+ ctxWrap->setShareContext(m_context); // only needed for correct bookkeeping
+ if (!ctxWrap->create())
+ qFatal("Failed to created wrapping context");
+ Q_ASSERT(ctxWrap->nativeHandle().value<QEGLNativeContext>().context() == ctx);
+
+ QOffscreenSurface surface;
+ surface.setFormat(fmt);
+ surface.create();
+
+ if (!ctxWrap->makeCurrent(&surface))
+ qFatal("Failed to make pbuffer surface current");
+
+ // Create the texture.
+ QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
+ GLuint textureId = 0;
+ f->glGenTextures(1, &textureId);
+ f->glBindTexture(GL_TEXTURE_2D, textureId);
+ f->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_image.width(), m_image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ m_image.constBits());
+ Q_ASSERT(f->glGetError() == GL_NO_ERROR);
+
+ ctxWrap->doneCurrent();
+ delete ctxWrap; // ctx is not destroyed
+ eglDestroyContext(dpy, ctx); // resources like the texture stay alive until any context on the share list is alive
+ Q_ASSERT(eglGetError() == EGL_SUCCESS);
+
+ m_textureId = textureId;
+}
diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.h b/tests/manual/qopenglcontext/qopenglcontextwindow.h
new file mode 100644
index 0000000000..6fcb3633bf
--- /dev/null
+++ b/tests/manual/qopenglcontext/qopenglcontextwindow.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENGLCONTEXTWINDOW_H
+#define QOPENGLCONTEXTWINDOW_H
+
+#include <QtGui/QWindow>
+#include <QtGui/QOpenGLContext>
+#include <QtGui/QImage>
+#include <QtCore/QVariant>
+#include <QtGui/private/qopengltextureblitter_p.h>
+
+class QOpenGLContextWindow : public QWindow
+{
+ Q_OBJECT
+
+public:
+ QOpenGLContextWindow();
+ ~QOpenGLContextWindow();
+
+ void render();
+
+protected:
+ void exposeEvent(QExposeEvent *event);
+
+private:
+ qreal dWidth() const { return width() * devicePixelRatio(); }
+ qreal dHeight() const { return height() * devicePixelRatio(); }
+ void createForeignContext();
+
+ QOpenGLContext *m_context;
+ QImage m_image;
+ QVariant m_nativeHandle;
+ uint m_textureId;
+ QOpenGLTextureBlitter *m_blitter;
+};
+
+#endif
diff --git a/tests/manual/qopenglcontext/qticon64.png b/tests/manual/qopenglcontext/qticon64.png
new file mode 100644
index 0000000000..76f02c6c96
--- /dev/null
+++ b/tests/manual/qopenglcontext/qticon64.png
Binary files differ
diff --git a/tests/manual/qopenglwidget/openglwidget/main.cpp b/tests/manual/qopenglwidget/openglwidget/main.cpp
index 68f9be7199..0268d47767 100644
--- a/tests/manual/qopenglwidget/openglwidget/main.cpp
+++ b/tests/manual/qopenglwidget/openglwidget/main.cpp
@@ -45,20 +45,32 @@
#include <QMdiArea>
#include <QLCDNumber>
#include <QTimer>
-
+#include <QSurfaceFormat>
+#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
+ QSurfaceFormat format;
+ if (QCoreApplication::arguments().contains(QLatin1String("--multisample")))
+ format.setSamples(4);
+ if (QCoreApplication::arguments().contains(QLatin1String("--coreprofile"))) {
+ format.setVersion(3, 2);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+ }
+ qDebug() << "Requesting" << format;
+
QMdiArea w;
w.resize(400,400);
OpenGLWidget *glw = new OpenGLWidget;
+ glw->setFormat(format);
w.addSubWindow(glw);
glw->setMinimumSize(100,100);
OpenGLWidget *glw2 = new OpenGLWidget;
+ glw2->setFormat(format);
glw2->setMinimumSize(100,100);
w.addSubWindow(glw2);
@@ -69,5 +81,8 @@ int main(int argc, char *argv[])
w.show();
+ if (glw->isValid())
+ qDebug() << "Got" << glw->format();
+
return a.exec();
}
diff --git a/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp b/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp
index bec89b6b41..516de35ff8 100644
--- a/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp
+++ b/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp
@@ -58,7 +58,7 @@
#include <QtCore/qmath.h>
#include <qopengl.h>
-class OpenGLWidgetPrivate
+class OpenGLWidgetPrivate : protected QOpenGLFunctions
{
public:
OpenGLWidgetPrivate(QWidget *q)
@@ -91,7 +91,7 @@ OpenGLWidget::OpenGLWidget(QWidget *parent)
{
d = new OpenGLWidgetPrivate(this);
QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(updateGL()));
+ connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(30);
}
@@ -137,6 +137,7 @@ static const char *fragmentShaderSource =
void OpenGLWidgetPrivate::initialize()
{
+ initializeOpenGLFunctions();
m_program = new QOpenGLShaderProgram;
m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
@@ -157,7 +158,7 @@ void OpenGLWidgetPrivate::render()
m_program->bind();
QMatrix4x4 matrix;
- matrix.perspective(60, 4.0/3.0, 0.1, 100.0);
+ matrix.perspective(60.0f, 4.0f/3.0f, 0.1f, 100.0f);
matrix.translate(0, 0, -2);
matrix.rotate(100.0f * m_frame / 30/*screen()->refreshRate()*/, 0, 1, 0);
diff --git a/tests/manual/qopenglwidget/openglwidget/openglwidget.h b/tests/manual/qopenglwidget/openglwidget/openglwidget.h
index eaba27df26..ada01d4cc1 100644
--- a/tests/manual/qopenglwidget/openglwidget/openglwidget.h
+++ b/tests/manual/qopenglwidget/openglwidget/openglwidget.h
@@ -42,7 +42,7 @@
#ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H
-#include <QtWidgets/private/qopenglwidget_p.h>
+#include <QtWidgets/QOpenGLWidget>
class OpenGLWidgetPrivate;
class OpenGLWidget : public QOpenGLWidget
diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp
index 905c7d6f77..c085d3fd5b 100644
--- a/tests/manual/qscreen/main.cpp
+++ b/tests/manual/qscreen/main.cpp
@@ -49,6 +49,9 @@
int i = 0;
+typedef QHash<QScreen*, PropertyWatcher*> ScreensHash;
+Q_GLOBAL_STATIC(ScreensHash, props);
+
void updateSiblings(PropertyWatcher* w)
{
QLineEdit *siblingsField = w->findChild<QLineEdit *>("siblings");
@@ -88,12 +91,19 @@ void screenAdded(QScreen* screen)
geom.moveCenter(screen->geometry().center());
w->move(geom.topLeft());
+ 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);
+}
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@@ -101,5 +111,6 @@ int main(int argc, char *argv[])
foreach (QScreen *screen, screens)
screenAdded(screen);
QObject::connect((const QGuiApplication*)QGuiApplication::instance(), &QGuiApplication::screenAdded, &screenAdded);
+ QObject::connect((const QGuiApplication*)QGuiApplication::instance(), &QGuiApplication::screenRemoved, &screenRemoved);
return a.exec();
}
diff --git a/tests/manual/qscreen/propertywatcher.cpp b/tests/manual/qscreen/propertywatcher.cpp
index 2213f4ac1d..9e34c69799 100644
--- a/tests/manual/qscreen/propertywatcher.cpp
+++ b/tests/manual/qscreen/propertywatcher.cpp
@@ -82,6 +82,5 @@ void PropertyWatcher::updateAllFields()
void PropertyWatcher::subjectDestroyed()
{
- hide();
- deleteLater();
+ qDebug("screen destroyed");
}
diff --git a/tests/manual/qtabletevent/device_information/main.cpp b/tests/manual/qtabletevent/device_information/main.cpp
index 54f9f5cb54..1c83023cee 100644
--- a/tests/manual/qtabletevent/device_information/main.cpp
+++ b/tests/manual/qtabletevent/device_information/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -40,11 +40,21 @@
****************************************************************************/
#include <QApplication>
+#include <QDebug>
#include "tabletwidget.h"
int main(int argc, char **argv) {
- QApplication app(argc, argv);
- TabletWidget tabletWidget;
- tabletWidget.showMaximized();
- return app.exec();
+ QApplication app(argc, argv);
+ bool mouseToo = false;
+ if (app.arguments().contains(QLatin1String("--nomouse")) || app.arguments().contains(QLatin1String("-nomouse")))
+ mouseToo = false;
+ else if (app.arguments().contains(QLatin1String("--mouse")) || app.arguments().contains(QLatin1String("-mouse")))
+ mouseToo = true;
+ if (mouseToo)
+ qDebug() << "will show mouse events coming from the tablet as well as QTabletEvents";
+ else
+ qDebug() << "will not show mouse events from the tablet; use the --mouse option to enable";
+ TabletWidget tabletWidget(mouseToo);
+ tabletWidget.showMaximized();
+ return app.exec();
}
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
index 7b5de72e27..c2fbe76e5b 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
@@ -42,8 +42,11 @@
#include "tabletwidget.h"
#include <QPainter>
#include <QApplication>
+#include <QDebug>
+#include <QMetaObject>
+#include <QMetaEnum>
-TabletWidget::TabletWidget()
+TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo)
{
QPalette newPalette = palette();
newPalette.setColor(QPalette::Window, Qt::white);
@@ -76,12 +79,14 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
mPress = event->pressure();
mTangential = event->tangentialPressure();
mRot = event->rotation();
+ mButton = event->button();
+ mButtons = event->buttons();
if (isVisible())
update();
break;
}
case QEvent::MouseMove:
- {
+ if (mMouseToo) {
resetAttributes();
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
mType = event->type();
@@ -129,7 +134,7 @@ void TabletWidget::paintEvent(QPaintEvent *)
|| mType == QEvent::TabletMove || mType == QEvent::TabletPress
|| mType == QEvent::TabletRelease) {
- eventInfo << QString("Hight res global position: %1 %2").arg(QString::number(mHiResGlobalPos.x()), QString::number(mHiResGlobalPos.y()));
+ eventInfo << QString("High res global position: %1 %2").arg(QString::number(mHiResGlobalPos.x()), QString::number(mHiResGlobalPos.y()));
QString pointerType("Pointer type: ");
switch (mPointerType) {
@@ -148,7 +153,6 @@ void TabletWidget::paintEvent(QPaintEvent *)
}
eventInfo << pointerType;
-
QString deviceString = "Device type: ";
switch (mDev) {
case QTabletEvent::NoDevice:
@@ -172,6 +176,8 @@ void TabletWidget::paintEvent(QPaintEvent *)
}
eventInfo << deviceString;
+ eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16);
+ eventInfo << QString("Buttons currently pressed: %1 (0x%2)").arg(buttonsToString(mButtons)).arg(mButtons, 0, 16);
eventInfo << QString("Pressure: %1").arg(QString::number(mPress));
eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential));
eventInfo << QString("Rotation: %1").arg(QString::number(mRot));
@@ -182,7 +188,25 @@ void TabletWidget::paintEvent(QPaintEvent *)
eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique));
}
- painter.drawText(rect(), eventInfo.join("\n"));
+ QString text = eventInfo.join("\n");
+ painter.drawText(rect(), text);
+}
+
+const char *TabletWidget::buttonToString(Qt::MouseButton b)
+{
+ static int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons");
+ return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(b);
+}
+
+QString TabletWidget::buttonsToString(Qt::MouseButtons bs)
+{
+ QStringList ret;
+ for (int i = 0; (uint)(1 << i) <= Qt::MaxMouseButton; ++i) {
+ Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i);
+ if (bs.testFlag(b))
+ ret << buttonToString(b);
+ }
+ return ret.join("|");
}
void TabletWidget::tabletEvent(QTabletEvent *event)
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h
index a60fa8d83f..8efdd63697 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.h
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.h
@@ -49,11 +49,13 @@
class TabletWidget : public QWidget
{
public:
- TabletWidget();
+ TabletWidget(bool mouseToo);
protected:
bool eventFilter(QObject *obj, QEvent *ev);
void tabletEvent(QTabletEvent *event);
void paintEvent(QPaintEvent *event);
+ const char *buttonToString(Qt::MouseButton b);
+ QString buttonsToString(Qt::MouseButtons bs);
private:
void resetAttributes() {
mType = mDev = mPointerType = mXT = mYT = mZ = 0;
@@ -66,8 +68,11 @@ private:
QPoint mPos, mGPos;
QPointF mHiResGlobalPos;
int mDev, mPointerType, mXT, mYT, mZ;
+ Qt::MouseButton mButton;
+ Qt::MouseButtons mButtons;
qreal mPress, mTangential, mRot;
qint64 mUnique;
+ bool mMouseToo;
};
#endif // TABLETWIDGET_H
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
index ce77cf8cff..60bedbd8f4 100644
--- a/tests/manual/qtabletevent/regular_widgets/main.cpp
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -54,16 +54,20 @@
enum TabletPointType {
TabletButtonPress,
TabletButtonRelease,
- TabletMove,
- TabletDraw
+ TabletMove
};
struct TabletPoint
{
- TabletPoint(const QPoint &p = QPoint(), TabletPointType t = TabletMove) : pos(p), type(t) {}
+ TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove,
+ Qt::MouseButton b = Qt::LeftButton, QTabletEvent::PointerType pt = QTabletEvent::UnknownPointer, qreal prs = 0) :
+ pos(p), type(t), button(b), ptype(pt), pressure(prs) {}
- QPoint pos;
+ QPointF pos;
TabletPointType type;
+ Qt::MouseButton button;
+ QTabletEvent::PointerType ptype;
+ qreal pressure;
};
class EventReportWidget : public QWidget
@@ -90,36 +94,47 @@ private:
bool m_lastIsMouseMove;
bool m_lastIsTabletMove;
+ Qt::MouseButton m_lastButton;
QVector<TabletPoint> m_points;
};
EventReportWidget::EventReportWidget()
: m_lastIsMouseMove(false)
, m_lastIsTabletMove(false)
+ , m_lastButton(Qt::NoButton)
{ }
void EventReportWidget::paintEvent(QPaintEvent *)
{
QPainter p(this);
- const QRect geom = QRect(QPoint(0, 0), size());
+ const QRectF geom = QRectF(QPoint(0, 0), size());
p.fillRect(geom, Qt::white);
- p.drawRect(QRect(geom.topLeft(), geom.bottomRight() - QPoint(1,1)));
+ p.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1,1)));
+ p.setPen(Qt::white);
foreach (const TabletPoint &t, m_points) {
if (geom.contains(t.pos)) {
QPainterPath pp;
- pp.addEllipse(t.pos, 5, 5);
+ pp.addEllipse(t.pos, 8, 8);
+ QRectF pointBounds(t.pos.x() - 10, t.pos.y() - 10, 20, 20);
switch (t.type) {
case TabletButtonPress:
- p.fillPath(pp, Qt::black);
+ p.fillPath(pp, Qt::darkGreen);
+ if (t.button != Qt::NoButton)
+ p.drawText(pointBounds, Qt::AlignCenter, QString::number(t.button));
break;
case TabletButtonRelease:
p.fillPath(pp, Qt::red);
+ if (t.button != Qt::NoButton)
+ p.drawText(pointBounds, Qt::AlignCenter, QString::number(t.button));
break;
case TabletMove:
- p.drawPath(pp);
- break;
- case TabletDraw:
- p.fillPath(pp, Qt::blue);
+ if (t.pressure > 0.0) {
+ p.setPen(t.ptype == QTabletEvent::Eraser ? Qt::red : Qt::black);
+ p.drawEllipse(t.pos, t.pressure * 10.0, t.pressure * 10.0);
+ p.setPen(Qt::white);
+ } else {
+ p.fillRect(t.pos.x() - 2, t.pos.y() - 2, 4, 4, Qt::black);
+ }
break;
}
}
@@ -128,37 +143,30 @@ void EventReportWidget::paintEvent(QPaintEvent *)
void EventReportWidget::tabletEvent(QTabletEvent *event)
{
- QWidget::tabletEvent(event);
+ QWidget::tabletEvent(event);
QString type;
switch (event->type()) {
case QEvent::TabletEnterProximity:
- m_lastIsTabletMove = false;
type = QString::fromLatin1("TabletEnterProximity");
break;
case QEvent::TabletLeaveProximity:
- m_lastIsTabletMove = false;
type = QString::fromLatin1("TabletLeaveProximity");
break;
case QEvent::TabletMove:
- if (m_lastIsTabletMove)
- return;
-
- m_lastIsTabletMove = true;
type = QString::fromLatin1("TabletMove");
- m_points.push_back(TabletPoint(event->pos(), event->pressure() ? TabletDraw : TabletMove));
+ m_points.push_back(TabletPoint(event->pos(), TabletMove, m_lastButton, event->pointerType(), event->pressure()));
update();
break;
case QEvent::TabletPress:
- m_lastIsTabletMove = false;
type = QString::fromLatin1("TabletPress");
- m_points.push_back(TabletPoint(event->pos(), TabletButtonPress));
+ m_points.push_back(TabletPoint(event->pos(), TabletButtonPress, event->button(), event->pointerType()));
+ m_lastButton = event->button();
update();
break;
case QEvent::TabletRelease:
- m_lastIsTabletMove = false;
type = QString::fromLatin1("TabletRelease");
- m_points.push_back(TabletPoint(event->pos(), TabletButtonRelease));
+ m_points.push_back(TabletPoint(event->pos(), TabletButtonRelease, event->button(), event->pointerType()));
update();
break;
default:
@@ -166,10 +174,51 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
break;
}
- qDebug() << "Tablet event, type = " << type
- << " position = " << event->pos()
- << " global position = " << event->globalPos()
- << " cursor at " << QCursor::pos();
+ QString pointerType = "UNKNOWN";
+ switch (event->pointerType()) {
+ case QTabletEvent::Pen:
+ pointerType = "Pen";
+ break;
+ case QTabletEvent::Cursor:
+ pointerType = "Cursor";
+ break;
+ case QTabletEvent::Eraser:
+ pointerType = "Eraser";
+ break;
+ default:
+ break;
+ }
+
+ QString device = "UNKNOWN";
+ switch (event->device()) {
+ case QTabletEvent::Puck:
+ pointerType = "Puck";
+ break;
+ case QTabletEvent::Stylus:
+ pointerType = "Stylus";
+ break;
+ case QTabletEvent::Airbrush:
+ pointerType = "Airbrush";
+ break;
+ case QTabletEvent::FourDMouse:
+ pointerType = "FourDMouse";
+ break;
+ case QTabletEvent::RotationStylus:
+ pointerType = "RotationStylus";
+ break;
+ default:
+ break;
+ }
+
+ if (!m_lastIsTabletMove)
+ qDebug() << "Tablet event, type = " << type
+ << " position = " << event->pos()
+ << " global position = " << event->globalPos()
+ << " cursor at " << QCursor::pos()
+ << " buttons " << event->buttons() << " changed " << event->button()
+ << " pointer type " << pointerType << " device " << device;
+
+ m_lastIsTabletMove = (event->type() == QEvent::TabletMove);
}
void EventReportWidget::outputMouseEvent(QMouseEvent *event)
diff --git a/tests/manual/widgets/itemviews/itemviews.pro b/tests/manual/widgets/itemviews/itemviews.pro
index 6b91531a87..53f658d54d 100644
--- a/tests/manual/widgets/itemviews/itemviews.pro
+++ b/tests/manual/widgets/itemviews/itemviews.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = delegate qheaderview qtreeview qtreewidget
+SUBDIRS = delegate qheaderview qtreeview qtreewidget tableview-span-navigation
diff --git a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest.pro b/tests/manual/widgets/itemviews/qheaderview/qheaderview.pro
index f83136266d..f83136266d 100644
--- a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest.pro
+++ b/tests/manual/widgets/itemviews/qheaderview/qheaderview.pro
diff --git a/tests/manual/widgets/itemviews/qtreeview/qtreeviewtest.pro b/tests/manual/widgets/itemviews/qtreeview/qtreeview.pro
index c241ee1045..c241ee1045 100644
--- a/tests/manual/widgets/itemviews/qtreeview/qtreeviewtest.pro
+++ b/tests/manual/widgets/itemviews/qtreeview/qtreeview.pro
diff --git a/tests/manual/widgets/itemviews/qtreewidget/qtreewidgettest.pro b/tests/manual/widgets/itemviews/qtreewidget/qtreewidget.pro
index 4b1da9be38..4b1da9be38 100644
--- a/tests/manual/widgets/itemviews/qtreewidget/qtreewidgettest.pro
+++ b/tests/manual/widgets/itemviews/qtreewidget/qtreewidget.pro
diff --git a/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp b/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp
new file mode 100644
index 0000000000..8421d0661b
--- /dev/null
+++ b/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QStandardItemModel>
+#include <QTableView>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QStandardItemModel model(4, 4);
+ QTableView tableView;
+ tableView.setSizeAdjustPolicy(QTableView::AdjustToContents);
+ tableView.setModel(&model);
+
+ for (int row = 0; row < model.rowCount(); ++row) {
+ for (int column = 0; column < model.columnCount(); ++column) {
+ QModelIndex index = model.index(row, column, QModelIndex());
+ model.setData(index, QVariant(QString("%1,%2").arg(row).arg(column)));
+ }
+ }
+
+ tableView.setSpan(1, 1, 2, 2);
+
+ tableView.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro b/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro
new file mode 100644
index 0000000000..ffa006a2d8
--- /dev/null
+++ b/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro
@@ -0,0 +1,8 @@
+
+TEMPLATE = app
+TARGET = tableview-span-navigation
+INCLUDEPATH += .
+
+QT += widgets
+
+SOURCES += main.cpp
diff --git a/tests/manual/widgets/kernel/layoutreplace/main.pro b/tests/manual/widgets/kernel/layoutreplace/layoutreplace.pro
index 54c6a4a9fc..54c6a4a9fc 100644
--- a/tests/manual/widgets/kernel/layoutreplace/main.pro
+++ b/tests/manual/widgets/kernel/layoutreplace/layoutreplace.pro
diff --git a/tests/manual/widgets/kernel/qtooltip/main.pro b/tests/manual/widgets/kernel/qtooltip/qtooltip.pro
index dac880a10e..dac880a10e 100644
--- a/tests/manual/widgets/kernel/qtooltip/main.pro
+++ b/tests/manual/widgets/kernel/qtooltip/qtooltip.pro
diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.pro b/tests/manual/widgets/qgraphicsview/rubberband/rubberband.pro
index 805b0cc119..805b0cc119 100644
--- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.pro
+++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberband.pro