summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/collections/tst_collections.cpp11
-rw-r--r--tests/auto/dbus.pro2
-rw-r--r--tests/auto/declarative/declarative.pro5
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/attached.qml2
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml25
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp51
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml22
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h7
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp69
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp51
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp42
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/orientchange.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp103
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml50
-rw-r--r--tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp73
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp22
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml7
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp7
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml8
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml1
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_readonly.qml8
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_readonly.qml8
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp156
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/mouseselection_default.qml7
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false.qml7
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_readonly.qml8
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_words.qml7
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_readonly.qml8
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_words.qml7
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp300
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.html17
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.icobin318 -> 0 bytes
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.pngbin3961 -> 0 bytes
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.qml6
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/elements.html14
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/elements.qml8
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/forward.html12
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/forward.pngbin2377 -> 0 bytes
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/javaScript.html11
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/javaScript.qml12
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/loadError.qml6
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/newwindows.html16
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/newwindows.qml34
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/pixelCache.html10
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml6
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml34
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/sethtml.qml6
-rw-r--r--tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro16
-rw-r--r--tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp520
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp2
-rw-r--r--tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp30
-rw-r--r--tests/auto/gui.pro7
-rw-r--r--tests/auto/headers/tst_headers.cpp4
-rw-r--r--tests/auto/lancelot/scripts/hinting.qps26
-rw-r--r--tests/auto/lancelot/tst_lancelot.cpp14
-rw-r--r--tests/auto/macnativeevents/tst_macnativeevents.cpp8
-rw-r--r--tests/auto/moc/tst_moc.cpp22
-rw-r--r--tests/auto/network.pro9
-rw-r--r--tests/auto/networkselftest/tst_networkselftest.cpp42
-rw-r--r--tests/auto/platformsocketengine/.gitignore1
-rw-r--r--tests/auto/platformsocketengine/platformsocketengine.pri (renamed from tests/auto/qnativesocketengine/qsocketengine.pri)0
-rw-r--r--tests/auto/platformsocketengine/platformsocketengine.pro16
-rw-r--r--tests/auto/platformsocketengine/tst_platformsocketengine.cpp (renamed from tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp)192
-rw-r--r--tests/auto/q3combobox/tst_q3combobox.cpp4
-rw-r--r--tests/auto/q3progressbar/tst_q3progressbar.cpp9
-rw-r--r--tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp30
-rw-r--r--tests/auto/qaccessibility/tst_qaccessibility.cpp426
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp12
-rw-r--r--tests/auto/qcomplextext/tst_qcomplextext.cpp88
-rw-r--r--tests/auto/qdatetime/tst_qdatetime.cpp34
-rw-r--r--tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp23
-rw-r--r--tests/auto/qdbusabstractadaptor/myobject.h286
-rw-r--r--tests/auto/qdbusabstractadaptor/qdbusabstractadaptor.pro9
-rw-r--r--tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.cpp167
-rw-r--r--tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.pro5
-rw-r--r--tests/auto/qdbusabstractadaptor/test/test.pro7
-rw-r--r--tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp985
-rw-r--r--tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml2
-rw-r--r--tests/auto/qdbusabstractinterface/interface.h1
-rw-r--r--tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro17
-rw-r--r--tests/auto/qdbusabstractinterface/qpinger/qpinger.cpp (renamed from tests/auto/qdbusperformance/server/server.cpp)75
-rw-r--r--tests/auto/qdbusabstractinterface/qpinger/qpinger.pro5
-rw-r--r--tests/auto/qdbusabstractinterface/test/test.pro13
-rw-r--r--tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp573
-rw-r--r--tests/auto/qdbusconnection/tst_qdbusconnection.cpp382
-rw-r--r--tests/auto/qdbusinterface/myobject.h164
-rw-r--r--tests/auto/qdbusinterface/qdbusinterface.pro7
-rw-r--r--tests/auto/qdbusinterface/qmyserver/qmyserver.cpp155
-rw-r--r--tests/auto/qdbusinterface/qmyserver/qmyserver.pro5
-rw-r--r--tests/auto/qdbusinterface/test/test.pro7
-rw-r--r--tests/auto/qdbusinterface/tst_qdbusinterface.cpp629
-rw-r--r--tests/auto/qdbusmarshall/common.h69
-rw-r--r--tests/auto/qdbusmarshall/qdbusmarshall.pro2
-rw-r--r--tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp94
-rw-r--r--tests/auto/qdbusperformance/.gitignore2
-rw-r--r--tests/auto/qdbusperformance/qdbusperformance.pro8
-rw-r--r--tests/auto/qdbusperformance/server/server.pro5
-rw-r--r--tests/auto/qdbusperformance/serverobject.h115
-rw-r--r--tests/auto/qdbusperformance/test/test.pro7
-rw-r--r--tests/auto/qdbusperformance/tst_qdbusperformance.cpp230
-rw-r--r--tests/auto/qdbustype/qdbustype.pro10
-rw-r--r--tests/auto/qdbustype/tst_qdbustype.cpp273
-rw-r--r--tests/auto/qdir/qdir.pro2
-rw-r--r--tests/auto/qdir/tst_qdir.cpp26
-rw-r--r--tests/auto/qdiriterator/tst_qdiriterator.cpp55
-rw-r--r--tests/auto/qeventloop/qeventloop.pro1
-rw-r--r--tests/auto/qeventloop/tst_qeventloop.cpp5
-rw-r--r--tests/auto/qfile/tst_qfile.cpp11
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp31
-rw-r--r--tests/auto/qftp/tst_qftp.cpp103
-rw-r--r--tests/auto/qfuture/tst_qfuture.cpp28
-rw-r--r--tests/auto/qfuture/versioncheck.h4
-rw-r--r--tests/auto/qglyphs/tst_qglyphs.cpp21
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp3
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp79
-rw-r--r--tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp321
-rw-r--r--tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp40
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp4
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp41
-rw-r--r--tests/auto/qhostinfo/tst_qhostinfo.cpp152
-rw-r--r--tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp48
-rw-r--r--tests/auto/qhttpsocketengine/qhttpsocketengine.pro2
-rw-r--r--tests/auto/qidentityproxymodel/qidentityproxymodel.pro6
-rw-r--r--tests/auto/qidentityproxymodel/tst_qidentityproxymodel.cpp334
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp54
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp136
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp3
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp161
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp2
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp29
-rw-r--r--tests/auto/qmutex/tst_qmutex.cpp69
-rw-r--r--tests/auto/qnativesocketengine/.gitignore1
-rw-r--r--tests/auto/qnativesocketengine/qnativesocketengine.pro13
-rw-r--r--tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp18
-rw-r--r--tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro1
-rw-r--r--tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp8
-rw-r--r--tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp8
-rw-r--r--tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp9
-rw-r--r--tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro1
-rw-r--r--tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp38
-rw-r--r--tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp38
-rw-r--r--tests/auto/qnetworkproxyfactory/qnetworkproxyfactory.pro2
-rw-r--r--tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp144
-rw-r--r--tests/auto/qnetworkreply/image1.jpgbin0 -> 1045459 bytes
-rw-r--r--tests/auto/qnetworkreply/image2.jpgbin0 -> 879218 bytes
-rw-r--r--tests/auto/qnetworkreply/image3.jpgbin0 -> 887729 bytes
-rw-r--r--tests/auto/qnetworkreply/test/test.pro16
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp550
-rw-r--r--tests/auto/qnetworksession/test/tst_qnetworksession.cpp8
-rw-r--r--tests/auto/qobject/tst_qobject.cpp31
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp84
-rw-r--r--tests/auto/qpainterpath/tst_qpainterpath.cpp4
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp65
-rw-r--r--tests/auto/qplaintextedit/tst_qplaintextedit.cpp18
-rw-r--r--tests/auto/qpluginloader/tst_qpluginloader.cpp6
-rw-r--r--tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp67
-rw-r--r--tests/auto/qrawfont/qrawfont.pro13
-rw-r--r--tests/auto/qrawfont/testfont.ttfbin0 -> 63212 bytes
-rw-r--r--tests/auto/qrawfont/testfont_bold_italic.ttfbin0 -> 49760 bytes
-rw-r--r--tests/auto/qrawfont/tst_qrawfont.cpp814
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp2
-rw-r--r--tests/auto/qscriptv8testsuite/abstracttestsuite.cpp12
-rw-r--r--tests/auto/qscriptv8testsuite/skip.txt14
-rw-r--r--tests/auto/qsemaphore/tst_qsemaphore.cpp26
-rw-r--r--tests/auto/qsocketnotifier/qsocketnotifier.pro2
-rw-r--r--tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp123
-rw-r--r--tests/auto/qsocks5socketengine/qsocks5socketengine.pro2
-rw-r--r--tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp34
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp137
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp7
-rw-r--r--tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp6
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp6
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted1.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted2.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted3.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted4.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted5.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted6.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted7.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted8.pem19
-rw-r--r--tests/auto/qsslcertificate/more-certificates/blacklisted9.pem19
-rw-r--r--tests/auto/qsslcertificate/tst_qsslcertificate.cpp11
-rw-r--r--tests/auto/qsslkey/tst_qsslkey.cpp4
-rw-r--r--tests/auto/qsslsocket/certs/fake-login.live.com.key15
-rw-r--r--tests/auto/qsslsocket/certs/fake-login.live.com.pem19
-rw-r--r--tests/auto/qsslsocket/qsslsocket.pro4
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp101
-rw-r--r--tests/auto/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro10
-rw-r--r--tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp7
-rw-r--r--tests/auto/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro10
-rw-r--r--tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp12
-rw-r--r--tests/auto/qstring/qstring.pro2
-rw-r--r--tests/auto/qstring/tst_qstring.cpp93
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp56
-rw-r--r--tests/auto/qstringlist/tst_qstringlist.cpp13
-rw-r--r--tests/auto/qstyle/tst_qstyle.cpp12
-rw-r--r--tests/auto/qtablewidget/tst_qtablewidget.cpp3
-rw-r--r--tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp1
-rw-r--r--tests/auto/qtcpserver/crashingServer/crashingServer.pro1
-rw-r--r--tests/auto/qtcpserver/qtcpserver.pro2
-rw-r--r--tests/auto/qtcpserver/test/test.pro7
-rw-r--r--tests/auto/qtcpserver/tst_qtcpserver.cpp72
-rw-r--r--tests/auto/qtcpsocket/qtcpsocket.pro1
-rw-r--r--tests/auto/qtcpsocket/stressTest/stressTest.pro1
-rw-r--r--tests/auto/qtcpsocket/test/test.pro5
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp111
-rw-r--r--tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp167
-rw-r--r--tests/auto/qtextblock/tst_qtextblock.cpp12
-rw-r--r--tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp6
-rw-r--r--tests/auto/qtextedit/tst_qtextedit.cpp149
-rw-r--r--tests/auto/qthread/tst_qthread.cpp85
-rw-r--r--tests/auto/qthreadstorage/tst_qthreadstorage.cpp15
-rw-r--r--tests/auto/qudpsocket/clientserver/clientserver.pro2
-rw-r--r--tests/auto/qudpsocket/qudpsocket.pro2
-rw-r--r--tests/auto/qudpsocket/test/test.pro2
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp239
-rw-r--r--tests/auto/qundogroup/testdata/qundogroup.ts25
-rw-r--r--tests/auto/qundogroup/tst_qundogroup.cpp37
-rw-r--r--tests/auto/qundostack/testdata/qundostack.ts25
-rw-r--r--tests/auto/qundostack/tst_qundostack.cpp94
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp21
-rw-r--r--tests/auto/qwizard/tst_qwizard.cpp13
-rw-r--r--tests/auto/qxmlquery/tst_qxmlquery.cpp2
-rw-r--r--tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro2
-rw-r--r--tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro2
-rw-r--r--tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro2
238 files changed, 10571 insertions, 2389 deletions
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp
index 9b24660895..b1ea32629b 100644
--- a/tests/auto/collections/tst_collections.cpp
+++ b/tests/auto/collections/tst_collections.cpp
@@ -104,13 +104,6 @@ void foo()
#include "q3cleanuphandler.h"
#endif
-// Do not test initialization of pods on msvc6 and msvc 2002
-// This is a known issue
-#if defined Q_CC_MSVC && _MSC_VER < 1310
-# define NOPODINITIALIZATION
-#endif
-
-
template class QList<int>;
//TESTED_FILES=
@@ -198,10 +191,6 @@ QT_END_NAMESPACE
struct Pod {
int i1, i2;
-
-#if defined NOPODINITIALIZATION
- Pod() : i1(0), i2(0) { }
-#endif
};
tst_Collections::tst_Collections()
diff --git a/tests/auto/dbus.pro b/tests/auto/dbus.pro
index e5f87e34b3..31b46a31f2 100644
--- a/tests/auto/dbus.pro
+++ b/tests/auto/dbus.pro
@@ -11,9 +11,9 @@ SUBDIRS=\
qdbusmetatype \
qdbuspendingcall \
qdbuspendingreply \
- qdbusperformance \
qdbusreply \
qdbusservicewatcher \
+ qdbustype \
qdbusthreading \
qdbusxmlparser \
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 08f0b9ed38..98e15e8b0e 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -76,11 +76,6 @@ contains(QT_CONFIG, private_tests) {
qdeclarativeworkerscript \
qdeclarativexmllistmodel \
qpacketprotocol
-
-contains(QT_CONFIG, webkit) {
- SUBDIRS += \
- qdeclarativewebview
-}
}
# Tests which should run in Pulse
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/attached.qml b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
index 5da4a69441..c5d5535bb7 100644
--- a/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
@@ -17,7 +17,7 @@ Rectangle {
transitions: Transition {
PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
- ScriptAction { script: console.log(ListView.delayRemove ? "on" : "off") }
+ ScriptAction { script: console.log(wrapper.ListView.delayRemove ? "on" : "off") }
}
Component.onCompleted: {
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml
new file mode 100644
index 0000000000..aa384c335f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml
@@ -0,0 +1,25 @@
+import QtQuick 1.0
+
+Rectangle {
+ id: container
+
+ width: 400; height: 400;
+ property Item myItem
+
+ function doCreate() {
+ myItem = myComponent.createObject(container)
+ myItem.x = 100
+ }
+
+ Component {
+ id: myComponent
+ Rectangle {
+ width: 100
+ height: 100
+ color: "green"
+ Behavior on x { NumberAnimation { duration: 500 } }
+ }
+ }
+
+ Component.onCompleted: doCreate()
+}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 80ba907d20..4536d9ef27 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -81,6 +81,7 @@ private slots:
void groupedPropertyCrash();
void runningTrue();
void sameValue();
+ void delayedRegistration();
};
void tst_qdeclarativebehaviors::simpleBehavior()
@@ -412,6 +413,23 @@ void tst_qdeclarativebehaviors::sameValue()
QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
}
+//QTBUG-18362
+void tst_qdeclarativebehaviors::delayedRegistration()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/delayedRegistration.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeItem *innerRect = rect->property("myItem").value<QDeclarativeItem*>();
+ QVERIFY(innerRect != 0);
+
+ QCOMPARE(innerRect->property("x").toInt(), int(0));
+
+ QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
+}
+
QTEST_MAIN(tst_qdeclarativebehaviors)
#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
index 7237553d32..dba2007e94 100644
--- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -66,7 +66,6 @@
Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State)
-
class tst_QDeclarativeDebug : public QObject
{
Q_OBJECT
@@ -119,6 +118,18 @@ private slots:
void setBindingInStates();
};
+class NonScriptProperty : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false)
+public:
+ int nonScriptProp() const { return 0; }
+ void setNonScriptProp(int) {}
+signals:
+ void nonScriptPropChanged();
+};
+QML_DECLARE_TYPE(NonScriptProperty)
+
+
QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int context, bool recursive)
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
@@ -283,6 +294,7 @@ void tst_QDeclarativeDebug::compareProperties(const QDeclarativeDebugPropertyRef
void tst_QDeclarativeDebug::initTestCase()
{
qRegisterMetaType<QDeclarativeDebugWatch::State>();
+ qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement");
QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!");
QDeclarativeDebugHelper::enableDebugging();
@@ -292,7 +304,8 @@ void tst_QDeclarativeDebug::initTestCase()
QList<QByteArray> qml;
qml << "import QtQuick 1.0\n"
- "Item {"
+ "import Test 1.0\n"
+ "Item {"
"id: root\n"
"width: 10; height: 20; scale: blueRect.scale;"
"Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
@@ -308,6 +321,8 @@ void tst_QDeclarativeDebug::initTestCase()
"list[0] = blueRect;\n"
"varObjList = list;\n"
"}\n"
+ "NonScriptPropertyElement {\n"
+ "}\n"
"}";
// add second component to test multiple root contexts
@@ -649,7 +664,13 @@ void tst_QDeclarativeDebug::queryAvailableEngines()
QCOMPARE(e.name(), m_engine->objectName());
}
+ // Make query invalid by deleting client
+ q_engines = m_dbg->queryAvailableEngines(this);
+ QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Error);
delete q_engines;
+ m_dbg = new QDeclarativeEngineDebug(m_conn, this);
}
void tst_QDeclarativeDebug::queryRootContexts()
@@ -657,6 +678,7 @@ void tst_QDeclarativeDebug::queryRootContexts()
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
int engineId = q_engines->engines()[0].debugId();
+ delete q_engines;
QDeclarativeDebugRootContextQuery *q_context;
@@ -688,8 +710,13 @@ void tst_QDeclarativeDebug::queryRootContexts()
QVERIFY(context.contexts()[0].debugId() >= 0);
QCOMPARE(context.contexts()[0].name(), QString("tst_QDeclarativeDebug_childContext"));
- delete q_engines;
+ // Make query invalid by deleting client
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
delete q_context;
+ m_dbg = new QDeclarativeEngineDebug(m_conn, this);
}
void tst_QDeclarativeDebug::queryObject()
@@ -721,12 +748,19 @@ void tst_QDeclarativeDebug::queryObject()
delete q_engines;
delete q_context;
+
+ // Make query invalid by deleting client
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Error);
delete q_obj;
+ m_dbg = new QDeclarativeEngineDebug(m_conn, this);
// check source as defined in main()
QDeclarativeDebugFileReference source = obj.source();
QCOMPARE(source.url(), QUrl::fromLocalFile(""));
- QCOMPARE(source.lineNumber(), 2);
+ QCOMPARE(source.lineNumber(), 3);
QCOMPARE(source.columnNumber(), 1);
// generically test all properties, children and childrens' properties
@@ -796,7 +830,14 @@ void tst_QDeclarativeDebug::queryExpressionResult()
delete q_engines;
delete q_context;
+
+ // Make query invalid by deleting client
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
delete q_expr;
+ m_dbg = new QDeclarativeEngineDebug(m_conn, this);
}
void tst_QDeclarativeDebug::queryExpressionResult_data()
@@ -986,7 +1027,7 @@ void tst_QDeclarativeDebug::setBindingForObject()
// set handler
//
rootObject = findRootObject();
- QCOMPARE(rootObject.children().size(), 3);
+ QCOMPARE(rootObject.children().size(), 4); // Rectangle, Text, MouseArea, QDeclarativeComponentAttached
QDeclarativeDebugObjectReference mouseAreaObject = rootObject.children().at(2);
QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
waitForQuery(q_obj);
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml
new file mode 100644
index 0000000000..a7184c9200
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml
@@ -0,0 +1,22 @@
+import Qt.test 1.0
+import Qt.test 1.0 as Namespace
+
+MyQmlObject {
+ property alias a: me.a
+ property alias b: me.a
+ property alias c: me.a
+ property alias d: me.a
+
+ property MyQmlObject obj
+ obj: MyQmlObject {
+ MyQmlObject.value2: 13
+
+ id: me
+ property int a: MyQmlObject.value2 * 2
+ property int b: Namespace.MyQmlObject.value2 * 2
+ property int c: me.Namespace.MyQmlObject.value * 2
+ property int d: me.Namespace.MyQmlObject.value * 2
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml b/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml
new file mode 100644
index 0000000000..cbbbbf921a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml
@@ -0,0 +1,11 @@
+import QtQuick 1.0
+import Qt.test 1.0
+
+MyQmlObject {
+ function test1() {
+ value = 4.2
+ }
+ function test2() {
+ value = 7.9
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
index 8addcb9125..6467c42bb9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
@@ -1,5 +1,5 @@
import Qt.test 1.0
MyQmlObject {
- onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c)
+ onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c + ' ' + d + ' ' + e)
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
index ffbe317690..4fc2dab943 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
@@ -7,10 +7,12 @@ MyQmlObject
property real realProperty
property color colorProperty
property variant variantProperty
+ property int enumProperty
+ property int qtEnumProperty
- signal mySignal(int a, real b, color c, variant d)
+ signal mySignal(int a, real b, color c, variant d, int e, int f)
- onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; }
+ onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; enumProperty = e; qtEnumProperty = f; }
- onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1))
+ onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton)
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index 7e63bd54f9..1d65b15476 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -127,6 +127,8 @@ void registerTypes()
qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
+ qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
+ qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 081cc4ce5a..ad38d279bb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -60,17 +60,18 @@ class MyQmlAttachedObject : public QObject
{
Q_OBJECT
Q_PROPERTY(int value READ value CONSTANT)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
public:
MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
int value() const { return 19; }
int value2() const { return m_value2; }
- void setValue2(int v) { m_value2 = v; }
+ void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
void emitMySignal() { emit mySignal(); }
signals:
+ void value2Changed();
void mySignal();
private:
@@ -159,7 +160,7 @@ public:
signals:
void basicSignal();
- void argumentSignal(int a, QString b, qreal c);
+ void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
void stringChanged();
void objectChanged();
void anotherBasicSignal();
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 6be0275ab8..c7926b0567 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -176,6 +176,7 @@ private slots:
void aliasBindingsOverrideTarget();
void aliasWritesOverrideBindings();
void pushCleanContext();
+ void realToInt();
void include();
@@ -304,8 +305,8 @@ void tst_qdeclarativeecmascript::signalAssignment()
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.25);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25"));
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
}
}
@@ -650,6 +651,16 @@ void tst_qdeclarativeecmascript::attachedProperties()
}
{
+ QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 26);
+ QCOMPARE(object->property("b").toInt(), 26);
+ QCOMPARE(object->property("c").toInt(), 26);
+ QCOMPARE(object->property("d").toInt(), 26);
+ }
+
+ {
QDeclarativeComponent component(&engine, TEST_FILE("writeAttachedProperty.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -870,7 +881,7 @@ void tst_qdeclarativeecmascript::scope()
QCOMPARE(object->property("test").toInt(), 0);
QCOMPARE(object->property("test2").toString(), QString());
- emit object->argumentSignal(13, "Argument Scope", 9);
+ emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 13);
QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
@@ -895,6 +906,8 @@ void tst_qdeclarativeecmascript::signalParameterTypes()
QCOMPARE(object->property("realProperty").toReal(), 19.2);
QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
+ QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
+ QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
}
/*
@@ -1139,7 +1152,7 @@ void tst_qdeclarativeecmascript::signalTriggeredBindings()
QCOMPARE(object->property("test1").toReal(), 200.);
QCOMPARE(object->property("test2").toReal(), 200.);
- object->argumentSignal(10, QString(), 10);
+ object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("base").toReal(), 400.);
QCOMPARE(object->property("test1").toReal(), 400.);
@@ -1940,7 +1953,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1953,7 +1966,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1966,7 +1979,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1979,7 +1992,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -1992,7 +2005,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -2005,7 +2018,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2021,13 +2034,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2040,13 +2053,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -2059,13 +2072,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 3);
delete object;
@@ -2077,13 +2090,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
QCOMPARE(object->property("test").toInt(), 3);
delete object;
@@ -3065,6 +3078,18 @@ void tst_qdeclarativeecmascript::pushCleanContext()
QCOMPARE(func2.call().toInt32(), 6);
}
+void tst_qdeclarativeecmascript::realToInt()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("realToInt.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "test1");
+ QCOMPARE(object->value(), int(4));
+ QMetaObject::invokeMethod(object, "test2");
+ QCOMPARE(object->value(), int(8));
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index d499edf08c..4fa1cb3796 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -110,7 +110,7 @@ void tst_qdeclarativeflickable::create()
QCOMPARE(obj->isInteractive(), true);
QCOMPARE(obj->boundsBehavior(), QDeclarativeFlickable::DragAndOvershootBounds);
QCOMPARE(obj->pressDelay(), 0);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+ QCOMPARE(obj->maximumFlickVelocity(), 2500.);
delete obj;
}
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index c18393429f..c8e7817adc 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -97,6 +97,7 @@ private slots:
void onRemove_data();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
+ void contentPosJump();
private:
QDeclarativeView *createView();
@@ -2077,6 +2078,56 @@ void tst_QDeclarativeGridView::testQtQuick11Attributes_data()
<< "";
}
+void tst_QDeclarativeGridView::contentPosJump()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 100; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ // Test jumping more than a page of items.
+ gridview->setContentY(500);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ gridview->setContentY(-100);
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ QVERIFY(itemCount < 15);
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativeGridView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml b/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml
index 739299d033..cd092bc760 100644
--- a/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml
+++ b/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml
@@ -1,6 +1,10 @@
import QtQuick 1.0
Image {
+ property int widthChange: 0
+ property int heightChange: 0
source: "heart.png"
fillMode: Image.PreserveAspectFit;
+ onWidthChanged: widthChange += 1
+ onHeightChanged: heightChange += 1
}
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index 9e090d2e4d..87e33474d3 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -91,6 +91,7 @@ private slots:
void sourceSize_QTBUG_14303();
void sourceSize_QTBUG_16389();
void nullPixmapPaint();
+ void resetSourceSize();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
@@ -247,14 +248,22 @@ void tst_qdeclarativeimage::preserveAspectRatio()
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml"));
QDeclarativeImage *image = qobject_cast<QDeclarativeImage*>(canvas->rootObject());
QVERIFY(image != 0);
+ QCOMPARE(image->property("widthChange").toInt(), 1);
+ QCOMPARE(image->property("heightChange").toInt(), 1);
image->setWidth(80.0);
+ QCOMPARE(image->property("widthChange").toInt(), 2);
+ QCOMPARE(image->property("heightChange").toInt(), 2);
QCOMPARE(image->width(), 80.);
QCOMPARE(image->height(), 80.);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml"));
image = qobject_cast<QDeclarativeImage*>(canvas->rootObject());
- image->setHeight(60.0);
QVERIFY(image != 0);
+ QCOMPARE(image->property("widthChange").toInt(), 1);
+ QCOMPARE(image->property("heightChange").toInt(), 1);
+ image->setHeight(60.0);
+ QCOMPARE(image->property("widthChange").toInt(), 2);
+ QCOMPARE(image->property("heightChange").toInt(), 2);
QCOMPARE(image->height(), 60.);
QCOMPARE(image->width(), 60.);
delete canvas;
@@ -693,6 +702,27 @@ void tst_qdeclarativeimage::nullPixmapPaint()
delete image;
}
+void tst_qdeclarativeimage::resetSourceSize()
+{
+ QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString();
+ QString componentStr = "import QtQuick 1.1\nImage { function reset() { sourceSize = undefined }\nsource: \"" + src + "\"; sourceSize: Qt.size(100,100) }";
+
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->pixmap().width(), 100);
+ QCOMPARE(obj->pixmap().height(), 100);
+ QCOMPARE(obj->sourceSize().height(), 100);
+ QCOMPARE(obj->sourceSize().width(), 100);
+
+ QMetaObject::invokeMethod(obj, "reset");
+ QCOMPARE(obj->pixmap().width(), 200);
+ QCOMPARE(obj->pixmap().height(), 200);
+ QCOMPARE(obj->sourceSize().height(), 200);
+ QCOMPARE(obj->sourceSize().width(), 200);
+}
+
void tst_qdeclarativeimage::testQtQuick11Attributes()
{
QFETCH(QString, code);
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 5a2591f042..2ce493bd2a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -174,7 +174,7 @@ private:
QVERIFY(component.errors().isEmpty()); \
} else { \
QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly)); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
QByteArray data = file.readAll(); \
file.close(); \
QList<QByteArray> expected = data.split('\n'); \
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 14af19c148..7ca2b79024 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -106,6 +106,7 @@ private slots:
void property_changes_data();
void property_changes_worker();
void property_changes_worker_data();
+ void clear();
};
int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName)
{
@@ -1094,6 +1095,47 @@ void tst_qdeclarativelistmodel::property_changes_worker_data()
property_changes_data();
}
+void tst_qdeclarativelistmodel::clear()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeListModel model;
+ QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+
+ QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(&engine);
+ QScriptValue sv = seng->newObject();
+ QVariant result;
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ sv.setProperty("propertyA", "value a");
+ sv.setProperty("propertyB", "value b");
+ model.append(sv);
+ QCOMPARE(model.count(), 1);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ model.append(sv);
+ model.append(sv);
+ QCOMPARE(model.count(), 2);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ // clearing does not remove the roles
+ sv.setProperty("propertyC", "value c");
+ model.append(sv);
+ QList<int> roles = model.roles();
+ model.clear();
+ QCOMPARE(model.count(), 0);
+ QCOMPARE(model.roles(), roles);
+ QCOMPARE(model.toString(roles[0]), QString("propertyA"));
+ QCOMPARE(model.toString(roles[1]), QString("propertyB"));
+ QCOMPARE(model.toString(roles[2]), QString("propertyC"));
+}
+
QTEST_MAIN(tst_qdeclarativelistmodel)
#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativelistview/data/orientchange.qml b/tests/auto/declarative/qdeclarativelistview/data/orientchange.qml
new file mode 100644
index 0000000000..c7aa0cd1d3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/orientchange.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+ListView {
+ width: 240; height: 320
+ delegate: Rectangle { objectName: "wrapper"; width: 80; height: 80 }
+ model: 100
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 2267a894b2..0c96587b30 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -119,6 +119,8 @@ private slots:
void testQtQuick11Attributes_data();
void rightToLeft();
void test_mirroring();
+ void orientationChange();
+ void contentPosJump();
private:
template <class T> void items();
@@ -2583,6 +2585,107 @@ void tst_QDeclarativeListView::test_mirroring()
delete canvasB;
}
+void tst_QDeclarativeListView::orientationChange()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/orientchange.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(canvas->rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ listview->positionViewAtIndex(50, QDeclarativeListView::Beginning);
+
+ // Confirm items positioned correctly
+ for (int i = 50; i < 54; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*80.0);
+ }
+
+ listview->setOrientation(QDeclarativeListView::Horizontal);
+ QCOMPARE(listview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 3; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->x(), i*80.0);
+ }
+
+ listview->positionViewAtIndex(50, QDeclarativeListView::Beginning);
+ listview->setOrientation(QDeclarativeListView::Vertical);
+ QCOMPARE(listview->contentX(), 0.);
+ //
+ // Confirm items positioned correctly
+ for (int i = 0; i < 4; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*80.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::contentPosJump()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ // Test jumping more than a page of items.
+ listview->setContentY(500);
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 25; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ listview->setContentY(-100);
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ QVERIFY(itemCount < 20);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
index dc104e23e8..9d1c609616 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
@@ -85,7 +85,7 @@ private slots:
QVERIFY(component.errors().isEmpty()); \
} else { \
QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly)); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
QByteArray data = file.readAll(); \
file.close(); \
QList<QByteArray> expected = data.split('\n'); \
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 8000137ca6..46c351985f 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -458,6 +458,16 @@ void tst_QDeclarativePathView::dataModel()
model.removeItem(model.count()-1);
QCOMPARE(pathview->currentIndex(), model.count()-1);
+ // QTBUG-18825
+ // Confirm that the target offset is adjusted when removing items
+ pathview->setCurrentIndex(model.count()-1);
+ QTRY_COMPARE(pathview->offset(), 1.);
+ pathview->setCurrentIndex(model.count()-5);
+ model.removeItem(model.count()-1);
+ model.removeItem(model.count()-1);
+ model.removeItem(model.count()-1);
+ QTRY_COMPARE(pathview->offset(), 2.);
+
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml b/tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml
new file mode 100644
index 0000000000..2da58fce3a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml
@@ -0,0 +1,50 @@
+import QtQuick 1.1
+
+Flickable {
+ id: flick
+ property real scale: 1.0
+ width: 640
+ height: 360
+ contentWidth: 500
+ contentHeight: 500
+
+ PinchArea {
+ objectName: "pincharea"
+ width: Math.max(flick.contentWidth, flick.width)
+ height: Math.max(flick.contentHeight, flick.height)
+
+ property real initialWidth
+ property real initialHeight
+ onPinchStarted: {
+ initialWidth = flick.contentWidth
+ initialHeight = flick.contentHeight
+ }
+
+ onPinchUpdated: {
+ // adjust content pos due to drag
+ flick.contentX += pinch.previousCenter.x - pinch.center.x
+ flick.contentY += pinch.previousCenter.y - pinch.center.y
+
+ // resize content
+ flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
+ flick.scale = pinch.scale
+ }
+
+ onPinchFinished: {
+ // Move its content within bounds.
+ flick.returnToBounds()
+ }
+
+ Rectangle {
+ width: flick.contentWidth
+ height: flick.contentHeight
+ color: "white"
+ Rectangle {
+ anchors.centerIn: parent
+ width: parent.width-40
+ height: parent.height-40
+ color: "blue"
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp b/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp
index f175033e10..90506baedd 100644
--- a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp
+++ b/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QSignalSpy>
#include <private/qdeclarativepincharea_p.h>
#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativeflickable_p.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativecontext.h>
@@ -58,6 +59,7 @@ private slots:
void pinchProperties();
void scale();
void pan();
+ void flickable();
private:
QDeclarativeView *createView();
@@ -301,6 +303,77 @@ void tst_QDeclarativePinchArea::pan()
delete canvas;
}
+void tst_QDeclarativePinchArea::flickable()
+{
+ QDeclarativeView *canvas = createView();
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickresize.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QDeclarativePinchArea *pinchArea = canvas->rootObject()->findChild<QDeclarativePinchArea*>("pincharea");
+ QDeclarativePinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QDeclarativeFlickable *root = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject());
+ QVERIFY(root != 0);
+
+ QWidget *vp = canvas->viewport();
+
+ QPoint p1(110, 80);
+ QPoint p2(100, 100);
+
+ // begin by moving one touch point (mouse)
+ QTest::mousePress(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1));
+ QTest::touchEvent(vp).press(0, p1);
+ {
+ p1 -= QPoint(10,10);
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::touchEvent(vp).move(0, p1);
+ }
+ {
+ p1 -= QPoint(10,10);
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(vp, &mv);
+ QTest::touchEvent(vp).move(0, p1);
+ }
+ {
+ p1 -= QPoint(10,10);
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(vp, &mv);
+ QTest::touchEvent(vp).move(0, p1);
+ }
+
+ // Flickable has reacted to the gesture
+ QVERIFY(root->isMoving());
+ QVERIFY(root->property("scale").toReal() == 1.0);
+
+ // add another touch point and continue moving
+ QTest::touchEvent(vp).stationary(0).press(1, p2);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(vp).move(0, p1).move(1, p2);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(vp).move(0, p1).move(1, p2);
+
+ // PinchArea has stolen the gesture.
+ QVERIFY(!root->isMoving());
+ QVERIFY(root->property("scale").toReal() > 1.0);
+
+ QTest::mouseRelease(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1));
+ QTest::touchEvent(vp).release(0, p1).release(1, p2);
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativePinchArea::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
index 92ab72281a..78821cb3d3 100644
--- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -154,6 +154,15 @@ void tst_QDeclarativePositioners::test_horizontal_rtl()
QCOMPARE(row->width(), 110.0);
QCOMPARE(row->height(), 50.0);
+ // Change the width of the row and check that items stay to the right
+ row->setWidth(200);
+ QCOMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+
delete canvas;
}
@@ -527,6 +536,19 @@ void tst_QDeclarativePositioners::test_grid_rightToLeft()
QCOMPARE(grid->width(), 100.0);
QCOMPARE(grid->height(), 100.0);
+ // Change the width of the grid and check that items stay to the right
+ grid->setWidth(200);
+ QCOMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 100.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 150.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 140.0);
+ QCOMPARE(five->y(), 50.0);
+
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml b/tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml
new file mode 100644
index 0000000000..60ae15c4e1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.1
+
+Text {
+ text: "Hello World"
+ elide: Text.ElideRight
+ width: 30
+}
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 3d6641babe..557603f1f7 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -390,6 +390,13 @@ void tst_qdeclarativetext::elide()
QCOMPARE(textObject->width(), 100.);
}
}
+
+ // QTBUG-18627
+ QUrl qmlfile = QUrl::fromLocalFile(SRCDIR "/data/elideimplicitwidth.qml");
+ QDeclarativeComponent textComponent(&engine, qmlfile);
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(textComponent.create());
+ QVERIFY(item != 0);
+ QVERIFY(item->implicitWidth() > item->width());
}
void tst_qdeclarativetext::textFormat()
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml b/tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml
new file mode 100644
index 0000000000..3af0313692
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+TextEdit {
+ focus: true
+ objectName: "myEdit"
+ width: 50
+ text: "This is a long piece of text"
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
index c7c21fc8b2..f7fb3e7ced 100644
--- a/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
@@ -2,6 +2,7 @@ import QtQuick 1.0
Rectangle { width: 300; height: 300; color: "white"
TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject"
+ anchors.fill: parent
resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance" } } ]
cursorDelegate: cursor
}
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_readonly.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_readonly.qml
new file mode 100644
index 0000000000..4aea61160f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_readonly.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+TextEdit {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: false
+ readOnly: true
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_readonly.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_readonly.qml
new file mode 100644
index 0000000000..959e683721
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_readonly.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+TextEdit {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: true
+ readOnly: true
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index f62c2c57df..2fad88d339 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -119,6 +119,10 @@ private slots:
void moveCursorSelectionSequence();
void mouseSelection_data();
void mouseSelection();
+ void deferEnableSelectByMouse_data();
+ void deferEnableSelectByMouse();
+ void deferDisableSelectByMouse_data();
+ void deferDisableSelectByMouse();
void mouseSelectionMode_data();
void mouseSelectionMode();
void dragMouseSelection();
@@ -148,6 +152,7 @@ private slots:
void preeditMicroFocus();
void inputContextMouseHandler();
void inputMethodComposing();
+ void cursorRectangleSize();
private:
void simulateKey(QDeclarativeView *, int key, Qt::KeyboardModifiers modifiers = 0);
@@ -787,6 +792,14 @@ void tst_qdeclarativetextedit::selection()
QCOMPARE(textEditObject->selectionEnd(), i);
QVERIFY(textEditObject->selectedText().isNull());
}
+ //Test cursor follows selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->select(i,i);
+ QCOMPARE(textEditObject->cursorPosition(), i);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ }
+
textEditObject->setCursorPosition(0);
QVERIFY(textEditObject->cursorPosition() == 0);
@@ -811,10 +824,12 @@ void tst_qdeclarativetextedit::selection()
for(int i=0; i<= testStr.size(); i++) {
textEditObject->select(0,i);
QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
+ QCOMPARE(textEditObject->cursorPosition(), i);
}
for(int i=0; i<= testStr.size(); i++) {
textEditObject->select(i,testStr.size());
QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
+ QCOMPARE(textEditObject->cursorPosition(), testStr.size());
}
textEditObject->setCursorPosition(0);
@@ -1340,6 +1355,92 @@ void tst_qdeclarativetextedit::mouseSelection()
else
QVERIFY(str.isEmpty());
+ // Clicking and shift to clicking between the same points should select the same text.
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y)));
+ QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y)));
+ QCOMPARE(textEditObject->selectedText(), str);
+
+ delete canvas;
+}
+
+void tst_qdeclarativetextedit::deferEnableSelectByMouse_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+
+ QTest::newRow("writable") << SRCDIR "/data/mouseselection_false.qml";
+ QTest::newRow("read only") << SRCDIR "/data/mouseselection_false_readonly.qml";
+}
+
+void tst_qdeclarativetextedit::deferEnableSelectByMouse()
+{
+ // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
+ QFETCH(QString, qmlfile);
+
+ QDeclarativeView *canvas = createView(qmlfile);
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textEditObject->height()/2;
+
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
+ textEditObject->setSelectByMouse(true);
+ //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
+ QVERIFY(textEditObject->selectedText().isEmpty());
+
+ delete canvas;
+}
+
+void tst_qdeclarativetextedit::deferDisableSelectByMouse_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+
+ QTest::newRow("writable") << SRCDIR "/data/mouseselection_true.qml";
+ QTest::newRow("read only") << SRCDIR "/data/mouseselection_true_readonly.qml";
+}
+
+void tst_qdeclarativetextedit::deferDisableSelectByMouse()
+{
+ // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
+ QFETCH(QString, qmlfile);
+
+ QDeclarativeView *canvas = createView(qmlfile);
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textEditObject->height()/2;
+
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
+ textEditObject->setSelectByMouse(false);
+ //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
+ QVERIFY(textEditObject->selectedText().length() > 3);
+
delete canvas;
}
@@ -1436,6 +1537,12 @@ void tst_qdeclarativetextedit::mouseSelectionMode()
QVERIFY(str != text);
}
+ // Clicking and shift to clicking between the same points should select the same text.
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y)));
+ QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y)));
+ QCOMPARE(textEditObject->selectedText(), str);
+
delete canvas;
}
@@ -1523,9 +1630,31 @@ void tst_qdeclarativetextedit::cursorDelegate()
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
}
+ const QString preedit = "preedit";
+ for (int i = 0; i <= preedit.length(); i++) {
+ QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant()));
+ QApplication::sendEvent(view, &event);
+
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ }
textEditObject->setCursorPosition(0);
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QVERIFY(textEditObject->cursorRectangle().y() >= 0);
+ QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->cursorRectangle().height());
+ textEditObject->setVAlign(QDeclarativeTextEdit::AlignVCenter);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QVERIFY(textEditObject->cursorRectangle().y() > (textEditObject->height() / 2) - textEditObject->cursorRectangle().height());
+ QVERIFY(textEditObject->cursorRectangle().y() < (textEditObject->height() / 2) + textEditObject->cursorRectangle().height());
+ textEditObject->setVAlign(QDeclarativeTextEdit::AlignBottom);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QVERIFY(textEditObject->cursorRectangle().y() > textEditObject->height() - (textEditObject->cursorRectangle().height() * 2));
+ QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->height());
+
//Test Delegate gets deleted
textEditObject->setCursorDelegate(0);
QVERIFY(!textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
@@ -2214,6 +2343,8 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QSignalSpy cursorRectangleSpy(&edit, SIGNAL(cursorRectangleChanged()));
+
QRect currentRect;
QRect previousRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
@@ -2224,8 +2355,9 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
QCOMPARE(currentRect, previousRect);
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
- QCOMPARE(ic.updateReceived, true);
+ QCOMPARE(ic.updateReceived, false); // The cursor position hasn't changed.
#endif
+ QCOMPARE(cursorRectangleSpy.count(), 0);
// Verify that the micro focus rect moves to the left as the cursor position
// is incremented.
@@ -2237,6 +2369,8 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QCOMPARE(ic.updateReceived, true);
#endif
+ QVERIFY(cursorRectangleSpy.count() > 0);
+ cursorRectangleSpy.clear();
previousRect = currentRect;
}
@@ -2250,6 +2384,7 @@ void tst_qdeclarativetextedit::preeditMicroFocus()
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QCOMPARE(ic.updateReceived, true);
#endif
+ QVERIFY(cursorRectangleSpy.count() > 0);
}
void tst_qdeclarativetextedit::inputContextMouseHandler()
@@ -2409,6 +2544,25 @@ void tst_qdeclarativetextedit::inputMethodComposing()
QCOMPARE(spy.count(), 2);
}
+void tst_qdeclarativetextedit::cursorRectangleSize()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml");
+ QVERIFY(canvas->rootObject() != 0);
+ canvas->show();
+ canvas->setFocus();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+
+ QDeclarativeTextEdit *textEdit = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEdit != 0);
+ textEdit->setFocus(Qt::OtherFocusReason);
+ QRectF cursorRect = textEdit->positionToRectangle(textEdit->cursorPosition());
+ QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
+ QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
+
+ QCOMPARE(microFocusFromScene.size(), cursorRect.size());
+ QCOMPARE(microFocusFromApp.size(), cursorRect.size());
+}
QTEST_MAIN(tst_qdeclarativetextedit)
#include "tst_qdeclarativetextedit.moc"
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_default.qml b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_default.qml
new file mode 100644
index 0000000000..eea83ed035
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_default.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+TextInput {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: false
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false.qml b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false.qml
new file mode 100644
index 0000000000..eea83ed035
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+TextInput {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: false
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_readonly.qml b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_readonly.qml
new file mode 100644
index 0000000000..36a95634e3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_readonly.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+TextInput {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: false
+ readOnly: true
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_words.qml b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_words.qml
new file mode 100644
index 0000000000..eea83ed035
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_words.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+TextInput {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: false
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_readonly.qml b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_readonly.qml
new file mode 100644
index 0000000000..678a89aa8b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_readonly.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+TextInput {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: true
+ readOnly: true
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_words.qml b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_words.qml
new file mode 100644
index 0000000000..8115ba05e3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_words.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+TextInput {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ selectByMouse: true
+}
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 45f38a4678..a241241505 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -95,6 +95,12 @@ private slots:
void moveCursorSelection();
void moveCursorSelectionSequence_data();
void moveCursorSelectionSequence();
+ void mouseSelection_data();
+ void mouseSelection();
+ void deferEnableSelectByMouse_data();
+ void deferEnableSelectByMouse();
+ void deferDisableSelectByMouse_data();
+ void deferDisableSelectByMouse();
void dragMouseSelection();
void mouseSelectionMode_data();
void mouseSelectionMode();
@@ -135,6 +141,7 @@ private slots:
void preeditMicroFocus();
void inputContextMouseHandler();
void inputMethodComposing();
+ void cursorRectangleSize();
private:
void simulateKey(QDeclarativeView *, int key);
@@ -374,6 +381,13 @@ void tst_qdeclarativetextinput::selection()
QCOMPARE(textinputObject->selectionEnd(), i);
QVERIFY(textinputObject->selectedText().isNull());
}
+ //Test cursor follows selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->select(i,i);
+ QCOMPARE(textinputObject->cursorPosition(), i);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ }
textinputObject->setCursorPosition(0);
QVERIFY(textinputObject->cursorPosition() == 0);
@@ -398,10 +412,12 @@ void tst_qdeclarativetextinput::selection()
for(int i=0; i<= testStr.size(); i++) {
textinputObject->select(0,i);
QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
+ QCOMPARE(textinputObject->cursorPosition(), i);
}
for(int i=0; i<= testStr.size(); i++) {
textinputObject->select(i,testStr.size());
QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
+ QCOMPARE(textinputObject->cursorPosition(), testStr.size());
}
textinputObject->setCursorPosition(0);
@@ -604,10 +620,8 @@ void tst_qdeclarativetextinput::moveCursorSelection_data()
<< standard[2] << 13 << 6 << QDeclarativeTextInput::SelectWords << 6 << 13 << false;
QTest::newRow("Hello<(, world!)>|words")
<< standard[2] << 5 << 13 << QDeclarativeTextInput::SelectWords << 5 << 13 << true;
- // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings.
- // QTBUG-11365
- // QTest::newRow("world<(!)>|words")
- // << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true;
+ QTest::newRow("world<(!)>|words")
+ << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true;
QTest::newRow("world!<()>)|words")
<< standard[2] << 13 << 13 << QDeclarativeTextInput::SelectWords << 13 << 13 << true;
QTest::newRow("world<()>!)|words")
@@ -653,16 +667,15 @@ void tst_qdeclarativetextinput::moveCursorSelection_data()
QTest::newRow(" <s(pac)ey> text |words")
<< standard[4] << 1 << 4 << QDeclarativeTextInput::SelectWords << 1 << 7 << true;
QTest::newRow(" spacey <t(ex)t> |words")
- << standard[4] << 11 << 13 << QDeclarativeTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365
+ << standard[4] << 11 << 13 << QDeclarativeTextInput::SelectWords << 10 << 14 << true;
QTest::newRow("<( )>spacey text |words|ltr")
<< standard[4] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 1 << false;
QTest::newRow("<( )spacey> text |words|rtl")
<< standard[4] << 1 << 0 << QDeclarativeTextInput::SelectWords << 0 << 7 << false;
QTest::newRow("spacey <text( )>|words|ltr")
<< standard[4] << 14 << 15 << QDeclarativeTextInput::SelectWords << 10 << 15 << false;
-// QTBUG-11365
-// QTest::newRow("spacey text<( )>|words|rtl")
-// << standard[4] << 15 << 14 << QDeclarativeTextInput::SelectWords << 14 << 15 << false;
+ QTest::newRow("spacey text<( )>|words|rtl")
+ << standard[4] << 15 << 14 << QDeclarativeTextInput::SelectWords << 14 << 15 << false;
QTest::newRow("<()> spacey text |words")
<< standard[4] << 0 << 0 << QDeclarativeTextInput::SelectWords << 0 << 0 << false;
QTest::newRow(" spacey text <()>|words")
@@ -857,23 +870,21 @@ void tst_qdeclarativetextinput::moveCursorSelectionSequence_data()
<< 15 << 12 << 15
<< 10 << 15
<< 15 << 15;
-// QTBUG-11365
-// QTest::newRow(" spacey <te(xt{^ )>}|rtl")
-// << standard[4]
-// << 15 << 12 << 14
-// << 10 << 15
-// << 14 << 15;
+ QTest::newRow(" spacey <te(xt{^ )>}|rtl")
+ << standard[4]
+ << 15 << 12 << 14
+ << 10 << 15
+ << 14 << 15;
QTest::newRow(" spacey {<te(x^t} )>|ltr")
<< standard[4]
<< 12 << 15 << 13
<< 10 << 15
<< 10 << 14;
-// QTBUG-11365
-// QTest::newRow(" spacey {<te(xt^} )>|ltr")
-// << standard[4]
-// << 12 << 15 << 14
-// << 10 << 15
-// << 10 << 14;
+ QTest::newRow(" spacey {<te(xt^} )>|ltr")
+ << standard[4]
+ << 12 << 15 << 14
+ << 10 << 15
+ << 10 << 14;
}
void tst_qdeclarativetextinput::moveCursorSelectionSequence()
@@ -906,6 +917,141 @@ void tst_qdeclarativetextinput::moveCursorSelectionSequence()
QCOMPARE(textinputObject->selectionEnd(), selection2End);
}
+void tst_qdeclarativetextinput::mouseSelection_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<bool>("expectSelection");
+
+ // import installed
+ QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << true;
+ QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << false;
+ QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << false;
+ QTest::newRow("on word selection") << SRCDIR "/data/mouseselection_true_words.qml" << true;
+ QTest::newRow("off word selection") << SRCDIR "/data/mouseselection_false_words.qml" << false;
+ QTest::newRow("on read only") << SRCDIR "/data/mouseselection_true_readonly.qml" << true;
+ QTest::newRow("off read only") << SRCDIR "/data/mouseselection_false_readonly.qml" << false;
+}
+
+void tst_qdeclarativetextinput::mouseSelection()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(bool, expectSelection);
+
+ QDeclarativeView *canvas = createView(qmlfile);
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textInputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textInputObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textInputObject->height()/2;
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
+ //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
+ QString str = textInputObject->selectedText();
+ if (expectSelection)
+ QVERIFY(str.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform)
+ else
+ QVERIFY(str.isEmpty());
+
+ // Clicking and shift to clicking between the same points should select the same text.
+ textInputObject->setCursorPosition(0);
+ QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y)));
+ QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y)));
+ QCOMPARE(textInputObject->selectedText(), str);
+
+ delete canvas;
+}
+
+void tst_qdeclarativetextinput::deferEnableSelectByMouse_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+
+ QTest::newRow("writable") << SRCDIR "/data/mouseselection_false.qml";
+ QTest::newRow("read only") << SRCDIR "/data/mouseselection_false_readonly.qml";
+}
+
+void tst_qdeclarativetextinput::deferEnableSelectByMouse()
+{
+ // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
+ QFETCH(QString, qmlfile);
+
+ QDeclarativeView *canvas = createView(qmlfile);
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textInputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textInputObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textInputObject->height()/2;
+
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
+ textInputObject->setSelectByMouse(true);
+ //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
+ QVERIFY(textInputObject->selectedText().isEmpty());
+
+ delete canvas;
+}
+
+void tst_qdeclarativetextinput::deferDisableSelectByMouse_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+
+ QTest::newRow("writable") << SRCDIR "/data/mouseselection_true.qml";
+ QTest::newRow("read only") << SRCDIR "/data/mouseselection_true_readonly.qml";
+}
+
+void tst_qdeclarativetextinput::deferDisableSelectByMouse()
+{
+ // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
+ QFETCH(QString, qmlfile);
+
+ QDeclarativeView *canvas = createView(qmlfile);
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textInputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textInputObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textInputObject->height()/2;
+
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
+ textInputObject->setSelectByMouse(false);
+ //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
+ QVERIFY(textInputObject->selectedText().length() > 3);
+
+ delete canvas;
+}
+
void tst_qdeclarativetextinput::dragMouseSelection()
{
QString qmlfile = SRCDIR "/data/mouseselection_true.qml";
@@ -1368,8 +1514,10 @@ void tst_qdeclarativetextinput::inputMethods()
QVERIFY(canvas->rootObject() != 0);
QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
QVERIFY(input != 0);
+ QVERIFY(input->imHints() & Qt::ImhNoPredictiveText);
QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText);
- input->setInputMethodHints(Qt::ImhUppercaseOnly);
+ input->setIMHints(Qt::ImhUppercaseOnly);
+ QVERIFY(input->imHints() & Qt::ImhUppercaseOnly);
QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
QVERIFY(canvas->rootObject() != 0);
@@ -1633,12 +1781,20 @@ void tst_qdeclarativetextinput::cursorDelegate()
//Test Delegate gets moved
for(int i=0; i<= textInputObject->text().length(); i++){
textInputObject->setCursorPosition(i);
- //+5 is because the TextInput cursorRectangle is just a 10xHeight area centered on cursor position
- QCOMPARE(textInputObject->cursorRectangle().x() + 5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ }
+ const QString preedit = "preedit";
+ for (int i = 0; i <= preedit.length(); i++) {
+ QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant()));
+ QApplication::sendEvent(view, &event);
+
+ QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
}
textInputObject->setCursorPosition(0);
- QCOMPARE(textInputObject->cursorRectangle().x()+5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
//Test Delegate gets deleted
textInputObject->setCursorDelegate(0);
@@ -1727,19 +1883,26 @@ void tst_qdeclarativetextinput::cursorRectangle()
QRect r;
+ // some tolerance for different fonts.
+#ifdef Q_OS_LINUX
+ const int error = 2;
+#else
+ const int error = 5;
+#endif
+
for (int i = 0; i <= 5; ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
int textWidth = fm.width(text.mid(0, i));
- QVERIFY(r.left() < textWidth);
- QVERIFY(r.right() > textWidth);
+ QVERIFY(r.left() < textWidth + error);
+ QVERIFY(r.right() > textWidth - error);
QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r);
}
// Check the cursor rectangle remains within the input bounding rect when auto scrolling.
QVERIFY(r.left() < input.boundingRect().width());
- QVERIFY(r.right() >= input.width());
+ QVERIFY(r.right() >= input.width() - error);
for (int i = 6; i < text.length(); ++i) {
input.setCursorPosition(i);
@@ -1803,6 +1966,7 @@ void tst_qdeclarativetextinput::echoMode()
ref &= ~Qt::ImhHiddenText;
ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhNone);
input->setEchoMode(QDeclarativeTextInput::NoEcho);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String(""));
@@ -1811,6 +1975,7 @@ void tst_qdeclarativetextinput::echoMode()
ref |= Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhNone);
input->setEchoMode(QDeclarativeTextInput::Password);
//Password
ref |= Qt::ImhHiddenText;
@@ -1818,6 +1983,7 @@ void tst_qdeclarativetextinput::echoMode()
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("********"));
QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhNone);
input->setPasswordCharacter(QChar('Q'));
QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
QCOMPARE(input->text(), initial);
@@ -1827,6 +1993,7 @@ void tst_qdeclarativetextinput::echoMode()
ref &= ~Qt::ImhHiddenText;
ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhNone);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
@@ -1847,6 +2014,40 @@ void tst_qdeclarativetextinput::echoMode()
QCOMPARE(input->displayText(), initial);
QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
+ // Test echo mode doesn't override imHints.
+ input->setIMHints(Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
+ ref |= Qt::ImhDialableCharactersOnly;
+ //Normal
+ input->setEchoMode(QDeclarativeTextInput::Normal);
+ ref |= Qt::ImhHiddenText;
+ ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
+ //NoEcho
+ input->setEchoMode(QDeclarativeTextInput::NoEcho);
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
+ //Password
+ input->setEchoMode(QDeclarativeTextInput::Password);
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
+ //PasswordEchoOnEdit
+ input->setEchoMode(QDeclarativeTextInput::PasswordEchoOnEdit);
+ ref &= ~Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
+ //Normal
+ input->setEchoMode(QDeclarativeTextInput::Normal);
+ ref |= Qt::ImhHiddenText;
+ ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
+ QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
+
delete canvas;
}
@@ -2240,18 +2441,25 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
QCOMPARE(input.positionAt(0), 0);
QCOMPARE(input.positionAt(input.width()), 5);
+ // some tolerance for different fonts.
+#ifdef Q_OS_LINUX
+ const int error = 2;
+#else
+ const int error = 5;
+#endif
+
// test if the preedit is larger than the text input that the
// character preceding the cursor is still visible.
qreal x = input.positionToRectangle(0).x();
for (int i = 0; i < 3; ++i) {
ic.sendPreeditText(preeditText, i + 1);
- QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)));
+ QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input.positionToRectangle(0).x() < x);
x = input.positionToRectangle(0).x();
}
for (int i = 1; i >= 0; --i) {
ic.sendPreeditText(preeditText, i + 1);
- QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)));
+ QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input.positionToRectangle(0).x() > x);
x = input.positionToRectangle(0).x();
}
@@ -2276,6 +2484,20 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
ic.sendPreeditText(preeditText.mid(0, 3), 1);
QCOMPARE(input.positionAt(0), 0);
QCOMPARE(input.positionAt(input.width()), 5);
+
+ ic.sendEvent(QInputMethodEvent());
+ input.setAutoScroll(true);
+ // Test committing pre-edit text at the start of the string. QTBUG-18789
+ input.setCursorPosition(0);
+ ic.sendPreeditText(input.text(), 5);
+ QCOMPARE(input.positionAt(0), 0);
+
+ QInputMethodEvent event;
+ event.setCommitString(input.text());
+ ic.sendEvent(event);
+
+ QCOMPARE(input.positionAt(0), 0);
+ QCOMPARE(input.positionAt(input.width()), 5);
}
void tst_qdeclarativetextinput::preeditMicroFocus()
@@ -2489,6 +2711,26 @@ void tst_qdeclarativetextinput::inputMethodComposing()
QCOMPARE(spy.count(), 2);
}
+void tst_qdeclarativetextinput::cursorRectangleSize()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml");
+ QVERIFY(canvas->rootObject() != 0);
+ canvas->show();
+ canvas->setFocus();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+
+ QDeclarativeTextInput *textInput = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textInput != 0);
+ textInput->setFocus(Qt::OtherFocusReason);
+ QRectF cursorRect = textInput->positionToRectangle(textInput->cursorPosition());
+ QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
+ QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
+
+ QCOMPARE(microFocusFromScene.size(), cursorRect.size());
+ QCOMPARE(microFocusFromApp.size(), cursorRect.size());
+}
+
QTEST_MAIN(tst_qdeclarativetextinput)
#include "tst_qdeclarativetextinput.moc"
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 85d7876f28..7b384f81aa 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -190,6 +190,11 @@ void tst_qdeclarativevisualdatamodel::rootIndex()
QMetaObject::invokeMethod(obj, "setRootToParent");
QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+ QMetaObject::invokeMethod(obj, "setRoot");
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
+ model.clear(); // will emit modelReset()
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+
delete obj;
}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.html b/tests/auto/declarative/qdeclarativewebview/data/basic.html
deleted file mode 100644
index 22e3e243d0..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/basic.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<html>
-<head><title>Basic</title>
-<link rel="icon" sizes="48x48" href="basic.png">
-<script type="text/javascript">
-<!--
-window.onload = function(){ window.status = "status here"; }
-// -->
-</script>
-</head>
-<body leftmargin="0" marginwidth="0">
-<table width="123">
-<tbody>
-<tr><td>This is a basic test.</td></tr>
-</tbody>
-</table>
-</body>
-</html>
diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.ico b/tests/auto/declarative/qdeclarativewebview/data/basic.ico
deleted file mode 100644
index 8f3d05e718..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/basic.ico
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.png b/tests/auto/declarative/qdeclarativewebview/data/basic.png
deleted file mode 100644
index 35717cca58..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/basic.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.qml b/tests/auto/declarative/qdeclarativewebview/data/basic.qml
deleted file mode 100644
index 73330cd56d..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/basic.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-import QtWebKit 1.0
-
-WebView {
- url: "basic.html"
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/elements.html b/tests/auto/declarative/qdeclarativewebview/data/elements.html
deleted file mode 100644
index 923686794b..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/elements.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<body leftmargin=0 topmargin=0>
-<table width="300px" border=1 cellpadding=0 cellspacing=0>
-<tr>
-<td align=center width=25%%><p>A</p></td>
-<td width=75% height=50px>
- <table width=100% border=1 cellpadding=0 cellspacing=0>
- <tr>
- <td align=center width=50% height=50px><p>B</p></td>
- <td align=center width=50% height=50px><p>C</p></td>
- </tr>
- </table>
-</td>
-</tr>
-</table>
diff --git a/tests/auto/declarative/qdeclarativewebview/data/elements.qml b/tests/auto/declarative/qdeclarativewebview/data/elements.qml
deleted file mode 100644
index b86dd9d968..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/elements.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-import QtWebKit 1.0
-
-WebView {
- url: "elements.html"
- width: 310
- height: 100
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/forward.html b/tests/auto/declarative/qdeclarativewebview/data/forward.html
deleted file mode 100644
index 62ab62da92..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/forward.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<html>
-<head><title>Forward</title>
-<link rel="icon" sizes="32x32" href="forward.png">
-</head>
-<body leftmargin="0" marginwidth="0">
-<table width="123">
-<tbody>
-<tr><td>This is more.</td></tr>
-</tbody>
-</table>
-</body>
-</html>
diff --git a/tests/auto/declarative/qdeclarativewebview/data/forward.png b/tests/auto/declarative/qdeclarativewebview/data/forward.png
deleted file mode 100644
index a82533e3d3..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/forward.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativewebview/data/javaScript.html b/tests/auto/declarative/qdeclarativewebview/data/javaScript.html
deleted file mode 100644
index 35270bc472..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/javaScript.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<html>
-<head><title>JavaScript</title>
-<link rel="icon" sizes="48x48" href="basic.png">
-<script type="text/javascript">
-<!--
-window.onload = function(){ window.status = "status here"; }
-// -->
-</script>
-</head>
-<body>
-This is a JS test.
diff --git a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
deleted file mode 100644
index 527e3b9832..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-import QtWebKit 1.0
-
-WebView {
- url: "javaScript.html"
- javaScriptWindowObjects: [
- QtObject {
- property string qmlprop: "qmlvalue"
- WebView.windowObjectName: "myjsname"
- }
- ]
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
deleted file mode 100644
index baab1a08fa..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-import QtWebKit 1.0
-
-WebView {
- url: "does-not-exist.html"
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/newwindows.html b/tests/auto/declarative/qdeclarativewebview/data/newwindows.html
deleted file mode 100644
index dd541f9b16..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/newwindows.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<html>
-<head>
-<script type="text/javascript">
-<!--
-function clickTheLink()
-{
- var ev = document.createEvent('MouseEvents');
- ev.initEvent( "click", true, false );
- document.getElementById('thelink').dispatchEvent(ev);
-}
-// -->
-</script>
-</head>
-<h1>Multiple windows...</h1>
-
-<a id=thelink target="_blank" href="newwindows.html">Popup!</a>
diff --git a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
deleted file mode 100644
index e66631d881..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-// Demonstrates opening new WebViews from HTML
-
-import QtQuick 1.0
-import QtWebKit 1.0
-
-Grid {
- columns: 3
- id: pages
- height: 300; width: 600
- property int total: 0
-
- Component {
- id: webViewPage
- Rectangle {
- width: webView.width
- height: webView.height
- border.color: "gray"
-
- WebView {
- id: webView
- width: 150 // force predictable for test
- newWindowComponent: webViewPage
- newWindowParent: pages
- url: "newwindows.html"
- Timer {
- interval: 10; running: total<4; repeat: false;
- onTriggered: { if (webView.status==WebView.Ready) { total++; webView.evaluateJavaScript("clickTheLink()") } }
- }
- }
- }
- }
-
- Loader { sourceComponent: webViewPage }
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/pixelCache.html b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.html
deleted file mode 100644
index 9412674091..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/pixelCache.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
-<body topmargin=0 leftmargin=0>
-<table width=120 cellpadding=0 cellspacing=0>
-<tr><td>
-<h1>Pixel Cache</h1>
-This test is for the pixel cache. Because this is a long document,
-as it scrolls, more of the document will need to be rendered.
-If the pixelCacheSize is small, the first parts of the document will
-no longer be in the cache when it returns.
-</table>
diff --git a/tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml
deleted file mode 100644
index 08e4d65719..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import Test 1.0
-
-MyWebView {
- anchors.fill: parent
- url: "pixelCache.html"
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
deleted file mode 100644
index db06887828..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import QtQuick 1.0
-import QtWebKit 1.0
-
-Item {
- width: 240
- height: 160
- Grid {
- anchors.fill: parent
- objectName: "newWindowParent"
- id: newWindowParent
- }
-
- Row {
- anchors.fill: parent
- id: oldWindowParent
- objectName: "oldWindowParent"
- }
-
- Loader {
- sourceComponent: webViewComponent
- }
- Component {
- id: webViewComponent
- WebView {
- id: webView
- objectName: "webView"
- newWindowComponent: webViewComponent
- newWindowParent: oldWindowParent
- url: "basic.html"
- renderingEnabled: true
- pressGrabTime: 200
- }
- }
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
deleted file mode 100644
index 7889704879..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-import QtWebKit 1.0
-
-WebView {
- html: "<p>This is a <b>string</b> set on the WebView"
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
deleted file mode 100644
index af13d33f73..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-contains(QT_CONFIG,webkit): QT += webkit
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativewebview.cpp
-
-symbian: {
- importFiles.files = data
- importFiles.path = .
- DEPLOYMENT += importFiles
-} else {
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
-
-CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
deleted file mode 100644
index 9f99e839e6..0000000000
--- a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
+++ /dev/null
@@ -1,520 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include "../../../shared/util.h"
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativepositioners_p.h>
-#include <QtWebKit/qwebpage.h>
-#include <QtWebKit/qwebframe.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include <QtGui/qpainter.h>
-
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-#define SRCDIR "."
-#endif
-
-class tst_qdeclarativewebview : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativewebview() {}
-
-private slots:
- void initTestCase();
- void basicProperties();
- void settings();
- void historyNav();
- void multipleWindows();
- void elementAreaAt();
- void loadError();
- void setHtml();
- void javaScript();
- void cleanupTestCase();
- //void pixelCache();
- void newWindowParent();
- void newWindowComponent();
- void renderingEnabled();
- void pressGrabTime();
-
-private:
- void checkNoErrors(const QDeclarativeComponent& component);
- QDeclarativeEngine engine;
- QString tmpDir() const
- {
- static QString tmpd = QDir::tempPath()+"/tst_qdeclarativewebview-"
- + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
- return tmpd;
- }
-};
-
-void tst_qdeclarativewebview::initTestCase()
-{
-}
-
-static QString strippedHtml(QString html)
-{
- html.replace(QRegExp("\\s+"),"");
- return html;
-}
-
-static QString fileContents(const QString& filename)
-{
- QFile file(filename);
- file.open(QIODevice::ReadOnly);
- return QString::fromUtf8(file.readAll());
-}
-
-
-static void removeRecursive(const QString& dirname)
-{
- QDir dir(dirname);
- QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
- for (int i = 0; i < entries.count(); ++i)
- if (entries[i].isDir())
- removeRecursive(entries[i].filePath());
- else
- dir.remove(entries[i].fileName());
- QDir().rmdir(dirname);
-}
-
-void tst_qdeclarativewebview::cleanupTestCase()
-{
- removeRecursive(tmpDir());
-}
-
-void tst_qdeclarativewebview::checkNoErrors(const QDeclarativeComponent& component)
-{
- // Wait until the component is ready
- QTRY_VERIFY(component.isReady() || component.isError());
-
- if (component.isError()) {
- QList<QDeclarativeError> errors = component.errors();
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QDeclarativeError &error = errors.at(ii);
- QByteArray errorStr = QByteArray::number(error.line()) + ":" +
- QByteArray::number(error.column()) + ":" +
- error.description().toUtf8();
- qWarning() << errorStr;
- }
- }
- QVERIFY(!component.isError());
-}
-
-void tst_qdeclarativewebview::basicProperties()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QObject *wv = component.create();
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QCOMPARE(wv->property("title").toString(),QString("Basic"));
- QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48);
- QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->property("statusText").toString(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString()));
- QCOMPARE(wv->property("preferredWidth").toInt(), 0);
- QCOMPARE(wv->property("preferredHeight").toInt(), 0);
- QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
-
- wv->setProperty("pixelCacheSize", 0); // mainly testing that it doesn't crash or anything!
- QCOMPARE(wv->property("pixelCacheSize").toInt(),0);
- qvariant_cast<QAction*>(wv->property("reload"))->trigger();
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
-}
-
-void tst_qdeclarativewebview::settings()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QObject *wv = component.create();
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
-
- QObject *s = QDeclarativeProperty(wv,"settings").object();
- QVERIFY(s != 0);
-
- // merely tests that setting gets stored (in QWebSettings)
- // behavioural tests are in WebKit.
- for (int b=0; b<=1; ++b) {
- bool on = !!b;
-
- s->setProperty("autoLoadImages", on);
- s->setProperty("developerExtrasEnabled", on);
- s->setProperty("javaEnabled", on);
- s->setProperty("javascriptCanAccessClipboard", on);
- s->setProperty("javascriptCanOpenWindows", on);
- s->setProperty("javascriptEnabled", on);
- s->setProperty("linksIncludedInFocusChain", on);
- s->setProperty("localContentCanAccessRemoteUrls", on);
- s->setProperty("localStorageDatabaseEnabled", on);
- s->setProperty("offlineStorageDatabaseEnabled", on);
- s->setProperty("offlineWebApplicationCacheEnabled", on);
- s->setProperty("pluginsEnabled", on);
- s->setProperty("printElementBackgrounds", on);
- s->setProperty("privateBrowsingEnabled", on);
- s->setProperty("zoomTextOnly", on);
-
- QVERIFY(s->property("autoLoadImages") == on);
- QVERIFY(s->property("developerExtrasEnabled") == on);
- QVERIFY(s->property("javaEnabled") == on);
- QVERIFY(s->property("javascriptCanAccessClipboard") == on);
- QVERIFY(s->property("javascriptCanOpenWindows") == on);
- QVERIFY(s->property("javascriptEnabled") == on);
- QVERIFY(s->property("linksIncludedInFocusChain") == on);
- QVERIFY(s->property("localContentCanAccessRemoteUrls") == on);
- QVERIFY(s->property("localStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on);
- QVERIFY(s->property("pluginsEnabled") == on);
- QVERIFY(s->property("printElementBackgrounds") == on);
- QVERIFY(s->property("privateBrowsingEnabled") == on);
- QVERIFY(s->property("zoomTextOnly") == on);
-
- QVERIFY(s->property("autoLoadImages") == on);
- QVERIFY(s->property("developerExtrasEnabled") == on);
- QVERIFY(s->property("javaEnabled") == on);
- QVERIFY(s->property("javascriptCanAccessClipboard") == on);
- QVERIFY(s->property("javascriptCanOpenWindows") == on);
- QVERIFY(s->property("javascriptEnabled") == on);
- QVERIFY(s->property("linksIncludedInFocusChain") == on);
- QVERIFY(s->property("localContentCanAccessRemoteUrls") == on);
- QVERIFY(s->property("localStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on);
- QVERIFY(s->property("pluginsEnabled") == on);
- QVERIFY(s->property("printElementBackgrounds") == on);
- QVERIFY(s->property("privateBrowsingEnabled") == on);
- QVERIFY(s->property("zoomTextOnly") == on);
- }
-}
-
-void tst_qdeclarativewebview::historyNav()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QObject *wv = component.create();
- QVERIFY(wv != 0);
- for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QCOMPARE(wv->property("title").toString(),QString("Basic"));
- QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48);
- QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->property("statusText").toString(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString()));
- QCOMPARE(wv->property("preferredWidth").toDouble(), 0.0);
- QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
-
- qvariant_cast<QAction*>(wv->property("reload"))->trigger();
- }
-
- wv->setProperty("url", QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QCOMPARE(wv->property("title").toString(),QString("Forward"));
- QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 32);
- QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/forward.png"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->property("html").toString()));
- QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
- QCOMPARE(wv->property("statusText").toString(),QString(""));
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
- QVERIFY(qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
-
- qvariant_cast<QAction*>(wv->property("back"))->trigger();
-
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QCOMPARE(wv->property("title").toString(),QString("Basic"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString()));
- QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
- QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
- QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
- QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
- QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
-}
-
-void tst_qdeclarativewebview::multipleWindows()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/newwindows.qml"));
- checkNoErrors(component);
-
- QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(component.create());
- QVERIFY(grid != 0);
- QTRY_COMPARE(grid->children().count(), 2+4); // Component, Loader (with 1 WebView), 4 new-window WebViews
- QDeclarativeItem* popup = qobject_cast<QDeclarativeItem*>(grid->children().at(2)); // first popup after Component and Loader.
- QVERIFY(popup != 0);
- QTRY_COMPARE(popup->x(), 150.0);
-}
-
-void tst_qdeclarativewebview::loadError()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/loadError.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QObject *wv = component.create();
- QVERIFY(wv != 0);
- for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QCOMPARE(wv->property("title").toString(),QString(""));
- QCOMPARE(wv->property("statusText").toString(),QString("")); // HTML 'status bar' text, not error message
- QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url
- QCOMPARE(wv->property("status").toInt(), 3 /*QDeclarativeWebView::Error*/);
-
- qvariant_cast<QAction*>(wv->property("reload"))->trigger();
- }
-}
-
-void tst_qdeclarativewebview::setHtml()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml"));
- checkNoErrors(component);
- QObject *wv = component.create();
- QVERIFY(wv != 0);
- QCOMPARE(wv->property("html").toString(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
-
- QSignalSpy spy(wv, SIGNAL(htmlChanged()));
- wv->setProperty("html", QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>"));
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qdeclarativewebview::elementAreaAt()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml"));
- checkNoErrors(component);
- QObject *wv = component.create();
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
-
- /* not now it's a plugin...
- QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html
- QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B
- QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view
- QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC
- QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view
- */
-}
-
-void tst_qdeclarativewebview::javaScript()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml"));
- checkNoErrors(component);
- QObject *wv = component.create();
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- /* not now it's a plugin...
- QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123);
- QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here"));
- QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue"));
- */
-}
-
-/*
-Cannot be done now that webkit is a plugin
-
-void tst_qdeclarativewebview::pixelCache()
-{
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml"));
- checkNoErrors(component);
- MyWebView *wv = qobject_cast<MyWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress"), 1.0);
- QPixmap pm(150,150);
- QPainter p(&pm);
- wv->paint(&p,0,0);
- const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area
- QCOMPARE(wv->property("pixelsPainted"), expected);
- wv->paint(&p,0,0);
- QCOMPARE(wv->property("pixelsPainted"), expected); // nothing new needed to be painted
- wv->setProperty("pixelCacheSize", 0); // clears the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->property("pixelsPainted"), expected*2); // everything needed to be painted
- // Note that painted things always go into the cache (even if they don't "fit"),
- // just that they will be removed if anything else needs to be painted.
- wv->setProperty("pixelCacheSize", expected); // won't clear the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->property("pixelsPainted"), expected*2); // still there
- wv->setProperty("pixelCacheSize", expected-1); // too small - will clear the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->property("pixelsPainted"), expected*3); // repainted
-}
-*/
-
-void tst_qdeclarativewebview::newWindowParent()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
- checkNoErrors(component);
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QObject *wv = rootItem->findChild<QObject*>("webView");
- QVERIFY(rootItem != 0);
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
-
- QDeclarativeItem* oldWindowParent = rootItem->findChild<QDeclarativeItem*>("oldWindowParent");
- QCOMPARE(qvariant_cast<QDeclarativeItem*>(wv->property("newWindowParent")), oldWindowParent);
- QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged()));
-
- QDeclarativeItem* newWindowParent = rootItem->findChild<QDeclarativeItem*>("newWindowParent");
- wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent));
- QVERIFY(newWindowParent);
- QVERIFY(oldWindowParent);
- QVERIFY(oldWindowParent->childItems().count() == 0);
- QCOMPARE(wv->property("newWindowParent"), QVariant::fromValue(newWindowParent));
- QCOMPARE(newWindowParentSpy.count(),1);
-
- wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent));
- QCOMPARE(newWindowParentSpy.count(),1);
-
- wv->setProperty("newWindowParent", QVariant::fromValue((QDeclarativeItem*)0));
- QCOMPARE(newWindowParentSpy.count(),2);
-}
-
-void tst_qdeclarativewebview::newWindowComponent()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
- checkNoErrors(component);
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QObject *wv = rootItem->findChild<QObject*>("webView");
- QVERIFY(rootItem != 0);
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
-
- QDeclarativeComponent substituteComponent(&engine);
- substituteComponent.setData("import QtQuick 1.0; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile(""));
- QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged()));
-
- wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent));
- QCOMPARE(wv->property("newWindowComponent"), QVariant::fromValue(&substituteComponent));
- QCOMPARE(newWindowComponentSpy.count(),1);
-
- wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent));
- QCOMPARE(newWindowComponentSpy.count(),1);
-
- wv->setProperty("newWindowComponent", QVariant::fromValue((QDeclarativeComponent*)0));
- QCOMPARE(newWindowComponentSpy.count(),2);
-}
-
-void tst_qdeclarativewebview::renderingEnabled()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
- checkNoErrors(component);
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QObject *wv = rootItem->findChild<QObject*>("webView");
- QVERIFY(rootItem != 0);
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
-
- QVERIFY(wv->property("renderingEnabled").toBool());
- QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged()));
-
- wv->setProperty("renderingEnabled", false);
- QVERIFY(!wv->property("renderingEnabled").toBool());
- QCOMPARE(renderingEnabledSpy.count(),1);
-
- wv->setProperty("renderingEnabled", false);
- QCOMPARE(renderingEnabledSpy.count(),1);
-
- wv->setProperty("renderingEnabled", true);
- QCOMPARE(renderingEnabledSpy.count(),2);
-}
-
-void tst_qdeclarativewebview::pressGrabTime()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
- checkNoErrors(component);
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QObject *wv = rootItem->findChild<QObject*>("webView");
- QVERIFY(rootItem != 0);
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QCOMPARE(wv->property("pressGrabTime").toInt(), 200);
- QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged()));
-
- wv->setProperty("pressGrabTime", 100);
- QCOMPARE(wv->property("pressGrabTime").toInt(), 100);
- QCOMPARE(pressGrabTimeSpy.count(),1);
-
- wv->setProperty("pressGrabTime", 100);
- QCOMPARE(pressGrabTimeSpy.count(),1);
-
- wv->setProperty("pressGrabTime", 0);
- QCOMPARE(pressGrabTimeSpy.count(),2);
-}
-
-QTEST_MAIN(tst_qdeclarativewebview)
-
-#include "tst_qdeclarativewebview.moc"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 4ec278332b..c4f4058753 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -421,7 +421,7 @@ void tst_qdeclarativexmllistmodel::headers()
QTRY_COMPARE(model->status(), QDeclarativeXmlListModel::Ready);
QVariantMap expectedHeaders;
- expectedHeaders["Accept"] = "application/xml";
+ expectedHeaders["Accept"] = "application/xml,*/*";
QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count());
foreach (const QString &header, expectedHeaders.keys()) {
diff --git a/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
index 06baed8e48..f12bcc32db 100644
--- a/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+++ b/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
@@ -140,9 +140,9 @@ void tst_QMetaObjectBuilder::mocVersionCheck()
// whenenver moc changes. Once QMetaObjectBuilder has been
// updated, this test can be changed to check for the next version.
int version = int(QObject::staticMetaObject.d.data[0]);
- QVERIFY(version == 4 || version == 5);
+ QVERIFY(version == 4 || version == 5 || version == 6);
version = int(staticMetaObject.d.data[0]);
- QVERIFY(version == 4 || version == 5);
+ QVERIFY(version == 4 || version == 5 || version == 6);
}
void tst_QMetaObjectBuilder::create()
@@ -546,6 +546,8 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(!nullProp.isUser());
QVERIFY(!nullProp.hasStdCppSet());
QVERIFY(!nullProp.isEnumOrFlag());
+ QVERIFY(!nullProp.isConstant());
+ QVERIFY(!nullProp.isFinal());
QCOMPARE(nullProp.index(), 0);
// Add a property and check its attributes.
@@ -563,6 +565,8 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(!prop1.isUser());
QVERIFY(!prop1.hasStdCppSet());
QVERIFY(!prop1.isEnumOrFlag());
+ QVERIFY(!prop1.isConstant());
+ QVERIFY(!prop1.isFinal());
QCOMPARE(prop1.index(), 0);
QCOMPARE(builder.propertyCount(), 1);
@@ -581,6 +585,8 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(!prop2.isUser());
QVERIFY(!prop2.hasStdCppSet());
QVERIFY(!prop2.isEnumOrFlag());
+ QVERIFY(!prop2.isConstant());
+ QVERIFY(!prop2.isFinal());
QCOMPARE(prop2.index(), 1);
QCOMPARE(builder.propertyCount(), 2);
@@ -602,6 +608,8 @@ void tst_QMetaObjectBuilder::property()
prop1.setUser(true);
prop1.setStdCppSet(true);
prop1.setEnumOrFlag(true);
+ prop1.setConstant(true);
+ prop1.setFinal(true);
// Check that prop1 is changed, but prop2 is not.
QCOMPARE(prop1.name(), QByteArray("foo"));
@@ -616,6 +624,8 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(prop1.isUser());
QVERIFY(prop1.hasStdCppSet());
QVERIFY(prop1.isEnumOrFlag());
+ QVERIFY(prop1.isConstant());
+ QVERIFY(prop1.isFinal());
QVERIFY(prop2.isReadable());
QVERIFY(prop2.isWritable());
QCOMPARE(prop2.name(), QByteArray("bar"));
@@ -628,6 +638,8 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(!prop2.isUser());
QVERIFY(!prop2.hasStdCppSet());
QVERIFY(!prop2.isEnumOrFlag());
+ QVERIFY(!prop2.isConstant());
+ QVERIFY(!prop2.isFinal());
// Remove prop1 and check that prop2 becomes index 0.
builder.removeProperty(0);
@@ -643,6 +655,8 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(!prop2.isUser());
QVERIFY(!prop2.hasStdCppSet());
QVERIFY(!prop2.isEnumOrFlag());
+ QVERIFY(!prop2.isConstant());
+ QVERIFY(!prop2.isFinal());
QCOMPARE(prop2.index(), 0);
// Perform index-based lookup again.
@@ -666,6 +680,8 @@ void tst_QMetaObjectBuilder::property()
prop2.setUser(false); \
prop2.setStdCppSet(false); \
prop2.setEnumOrFlag(false); \
+ prop2.setConstant(false); \
+ prop2.setFinal(false); \
} while (0)
#define COUNT_FLAGS() \
((prop2.isReadable() ? 1 : 0) + \
@@ -677,7 +693,9 @@ void tst_QMetaObjectBuilder::property()
(prop2.isEditable() ? 1 : 0) + \
(prop2.isUser() ? 1 : 0) + \
(prop2.hasStdCppSet() ? 1 : 0) + \
- (prop2.isEnumOrFlag() ? 1 : 0))
+ (prop2.isEnumOrFlag() ? 1 : 0) + \
+ (prop2.isConstant() ? 1 : 0) + \
+ (prop2.isFinal() ? 1 : 0))
#define CHECK_FLAG(setFunc,isFunc) \
do { \
CLEAR_FLAGS(); \
@@ -696,6 +714,8 @@ void tst_QMetaObjectBuilder::property()
CHECK_FLAG(setUser, isUser);
CHECK_FLAG(setStdCppSet, hasStdCppSet);
CHECK_FLAG(setEnumOrFlag, isEnumOrFlag);
+ CHECK_FLAG(setConstant, isConstant);
+ CHECK_FLAG(setFinal, isFinal);
// Check that nothing else changed.
QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Properties));
@@ -920,9 +940,9 @@ void tst_QMetaObjectBuilder::relatedMetaObject()
QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::RelatedMetaObjects));
}
-static int smetacall(QMetaObject::Call, int, void **)
+static void smetacall(QObject *, QMetaObject::Call, int, void **)
{
- return 0;
+ return;
}
void tst_QMetaObjectBuilder::staticMetacall()
diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro
index 186f00c126..22c5e51c91 100644
--- a/tests/auto/gui.pro
+++ b/tests/auto/gui.pro
@@ -84,6 +84,7 @@ SUBDIRS=\
qheaderview \
qicoimageformat \
qicon \
+ qidentityproxymodel \
qimageiohandler \
qimagereader \
qimagewriter \
@@ -114,9 +115,6 @@ SUBDIRS=\
qmovie \
qvolatileimage \
qnetworkaccessmanager_and_qprogressdialog \
- qnetworkcachemetadata \
- qnetworkdiskcache \
- qnetworkreply \
qpaintengine \
qpainterpath \
qpainterpathstroker \
@@ -139,6 +137,7 @@ SUBDIRS=\
qpushbutton \
qquaternion \
qradiobutton \
+ qrawfont \
qregexpvalidator \
qregion \
qscrollarea \
@@ -169,7 +168,6 @@ SUBDIRS=\
qtabbar \
qtableview \
qtablewidget \
- qtcpserver \
qtcpsocket \
qtessellator \
qtextblock \
@@ -196,7 +194,6 @@ SUBDIRS=\
qtreeview \
qtreewidget \
qtreewidgetitemiterator \
- qudpsocket \
qundogroup \
qundostack \
qvectornd \
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index b5c65ef9ba..b6135d071f 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -243,6 +243,10 @@ void tst_Headers::licenseCheck()
QCOMPARE(content.at(i++), QString("**"));
if (sourceFile.endsWith("/tests/auto/modeltest/dynamictreemodel.cpp")
|| sourceFile.endsWith("/tests/auto/modeltest/dynamictreemodel.h")
+ || sourceFile.endsWith("/src/gui/itemviews/qidentityproxymodel.h")
+ || sourceFile.endsWith("/src/gui/itemviews/qidentityproxymodel.cpp")
+ || sourceFile.endsWith("/doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp")
+ || sourceFile.endsWith("/tests/auto/qidentityproxymodel/tst_qidentityproxymodel.cpp")
|| sourceFile.endsWith("/src/network/kernel/qnetworkproxy_p.h"))
{
// These files are not copyrighted by Nokia.
diff --git a/tests/auto/lancelot/scripts/hinting.qps b/tests/auto/lancelot/scripts/hinting.qps
new file mode 100644
index 0000000000..7ce21b287a
--- /dev/null
+++ b/tests/auto/lancelot/scripts/hinting.qps
@@ -0,0 +1,26 @@
+translate 10 50
+setFont "sansserif" 10
+drawText 0 0 "Default hinting:"
+setFont "times" 12 normal normal default
+drawText 0 20 "The quick brown fox jumps over the lazy dog"
+
+translate 0 50
+setFont "sansserif" 10
+drawText 0 0 "No hinting:"
+setFont "times" 12 normal normal none
+drawText 0 20 "The quick brown fox jumps over the lazy dog"
+
+translate 0 50
+setFont "sansserif" 10
+drawText 0 0 "Vertical hinting:"
+setFont "times" 12 normal normal vertical
+drawText 0 20 "The quick brown fox jumps over the lazy dog"
+
+translate 0 50
+setFont "sansserif" 10
+drawText 0 0 "Full hinting:"
+setFont "times" 12 normal normal full
+drawText 0 20 "The quick brown fox jumps over the lazy dog"
+
+
+# Note: there is also the textlayout_draw command which might be interesting here.
diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp
index e515c4884d..2eb3f200ed 100644
--- a/tests/auto/lancelot/tst_lancelot.cpp
+++ b/tests/auto/lancelot/tst_lancelot.cpp
@@ -239,13 +239,23 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format)
QSKIP("Blacklisted by baseline server.", SkipSingle);
ImageItem rendered = render(baseline, engine, format);
+ static int consecutiveErrs = 0;
if (rendered.image.isNull()) { // Assume an error in the test environment, not Qt
QWARN("Error: Failed to render image.");
- QSKIP("Aborted due to errors.", SkipSingle);
+ if (++consecutiveErrs < 3) {
+ QSKIP("Aborted due to errors.", SkipSingle);
+ } else {
+ consecutiveErrs = 0;
+ QSKIP("Too many errors, skipping rest of testfunction.", SkipAll);
+ }
+ } else {
+ consecutiveErrs = 0;
}
+
if (baseline.status == ImageItem::BaselineNotFound) {
- proto.submitNewBaseline(rendered, 0);
+ if (!proto.submitNewBaseline(rendered, 0))
+ QWARN("Failed to submit new baseline: " + proto.errorMessage().toLatin1());
QSKIP("Baseline not found; new baseline created.", SkipSingle);
}
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp
index 3dc0506637..9c18a3ccd1 100644
--- a/tests/auto/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp
@@ -69,7 +69,7 @@ private slots:
void testMouseEnter();
void testChildDialogInFrontOfModalParent();
#ifdef QT_MAC_USE_COCOA
- void testChildWindowInFrontOfParentWindow();
+// void testChildWindowInFrontOfParentWindow();
// void testChildToolWindowInFrontOfChildNormalWindow();
void testChildWindowInFrontOfStaysOnTopParentWindow();
#endif
@@ -319,6 +319,11 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent()
}
#ifdef QT_MAC_USE_COCOA
+#if 0
+// This test is disabled as of Qt-4.7.4 because we cannot do it
+// unless we use the Cocoa sub window API. But using that opens up
+// a world of side effects that we cannot live with. So we rather
+// not support child-on-top-of-parent instead.
void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow()
{
// Test that a child window always stacks in front of its parent window.
@@ -343,6 +348,7 @@ void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow()
QTest::qWait(100);
QVERIFY(!child.isVisible());
}
+#endif
/* This test can be enabled once setStackingOrder has been fixed in qwidget_mac.mm
void tst_MacNativeEvents::testChildToolWindowInFrontOfChildNormalWindow()
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index 203f0aeeb3..7a8f958aca 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -497,7 +497,7 @@ private slots:
void revisions();
void warnings_data();
void warnings();
-
+ void privateClass();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -517,6 +517,7 @@ private:
private:
QString qtIncludePath;
+ class PrivateClass;
};
void tst_Moc::initTestCase()
@@ -1648,6 +1649,25 @@ void tst_Moc::warnings()
}
+class tst_Moc::PrivateClass : public QObject {
+ Q_PROPERTY(int someProperty READ someSlot WRITE someSlot2)
+Q_OBJECT
+Q_SIGNALS:
+ void someSignal();
+public Q_SLOTS:
+ int someSlot() { return 1; }
+ void someSlot2(int) {}
+public:
+ Q_INVOKABLE PrivateClass() {}
+};
+
+void tst_Moc::privateClass()
+{
+ QVERIFY(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()") == 0);
+ QVERIFY(PrivateClass::staticMetaObject.indexOfSignal("someSignal()") > 0);
+}
+
+
QTEST_APPLESS_MAIN(tst_Moc)
#include "tst_moc.moc"
diff --git a/tests/auto/network.pro b/tests/auto/network.pro
index b427f1c1bd..e4cecce450 100644
--- a/tests/auto/network.pro
+++ b/tests/auto/network.pro
@@ -16,15 +16,18 @@ SUBDIRS=\
qhttpnetworkconnection \
qhttpnetworkreply \
qhttpsocketengine \
- qnativesocketengine \
+ platformsocketengine \
qnetworkaccessmanager \
qnetworkaddressentry \
+ qnetworkcachemetadata \
qnetworkconfiguration \
qnetworkconfigurationmanager \
qnetworkcookie \
qnetworkcookiejar \
+ qnetworkdiskcache \
qnetworkinterface \
qnetworkproxy \
+ qnetworkreply \
qnetworkrequest \
qnetworksession \
qobjectperformance \
@@ -37,13 +40,15 @@ SUBDIRS=\
qsslsocket \
qsslsocket_onDemandCertificates_member \
qsslsocket_onDemandCertificates_static \
+ qtcpserver \
+ qudpsocket \
# qnetworkproxyfactory \ # Uses a hardcoded proxy configuration
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
qauthenticator \
qhttpnetworkconnection \
qhttpnetworkreply \
- qnativesocketengine \
+ platformsocketengine \
qsocketnotifier \
qsocks5socketengine \
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp
index 64de64a30c..f40ea3e065 100644
--- a/tests/auto/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/networkselftest/tst_networkselftest.cpp
@@ -44,6 +44,12 @@
#include <time.h>
+#ifndef QT_NO_BEARERMANAGEMENT
+#include <QtNetwork/qnetworkconfigmanager.h>
+#include <QtNetwork/qnetworkconfiguration.h>
+#include <QtNetwork/qnetworksession.h>
+#endif
+
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
// Current path (C:\private\<UID>) contains only ascii chars
@@ -64,6 +70,7 @@ public:
QHostAddress serverIpAddress();
private slots:
+ void initTestCase();
void hostTest();
void dnsResolution_data();
void dnsResolution();
@@ -91,6 +98,12 @@ private slots:
// ssl supported test
void supportsSsl();
+private:
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QScopedPointer<QNetworkSession> networkSession;
+#endif
};
class Chat
@@ -354,6 +367,19 @@ QHostAddress tst_NetworkSelfTest::serverIpAddress()
return cachedIpAddress;
}
+void tst_NetworkSelfTest::initTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
+}
+
void tst_NetworkSelfTest::hostTest()
{
// this is a localhost self-test
@@ -469,7 +495,8 @@ void tst_NetworkSelfTest::fileLineEndingTest()
static QList<Chat> ftpChat(const QByteArray &userSuffix = QByteArray())
{
- return QList<Chat>() << Chat::expect("220")
+ QList<Chat> rv;
+ rv << Chat::expect("220")
<< Chat::discardUntil("\r\n")
<< Chat::send("USER anonymous" + userSuffix + "\r\n")
<< Chat::expect("331")
@@ -504,10 +531,15 @@ static QList<Chat> ftpChat(const QByteArray &userSuffix = QByteArray())
// << Chat::send("SIZE nonASCII/german_\344\366\374\304\326\334\337\r\n")
// << Chat::expect("213 40\r\n")
- << Chat::send("QUIT\r\n")
- << Chat::expect("221")
- << Chat::discardUntil("\r\n")
- << Chat::RemoteDisconnect;
+ << Chat::send("QUIT\r\n");
+#ifdef Q_OS_SYMBIAN
+ if (userSuffix.length() == 0) // received but unacknowledged packets are discarded by TCP RST, so this doesn't work with frox proxy
+#endif
+ rv << Chat::expect("221")
+ << Chat::discardUntil("\r\n");
+
+ rv << Chat::RemoteDisconnect;
+ return rv;
}
void tst_NetworkSelfTest::ftpServer()
diff --git a/tests/auto/platformsocketengine/.gitignore b/tests/auto/platformsocketengine/.gitignore
new file mode 100644
index 0000000000..afe93891ff
--- /dev/null
+++ b/tests/auto/platformsocketengine/.gitignore
@@ -0,0 +1 @@
+tst_platformsocketengine
diff --git a/tests/auto/qnativesocketengine/qsocketengine.pri b/tests/auto/platformsocketengine/platformsocketengine.pri
index 15f31fdbb5..15f31fdbb5 100644
--- a/tests/auto/qnativesocketengine/qsocketengine.pri
+++ b/tests/auto/platformsocketengine/platformsocketengine.pri
diff --git a/tests/auto/platformsocketengine/platformsocketengine.pro b/tests/auto/platformsocketengine/platformsocketengine.pro
new file mode 100644
index 0000000000..faf745c679
--- /dev/null
+++ b/tests/auto/platformsocketengine/platformsocketengine.pro
@@ -0,0 +1,16 @@
+load(qttest_p4)
+SOURCES += tst_platformsocketengine.cpp
+
+include(../platformsocketengine/platformsocketengine.pri)
+
+requires(contains(QT_CONFIG,private_tests))
+
+MOC_DIR=tmp
+
+QT = core network
+
+symbian {
+ TARGET.CAPABILITY = NetworkServices
+ INCLUDEPATH += $$OS_LAYER_SYSTEMINCLUDE
+ LIBS += -lesock
+}
diff --git a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
index 41eb1e2587..184371d0c9 100644
--- a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
+++ b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
@@ -50,7 +50,6 @@
#include <qdatastream.h>
-#include <private/qnativesocketengine_p.h>
#include <qhostaddress.h>
#include <qdatetime.h>
@@ -63,6 +62,20 @@
#include <stddef.h>
+#ifdef Q_OS_SYMBIAN
+#include <QNetworkConfigurationManager>
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
+#include <QScopedPointer>
+#define PLATFORMSOCKETENGINE QSymbianSocketEngine
+#define PLATFORMSOCKETENGINESTRING "QSymbianSocketEngine"
+#include <private/qsymbiansocketengine_p.h>
+#include <private/qcore_symbian_p.h>
+#else
+#define PLATFORMSOCKETENGINE QNativeSocketEngine
+#define PLATFORMSOCKETENGINESTRING "QNativeSocketEngine"
+#include <private/qnativesocketengine_p.h>
+#endif
#include <qstringlist.h>
@@ -70,13 +83,13 @@
//TESTED_FILES=network/qnativesocketengine.cpp network/qnativesocketengine_p.h network/qnativesocketengine_unix.cpp
-class tst_QNativeSocketEngine : public QObject
+class tst_PlatformSocketEngine : public QObject
{
Q_OBJECT
public:
- tst_QNativeSocketEngine();
- virtual ~tst_QNativeSocketEngine();
+ tst_PlatformSocketEngine();
+ virtual ~tst_PlatformSocketEngine();
public slots:
@@ -92,35 +105,35 @@ private slots:
void udpLoopbackPerformance();
void tcpLoopbackPerformance();
void readWriteBufferSize();
- void tooManySockets();
void bind();
void networkError();
void setSocketDescriptor();
void invalidSend();
void receiveUrgentData();
+ void tooManySockets();
};
-tst_QNativeSocketEngine::tst_QNativeSocketEngine()
+tst_PlatformSocketEngine::tst_PlatformSocketEngine()
{
Q_SET_DEFAULT_IAP
}
-tst_QNativeSocketEngine::~tst_QNativeSocketEngine()
+tst_PlatformSocketEngine::~tst_PlatformSocketEngine()
{
}
-void tst_QNativeSocketEngine::init()
+void tst_PlatformSocketEngine::init()
{
}
-void tst_QNativeSocketEngine::cleanup()
+void tst_PlatformSocketEngine::cleanup()
{
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::construction()
+void tst_PlatformSocketEngine::construction()
{
- QNativeSocketEngine socketDevice;
+ PLATFORMSOCKETENGINE socketDevice;
QVERIFY(!socketDevice.isValid());
@@ -137,17 +150,17 @@ void tst_QNativeSocketEngine::construction()
QVERIFY(socketDevice.peerPort() == 0);
QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
- QTest::ignoreMessage(QtWarningMsg, "QNativeSocketEngine::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
+ QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
QVERIFY(socketDevice.bytesAvailable() == 0);
- QTest::ignoreMessage(QtWarningMsg, "QNativeSocketEngine::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
+ QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::simpleConnectToIMAP()
+void tst_PlatformSocketEngine::simpleConnectToIMAP()
{
- QNativeSocketEngine socketDevice;
+ PLATFORMSOCKETENGINE socketDevice;
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
@@ -202,12 +215,9 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::udpLoopbackTest()
+void tst_PlatformSocketEngine::udpLoopbackTest()
{
-#ifdef SYMBIAN_WINSOCK_CONNECTIVITY
- QSKIP("Not working on Emulator without WinPCAP", SkipAll);
-#endif
- QNativeSocketEngine udpSocket;
+ PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
@@ -224,7 +234,7 @@ void tst_QNativeSocketEngine::udpLoopbackTest()
QVERIFY(port != 0);
// Initialize device #2
- QNativeSocketEngine udpSocket2;
+ PLATFORMSOCKETENGINE udpSocket2;
QVERIFY(udpSocket2.initialize(QAbstractSocket::UdpSocket));
// Connect device #2 to #1
@@ -253,12 +263,9 @@ void tst_QNativeSocketEngine::udpLoopbackTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::udpIPv6LoopbackTest()
+void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
{
-#if defined(Q_OS_SYMBIAN)
- QSKIP("Symbian: IPv6 is not yet supported", SkipAll);
-#endif
- QNativeSocketEngine udpSocket;
+ PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
bool init = udpSocket.initialize(QAbstractSocket::UdpSocket, QAbstractSocket::IPv6Protocol);
@@ -275,7 +282,7 @@ void tst_QNativeSocketEngine::udpIPv6LoopbackTest()
QVERIFY(port != 0);
// Initialize device #2
- QNativeSocketEngine udpSocket2;
+ PLATFORMSOCKETENGINE udpSocket2;
QVERIFY(udpSocket2.initialize(QAbstractSocket::UdpSocket, QAbstractSocket::IPv6Protocol));
// Connect device #2 to #1
@@ -305,12 +312,26 @@ void tst_QNativeSocketEngine::udpIPv6LoopbackTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::broadcastTest()
+void tst_PlatformSocketEngine::broadcastTest()
{
+#ifdef Q_OS_SYMBIAN
+ //broadcast isn't supported on loopback connections, but is on WLAN
+#ifndef QT_NO_BEARERMANAGEMENT
+ QScopedPointer<QNetworkConfigurationManager> netConfMan(new QNetworkConfigurationManager());
+ QNetworkConfiguration networkConfiguration(netConfMan->defaultConfiguration());
+ QScopedPointer<QNetworkSession> networkSession(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ bool ok = networkSession->waitForOpened(30000);
+ qDebug() << networkSession->isOpen() << networkSession->error() << networkSession->errorString();
+ QVERIFY(ok);
+ }
+#endif
+#endif
#ifdef Q_OS_AIX
QSKIP("Broadcast does not work on darko", SkipAll);
#endif
- QNativeSocketEngine broadcastSocket;
+ PLATFORMSOCKETENGINE broadcastSocket;
// Initialize a regular Udp socket
QVERIFY(broadcastSocket.initialize(QAbstractSocket::UdpSocket));
@@ -324,10 +345,18 @@ void tst_QNativeSocketEngine::broadcastTest()
// Broadcast an inappropriate troll message
QByteArray trollMessage
= "MOOT wtf is a MOOT? talk english not your sutpiD ENGLISH.";
- QVERIFY(broadcastSocket.writeDatagram(trollMessage.data(),
+ qint64 written = broadcastSocket.writeDatagram(trollMessage.data(),
trollMessage.size(),
QHostAddress::Broadcast,
- port) == trollMessage.size());
+ port);
+
+#ifdef Q_OS_SYMBIAN
+ //On symbian, broadcasts return 0 bytes written if none of the interfaces support it.
+ //Notably the loopback interfaces do not. (though they do support multicast!?)
+ if (written == 0)
+ QEXPECT_FAIL("", "No active interface supports broadcast", Abort);
+#endif
+ QCOMPARE((int)written, trollMessage.size());
// Wait until we receive it ourselves
#if defined(Q_OS_FREEBSD)
@@ -346,9 +375,9 @@ void tst_QNativeSocketEngine::broadcastTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::serverTest()
+void tst_PlatformSocketEngine::serverTest()
{
- QNativeSocketEngine server;
+ PLATFORMSOCKETENGINE server;
// Initialize a Tcp socket
QVERIFY(server.initialize(QAbstractSocket::TcpSocket));
@@ -363,7 +392,7 @@ void tst_QNativeSocketEngine::serverTest()
QVERIFY(server.state() == QAbstractSocket::ListeningState);
// Initialize a Tcp socket
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
QVERIFY(client.state() == QAbstractSocket::ConnectingState);
@@ -377,7 +406,7 @@ void tst_QNativeSocketEngine::serverTest()
// A socket device is initialized on the server side, passing the
// socket descriptor from accept(). It's pre-connected.
- QNativeSocketEngine serverSocket;
+ PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
@@ -400,12 +429,12 @@ void tst_QNativeSocketEngine::serverTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::udpLoopbackPerformance()
+void tst_PlatformSocketEngine::udpLoopbackPerformance()
{
#ifdef SYMBIAN_WINSOCK_CONNECTIVITY
QSKIP("Not working on Emulator without WinPCAP", SkipAll);
#endif
- QNativeSocketEngine udpSocket;
+ PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
@@ -422,7 +451,7 @@ void tst_QNativeSocketEngine::udpLoopbackPerformance()
QVERIFY(port != 0);
// Initialize device #2
- QNativeSocketEngine udpSocket2;
+ PLATFORMSOCKETENGINE udpSocket2;
QVERIFY(udpSocket2.initialize(QAbstractSocket::UdpSocket));
// Connect device #2 to #1
@@ -454,9 +483,9 @@ void tst_QNativeSocketEngine::udpLoopbackPerformance()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::tcpLoopbackPerformance()
+void tst_PlatformSocketEngine::tcpLoopbackPerformance()
{
- QNativeSocketEngine server;
+ PLATFORMSOCKETENGINE server;
// Initialize a Tcp socket
QVERIFY(server.initialize(QAbstractSocket::TcpSocket));
@@ -471,7 +500,7 @@ void tst_QNativeSocketEngine::tcpLoopbackPerformance()
QVERIFY(server.state() == QAbstractSocket::ListeningState);
// Initialize a Tcp socket
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
// Connect to our server
@@ -481,17 +510,21 @@ void tst_QNativeSocketEngine::tcpLoopbackPerformance()
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
}
- // The server accepts the connectio
+ // The server accepts the connection
int socketDescriptor = server.accept();
QVERIFY(socketDescriptor > 0);
// A socket device is initialized on the server side, passing the
// socket descriptor from accept(). It's pre-connected.
- QNativeSocketEngine serverSocket;
+ PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+#if defined (Q_OS_SYMBIAN) && defined (__WINS__)
+ const int messageSize = 1024 * 16;
+#else
const int messageSize = 1024 * 256;
+#endif
QByteArray message1(messageSize, '@');
QByteArray answer(messageSize, '@');
@@ -517,9 +550,9 @@ void tst_QNativeSocketEngine::tcpLoopbackPerformance()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::readWriteBufferSize()
+void tst_PlatformSocketEngine::readWriteBufferSize()
{
- QNativeSocketEngine device;
+ PLATFORMSOCKETENGINE device;
QVERIFY(device.initialize(QAbstractSocket::TcpSocket));
@@ -539,15 +572,15 @@ void tst_QNativeSocketEngine::readWriteBufferSize()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::tooManySockets()
+void tst_PlatformSocketEngine::tooManySockets()
{
#if defined Q_OS_WIN
QSKIP("Certain windows machines suffocate and spend too much time in this test.", SkipAll);
#endif
- QList<QNativeSocketEngine *> sockets;
- QNativeSocketEngine *socketLayer = 0;
+ QList<PLATFORMSOCKETENGINE *> sockets;
+ PLATFORMSOCKETENGINE *socketLayer = 0;
for (;;) {
- socketLayer = new QNativeSocketEngine;
+ socketLayer = new PLATFORMSOCKETENGINE;
sockets.append(socketLayer);
if (!socketLayer->initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol))
@@ -560,20 +593,20 @@ void tst_QNativeSocketEngine::tooManySockets()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::bind()
+void tst_PlatformSocketEngine::bind()
{
#if !defined Q_OS_WIN && !defined Q_OS_SYMBIAN
- QNativeSocketEngine binder;
+ PLATFORMSOCKETENGINE binder;
QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder.bind(QHostAddress::Any, 82));
QVERIFY(binder.error() == QAbstractSocket::SocketAccessError);
#endif
- QNativeSocketEngine binder2;
+ PLATFORMSOCKETENGINE binder2;
QVERIFY(binder2.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(binder2.bind(QHostAddress::Any, 31180));
- QNativeSocketEngine binder3;
+ PLATFORMSOCKETENGINE binder3;
QVERIFY(binder3.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder3.bind(QHostAddress::Any, 31180));
@@ -586,9 +619,9 @@ void tst_QNativeSocketEngine::bind()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::networkError()
+void tst_PlatformSocketEngine::networkError()
{
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
@@ -604,6 +637,12 @@ void tst_QNativeSocketEngine::networkError()
#ifdef Q_OS_WIN
// could use shutdown to produce different errors
::closesocket(client.socketDescriptor());
+#elif defined(Q_OS_SYMBIAN)
+ RSocket sock;
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(client.socketDescriptor(), sock));
+ TRequestStatus stat;
+ sock.Shutdown(RSocket::EImmediate, stat);
+ User::WaitForRequest(stat);
#else
::close(client.socketDescriptor());
#endif
@@ -612,31 +651,31 @@ void tst_QNativeSocketEngine::networkError()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::setSocketDescriptor()
+void tst_PlatformSocketEngine::setSocketDescriptor()
{
- QNativeSocketEngine socket1;
+ PLATFORMSOCKETENGINE socket1;
QVERIFY(socket1.initialize(QAbstractSocket::TcpSocket));
- QNativeSocketEngine socket2;
+ PLATFORMSOCKETENGINE socket2;
QVERIFY(socket2.initialize(socket1.socketDescriptor()));
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::invalidSend()
+void tst_PlatformSocketEngine::invalidSend()
{
- QNativeSocketEngine socket;
+ PLATFORMSOCKETENGINE socket;
QVERIFY(socket.initialize(QAbstractSocket::TcpSocket));
- QTest::ignoreMessage(QtWarningMsg, "QNativeSocketEngine::writeDatagram() was"
+ QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::writeDatagram() was"
" called by a socket other than QAbstractSocket::UdpSocket");
QCOMPARE(socket.writeDatagram("hei", 3, QHostAddress::LocalHost, 143),
(qlonglong) -1);
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::receiveUrgentData()
+void tst_PlatformSocketEngine::receiveUrgentData()
{
- QNativeSocketEngine server;
+ PLATFORMSOCKETENGINE server;
QVERIFY(server.initialize(QAbstractSocket::TcpSocket));
@@ -648,7 +687,7 @@ void tst_QNativeSocketEngine::receiveUrgentData()
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
@@ -660,7 +699,7 @@ void tst_QNativeSocketEngine::receiveUrgentData()
int socketDescriptor = server.accept();
QVERIFY(socketDescriptor > 0);
- QNativeSocketEngine serverSocket;
+ PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
@@ -676,7 +715,18 @@ void tst_QNativeSocketEngine::receiveUrgentData()
// The server sends an urgent message
msg = 'Q';
+#if defined(Q_OS_SYMBIAN)
+ RSocket sock;
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(socketDescriptor, sock));
+ TRequestStatus stat;
+ TSockXfrLength len;
+ sock.Send(TPtrC8((TUint8*)&msg,1), KSockWriteUrgent, stat, len);
+ User::WaitForRequest(stat);
+ QVERIFY(stat == KErrNone);
+ QCOMPARE(len(), 1);
+#else
QCOMPARE(int(::send(socketDescriptor, &msg, sizeof(msg), MSG_OOB)), 1);
+#endif
// The client receives the urgent message
QVERIFY(client.waitForRead());
@@ -689,7 +739,15 @@ void tst_QNativeSocketEngine::receiveUrgentData()
// The client sends an urgent message
msg = 'T';
int clientDescriptor = client.socketDescriptor();
+#if defined(Q_OS_SYMBIAN)
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(clientDescriptor, sock));
+ sock.Send(TPtrC8((TUint8*)&msg,1), KSockWriteUrgent, stat, len);
+ User::WaitForRequest(stat);
+ QVERIFY(stat == KErrNone);
+ QCOMPARE(len(), 1);
+#else
QCOMPARE(int(::send(clientDescriptor, &msg, sizeof(msg), MSG_OOB)), 1);
+#endif
// The server receives the urgent message
QVERIFY(serverSocket.waitForRead());
@@ -701,5 +759,5 @@ void tst_QNativeSocketEngine::receiveUrgentData()
}
-QTEST_MAIN(tst_QNativeSocketEngine)
-#include "tst_qnativesocketengine.moc"
+QTEST_MAIN(tst_PlatformSocketEngine)
+#include "tst_platformsocketengine.moc"
diff --git a/tests/auto/q3combobox/tst_q3combobox.cpp b/tests/auto/q3combobox/tst_q3combobox.cpp
index 17bd861f2f..825acb255b 100644
--- a/tests/auto/q3combobox/tst_q3combobox.cpp
+++ b/tests/auto/q3combobox/tst_q3combobox.cpp
@@ -1004,6 +1004,10 @@ void tst_Q3ComboBox::wheelEvent()
void tst_Q3ComboBox::task231724_clear()
{
+#ifdef Q_WS_MACX
+ return; // On Mac, we don't use a ListBox for the popup
+#endif
+
Q3ComboBox box;
for ( int i = 0; i <50; i++ ) {
diff --git a/tests/auto/q3progressbar/tst_q3progressbar.cpp b/tests/auto/q3progressbar/tst_q3progressbar.cpp
index 745e2d5528..3a0c3e21cc 100644
--- a/tests/auto/q3progressbar/tst_q3progressbar.cpp
+++ b/tests/auto/q3progressbar/tst_q3progressbar.cpp
@@ -45,6 +45,7 @@
#include <qapplication.h>
#include <qdebug.h>
#include <q3progressbar.h>
+#include "../../shared/util.h"
//TESTED_CLASS=
//TESTED_FILES=
@@ -106,7 +107,7 @@ void tst_Q3ProgressBar::setProgress()
{
MyCustomProgressBar * m_progressBar = new MyCustomProgressBar();
m_progressBar->show();
- QApplication::processEvents();
+ QTest::qWaitForWindowShown(m_progressBar);
//case with total steps = 0
m_progressBar->setTotalSteps(0);
@@ -114,10 +115,9 @@ void tst_Q3ProgressBar::setProgress()
m_progressBar->paintNumber = 0;
m_progressBar->setProgress(m_progressBar->progress() + 1);
QCOMPARE(oldValue + 1,m_progressBar->progress());
- QApplication::processEvents();
// It might be > 1 because it is animated.
- QVERIFY(m_progressBar->paintNumber >= 1);
+ QTRY_VERIFY(m_progressBar->paintNumber >= 1);
qDebug() << "Animation test: paintNumber =" << m_progressBar->paintNumber;
//standard case
@@ -125,10 +125,9 @@ void tst_Q3ProgressBar::setProgress()
m_progressBar->setProgress(0);
m_progressBar->paintNumber = 0;
m_progressBar->setProgress(m_progressBar->progress() + 1);
- QApplication::processEvents();
// It might be > 1 because other events might cause painting.
- QVERIFY(m_progressBar->paintNumber >= 1);
+ QTRY_VERIFY(m_progressBar->paintNumber >= 1);
qDebug() << "Standard test: paintNumber =" << m_progressBar->paintNumber;
}
diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
index db0d0a7e0b..e2842c1068 100644
--- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
+++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
@@ -45,6 +45,12 @@
#include "../../shared/util.h"
#include "../network-settings.h"
+#ifndef QT_NO_BEARERMANAGEMENT
+#include <QtNetwork/qnetworkconfigmanager.h>
+#include <QtNetwork/qnetworkconfiguration.h>
+#include <QtNetwork/qnetworksession.h>
+#endif
+
#define TESTFILE QString("http://%1/qtest/cgi-bin/").arg(QtNetworkSettings::serverName())
class tst_QAbstractNetworkCache : public QObject
@@ -56,6 +62,7 @@ public:
virtual ~tst_QAbstractNetworkCache();
private slots:
+ void initTestCase();
void expires_data();
void expires();
void expiresSynchronous_data();
@@ -81,6 +88,12 @@ private slots:
private:
void check();
void checkSynchronous();
+
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QScopedPointer<QNetworkSession> networkSession;
+#endif
};
class NetworkDiskCache : public QNetworkDiskCache
@@ -124,6 +137,19 @@ static bool AlwaysFalse = false;
Q_DECLARE_METATYPE(QNetworkRequest::CacheLoadControl)
+void tst_QAbstractNetworkCache::initTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
+}
+
void tst_QAbstractNetworkCache::expires_data()
{
QTest::addColumn<QNetworkRequest::CacheLoadControl>("cacheLoadControl");
@@ -235,14 +261,14 @@ void tst_QAbstractNetworkCache::cacheControl_data()
QTest::newRow("200-2") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << AlwaysFalse;
QTest::newRow("200-3") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << false;
- QTest::newRow("200-4") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-cache" << false;//AlwaysTrue;
+ QTest::newRow("200-4") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-cache" << false;
QTest::newRow("200-5") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-cache" << false;
QTest::newRow("304-0") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000" << true;
QTest::newRow("304-1") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << AlwaysFalse;
QTest::newRow("304-2") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << true;
- QTest::newRow("304-3") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << AlwaysTrue;
+ QTest::newRow("304-3") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << false;
QTest::newRow("304-4") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << true;
// see QTBUG-7060
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp
index 254fdf75ff..f4cd93f415 100644
--- a/tests/auto/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp
@@ -245,10 +245,13 @@ private slots:
void actionText();
void doAction();
+ void applicationTest();
+ void mainWindowTest();
void buttonTest();
void sliderTest();
void scrollBarTest();
void tabTest();
+ void tabWidgetTest();
void menuTest();
void spinBoxTest();
void doubleSpinBoxTest();
@@ -415,6 +418,11 @@ void tst_QAccessibility::eventTest()
QVERIFY_EVENT(button, 0, QAccessible::StateChanged);
QVERIFY_EVENT(button, 0, QAccessible::StateChanged);
+ button->setAccessibleName("Olaf the second");
+ QVERIFY_EVENT(button, 0, QAccessible::NameChanged);
+ button->setAccessibleDescription("This is a button labeled Olaf");
+ QVERIFY_EVENT(button, 0, QAccessible::DescriptionChanged);
+
button->hide();
QVERIFY_EVENT(button, 0, QAccessible::ObjectHide);
@@ -1677,48 +1685,90 @@ void tst_QAccessibility::doAction()
QSKIP("TODO: Implement me", SkipAll);
}
+void tst_QAccessibility::applicationTest()
+{
+ QLatin1String name = QLatin1String("My Name");
+ qApp->setApplicationName(name);
+ QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(qApp);
+ QCOMPARE(interface->text(QAccessible::Name, 0), name);
+ QCOMPARE(interface->role(0), QAccessible::Application);
+ delete interface;
+}
+
+void tst_QAccessibility::mainWindowTest()
+{
+ QMainWindow mw;
+ mw.resize(300, 200);
+ mw.show(); // triggers layout
+
+ QLatin1String name = QLatin1String("I am the main window");
+ mw.setWindowTitle(name);
+ QTest::qWaitForWindowShown(&mw);
+
+ QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mw);
+ QCOMPARE(interface->text(QAccessible::Name, 0), name);
+ QCOMPARE(interface->role(0), QAccessible::Window);
+ delete interface;
+}
+
+class CounterButton : public QPushButton {
+ Q_OBJECT
+public:
+ CounterButton(const QString& name, QWidget* parent)
+ : QPushButton(name, parent), clickCount(0)
+ {
+ connect(this, SIGNAL(clicked(bool)), SLOT(incClickCount()));
+ }
+ int clickCount;
+public Q_SLOTS:
+ void incClickCount() {
+ ++clickCount;
+ }
+};
+
void tst_QAccessibility::buttonTest()
{
-#if 0
- QAccessibleInterface *test = 0;
- Q3VBox vbox;
+ QWidget window;
+ window.setLayout(new QVBoxLayout);
// Standard push button
- QPushButton pushButton("Ok", &vbox);
+ CounterButton pushButton("Ok", &window);
- // toggle push button
- QPushButton togglepush("Toggle", &vbox);
- togglepush.setToggleButton(TRUE);
-
- // push button with a menu
- QPushButton menuButton("Menu", &vbox);
- Q3PopupMenu buttonMenu(&menuButton);
- buttonMenu.insertItem("Some item");
- menuButton.setPopup(&buttonMenu);
+ // toggle button
+ QPushButton toggleButton("Toggle", &window);
+ toggleButton.setCheckable(true);
// standard checkbox
- QCheckBox checkBox("Check me!", &vbox);
+ QCheckBox checkBox("Check me!", &window);
// tristate checkbox
- QCheckBox tristate("Tristate!", &vbox);
+ QCheckBox tristate("Tristate!", &window);
tristate.setTristate(TRUE);
// radiobutton
- QRadioButton radio("Radio me!", &vbox);
+ QRadioButton radio("Radio me!", &window);
// standard toolbutton
- QToolButton toolbutton(&vbox);
+ QToolButton toolbutton(&window);
toolbutton.setText("Tool");
toolbutton.setMinimumSize(20,20);
// standard toolbutton
- QToolButton toggletool(&vbox);
- toggletool.setToggleButton(TRUE);
+ QToolButton toggletool(&window);
+ toggletool.setCheckable(true);
toggletool.setText("Toggle");
toggletool.setMinimumSize(20,20);
+#if 0
+ // QT3_SUPPORT
+ // push button with a menu
+ QPushButton menuButton("Menu", &window);
+ Q3PopupMenu buttonMenu(&menuButton);
+ buttonMenu.insertItem("Some item");
+ menuButton.setPopup(&buttonMenu);
+
// menu toolbutton
- QToolButton menuToolButton(&vbox);
+ QToolButton menuToolButton(&window);
menuToolButton.setText("Menu Tool");
Q3PopupMenu toolMenu(&menuToolButton);
toolMenu.insertItem("Some item");
@@ -1726,140 +1776,146 @@ void tst_QAccessibility::buttonTest()
menuToolButton.setMinimumSize(20,20);
// splitted menu toolbutton
- QToolButton splitToolButton(&vbox);
+ QToolButton splitToolButton(&window);
splitToolButton.setTextLabel("Split Tool");
Q3PopupMenu splitMenu(&splitToolButton);
splitMenu.insertItem("Some item");
splitToolButton.setPopup(&splitMenu);
splitToolButton.setPopupDelay(0);
splitToolButton.setMinimumSize(20,20);
+#endif
// test push button
- QVERIFY(QAccessible::queryAccessibleInterface(&pushButton, &test));
- QCOMPARE(test->role(0), QAccessible::PushButton);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Press"));
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- pushButton.setDown(TRUE);
- QCOMPARE(test->state(0), (int)QAccessible::Pressed);
- QVERIFY(test->doAction(QAccessible::Press, 0));
+ QAccessibleInterface* interface = QAccessible::queryAccessibleInterface(&pushButton);
+ QAccessibleActionInterface* actionInterface = interface->actionInterface();
+ QVERIFY(actionInterface != 0);
+
+ QCOMPARE(interface->role(0), QAccessible::PushButton);
+
+ // currently our buttons only have click as action, press and release are missing
+ QCOMPARE(actionInterface->actionCount(), 1);
+ QCOMPARE(actionInterface->name(0), QString("Press"));
+ QCOMPARE(pushButton.clickCount, 0);
+ actionInterface->doAction(0);
QTest::qWait(500);
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- test->release();
-
- // test toggle push button
- QVERIFY(QAccessible::queryAccessibleInterface(&togglepush, &test));
- QCOMPARE(test->role(0), QAccessible::CheckBox);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- QVERIFY(test->doAction(QAccessible::Press, 0));
+ QCOMPARE(pushButton.clickCount, 1);
+ delete interface;
+
+ // test toggle button
+ interface = QAccessible::queryAccessibleInterface(&toggleButton);
+ actionInterface = interface->actionInterface();
+ QCOMPARE(interface->role(0), QAccessible::CheckBox);
+ QCOMPARE(actionInterface->description(0), QString("Toggles the button."));
+ QCOMPARE(actionInterface->name(0), QString("Check"));
+ QVERIFY(!toggleButton.isChecked());
+ QVERIFY((interface->state(0) & QAccessible::Checked) == 0);
+ actionInterface->doAction(0);
QTest::qWait(500);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Uncheck"));
- QCOMPARE(test->state(0), (int)QAccessible::Checked);
- test->release();
-
- // test menu push button
- QVERIFY(QAccessible::queryAccessibleInterface(&menuButton, &test));
- QCOMPARE(test->role(0), QAccessible::ButtonMenu);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Open"));
- QCOMPARE(test->state(0), (int)QAccessible::HasPopup);
- test->release();
+ QCOMPARE(actionInterface->name(0), QString("Uncheck"));
+ QVERIFY(toggleButton.isChecked());
+ QVERIFY((interface->state(0) & QAccessible::Checked));
+ delete interface;
+
+// // test menu push button
+// QVERIFY(QAccessible::queryAccessibleInterface(&menuButton, &test));
+// QCOMPARE(test->role(0), QAccessible::ButtonMenu);
+// QCOMPARE(test->defaultAction(0), QAccessible::Press);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Open"));
+// QCOMPARE(test->state(0), (int)QAccessible::HasPopup);
+// test->release();
// test check box
- QVERIFY(QAccessible::queryAccessibleInterface(&checkBox, &test));
- QCOMPARE(test->role(0), QAccessible::CheckBox);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- QVERIFY(test->doAction(QAccessible::Press, 0));
- QTest::qWait(500);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Uncheck"));
- QCOMPARE(test->state(0), (int)QAccessible::Checked);
- test->release();
-
- // test tristate check box
- QVERIFY(QAccessible::queryAccessibleInterface(&tristate, &test));
- QCOMPARE(test->role(0), QAccessible::CheckBox);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Toggle"));
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- QVERIFY(test->doAction(QAccessible::Press, 0));
- QTest::qWait(500);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
- QCOMPARE(test->state(0), (int)QAccessible::Mixed);
- QVERIFY(test->doAction(QAccessible::Press, 0));
+ interface = QAccessible::queryAccessibleInterface(&checkBox);
+ actionInterface = interface->actionInterface();
+ QCOMPARE(interface->role(0), QAccessible::CheckBox);
+ QCOMPARE(actionInterface->name(0), QString("Check"));
+ QVERIFY((interface->state(0) & QAccessible::Checked) == 0);
+ actionInterface->doAction(0);
QTest::qWait(500);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Uncheck"));
- QCOMPARE(test->state(0), (int)QAccessible::Checked);
- test->release();
+ QCOMPARE(actionInterface->name(0), QString("Uncheck"));
+ QVERIFY(interface->state(0) & QAccessible::Checked);
+ QVERIFY(checkBox.isChecked());
+ delete interface;
+
+// // test tristate check box
+// QVERIFY(QAccessible::queryAccessibleInterface(&tristate, &test));
+// QCOMPARE(test->role(0), QAccessible::CheckBox);
+// QCOMPARE(test->defaultAction(0), QAccessible::Press);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Toggle"));
+// QCOMPARE(test->state(0), (int)QAccessible::Normal);
+// QVERIFY(test->doAction(QAccessible::Press, 0));
+// QTest::qWait(500);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
+// QCOMPARE(test->state(0), (int)QAccessible::Mixed);
+// QVERIFY(test->doAction(QAccessible::Press, 0));
+// QTest::qWait(500);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Uncheck"));
+// QCOMPARE(test->state(0), (int)QAccessible::Checked);
+// test->release();
// test radiobutton
- QVERIFY(QAccessible::queryAccessibleInterface(&radio, &test));
- QCOMPARE(test->role(0), QAccessible::RadioButton);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- QVERIFY(test->doAction(QAccessible::Press, 0));
+ interface = QAccessible::queryAccessibleInterface(&radio);
+ actionInterface = interface->actionInterface();
+ QCOMPARE(interface->role(0), QAccessible::RadioButton);
+ QCOMPARE(actionInterface->name(0), QString("Check"));
+ QVERIFY((interface->state(0) & QAccessible::Checked) == 0);
+ actionInterface->doAction(0);
QTest::qWait(500);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
- QCOMPARE(test->state(0), (int)QAccessible::Checked);
- test->release();
-
- // test standard toolbutton
- QVERIFY(QAccessible::queryAccessibleInterface(&toolbutton, &test));
- QCOMPARE(test->role(0), QAccessible::PushButton);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Press"));
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- test->release();
-
- // toggle tool button
- QVERIFY(QAccessible::queryAccessibleInterface(&toggletool, &test));
- QCOMPARE(test->role(0), QAccessible::CheckBox);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
- QCOMPARE(test->state(0), (int)QAccessible::Normal);
- QVERIFY(test->doAction(QAccessible::Press, 0));
- QTest::qWait(500);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Uncheck"));
- QCOMPARE(test->state(0), (int)QAccessible::Checked);
- test->release();
-
- // test menu toolbutton
- QVERIFY(QAccessible::queryAccessibleInterface(&menuToolButton, &test));
- QCOMPARE(test->role(0), QAccessible::ButtonMenu);
- QCOMPARE(test->defaultAction(0), 1);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Open"));
- QCOMPARE(test->state(0), (int)QAccessible::HasPopup);
- QCOMPARE(test->actionCount(0), 1);
- QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 0), QString("Press"));
- test->release();
-
- // test splitted menu toolbutton
- QVERIFY(QAccessible::queryAccessibleInterface(&splitToolButton, &test));
- QCOMPARE(test->childCount(), 2);
- QCOMPARE(test->role(0), QAccessible::ButtonDropDown);
- QCOMPARE(test->role(1), QAccessible::PushButton);
- QCOMPARE(test->role(2), QAccessible::ButtonMenu);
- QCOMPARE(test->defaultAction(0), QAccessible::Press);
- QCOMPARE(test->defaultAction(1), QAccessible::Press);
- QCOMPARE(test->defaultAction(2), QAccessible::Press);
- QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Press"));
- QCOMPARE(test->state(0), (int)QAccessible::HasPopup);
- QCOMPARE(test->actionCount(0), 1);
- QCOMPARE(test->actionText(1, QAccessible::Name, 0), QString("Open"));
- QCOMPARE(test->actionText(test->defaultAction(1), QAccessible::Name, 1), QString("Press"));
- QCOMPARE(test->state(1), (int)QAccessible::Normal);
- QCOMPARE(test->actionText(test->defaultAction(2), QAccessible::Name, 2), QString("Open"));
- QCOMPARE(test->state(2), (int)QAccessible::HasPopup);
- test->release();
+ QCOMPARE(actionInterface->name(0), QString("Uncheck"));
+ QVERIFY(interface->state(0) & QAccessible::Checked);
+ QVERIFY(checkBox.isChecked());
+ delete interface;
+
+// // test standard toolbutton
+// QVERIFY(QAccessible::queryAccessibleInterface(&toolbutton, &test));
+// QCOMPARE(test->role(0), QAccessible::PushButton);
+// QCOMPARE(test->defaultAction(0), QAccessible::Press);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Press"));
+// QCOMPARE(test->state(0), (int)QAccessible::Normal);
+// test->release();
+
+// // toggle tool button
+// QVERIFY(QAccessible::queryAccessibleInterface(&toggletool, &test));
+// QCOMPARE(test->role(0), QAccessible::CheckBox);
+// QCOMPARE(test->defaultAction(0), QAccessible::Press);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
+// QCOMPARE(test->state(0), (int)QAccessible::Normal);
+// QVERIFY(test->doAction(QAccessible::Press, 0));
+// QTest::qWait(500);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Uncheck"));
+// QCOMPARE(test->state(0), (int)QAccessible::Checked);
+// test->release();
+
+// // test menu toolbutton
+// QVERIFY(QAccessible::queryAccessibleInterface(&menuToolButton, &test));
+// QCOMPARE(test->role(0), QAccessible::ButtonMenu);
+// QCOMPARE(test->defaultAction(0), 1);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Open"));
+// QCOMPARE(test->state(0), (int)QAccessible::HasPopup);
+// QCOMPARE(test->actionCount(0), 1);
+// QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 0), QString("Press"));
+// test->release();
+
+// // test splitted menu toolbutton
+// QVERIFY(QAccessible::queryAccessibleInterface(&splitToolButton, &test));
+// QCOMPARE(test->childCount(), 2);
+// QCOMPARE(test->role(0), QAccessible::ButtonDropDown);
+// QCOMPARE(test->role(1), QAccessible::PushButton);
+// QCOMPARE(test->role(2), QAccessible::ButtonMenu);
+// QCOMPARE(test->defaultAction(0), QAccessible::Press);
+// QCOMPARE(test->defaultAction(1), QAccessible::Press);
+// QCOMPARE(test->defaultAction(2), QAccessible::Press);
+// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Press"));
+// QCOMPARE(test->state(0), (int)QAccessible::HasPopup);
+// QCOMPARE(test->actionCount(0), 1);
+// QCOMPARE(test->actionText(1, QAccessible::Name, 0), QString("Open"));
+// QCOMPARE(test->actionText(test->defaultAction(1), QAccessible::Name, 1), QString("Press"));
+// QCOMPARE(test->state(1), (int)QAccessible::Normal);
+// QCOMPARE(test->actionText(test->defaultAction(2), QAccessible::Name, 2), QString("Open"));
+// QCOMPARE(test->state(2), (int)QAccessible::HasPopup);
+// test->release();
QTestAccessibility::clearEvents();
-#else
- QSKIP("No action interface in Qt 4 yet.", SkipAll);
-#endif
}
void tst_QAccessibility::sliderTest()
@@ -2194,6 +2250,95 @@ void tst_QAccessibility::tabTest()
QTestAccessibility::clearEvents();
}
+void tst_QAccessibility::tabWidgetTest()
+{
+ QTabWidget *tabWidget = new QTabWidget();
+ tabWidget->show();
+
+ // the interface for the tab is just a container for tabbar and stacked widget
+ QAccessibleInterface * const interface = QAccessible::queryAccessibleInterface(tabWidget);
+ QVERIFY(interface);
+ QCOMPARE(interface->childCount(), 2);
+ QCOMPARE(interface->role(0), QAccessible::Client);
+
+ // Create pages, check navigation
+ QLabel *label1 = new QLabel("Page 1", tabWidget);
+ tabWidget->addTab(label1, "Tab 1");
+ QLabel *label2 = new QLabel("Page 2", tabWidget);
+ tabWidget->addTab(label2, "Tab 2");
+
+ QCOMPARE(interface->childCount(), 2);
+
+ QAccessibleInterface* tabBarInterface = 0;
+ // there is no special logic to sort the children, so the contents will be 1, the tab bar 2
+ QCOMPARE(interface->navigate(QAccessible::Child, 2 , &tabBarInterface), 0);
+ QVERIFY(tabBarInterface);
+ QCOMPARE(tabBarInterface->childCount(), 4);
+ QCOMPARE(tabBarInterface->role(0), QAccessible::PageTabList);
+
+ QAccessibleInterface* tabButton1Interface = 0;
+ QCOMPARE(tabBarInterface->navigate(QAccessible::Child, 1 , &tabButton1Interface), 1);
+ QVERIFY(tabButton1Interface == 0);
+
+ QCOMPARE(tabBarInterface->role(1), QAccessible::PageTab);
+ QCOMPARE(tabBarInterface->text(QAccessible::Name, 1), QLatin1String("Tab 1"));
+ QCOMPARE(tabBarInterface->role(2), QAccessible::PageTab);
+ QCOMPARE(tabBarInterface->text(QAccessible::Name, 2), QLatin1String("Tab 2"));
+ QCOMPARE(tabBarInterface->role(3), QAccessible::PushButton);
+ QCOMPARE(tabBarInterface->text(QAccessible::Name, 3), QLatin1String("Scroll Left"));
+ QCOMPARE(tabBarInterface->role(4), QAccessible::PushButton);
+ QCOMPARE(tabBarInterface->text(QAccessible::Name, 4), QLatin1String("Scroll Right"));
+
+ QAccessibleInterface* stackWidgetInterface = 0;
+ QCOMPARE(interface->navigate(QAccessible::Child, 1, &stackWidgetInterface), 0);
+ QVERIFY(stackWidgetInterface);
+ QCOMPARE(stackWidgetInterface->childCount(), 2);
+ QCOMPARE(stackWidgetInterface->role(0), QAccessible::LayeredPane);
+
+ QAccessibleInterface* stackChild1Interface = 0;
+ QCOMPARE(stackWidgetInterface->navigate(QAccessible::Child, 1, &stackChild1Interface), 0);
+ QVERIFY(stackChild1Interface);
+#ifndef Q_CC_INTEL
+ QCOMPARE(stackChild1Interface->childCount(), 0);
+#endif
+ QCOMPARE(stackChild1Interface->role(0), QAccessible::StaticText);
+ QCOMPARE(stackChild1Interface->text(QAccessible::Name, 0), QLatin1String("Page 1"));
+ QCOMPARE(label1, stackChild1Interface->object());
+
+ // Navigation in stack widgets should be consistent
+ QAccessibleInterface* parent = 0;
+ QCOMPARE(stackChild1Interface->navigate(QAccessible::Ancestor, 1, &parent), 0);
+ QVERIFY(parent);
+#ifndef Q_CC_INTEL
+ QCOMPARE(parent->childCount(), 2);
+#endif
+ QCOMPARE(parent->role(0), QAccessible::LayeredPane);
+ delete parent;
+
+ QAccessibleInterface* stackChild2Interface = 0;
+ QCOMPARE(stackWidgetInterface->navigate(QAccessible::Child, 2, &stackChild2Interface), 0);
+ QVERIFY(stackChild2Interface);
+ QCOMPARE(stackChild2Interface->childCount(), 0);
+ QCOMPARE(stackChild2Interface->role(0), QAccessible::StaticText);
+ QCOMPARE(label2, stackChild2Interface->object()); // the text will be empty since it is not visible
+
+ QCOMPARE(stackChild2Interface->navigate(QAccessible::Ancestor, 1, &parent), 0);
+ QVERIFY(parent);
+#ifndef Q_CC_INTEL
+ QCOMPARE(parent->childCount(), 2);
+#endif
+ QCOMPARE(parent->role(0), QAccessible::LayeredPane);
+ delete parent;
+
+ delete tabBarInterface;
+ delete stackChild1Interface;
+ delete stackChild2Interface;
+ delete stackWidgetInterface;
+ delete interface;
+ delete tabWidget;
+ QTestAccessibility::clearEvents();
+}
+
void tst_QAccessibility::menuTest()
{
{
@@ -2510,6 +2655,11 @@ void tst_QAccessibility::textEditTest()
QCOMPARE(iface->text(QAccessible::Value, 4), QString("hello world"));
QCOMPARE(iface->text(QAccessible::Value, 5), QString("how are you today?"));
QCOMPARE(iface->text(QAccessible::Value, 6), QString());
+ QCOMPARE(iface->textInterface()->characterCount(), 31);
+ QFontMetrics fm(edit.font());
+ QCOMPARE(iface->textInterface()->characterRect(0, QAccessible2::RelativeToParent).size(), QSize(fm.width("h"), fm.height()));
+ QCOMPARE(iface->textInterface()->characterRect(5, QAccessible2::RelativeToParent).size(), QSize(fm.width(" "), fm.height()));
+ QCOMPARE(iface->textInterface()->characterRect(6, QAccessible2::RelativeToParent).size(), QSize(fm.width("w"), fm.height()));
}
QTestAccessibility::clearEvents();
}
@@ -3647,10 +3797,10 @@ void tst_QAccessibility::pushButtonTest()
QAccessibleInterface *acc;
QAccessibleInterface *acc2;
int entry = accToplevel->childAt(pt.x(), pt.y());
- int child = accToplevel->navigate(QAccessible::Child, entry, &acc);
+ accToplevel->navigate(QAccessible::Child, entry, &acc);
if (acc) {
entry = acc->childAt(pt.x(), pt.y());
- child = acc->navigate(QAccessible::Child, entry, &acc2);
+ acc->navigate(QAccessible::Child, entry, &acc2);
delete acc;
acc = acc2;
}
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 5fff22a2aa..0dea9be12b 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -898,12 +898,12 @@ void tst_QByteArray::indexOf_data()
QByteArray veryBigHaystack(500, 'a');
veryBigHaystack += 'B';
QTest::newRow("BoyerMooreStressTest") << veryBigHaystack << veryBigHaystack << 0 << 0;
- QTest::newRow("BoyerMooreStressTest2") << veryBigHaystack + 'c' << veryBigHaystack << 0 << 0;
- QTest::newRow("BoyerMooreStressTest3") << 'c' + veryBigHaystack << veryBigHaystack << 0 << 1;
- QTest::newRow("BoyerMooreStressTest4") << veryBigHaystack << veryBigHaystack + 'c' << 0 << -1;
- QTest::newRow("BoyerMooreStressTest5") << veryBigHaystack << 'c' + veryBigHaystack << 0 << -1;
- QTest::newRow("BoyerMooreStressTest6") << 'd' + veryBigHaystack << 'c' + veryBigHaystack << 0 << -1;
- QTest::newRow("BoyerMooreStressTest6") << veryBigHaystack + 'c' << 'c' + veryBigHaystack << 0 << -1;
+ QTest::newRow("BoyerMooreStressTest2") << QByteArray(veryBigHaystack + 'c') << QByteArray(veryBigHaystack) << 0 << 0;
+ QTest::newRow("BoyerMooreStressTest3") << QByteArray('c' + veryBigHaystack) << QByteArray(veryBigHaystack) << 0 << 1;
+ QTest::newRow("BoyerMooreStressTest4") << QByteArray(veryBigHaystack) << QByteArray(veryBigHaystack + 'c') << 0 << -1;
+ QTest::newRow("BoyerMooreStressTest5") << QByteArray(veryBigHaystack) << QByteArray('c' + veryBigHaystack) << 0 << -1;
+ QTest::newRow("BoyerMooreStressTest6") << QByteArray('d' + veryBigHaystack) << QByteArray('c' + veryBigHaystack) << 0 << -1;
+ QTest::newRow("BoyerMooreStressTest6") << QByteArray(veryBigHaystack + 'c') << QByteArray('c' + veryBigHaystack) << 0 << -1;
}
void tst_QByteArray::indexOf()
diff --git a/tests/auto/qcomplextext/tst_qcomplextext.cpp b/tests/auto/qcomplextext/tst_qcomplextext.cpp
index 3d8e29057d..58b31b4aa4 100644
--- a/tests/auto/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/qcomplextext/tst_qcomplextext.cpp
@@ -71,6 +71,10 @@ private slots:
void bidiReorderString();
void bidiCursor_qtbug2795();
void bidiCursor_PDF();
+ void bidiCursorMovement_data();
+ void bidiCursorMovement();
+ void bidiCursorLogicalMovement_data();
+ void bidiCursorLogicalMovement();
};
tst_QComplexText::tst_QComplexText()
@@ -185,6 +189,90 @@ void tst_QComplexText::bidiCursor_qtbug2795()
QVERIFY(x1 == x2);
}
+void tst_QComplexText::bidiCursorMovement_data()
+{
+ QTest::addColumn<QString>("logical");
+ QTest::addColumn<int>("basicDir");
+
+ const LV *data = logical_visual;
+ while ( data->name ) {
+ //next we fill it with data
+ QTest::newRow( data->name )
+ << QString::fromUtf8( data->logical )
+ << (int) data->basicDir;
+ data++;
+ }
+}
+
+void tst_QComplexText::bidiCursorMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+
+ QTextLayout layout(logical);
+
+ QTextOption option = layout.textOption();
+ option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
+ layout.setTextOption(option);
+ layout.setCursorMoveStyle(QTextCursor::Visual);
+ bool moved;
+ int oldPos, newPos = 0;
+ qreal x, newX;
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ newX = line.cursorToX(0);
+ do {
+ oldPos = newPos;
+ x = newX;
+ newX = line.cursorToX(oldPos);
+ if (basicDir == QChar::DirL) {
+ QVERIFY(newX >= x);
+ newPos = layout.rightCursorPosition(oldPos);
+ } else
+ {
+ QVERIFY(newX <= x);
+ newPos = layout.leftCursorPosition(oldPos);
+ }
+ moved = (oldPos != newPos);
+ } while (moved);
+}
+
+void tst_QComplexText::bidiCursorLogicalMovement_data()
+{
+ bidiCursorMovement_data();
+}
+
+void tst_QComplexText::bidiCursorLogicalMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+
+ QTextLayout layout(logical);
+
+ QTextOption option = layout.textOption();
+ option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
+ layout.setTextOption(option);
+ bool moved;
+ int oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ newPos = layout.nextCursorPosition(oldPos);
+ QVERIFY(newPos >= oldPos);
+ moved = (oldPos != newPos);
+ } while (moved);
+
+ do {
+ oldPos = newPos;
+ newPos = layout.previousCursorPosition(oldPos);
+ QVERIFY(newPos <= oldPos);
+ moved = (oldPos != newPos);
+ } while (moved);
+}
+
void tst_QComplexText::bidiCursor_PDF()
{
QString str = QString::fromUtf8("\342\200\252hello\342\200\254");
diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp
index fa9c70b8e1..d612911727 100644
--- a/tests/auto/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/qdatetime/tst_qdatetime.cpp
@@ -85,6 +85,8 @@ private slots:
void setTime_t();
void setMSecsSinceEpoch_data();
void setMSecsSinceEpoch();
+ void toString_isoDate_data();
+ void toString_isoDate();
void toString_enumformat();
void toString_strformat_data();
void toString_strformat();
@@ -198,8 +200,8 @@ void tst_QDateTime::ctor()
QDateTime dt3(QDate(2004, 1, 2), QTime(1, 2, 3), Qt::UTC);
QVERIFY(dt1 == dt2);
- QVERIFY(dt1 != dt3);
if (europeanTimeZone) {
+ QVERIFY(dt1 != dt3);
QVERIFY(dt1 < dt3);
QVERIFY(dt1.addSecs(3600).toUTC() == dt3);
}
@@ -506,6 +508,36 @@ void tst_QDateTime::setMSecsSinceEpoch()
QCOMPARE(dt, reference.addMSecs(msecs));
}
+void tst_QDateTime::toString_isoDate_data()
+{
+ QTest::addColumn<QDateTime>("dt");
+ QTest::addColumn<QString>("formatted");
+
+ QTest::newRow("localtime")
+ << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34))
+ << QString("1978-11-09T13:28:34");
+ QTest::newRow("UTC")
+ << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34), Qt::UTC)
+ << QString("1978-11-09T13:28:34Z");
+ QDateTime dt(QDate(1978, 11, 9), QTime(13, 28, 34));
+ dt.setUtcOffset(19800);
+ QTest::newRow("positive OffsetFromUTC")
+ << dt
+ << QString("1978-11-09T13:28:34+05:30");
+ dt.setUtcOffset(-7200);
+ QTest::newRow("negative OffsetFromUTC")
+ << dt
+ << QString("1978-11-09T13:28:34-02:00");
+}
+
+void tst_QDateTime::toString_isoDate()
+{
+ QFETCH(QDateTime, dt);
+ QFETCH(QString, formatted);
+
+ QCOMPARE(dt.toString(Qt::ISODate), formatted);
+}
+
void tst_QDateTime::toString_enumformat()
{
QDateTime dt1(QDate(1995, 5, 20), QTime(12, 34, 56));
diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
index abbf00d35d..f5dbea49d3 100644
--- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -275,6 +275,8 @@ private slots:
void focusNextPrevChild();
void taskQTBUG_12384_timeSpecShowTimeOnly();
+
+ void deleteCalendarWidget();
private:
EditorDateEdit* testWidget;
@@ -3431,5 +3433,26 @@ void tst_QDateTimeEdit::taskQTBUG_12384_timeSpecShowTimeOnly()
QCOMPARE(edit.time(), time.time());
}
+void tst_QDateTimeEdit::deleteCalendarWidget()
+{
+ {
+ // setup
+ QCalendarWidget *cw = 0;
+ QDateEdit edit;
+ QVERIFY(!edit.calendarWidget());
+ edit.setCalendarPopup(true);
+ QVERIFY(edit.calendarWidget());
+ edit.calendarWidget()->setObjectName("cw1");;
+
+ // delete
+ cw = edit.calendarWidget();
+ delete cw;
+
+ // it should create a new widget
+ QVERIFY(edit.calendarWidget());
+ QVERIFY(edit.calendarWidget()->objectName() != "cw1");
+ }
+}
+
QTEST_MAIN(tst_QDateTimeEdit)
#include "tst_qdatetimeedit.moc"
diff --git a/tests/auto/qdbusabstractadaptor/myobject.h b/tests/auto/qdbusabstractadaptor/myobject.h
new file mode 100644
index 0000000000..7353fa6e43
--- /dev/null
+++ b/tests/auto/qdbusabstractadaptor/myobject.h
@@ -0,0 +1,286 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYOBJECT_H
+#define MYOBJECT_H
+
+#include <QtCore/QObject>
+#include <QtDBus/QtDBus>
+
+extern const char *slotSpy;
+extern QString valueSpy;
+
+class QDBusSignalSpy: public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void slot(const QDBusMessage &msg)
+ {
+ ++count;
+ interface = msg.interface();
+ name = msg.member();
+ signature = msg.signature();
+ path = msg.path();
+ value.clear();
+ if (msg.arguments().count())
+ value = msg.arguments().at(0);
+ }
+
+public:
+ QDBusSignalSpy() : count(0) { }
+
+ int count;
+ QString interface;
+ QString name;
+ QString signature;
+ QString path;
+ QVariant value;
+};
+
+class Interface1: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "local.Interface1")
+public:
+ Interface1(QObject *parent) : QDBusAbstractAdaptor(parent)
+ { }
+};
+
+class Interface2: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "local.Interface2")
+ Q_PROPERTY(QString prop1 READ prop1)
+ Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2 SCRIPTABLE true)
+ Q_PROPERTY(QUrl nonDBusProperty READ nonDBusProperty)
+public:
+ Interface2(QObject *parent) : QDBusAbstractAdaptor(parent)
+ { setAutoRelaySignals(true); }
+
+ QString prop1() const
+ { return QLatin1String("QString Interface2::prop1() const"); }
+
+ QString prop2() const
+ { return QLatin1String("QString Interface2::prop2() const"); }
+
+ void setProp2(const QString &value)
+ {
+ slotSpy = "void Interface2::setProp2(const QString &)";
+ valueSpy = value;
+ }
+
+ QUrl nonDBusProperty() const
+ { return QUrl(); }
+
+ void emitSignal(const QString &, const QVariant &)
+ { emit signal(); }
+
+public slots:
+ void method()
+ {
+ slotSpy = "void Interface2::method()";
+ }
+
+ Q_SCRIPTABLE void scriptableMethod()
+ {
+ slotSpy = "void Interface2::scriptableMethod()";
+ }
+
+signals:
+ void signal();
+};
+
+class Interface3: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "local.Interface3")
+ Q_PROPERTY(QString prop1 READ prop1)
+ Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2)
+ Q_PROPERTY(QString interface3prop READ interface3prop)
+public:
+ Interface3(QObject *parent) : QDBusAbstractAdaptor(parent)
+ { setAutoRelaySignals(true); }
+
+ QString prop1() const
+ { return QLatin1String("QString Interface3::prop1() const"); }
+
+ QString prop2() const
+ { return QLatin1String("QString Interface3::prop2() const"); }
+
+ void setProp2(const QString &value)
+ {
+ slotSpy = "void Interface3::setProp2(const QString &)";
+ valueSpy = value;
+ }
+
+ QString interface3prop() const
+ { return QLatin1String("QString Interface3::interface3prop() const"); }
+
+ void emitSignal(const QString &name, const QVariant &value)
+ {
+ if (name == "signalVoid")
+ emit signalVoid();
+ else if (name == "signalInt")
+ emit signalInt(value.toInt());
+ else if (name == "signalString")
+ emit signalString(value.toString());
+ }
+
+public slots:
+ void methodVoid() { slotSpy = "void Interface3::methodVoid()"; }
+ void methodInt(int) { slotSpy = "void Interface3::methodInt(int)"; }
+ void methodString(QString) { slotSpy = "void Interface3::methodString(QString)"; }
+
+ int methodStringString(const QString &s, QString &out)
+ {
+ slotSpy = "int Interface3::methodStringString(const QString &, QString &)";
+ out = s;
+ return 42;
+ }
+
+signals:
+ void signalVoid();
+ void signalInt(int);
+ void signalString(const QString &);
+};
+
+class Interface4: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "local.Interface4")
+ Q_PROPERTY(QString prop1 READ prop1)
+ Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2)
+ Q_PROPERTY(QString interface4prop READ interface4prop)
+public:
+ Interface4(QObject *parent) : QDBusAbstractAdaptor(parent)
+ { setAutoRelaySignals(true); }
+
+ QString prop1() const
+ { return QLatin1String("QString Interface4::prop1() const"); }
+
+ QString prop2() const
+ { return QLatin1String("QString Interface4::prop2() const"); }
+
+ QString interface4prop() const
+ { return QLatin1String("QString Interface4::interface4prop() const"); }
+
+ void setProp2(const QString &value)
+ {
+ slotSpy = "void Interface4::setProp2(const QString &)";
+ valueSpy = value;
+ }
+
+ void emitSignal(const QString &, const QVariant &value)
+ {
+ switch (value.type())
+ {
+ case QVariant::Invalid:
+ emit signal();
+ break;
+ case QVariant::Int:
+ emit signal(value.toInt());
+ break;
+ case QVariant::String:
+ emit signal(value.toString());
+ break;
+ default:
+ break;
+ }
+ }
+
+public slots:
+ void method() { slotSpy = "void Interface4::method()"; }
+ void method(int) { slotSpy = "void Interface4::method(int)"; }
+ void method(QString) { slotSpy = "void Interface4::method(QString)"; }
+
+signals:
+ void signal();
+ void signal(int);
+ void signal(const QString &);
+};
+
+class MyObject: public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "local.MyObject")
+public:
+ Interface1 *if1;
+ Interface2 *if2;
+ Interface3 *if3;
+ Interface4 *if4;
+
+ MyObject(int n = 4)
+ : if1(0), if2(0), if3(0), if4(0)
+ {
+ switch (n)
+ {
+ case 4:
+ if4 = new Interface4(this);
+ case 3:
+ if3 = new Interface3(this);
+ case 2:
+ if2 = new Interface2(this);
+ case 1:
+ if1 = new Interface1(this);
+ }
+ }
+
+ void emitSignal(const QString &name, const QVariant &value)
+ {
+ if (name == "scriptableSignalVoid")
+ emit scriptableSignalVoid();
+ else if (name == "scriptableSignalInt")
+ emit scriptableSignalInt(value.toInt());
+ else if (name == "scriptableSignalString")
+ emit scriptableSignalString(value.toString());
+ else if (name == "nonScriptableSignalVoid")
+ emit nonScriptableSignalVoid();
+ }
+
+signals:
+ Q_SCRIPTABLE void scriptableSignalVoid();
+ Q_SCRIPTABLE void scriptableSignalInt(int);
+ Q_SCRIPTABLE void scriptableSignalString(QString);
+ void nonScriptableSignalVoid();
+};
+
+#endif // MYOBJECT_H \ No newline at end of file
diff --git a/tests/auto/qdbusabstractadaptor/qdbusabstractadaptor.pro b/tests/auto/qdbusabstractadaptor/qdbusabstractadaptor.pro
index 16358c580a..c3e3f7f503 100644
--- a/tests/auto/qdbusabstractadaptor/qdbusabstractadaptor.pro
+++ b/tests/auto/qdbusabstractadaptor/qdbusabstractadaptor.pro
@@ -1,10 +1,9 @@
load(qttest_p4)
QT = core
contains(QT_CONFIG,dbus): {
- SOURCES += tst_qdbusabstractadaptor.cpp
- QT += dbus
+ TEMPLATE = subdirs
+ CONFIG += ordered
+ SUBDIRS = qmyserver test
} else {
- SOURCES += ../qdbusmarshall/dummy.cpp
+ SOURCES += ../qdbusmarshall/dummy.cpp
}
-
-
diff --git a/tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.cpp b/tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.cpp
new file mode 100644
index 0000000000..238bc38014
--- /dev/null
+++ b/tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/QtCore>
+#include <QtDBus/QtDBus>
+
+#include "../myobject.h"
+
+static const char serviceName[] = "com.trolltech.autotests.qmyserver";
+static const char objectPath[] = "/com/trolltech/qmyserver";
+//static const char *interfaceName = serviceName;
+
+const char *slotSpy;
+QString valueSpy;
+
+Q_DECLARE_METATYPE(QDBusConnection::RegisterOptions)
+
+class MyServer : public QDBusServer
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "com.trolltech.autotests.qmyserver")
+
+public:
+ MyServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0)
+ : QDBusServer(addr, parent),
+ m_conn("none"),
+ obj(NULL)
+ {
+ connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&)));
+ }
+
+ ~MyServer()
+ {
+ if (obj)
+ obj->deleteLater();
+ }
+
+public slots:
+ QString address() const
+ {
+ return QDBusServer::address();
+ }
+
+ bool isConnected() const
+ {
+ return m_conn.isConnected();
+ }
+
+ void emitSignal(const QString& interface, const QString& name, const QDBusVariant& parameter)
+ {
+ if (interface.endsWith('2'))
+ obj->if2->emitSignal(name, parameter.variant());
+ else if (interface.endsWith('3'))
+ obj->if3->emitSignal(name, parameter.variant());
+ else if (interface.endsWith('4'))
+ obj->if4->emitSignal(name, parameter.variant());
+ else
+ obj->emitSignal(name, parameter.variant());
+ }
+
+ void emitSignal2(const QString& interface, const QString& name)
+ {
+ if (interface.endsWith('2'))
+ obj->if2->emitSignal(name, QVariant());
+ else if (interface.endsWith('3'))
+ obj->if3->emitSignal(name, QVariant());
+ else if (interface.endsWith('4'))
+ obj->if4->emitSignal(name, QVariant());
+ else
+ obj->emitSignal(name, QVariant());
+ }
+
+ void newMyObject(int nInterfaces = 4)
+ {
+ if (obj)
+ obj->deleteLater();
+ obj = new MyObject(nInterfaces);
+ }
+
+ void registerMyObject(const QString & path, int options)
+ {
+ m_conn.registerObject(path, obj, (QDBusConnection::RegisterOptions)options);
+ }
+
+ QString slotSpyServer()
+ {
+ return QLatin1String(slotSpy);
+ }
+
+ QString valueSpyServer()
+ {
+ return valueSpy;
+ }
+
+ void clearValueSpy()
+ {
+ valueSpy.clear();
+ }
+
+private slots:
+ void handleConnection(const QDBusConnection& con)
+ {
+ m_conn = con;
+ }
+
+private:
+ QDBusConnection m_conn;
+ MyObject* obj;
+};
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ QDBusConnection con = QDBusConnection::sessionBus();
+ if (!con.isConnected())
+ exit(1);
+
+ if (!con.registerService(serviceName))
+ exit(2);
+
+ MyServer server;
+ con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots);
+
+ printf("ready.\n");
+
+ return app.exec();
+}
+
+#include "qmyserver.moc" \ No newline at end of file
diff --git a/tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.pro b/tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.pro
new file mode 100644
index 0000000000..f4fe02c4eb
--- /dev/null
+++ b/tests/auto/qdbusabstractadaptor/qmyserver/qmyserver.pro
@@ -0,0 +1,5 @@
+SOURCES = qmyserver.cpp
+HEADERS = ../myobject.h
+TARGET = qmyserver
+QT += dbus
+QT -= gui
diff --git a/tests/auto/qdbusabstractadaptor/test/test.pro b/tests/auto/qdbusabstractadaptor/test/test.pro
new file mode 100644
index 0000000000..014a9e81f6
--- /dev/null
+++ b/tests/auto/qdbusabstractadaptor/test/test.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+SOURCES += ../tst_qdbusabstractadaptor.cpp
+HEADERS += ../myobject.h
+TARGET = ../tst_qdbusabstractadaptor
+
+QT = core
+QT += dbus
diff --git a/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
index a64b3d2dca..92503509fb 100644
--- a/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
+++ b/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
@@ -46,6 +46,11 @@
#include <QtDBus>
#include "../qdbusmarshall/common.h"
+#include "myobject.h"
+
+static const char serviceName[] = "com.trolltech.autotests.qmyserver";
+static const char objectPath[] = "/com/trolltech/qmyserver";
+static const char *interfaceName = serviceName;
const char *slotSpy;
QString valueSpy;
@@ -73,273 +78,6 @@ namespace QTest {
}
QT_END_NAMESPACE
-class tst_QDBusAbstractAdaptor: public QObject
-{
- Q_OBJECT
-
-private slots:
- void initTestCase() { commonInit(); }
- void methodCalls_data();
- void methodCalls();
- void methodCallScriptable();
- void signalEmissions_data();
- void signalEmissions();
- void sameSignalDifferentPaths();
- void sameObjectDifferentPaths();
- void scriptableSignalOrNot();
- void overloadedSignalEmission_data();
- void overloadedSignalEmission();
- void readProperties();
- void readPropertiesInvalidInterface();
- void readPropertiesEmptyInterface_data();
- void readPropertiesEmptyInterface();
- void readAllProperties();
- void readAllPropertiesInvalidInterface();
- void readAllPropertiesEmptyInterface_data();
- void readAllPropertiesEmptyInterface();
- void writeProperties();
-
- void typeMatching_data();
- void typeMatching();
-
- void methodWithMoreThanOneReturnValue();
-};
-
-class QDBusSignalSpy: public QObject
-{
- Q_OBJECT
-
-public slots:
- void slot(const QDBusMessage &msg)
- {
- ++count;
- interface = msg.interface();
- name = msg.member();
- signature = msg.signature();
- path = msg.path();
- value.clear();
- if (msg.arguments().count())
- value = msg.arguments().at(0);
- }
-
-public:
- QDBusSignalSpy() : count(0) { }
-
- int count;
- QString interface;
- QString name;
- QString signature;
- QString path;
- QVariant value;
-};
-
-class Interface1: public QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "local.Interface1")
-public:
- Interface1(QObject *parent) : QDBusAbstractAdaptor(parent)
- { }
-};
-
-class Interface2: public QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "local.Interface2")
- Q_PROPERTY(QString prop1 READ prop1)
- Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2 SCRIPTABLE true)
- Q_PROPERTY(QUrl nonDBusProperty READ nonDBusProperty)
-public:
- Interface2(QObject *parent) : QDBusAbstractAdaptor(parent)
- { setAutoRelaySignals(true); }
-
- QString prop1() const
- { return QLatin1String("QString Interface2::prop1() const"); }
-
- QString prop2() const
- { return QLatin1String("QString Interface2::prop2() const"); }
-
- void setProp2(const QString &value)
- {
- slotSpy = "void Interface2::setProp2(const QString &)";
- valueSpy = value;
- }
-
- QUrl nonDBusProperty() const
- { return QUrl(); }
-
- void emitSignal(const QString &, const QVariant &)
- { emit signal(); }
-
-public slots:
- void method()
- {
- slotSpy = "void Interface2::method()";
- }
-
- Q_SCRIPTABLE void scriptableMethod()
- {
- slotSpy = "void Interface2::scriptableMethod()";
- }
-
-signals:
- void signal();
-};
-
-class Interface3: public QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "local.Interface3")
- Q_PROPERTY(QString prop1 READ prop1)
- Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2)
- Q_PROPERTY(QString interface3prop READ interface3prop)
-public:
- Interface3(QObject *parent) : QDBusAbstractAdaptor(parent)
- { setAutoRelaySignals(true); }
-
- QString prop1() const
- { return QLatin1String("QString Interface3::prop1() const"); }
-
- QString prop2() const
- { return QLatin1String("QString Interface3::prop2() const"); }
-
- void setProp2(const QString &value)
- {
- slotSpy = "void Interface3::setProp2(const QString &)";
- valueSpy = value;
- }
-
- QString interface3prop() const
- { return QLatin1String("QString Interface3::interface3prop() const"); }
-
- void emitSignal(const QString &name, const QVariant &value)
- {
- if (name == "signalVoid")
- emit signalVoid();
- else if (name == "signalInt")
- emit signalInt(value.toInt());
- else if (name == "signalString")
- emit signalString(value.toString());
- }
-
-public slots:
- void methodVoid() { slotSpy = "void Interface3::methodVoid()"; }
- void methodInt(int) { slotSpy = "void Interface3::methodInt(int)"; }
- void methodString(QString) { slotSpy = "void Interface3::methodString(QString)"; }
-
- int methodStringString(const QString &s, QString &out)
- {
- slotSpy = "int Interface3::methodStringString(const QString &, QString &)";
- out = s;
- return 42;
- }
-
-signals:
- void signalVoid();
- void signalInt(int);
- void signalString(const QString &);
-};
-
-class Interface4: public QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "local.Interface4")
- Q_PROPERTY(QString prop1 READ prop1)
- Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2)
- Q_PROPERTY(QString interface4prop READ interface4prop)
-public:
- Interface4(QObject *parent) : QDBusAbstractAdaptor(parent)
- { setAutoRelaySignals(true); }
-
- QString prop1() const
- { return QLatin1String("QString Interface4::prop1() const"); }
-
- QString prop2() const
- { return QLatin1String("QString Interface4::prop2() const"); }
-
- QString interface4prop() const
- { return QLatin1String("QString Interface4::interface4prop() const"); }
-
- void setProp2(const QString &value)
- {
- slotSpy = "void Interface4::setProp2(const QString &)";
- valueSpy = value;
- }
-
- void emitSignal(const QString &, const QVariant &value)
- {
- switch (value.type())
- {
- case QVariant::Invalid:
- emit signal();
- break;
- case QVariant::Int:
- emit signal(value.toInt());
- break;
- case QVariant::String:
- emit signal(value.toString());
- break;
- default:
- break;
- }
- }
-
-public slots:
- void method() { slotSpy = "void Interface4::method()"; }
- void method(int) { slotSpy = "void Interface4::method(int)"; }
- void method(QString) { slotSpy = "void Interface4::method(QString)"; }
-
-signals:
- void signal();
- void signal(int);
- void signal(const QString &);
-};
-
-class MyObject: public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "local.MyObject")
-public:
- Interface1 *if1;
- Interface2 *if2;
- Interface3 *if3;
- Interface4 *if4;
-
- MyObject(int n = 4)
- : if1(0), if2(0), if3(0), if4(0)
- {
- switch (n)
- {
- case 4:
- if4 = new Interface4(this);
- case 3:
- if3 = new Interface3(this);
- case 2:
- if2 = new Interface2(this);
- case 1:
- if1 = new Interface1(this);
- }
- }
-
- void emitSignal(const QString &name, const QVariant &value)
- {
- if (name == "scriptableSignalVoid")
- emit scriptableSignalVoid();
- else if (name == "scriptableSignalInt")
- emit scriptableSignalInt(value.toInt());
- else if (name == "scriptableSignalString")
- emit scriptableSignalString(value.toString());
- else if (name == "nonScriptableSignalVoid")
- emit nonScriptableSignalVoid();
- }
-
-signals:
- Q_SCRIPTABLE void scriptableSignalVoid();
- Q_SCRIPTABLE void scriptableSignalInt(int);
- Q_SCRIPTABLE void scriptableSignalString(QString);
- void nonScriptableSignalVoid();
-};
-
class TypesInterface: public QDBusAbstractAdaptor
{
Q_OBJECT
@@ -593,6 +331,191 @@ public slots:
}
};
+void newMyObjectPeer(int nInterfaces = 4)
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "newMyObject");
+ req << nInterfaces;
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+}
+
+void registerMyObjectPeer(const QString & path, QDBusConnection::RegisterOptions options = QDBusConnection::ExportAdaptors)
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "registerMyObject");
+ req << path;
+ req << (int)options;
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+}
+
+void emitSignalPeer(const QString &interface, const QString &name, const QVariant &parameter)
+{
+ if (parameter.isValid())
+ {
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "emitSignal");
+ req << interface;
+ req << name;
+ req << QVariant::fromValue(QDBusVariant(parameter));
+ QDBusConnection::sessionBus().send(req);
+ }
+ else
+ {
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "emitSignal2");
+ req << interface;
+ req << name;
+ QDBusConnection::sessionBus().send(req);
+ }
+
+ QTest::qWait(1000);
+}
+
+const char* slotSpyPeer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "slotSpyServer");
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+ return reply.arguments().at(0).toString().toLatin1().data();
+}
+
+QString valueSpyPeer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "valueSpyServer");
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+ return reply.arguments().at(0).toString();
+}
+
+void clearValueSpyPeer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "clearValueSpy");
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+}
+
+class tst_QDBusAbstractAdaptor: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void methodCalls_data();
+ void methodCalls();
+ void methodCallScriptable();
+ void signalEmissions_data();
+ void signalEmissions();
+ void sameSignalDifferentPaths();
+ void sameObjectDifferentPaths();
+ void scriptableSignalOrNot();
+ void overloadedSignalEmission_data();
+ void overloadedSignalEmission();
+ void readProperties();
+ void readPropertiesInvalidInterface();
+ void readPropertiesEmptyInterface_data();
+ void readPropertiesEmptyInterface();
+ void readAllProperties();
+ void readAllPropertiesInvalidInterface();
+ void readAllPropertiesEmptyInterface_data();
+ void readAllPropertiesEmptyInterface();
+ void writeProperties();
+
+ void methodCallsPeer_data();
+ void methodCallsPeer();
+ void methodCallScriptablePeer();
+ void signalEmissionsPeer_data();
+ void signalEmissionsPeer();
+ void sameSignalDifferentPathsPeer();
+ void sameObjectDifferentPathsPeer();
+ void scriptableSignalOrNotPeer();
+ void overloadedSignalEmissionPeer_data();
+ void overloadedSignalEmissionPeer();
+ void readPropertiesPeer();
+ void readPropertiesInvalidInterfacePeer();
+ void readPropertiesEmptyInterfacePeer_data();
+ void readPropertiesEmptyInterfacePeer();
+ void readAllPropertiesPeer();
+ void readAllPropertiesInvalidInterfacePeer();
+ void readAllPropertiesEmptyInterfacePeer_data();
+ void readAllPropertiesEmptyInterfacePeer();
+ void writePropertiesPeer();
+
+ void typeMatching_data();
+ void typeMatching();
+
+ void methodWithMoreThanOneReturnValue();
+ void methodWithMoreThanOneReturnValuePeer();
+private:
+ QProcess proc;
+};
+
+class WaitForQMyServer: public QObject
+{
+ Q_OBJECT
+public:
+ WaitForQMyServer();
+ bool ok();
+public Q_SLOTS:
+ void ownerChange(const QString &name)
+ {
+ if (name == serviceName)
+ loop.quit();
+ }
+
+private:
+ QEventLoop loop;
+};
+
+WaitForQMyServer::WaitForQMyServer()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ if (!ok()) {
+ connect(con.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
+ SLOT(ownerChange(QString)));
+ QTimer::singleShot(2000, &loop, SLOT(quit()));
+ loop.exec();
+ }
+}
+
+bool WaitForQMyServer::ok()
+{
+ return QDBusConnection::sessionBus().isConnected() &&
+ QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName);
+}
+
+void tst_QDBusAbstractAdaptor::initTestCase()
+{
+ commonInit();
+
+ // start peer server
+ #ifdef Q_OS_WIN
+ proc.start("qmyserver");
+ #else
+ proc.start("./qmyserver/qmyserver");
+ #endif
+ QVERIFY(proc.waitForStarted());
+
+ WaitForQMyServer w;
+ QVERIFY(w.ok());
+ //QTest::qWait(2000);
+
+ // get peer server address
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "address");
+ QDBusMessage rpl = QDBusConnection::sessionBus().call(req);
+ QVERIFY(rpl.type() == QDBusMessage::ReplyMessage);
+ QString address = rpl.arguments().at(0).toString();
+
+ // connect to peer server
+ QDBusConnection peercon = QDBusConnection::connectToPeer(address, "peer");
+ QVERIFY(peercon.isConnected());
+
+ QDBusMessage req2 = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "isConnected");
+ QDBusMessage rpl2 = QDBusConnection::sessionBus().call(req2);
+ QVERIFY(rpl2.type() == QDBusMessage::ReplyMessage);
+ QVERIFY(rpl2.arguments().at(0).toBool());
+}
+
+void tst_QDBusAbstractAdaptor::cleanupTestCase()
+{
+ proc.close();
+ proc.kill();
+}
+
void tst_QDBusAbstractAdaptor::methodCalls_data()
{
QTest::addColumn<int>("nInterfaces");
@@ -1151,6 +1074,512 @@ void tst_QDBusAbstractAdaptor::writeProperties()
}
}
+void tst_QDBusAbstractAdaptor::methodCallsPeer_data()
+{
+ methodCalls_data();
+}
+
+void tst_QDBusAbstractAdaptor::methodCallsPeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ {
+ // must fail: no object
+ QDBusInterface if1(QString(), "/", "local.Interface1", con);
+ QCOMPARE(if1.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ErrorMessage);
+ }
+
+ QFETCH(int, nInterfaces);
+ newMyObjectPeer(nInterfaces);
+ registerMyObjectPeer("/");
+
+ QDBusInterface if1(QString(), "/", "local.Interface1", con);
+ QDBusInterface if2(QString(), "/", "local.Interface2", con);
+ QDBusInterface if3(QString(), "/", "local.Interface3", con);
+ QDBusInterface if4(QString(), "/", "local.Interface4", con);
+
+ // must fail: no such method
+ QCOMPARE(if1.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ErrorMessage);
+ if (!nInterfaces--)
+ return;
+ if (!nInterfaces--)
+ return;
+
+ // simple call: one such method exists
+ QCOMPARE(if2.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface2::method()");
+ if (!nInterfaces--)
+ return;
+
+ // multiple methods in multiple interfaces, no name overlap
+ QCOMPARE(if1.call(QDBus::BlockWithGui, "methodVoid").type(), QDBusMessage::ErrorMessage);
+ QCOMPARE(if1.call(QDBus::BlockWithGui, "methodInt").type(), QDBusMessage::ErrorMessage);
+ QCOMPARE(if1.call(QDBus::BlockWithGui, "methodString").type(), QDBusMessage::ErrorMessage);
+ QCOMPARE(if2.call(QDBus::BlockWithGui, "methodVoid").type(), QDBusMessage::ErrorMessage);
+ QCOMPARE(if2.call(QDBus::BlockWithGui, "methodInt").type(), QDBusMessage::ErrorMessage);
+ QCOMPARE(if2.call(QDBus::BlockWithGui, "methodString").type(), QDBusMessage::ErrorMessage);
+
+ QCOMPARE(if3.call(QDBus::BlockWithGui, "methodVoid").type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface3::methodVoid()");
+ QCOMPARE(if3.call(QDBus::BlockWithGui, "methodInt", 42).type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface3::methodInt(int)");
+ QCOMPARE(if3.call(QDBus::BlockWithGui, "methodString", QString("")).type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface3::methodString(QString)");
+
+ if (!nInterfaces--)
+ return;
+
+ // method overloading: different interfaces
+ QCOMPARE(if4.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface4::method()");
+
+ // method overloading: different parameters
+ QCOMPARE(if4.call(QDBus::BlockWithGui, "method.i", 42).type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface4::method(int)");
+ QCOMPARE(if4.call(QDBus::BlockWithGui, "method.s", QString()).type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface4::method(QString)");
+}
+
+void tst_QDBusAbstractAdaptor::methodCallScriptablePeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer(2);
+ registerMyObjectPeer("/");
+
+ QDBusInterface if2(QString(), "/", "local.Interface2", con);
+
+ QCOMPARE(if2.call(QDBus::BlockWithGui,"scriptableMethod").type(), QDBusMessage::ReplyMessage);
+ QCOMPARE(slotSpyPeer(), "void Interface2::scriptableMethod()");
+}
+
+void tst_QDBusAbstractAdaptor::signalEmissionsPeer_data()
+{
+ signalEmissions_data();
+}
+
+void tst_QDBusAbstractAdaptor::signalEmissionsPeer()
+{
+ QFETCH(QString, interface);
+ QFETCH(QString, name);
+ QFETCH(QVariant, parameter);
+
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer(3);
+ registerMyObjectPeer("/", QDBusConnection::ExportAdaptors
+ | QDBusConnection::ExportScriptableSignals);
+
+ // connect all signals and emit only one
+ {
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/", "local.Interface2", "signal",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.Interface3", "signalVoid",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.Interface3", "signalInt",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.Interface3", "signalString",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.MyObject", "scriptableSignalVoid",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.MyObject", "scriptableSignalInt",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.MyObject", "scriptableSignalString",
+ &spy, SLOT(slot(QDBusMessage)));
+
+ emitSignalPeer(interface, name, parameter);
+
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.interface, interface);
+ QCOMPARE(spy.name, name);
+ QTEST(spy.signature, "signature");
+ QCOMPARE(spy.value, parameter);
+ }
+
+ // connect one signal and emit them all
+ {
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/", interface, name, &spy, SLOT(slot(QDBusMessage)));
+ emitSignalPeer("local.Interface2", "signal", QVariant());
+ emitSignalPeer("local.Interface3", "signalVoid", QVariant());
+ emitSignalPeer("local.Interface3", "signalInt", QVariant(1));
+ emitSignalPeer("local.Interface3", "signalString", QVariant("foo"));
+ emitSignalPeer("local.MyObject", "scriptableSignalVoid", QVariant());
+ emitSignalPeer("local.MyObject", "scriptableSignalInt", QVariant(1));
+ emitSignalPeer("local.MyObject", "scriptableSignalString", QVariant("foo"));
+
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.interface, interface);
+ QCOMPARE(spy.name, name);
+ QTEST(spy.signature, "signature");
+ QCOMPARE(spy.value, parameter);
+ }
+}
+
+void tst_QDBusAbstractAdaptor::sameSignalDifferentPathsPeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer(2);
+
+ registerMyObjectPeer("/p1");
+ registerMyObjectPeer("/p2");
+
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/p1", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
+ emitSignalPeer("local.Interface2", QString(), QVariant());
+ QTest::qWait(200);
+
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.interface, QString("local.Interface2"));
+ QCOMPARE(spy.name, QString("signal"));
+ QVERIFY(spy.signature.isEmpty());
+
+ // now connect the other one
+ spy.count = 0;
+ con.connect(QString(), "/p2", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
+ emitSignalPeer("local.Interface2", QString(), QVariant());
+ QTest::qWait(200);
+
+ QCOMPARE(spy.count, 2);
+}
+
+void tst_QDBusAbstractAdaptor::sameObjectDifferentPathsPeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer(2);
+
+ registerMyObjectPeer("/p1");
+ registerMyObjectPeer("/p2", 0); // don't export anything
+
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/p1", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/p2", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
+ emitSignalPeer("local.Interface2", QString(), QVariant());
+ QTest::qWait(200);
+
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.interface, QString("local.Interface2"));
+ QCOMPARE(spy.name, QString("signal"));
+ QVERIFY(spy.signature.isEmpty());
+}
+
+void tst_QDBusAbstractAdaptor::scriptableSignalOrNotPeer()
+{
+ QDBusConnection con("peer");;
+ QVERIFY(con.isConnected());
+
+ {
+ newMyObjectPeer(0);
+
+ registerMyObjectPeer("/p1", QDBusConnection::ExportScriptableSignals);
+ registerMyObjectPeer("/p2", 0); // don't export anything
+
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/p1", "local.MyObject", "scriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/p2", "local.MyObject", "scriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/p1", "local.MyObject", "nonScriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/p2", "local.MyObject", "nonScriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
+ emitSignalPeer("local.MyObject", "scriptableSignalVoid", QVariant());
+ emitSignalPeer("local.MyObject", "nonScriptableSignalVoid", QVariant());
+ QTest::qWait(200);
+
+ QCOMPARE(spy.count, 1); // only /p1 must have emitted
+ QCOMPARE(spy.interface, QString("local.MyObject"));
+ QCOMPARE(spy.name, QString("scriptableSignalVoid"));
+ QCOMPARE(spy.path, QString("/p1"));
+ QVERIFY(spy.signature.isEmpty());
+ }
+
+ {
+ newMyObjectPeer(0);
+
+ registerMyObjectPeer("/p1", QDBusConnection::ExportScriptableSignals);
+ registerMyObjectPeer("/p2", QDBusConnection::ExportScriptableSignals
+ | QDBusConnection::ExportNonScriptableSignals);
+
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/p1", "local.MyObject", "nonScriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/p2", "local.MyObject", "nonScriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
+ emitSignalPeer("local.MyObject", "nonScriptableSignalVoid", QVariant());
+ QTest::qWait(200);
+
+ QCOMPARE(spy.count, 1); // only /p2 must have emitted now
+ QCOMPARE(spy.interface, QString("local.MyObject"));
+ QCOMPARE(spy.name, QString("nonScriptableSignalVoid"));
+ QCOMPARE(spy.path, QString("/p2"));
+ QVERIFY(spy.signature.isEmpty());
+ }
+
+ {
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/p1", "local.MyObject", "destroyed", &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/p2", "local.MyObject", "destroyed", &spy, SLOT(slot(QDBusMessage)));
+
+ {
+ newMyObjectPeer(0);
+
+ registerMyObjectPeer("/p1", QDBusConnection::ExportScriptableSignals);
+ registerMyObjectPeer("/p2", QDBusConnection::ExportScriptableSignals
+ | QDBusConnection::ExportNonScriptableSignals);
+ } // <--- QObject emits the destroyed(QObject*) signal at this point
+
+ QTest::qWait(200);
+
+ QCOMPARE(spy.count, 0);
+ }
+}
+
+void tst_QDBusAbstractAdaptor::overloadedSignalEmissionPeer_data()
+{
+ overloadedSignalEmission_data();
+}
+
+void tst_QDBusAbstractAdaptor::overloadedSignalEmissionPeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QString interface = "local.Interface4";
+ QString name = "signal";
+ QFETCH(QVariant, parameter);
+ //QDBusInterface *if4 = new QDBusInterface(QString(), "/", interface, con);
+
+ // connect all signals and emit only one
+ {
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/", "local.Interface4", "signal", "",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.Interface4", "signal", "i",
+ &spy, SLOT(slot(QDBusMessage)));
+ con.connect(QString(), "/", "local.Interface4", "signal", "s",
+ &spy, SLOT(slot(QDBusMessage)));
+
+ emitSignalPeer(interface, name, parameter);
+
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.interface, interface);
+ QCOMPARE(spy.name, name);
+ QTEST(spy.signature, "signature");
+ QCOMPARE(spy.value, parameter);
+ }
+
+ QFETCH(QString, signature);
+ // connect one signal and emit them all
+ {
+ QDBusSignalSpy spy;
+ con.connect(QString(), "/", interface, name, signature, &spy, SLOT(slot(QDBusMessage)));
+ emitSignalPeer("local.Interface4", "signal", QVariant());
+ emitSignalPeer("local.Interface4", "signal", QVariant(1));
+ emitSignalPeer("local.Interface4", "signal", QVariant("foo"));
+
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.interface, interface);
+ QCOMPARE(spy.name, name);
+ QTEST(spy.signature, "signature");
+ QCOMPARE(spy.value, parameter);
+ }
+}
+
+void tst_QDBusAbstractAdaptor::readPropertiesPeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QDBusInterface properties(QString(), "/", "org.freedesktop.DBus.Properties", con);
+ for (int i = 2; i <= 4; ++i) {
+ QString name = QString("Interface%1").arg(i);
+
+ for (int j = 1; j <= 2; ++j) {
+ QString propname = QString("prop%1").arg(j);
+ QDBusReply<QVariant> reply =
+ properties.call(QDBus::BlockWithGui, "Get", "local." + name, propname);
+ QVariant value = reply;
+
+ QCOMPARE(value.userType(), int(QVariant::String));
+ QCOMPARE(value.toString(), QString("QString %1::%2() const").arg(name, propname));
+ }
+ }
+}
+
+void tst_QDBusAbstractAdaptor::readPropertiesInvalidInterfacePeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QDBusInterface properties(QString(), "/", "org.freedesktop.DBus.Properties", con);
+
+ // test an invalid interface:
+ QDBusReply<QVariant> reply = properties.call(QDBus::BlockWithGui, "Get", "local.DoesntExist", "prop1");
+ QVERIFY(!reply.isValid());
+}
+
+void tst_QDBusAbstractAdaptor::readPropertiesEmptyInterfacePeer_data()
+{
+ readPropertiesEmptyInterface_data();
+}
+
+void tst_QDBusAbstractAdaptor::readPropertiesEmptyInterfacePeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QDBusInterface properties(QString(), "/", "org.freedesktop.DBus.Properties", con);
+
+ QFETCH(QVariantMap, expectedProperties);
+ QFETCH(bool, existing);
+
+ QVariantMap::ConstIterator it = expectedProperties.constBegin();
+ for ( ; it != expectedProperties.constEnd(); ++it) {
+ QDBusReply<QVariant> reply = properties.call(QDBus::BlockWithGui, "Get", "", it.key());
+
+ if (existing) {
+ QVERIFY2(reply.isValid(), qPrintable(it.key()));
+ } else {
+ QVERIFY2(!reply.isValid(), qPrintable(it.key()));
+ continue;
+ }
+
+ QCOMPARE(int(reply.value().type()), int(QVariant::String));
+ if (it.value().isValid())
+ QCOMPARE(reply.value().toString(), it.value().toString());
+ }
+}
+
+void tst_QDBusAbstractAdaptor::readAllPropertiesPeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QDBusInterface properties(QString(), "/", "org.freedesktop.DBus.Properties", con);
+ for (int i = 2; i <= 4; ++i) {
+ QString name = QString("Interface%1").arg(i);
+ QDBusReply<QVariantMap> reply =
+ properties.call(QDBus::BlockWithGui, "GetAll", "local." + name);
+
+ for (int j = 1; j <= 2; ++j) {
+ QString propname = QString("prop%1").arg(j);
+ QVERIFY2(reply.value().contains(propname),
+ qPrintable(propname + " on " + name));
+ QVariant value = reply.value().value(propname);
+
+ QCOMPARE(value.userType(), int(QVariant::String));
+ QCOMPARE(value.toString(), QString("QString %1::%2() const").arg(name, propname));
+ }
+ }
+}
+
+void tst_QDBusAbstractAdaptor::readAllPropertiesInvalidInterfacePeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QDBusInterface properties(QString(), "/", "org.freedesktop.DBus.Properties", con);
+
+ // test an invalid interface:
+ QDBusReply<QVariantMap> reply = properties.call(QDBus::BlockWithGui, "GetAll", "local.DoesntExist");
+ QVERIFY(!reply.isValid());
+}
+
+void tst_QDBusAbstractAdaptor::readAllPropertiesEmptyInterfacePeer_data()
+{
+ readAllPropertiesEmptyInterface_data();
+}
+
+void tst_QDBusAbstractAdaptor::readAllPropertiesEmptyInterfacePeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QDBusInterface properties(QString(), "/", "org.freedesktop.DBus.Properties", con);
+
+ QDBusReply<QVariantMap> reply = properties.call(QDBus::BlockWithGui, "GetAll", "");
+ QVERIFY(reply.isValid());
+
+ QVariantMap allprops = reply;
+
+ QFETCH(QVariantMap, expectedProperties);
+ QFETCH(bool, existing);
+
+ QVariantMap::ConstIterator it = expectedProperties.constBegin();
+ if (existing) {
+ for ( ; it != expectedProperties.constEnd(); ++it) {
+ QVERIFY2(allprops.contains(it.key()), qPrintable(it.key()));
+
+ QVariant propvalue = allprops.value(it.key());
+ QVERIFY2(!propvalue.isNull(), qPrintable(it.key()));
+ QVERIFY2(propvalue.isValid(), qPrintable(it.key()));
+
+ QString stringvalue = propvalue.toString();
+ QVERIFY2(!stringvalue.isEmpty(), qPrintable(it.key()));
+
+ if (it.value().isValid())
+ QCOMPARE(stringvalue, it.value().toString());
+
+ // remove this property from the map
+ allprops.remove(it.key());
+ }
+
+ QVERIFY2(allprops.isEmpty(),
+ qPrintable(QStringList(allprops.keys()).join(" ")));
+ } else {
+ for ( ; it != expectedProperties.constEnd(); ++it)
+ QVERIFY2(!allprops.contains(it.key()), qPrintable(it.key()));
+ }
+}
+
+void tst_QDBusAbstractAdaptor::writePropertiesPeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QDBusInterface properties(QString(), "/", "org.freedesktop.DBus.Properties", con);
+ for (int i = 2; i <= 4; ++i) {
+ QString name = QString("Interface%1").arg(i);
+
+ clearValueSpyPeer();
+ properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop1"),
+ qVariantFromValue(QDBusVariant(name)));
+ QVERIFY(valueSpyPeer().isEmpty()); // call mustn't have succeeded
+
+ properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop2"),
+ qVariantFromValue(QDBusVariant(name)));
+ QCOMPARE(valueSpyPeer(), name);
+ QCOMPARE(QString(slotSpyPeer()), QString("void %1::setProp2(const QString &)").arg(name));
+ }
+}
+
#if 0
void tst_QDBusAbstractAdaptor::adaptorIntrospection_data()
{
@@ -1438,6 +1867,28 @@ void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValue()
QCOMPARE(qdbus_cast<QString>(reply.arguments().at(1)), testString);
}
+void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValuePeer()
+{
+ QDBusConnection con("peer");
+ QVERIFY(con.isConnected());
+
+ newMyObjectPeer();
+ registerMyObjectPeer("/");
+
+ QString testString = "This is a test string.";
+
+ QDBusInterface remote(QString(), "/", "local.Interface3", con);
+ QDBusMessage reply = remote.call(QDBus::BlockWithGui, "methodStringString", testString);
+ QVERIFY(reply.arguments().count() == 2);
+
+ QDBusReply<int> intreply = reply;
+ QVERIFY(intreply.isValid());
+ QCOMPARE(intreply.value(), 42);
+
+ QCOMPARE(reply.arguments().at(1).userType(), int(QVariant::String));
+ QCOMPARE(qdbus_cast<QString>(reply.arguments().at(1)), testString);
+}
+
QTEST_MAIN(tst_QDBusAbstractAdaptor)
#include "tst_qdbusabstractadaptor.moc"
diff --git a/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml
index fb2aab811f..1667591708 100644
--- a/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml
+++ b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml
@@ -24,7 +24,7 @@
</method>
<method name="multiOutMethod">
<arg type="s" direction="out"/>
- <arg type="i" direction="out"/
+ <arg type="i" direction="out"/>
</method>
</interface>
</node>
diff --git a/tests/auto/qdbusabstractinterface/interface.h b/tests/auto/qdbusabstractinterface/interface.h
index 9a14222f1e..62f81af369 100644
--- a/tests/auto/qdbusabstractinterface/interface.h
+++ b/tests/auto/qdbusabstractinterface/interface.h
@@ -84,6 +84,7 @@ class Interface: public QObject
Q_PROPERTY(RegisteredType complexProp READ complexProp WRITE setComplexProp SCRIPTABLE true)
friend class tst_QDBusAbstractInterface;
+ friend class PingerServer;
QString m_stringProp;
QDBusVariant m_variantProp;
RegisteredType m_complexProp;
diff --git a/tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro b/tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro
index a4853b8009..f9077b92cf 100644
--- a/tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro
+++ b/tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro
@@ -1,15 +1,10 @@
load(qttest_p4)
-QT = core
-contains(QT_CONFIG,dbus): {
- SOURCES += tst_qdbusabstractinterface.cpp interface.cpp
- HEADERS += interface.h
- QT += dbus
-
- # These are generated sources
- # To regenerate, see the command-line at the top of the files
- SOURCES += pinger.cpp
- HEADERS += pinger.h
+contains(QT_CONFIG,dbus): {
+ TEMPLATE = subdirs
+ CONFIG += ordered
+ SUBDIRS = qpinger test
+} else {
+ SOURCES += ../qdbusmarshall/dummy.cpp
}
-else:SOURCES += ../qdbusmarshall/dummy.cpp
OTHER_FILES += com.trolltech.QtDBus.Pinger.xml
diff --git a/tests/auto/qdbusperformance/server/server.cpp b/tests/auto/qdbusabstractinterface/qpinger/qpinger.cpp
index 3bd5efc108..3b605c8f52 100644
--- a/tests/auto/qdbusperformance/server/server.cpp
+++ b/tests/auto/qdbusabstractinterface/qpinger/qpinger.cpp
@@ -40,16 +40,79 @@
****************************************************************************/
#include <QtCore/QtCore>
#include <QtDBus/QtDBus>
+#include "../interface.h"
-#include "../serverobject.h"
+static const char serviceName[] = "com.trolltech.autotests.qpinger";
+static const char objectPath[] = "/com/trolltech/qpinger";
+//static const char *interfaceName = serviceName;
-static const char serviceName[] = "com.trolltech.autotests.performance";
-static const char objectPath[] = "/";
+class PingerServer : public QDBusServer
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "com.trolltech.autotests.qpinger")
+public:
+ PingerServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0)
+ : QDBusServer(addr, parent),
+ m_conn("none")
+ {
+ connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&)));
+ reset();
+ }
+
+public slots:
+ QString address() const
+ {
+ return QDBusServer::address();
+ }
+
+ bool isConnected() const
+ {
+ return m_conn.isConnected();
+ }
+
+ void reset()
+ {
+ targetObj.m_stringProp = "This is a test";
+ targetObj.m_variantProp = QDBusVariant(QVariant(42));
+ targetObj.m_complexProp = RegisteredType("This is a test");
+ }
+
+ void voidSignal()
+ {
+ emit targetObj.voidSignal();
+ }
+
+ void stringSignal(const QString& value)
+ {
+ emit targetObj.stringSignal(value);
+ }
+
+ void complexSignal(const QString& value)
+ {
+ RegisteredType reg(value);
+ emit targetObj.complexSignal(reg);
+ }
+
+private slots:
+ void handleConnection(const QDBusConnection& con)
+ {
+ m_conn = con;
+ m_conn.registerObject("/", &targetObj, QDBusConnection::ExportScriptableContents);
+ }
+
+private:
+ Interface targetObj;
+ QDBusConnection m_conn;
+};
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
+ // register the meta types
+ qDBusRegisterMetaType<RegisteredType>();
+ qRegisterMetaType<UnregisteredType>();
+
QDBusConnection con = QDBusConnection::sessionBus();
if (!con.isConnected())
exit(1);
@@ -57,8 +120,12 @@ int main(int argc, char *argv[])
if (!con.registerService(serviceName))
exit(2);
- ServerObject obj(objectPath, con);
+ PingerServer server;
+ con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots);
+
printf("ready.\n");
+
return app.exec();
}
+#include "qpinger.moc"
diff --git a/tests/auto/qdbusabstractinterface/qpinger/qpinger.pro b/tests/auto/qdbusabstractinterface/qpinger/qpinger.pro
new file mode 100644
index 0000000000..27545bbb0f
--- /dev/null
+++ b/tests/auto/qdbusabstractinterface/qpinger/qpinger.pro
@@ -0,0 +1,5 @@
+SOURCES = qpinger.cpp ../interface.cpp
+HEADERS = ../interface.h
+TARGET = qpinger
+QT += dbus
+QT -= gui
diff --git a/tests/auto/qdbusabstractinterface/test/test.pro b/tests/auto/qdbusabstractinterface/test/test.pro
new file mode 100644
index 0000000000..98bcaa70f5
--- /dev/null
+++ b/tests/auto/qdbusabstractinterface/test/test.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+SOURCES += ../tst_qdbusabstractinterface.cpp ../interface.cpp
+HEADERS += ../interface.h
+
+# These are generated sources
+# To regenerate, see the command-line at the top of the files
+SOURCES += ../pinger.cpp
+HEADERS += ../pinger.h
+
+TARGET = ../tst_qdbusabstractinterface
+
+QT = core
+QT += dbus
diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
index e8ce1f943e..6f93d8a61d 100644
--- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
+++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
@@ -49,6 +49,10 @@
#include "interface.h"
#include "pinger.h"
+static const char serviceName[] = "com.trolltech.autotests.qpinger";
+static const char objectPath[] = "/com/trolltech/qpinger";
+static const char *interfaceName = serviceName;
+
typedef QSharedPointer<com::trolltech::QtDBus::Pinger> Pinger;
class tst_QDBusAbstractInterface: public QObject
@@ -66,22 +70,47 @@ class tst_QDBusAbstractInterface: public QObject
return Pinger(new com::trolltech::QtDBus::Pinger(service, path, con));
}
+ Pinger getPingerPeer(const QString &path = "/")
+ {
+ QDBusConnection con = QDBusConnection("peer");
+ if (!con.isConnected())
+ return Pinger();
+ return Pinger(new com::trolltech::QtDBus::Pinger("", path, con));
+ }
+
+ void resetServer()
+ {
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "reset");
+ QDBusConnection::sessionBus().send(req);
+ }
+
public:
tst_QDBusAbstractInterface();
private slots:
void initTestCase();
+ void cleanupTestCase();
void makeVoidCall();
void makeStringCall();
void makeComplexCall();
void makeMultiOutCall();
+ void makeVoidCallPeer();
+ void makeStringCallPeer();
+ void makeComplexCallPeer();
+ void makeMultiOutCallPeer();
+
void makeAsyncVoidCall();
void makeAsyncStringCall();
void makeAsyncComplexCall();
void makeAsyncMultiOutCall();
+ void makeAsyncVoidCallPeer();
+ void makeAsyncStringCallPeer();
+ void makeAsyncComplexCallPeer();
+ void makeAsyncMultiOutCallPeer();
+
void stringPropRead();
void stringPropWrite();
void variantPropRead();
@@ -89,6 +118,13 @@ private slots:
void complexPropRead();
void complexPropWrite();
+ void stringPropReadPeer();
+ void stringPropWritePeer();
+ void variantPropReadPeer();
+ void variantPropWritePeer();
+ void complexPropReadPeer();
+ void complexPropWritePeer();
+
void stringPropDirectRead();
void stringPropDirectWrite();
void variantPropDirectRead();
@@ -96,6 +132,13 @@ private slots:
void complexPropDirectRead();
void complexPropDirectWrite();
+ void stringPropDirectReadPeer();
+ void stringPropDirectWritePeer();
+ void variantPropDirectReadPeer();
+ void variantPropDirectWritePeer();
+ void complexPropDirectReadPeer();
+ void complexPropDirectWritePeer();
+
void getVoidSignal_data();
void getVoidSignal();
void getStringSignal_data();
@@ -103,16 +146,31 @@ private slots:
void getComplexSignal_data();
void getComplexSignal();
+ void getVoidSignalPeer_data();
+ void getVoidSignalPeer();
+ void getStringSignalPeer_data();
+ void getStringSignalPeer();
+ void getComplexSignalPeer_data();
+ void getComplexSignalPeer();
+
void followSignal();
void createErrors_data();
void createErrors();
+ void createErrorsPeer_data();
+ void createErrorsPeer();
+
void callErrors_data();
void callErrors();
void asyncCallErrors_data();
void asyncCallErrors();
+ void callErrorsPeer_data();
+ void callErrorsPeer();
+ void asyncCallErrorsPeer_data();
+ void asyncCallErrorsPeer();
+
void propertyReadErrors_data();
void propertyReadErrors();
void propertyWriteErrors_data();
@@ -121,8 +179,53 @@ private slots:
void directPropertyReadErrors();
void directPropertyWriteErrors_data();
void directPropertyWriteErrors();
+
+ void propertyReadErrorsPeer_data();
+ void propertyReadErrorsPeer();
+ void propertyWriteErrorsPeer_data();
+ void propertyWriteErrorsPeer();
+ void directPropertyReadErrorsPeer_data();
+ void directPropertyReadErrorsPeer();
+ void directPropertyWriteErrorsPeer_data();
+ void directPropertyWriteErrorsPeer();
+private:
+ QProcess proc;
+};
+
+class WaitForQPinger: public QObject
+{
+ Q_OBJECT
+public:
+ WaitForQPinger();
+ bool ok();
+public Q_SLOTS:
+ void ownerChange(const QString &name)
+ {
+ if (name == serviceName)
+ loop.quit();
+ }
+
+private:
+ QEventLoop loop;
};
+WaitForQPinger::WaitForQPinger()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ if (!ok()) {
+ connect(con.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
+ SLOT(ownerChange(QString)));
+ QTimer::singleShot(2000, &loop, SLOT(quit()));
+ loop.exec();
+ }
+}
+
+bool WaitForQPinger::ok()
+{
+ return QDBusConnection::sessionBus().isConnected() &&
+ QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName);
+}
+
tst_QDBusAbstractInterface::tst_QDBusAbstractInterface()
{
// register the meta types
@@ -139,6 +242,39 @@ void tst_QDBusAbstractInterface::initTestCase()
QDBusConnection con = QDBusConnection::sessionBus();
QVERIFY(con.isConnected());
con.registerObject("/", &targetObj, QDBusConnection::ExportScriptableContents);
+
+ // start peer server
+ #ifdef Q_OS_WIN
+ proc.start("qpinger");
+ #else
+ proc.start("./qpinger/qpinger");
+ #endif
+ QVERIFY(proc.waitForStarted());
+
+ WaitForQPinger w;
+ QVERIFY(w.ok());
+ //QTest::qWait(2000);
+
+ // get peer server address
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "address");
+ QDBusMessage rpl = con.call(req);
+ QVERIFY(rpl.type() == QDBusMessage::ReplyMessage);
+ QString address = rpl.arguments().at(0).toString();
+
+ // connect to peer server
+ QDBusConnection peercon = QDBusConnection::connectToPeer(address, "peer");
+ QVERIFY(peercon.isConnected());
+
+ QDBusMessage req2 = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "isConnected");
+ QDBusMessage rpl2 = con.call(req2);
+ QVERIFY(rpl2.type() == QDBusMessage::ReplyMessage);
+ QVERIFY(rpl2.arguments().at(0).toBool());
+}
+
+void tst_QDBusAbstractInterface::cleanupTestCase()
+{
+ proc.close();
+ proc.kill();
}
void tst_QDBusAbstractInterface::makeVoidCall()
@@ -184,6 +320,49 @@ void tst_QDBusAbstractInterface::makeMultiOutCall()
QCOMPARE(value, expectedValue);
}
+void tst_QDBusAbstractInterface::makeVoidCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusReply<void> r = p->voidMethod();
+ QVERIFY(r.isValid());
+}
+
+void tst_QDBusAbstractInterface::makeStringCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusReply<QString> r = p->stringMethod();
+ QVERIFY(r.isValid());
+ QCOMPARE(r.value(), targetObj.stringMethod());
+}
+
+void tst_QDBusAbstractInterface::makeComplexCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusReply<RegisteredType> r = p->complexMethod();
+ QVERIFY(r.isValid());
+ QCOMPARE(r.value(), targetObj.complexMethod());
+}
+
+void tst_QDBusAbstractInterface::makeMultiOutCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ int value;
+ QDBusReply<QString> r = p->multiOutMethod(value);
+ QVERIFY(r.isValid());
+
+ int expectedValue;
+ QCOMPARE(r.value(), targetObj.multiOutMethod(expectedValue));
+ QCOMPARE(value, expectedValue);
+}
+
void tst_QDBusAbstractInterface::makeAsyncVoidCall()
{
Pinger p = getPinger();
@@ -230,6 +409,55 @@ void tst_QDBusAbstractInterface::makeAsyncMultiOutCall()
QCOMPARE(r.argumentAt<1>(), expectedValue);
}
+void tst_QDBusAbstractInterface::makeAsyncVoidCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusPendingReply<void> r = p->voidMethod();
+ r.waitForFinished();
+ QVERIFY(r.isValid());
+}
+void tst_QDBusAbstractInterface::makeAsyncStringCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusMessage reply = p->call(QDBus::BlockWithGui, QLatin1String("voidMethod"));
+ QVERIFY(reply.type() == QDBusMessage::ReplyMessage);
+
+ QDBusPendingReply<QString> r = p->stringMethod();
+ r.waitForFinished();
+ QVERIFY(r.isValid());
+ QCOMPARE(r.value(), targetObj.stringMethod());
+}
+
+void tst_QDBusAbstractInterface::makeAsyncComplexCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusPendingReply<RegisteredType> r = p->complexMethod();
+ r.waitForFinished();
+ QVERIFY(r.isValid());
+ QCOMPARE(r.value(), targetObj.complexMethod());
+}
+
+void tst_QDBusAbstractInterface::makeAsyncMultiOutCallPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusPendingReply<QString, int> r = p->multiOutMethod();
+ r.waitForFinished();
+ QVERIFY(r.isValid());
+
+ int expectedValue;
+ QCOMPARE(r.value(), targetObj.multiOutMethod(expectedValue));
+ QCOMPARE(r.argumentAt<1>(), expectedValue);
+ QCoreApplication::instance()->processEvents();
+}
+
void tst_QDBusAbstractInterface::stringPropRead()
{
Pinger p = getPinger();
@@ -295,6 +523,77 @@ void tst_QDBusAbstractInterface::complexPropWrite()
QCOMPARE(targetObj.m_complexProp, expectedValue);
}
+void tst_QDBusAbstractInterface::stringPropReadPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QString expectedValue = "This is a test";
+ QVariant v = p->property("stringProp");
+ QVERIFY(v.isValid());
+ QCOMPARE(v.toString(), expectedValue);
+}
+
+void tst_QDBusAbstractInterface::stringPropWritePeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QString expectedValue = "This is a value";
+ QVERIFY(p->setProperty("stringProp", expectedValue));
+ QCOMPARE(targetObj.m_stringProp, expectedValue);
+}
+
+void tst_QDBusAbstractInterface::variantPropReadPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QDBusVariant expectedValue = QDBusVariant(QVariant(42));
+ QVariant v = p->property("variantProp");
+ QVERIFY(v.isValid());
+ QDBusVariant value = v.value<QDBusVariant>();
+ QCOMPARE(value.variant().userType(), expectedValue.variant().userType());
+ QCOMPARE(value.variant(), expectedValue.variant());
+}
+
+void tst_QDBusAbstractInterface::variantPropWritePeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47));
+ QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue)));
+ QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant());
+}
+
+void tst_QDBusAbstractInterface::complexPropReadPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ RegisteredType expectedValue = RegisteredType("This is a test");
+ QVariant v = p->property("complexProp");
+ QVERIFY(v.userType() == qMetaTypeId<RegisteredType>());
+ QCOMPARE(v.value<RegisteredType>(), expectedValue);
+}
+
+void tst_QDBusAbstractInterface::complexPropWritePeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ RegisteredType expectedValue = RegisteredType("This is a value");
+ QVERIFY(p->setProperty("complexProp", qVariantFromValue(expectedValue)));
+ QCOMPARE(targetObj.m_complexProp, expectedValue);
+}
+
void tst_QDBusAbstractInterface::stringPropDirectRead()
{
Pinger p = getPinger();
@@ -353,6 +652,70 @@ void tst_QDBusAbstractInterface::complexPropDirectWrite()
QCOMPARE(targetObj.m_complexProp, expectedValue);
}
+void tst_QDBusAbstractInterface::stringPropDirectReadPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QString expectedValue = "This is a test";
+ QCOMPARE(p->stringProp(), expectedValue);
+}
+
+void tst_QDBusAbstractInterface::stringPropDirectWritePeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QString expectedValue = "This is a value";
+ p->setStringProp(expectedValue);
+ QCOMPARE(targetObj.m_stringProp, expectedValue);
+}
+
+void tst_QDBusAbstractInterface::variantPropDirectReadPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QDBusVariant expectedValue = QDBusVariant(42);
+ QCOMPARE(p->variantProp().variant(), expectedValue.variant());
+}
+
+void tst_QDBusAbstractInterface::variantPropDirectWritePeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47));
+ p->setVariantProp(expectedValue);
+ QCOMPARE(targetObj.m_variantProp.variant().userType(), expectedValue.variant().userType());
+ QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant());
+}
+
+void tst_QDBusAbstractInterface::complexPropDirectReadPeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ RegisteredType expectedValue = RegisteredType("This is a test");
+ QCOMPARE(p->complexProp(), expectedValue);
+}
+
+void tst_QDBusAbstractInterface::complexPropDirectWritePeer()
+{
+ Pinger p = getPingerPeer();
+ QVERIFY2(p, "Not connected to D-Bus");
+ resetServer();
+
+ RegisteredType expectedValue = RegisteredType("This is a value");
+ p->setComplexProp(expectedValue);
+ QCOMPARE(targetObj.m_complexProp, expectedValue);
+}
+
void tst_QDBusAbstractInterface::getVoidSignal_data()
{
QTest::addColumn<QString>("service");
@@ -437,6 +800,89 @@ void tst_QDBusAbstractInterface::getComplexSignal()
QCOMPARE(s[0][0].value<RegisteredType>(), expectedValue);
}
+void tst_QDBusAbstractInterface::getVoidSignalPeer_data()
+{
+ QTest::addColumn<QString>("path");
+
+ QTest::newRow("specific") << "/";
+ QTest::newRow("wildcard") << QString();
+}
+
+void tst_QDBusAbstractInterface::getVoidSignalPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we need to connect the signal somewhere in order for D-Bus to enable the rules
+ QTestEventLoop::instance().connect(p.data(), SIGNAL(voidSignal()), SLOT(exitLoop()));
+ QSignalSpy s(p.data(), SIGNAL(voidSignal()));
+
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "voidSignal");
+ QVERIFY(QDBusConnection::sessionBus().send(req));
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QVERIFY(s.size() == 1);
+ QVERIFY(s.at(0).size() == 0);
+}
+
+void tst_QDBusAbstractInterface::getStringSignalPeer_data()
+{
+ getVoidSignalPeer_data();
+}
+
+void tst_QDBusAbstractInterface::getStringSignalPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we need to connect the signal somewhere in order for D-Bus to enable the rules
+ QTestEventLoop::instance().connect(p.data(), SIGNAL(stringSignal(QString)), SLOT(exitLoop()));
+ QSignalSpy s(p.data(), SIGNAL(stringSignal(QString)));
+
+ QString expectedValue = "Good morning";
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "stringSignal");
+ req << expectedValue;
+ QVERIFY(QDBusConnection::sessionBus().send(req));
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QVERIFY(s.size() == 1);
+ QVERIFY(s[0].size() == 1);
+ QCOMPARE(s[0][0].userType(), int(QVariant::String));
+ QCOMPARE(s[0][0].toString(), expectedValue);
+}
+
+void tst_QDBusAbstractInterface::getComplexSignalPeer_data()
+{
+ getVoidSignalPeer_data();
+}
+
+void tst_QDBusAbstractInterface::getComplexSignalPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we need to connect the signal somewhere in order for D-Bus to enable the rules
+ QTestEventLoop::instance().connect(p.data(), SIGNAL(complexSignal(RegisteredType)), SLOT(exitLoop()));
+ QSignalSpy s(p.data(), SIGNAL(complexSignal(RegisteredType)));
+
+ RegisteredType expectedValue("Good evening");
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "complexSignal");
+ req << "Good evening";
+ QVERIFY(QDBusConnection::sessionBus().send(req));
+ QTestEventLoop::instance().enterLoop(2);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QVERIFY(s.size() == 1);
+ QVERIFY(s[0].size() == 1);
+ QCOMPARE(s[0][0].userType(), qMetaTypeId<RegisteredType>());
+ QCOMPARE(s[0][0].value<RegisteredType>(), expectedValue);
+}
+
void tst_QDBusAbstractInterface::followSignal()
{
const QString serviceToFollow = "com.trolltech.tst_qdbusabstractinterface.FollowMe";
@@ -514,6 +960,24 @@ void tst_QDBusAbstractInterface::createErrors()
QTEST(p->lastError().name(), "errorName");
}
+void tst_QDBusAbstractInterface::createErrorsPeer_data()
+{
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<QString>("errorName");
+
+ QTest::newRow("invalid-path") << "this isn't valid" << "com.trolltech.QtDBus.Error.InvalidObjectPath";
+}
+
+void tst_QDBusAbstractInterface::createErrorsPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QVERIFY(!p->isValid());
+ QTEST(p->lastError().name(), "errorName");
+}
+
void tst_QDBusAbstractInterface::callErrors_data()
{
createErrors_data();
@@ -556,6 +1020,43 @@ void tst_QDBusAbstractInterface::asyncCallErrors()
QCOMPARE(p->lastError().name(), r.error().name());
}
+void tst_QDBusAbstractInterface::callErrorsPeer_data()
+{
+ createErrorsPeer_data();
+ QTest::newRow("path-wildcard") << QString() << "com.trolltech.QtDBus.Error.InvalidObjectPath";
+}
+
+void tst_QDBusAbstractInterface::callErrorsPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we shouldn't be able to make this call:
+ QDBusReply<QString> r = p->stringMethod();
+ QVERIFY(!r.isValid());
+ QTEST(r.error().name(), "errorName");
+ QCOMPARE(p->lastError().name(), r.error().name());
+}
+
+void tst_QDBusAbstractInterface::asyncCallErrorsPeer_data()
+{
+ callErrorsPeer_data();
+}
+
+void tst_QDBusAbstractInterface::asyncCallErrorsPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we shouldn't be able to make this call:
+ QDBusPendingReply<QString> r = p->stringMethod();
+ QVERIFY(r.isError());
+ QTEST(r.error().name(), "errorName");
+ QCOMPARE(p->lastError().name(), r.error().name());
+}
+
void tst_QDBusAbstractInterface::propertyReadErrors_data()
{
callErrors_data();
@@ -632,5 +1133,77 @@ void tst_QDBusAbstractInterface::directPropertyWriteErrors()
QTEST(p->lastError().name(), "errorName");
}
+void tst_QDBusAbstractInterface::propertyReadErrorsPeer_data()
+{
+ callErrorsPeer_data();
+}
+
+void tst_QDBusAbstractInterface::propertyReadErrorsPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we shouldn't be able to get this value:
+ QVariant v = p->property("stringProp");
+ QVERIFY(v.isNull());
+ QVERIFY(!v.isValid());
+ QTEST(p->lastError().name(), "errorName");
+}
+
+void tst_QDBusAbstractInterface::propertyWriteErrorsPeer_data()
+{
+ callErrorsPeer_data();
+}
+
+void tst_QDBusAbstractInterface::propertyWriteErrorsPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we shouldn't be able to get this value:
+ if (p->isValid())
+ QCOMPARE(int(p->lastError().type()), int(QDBusError::NoError));
+ QVERIFY(!p->setProperty("stringProp", ""));
+ QTEST(p->lastError().name(), "errorName");
+}
+
+void tst_QDBusAbstractInterface::directPropertyReadErrorsPeer_data()
+{
+ callErrorsPeer_data();
+}
+
+void tst_QDBusAbstractInterface::directPropertyReadErrorsPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we shouldn't be able to get this value:
+ QString v = p->stringProp();
+ QVERIFY(v.isNull());
+ QTEST(p->lastError().name(), "errorName");
+}
+
+void tst_QDBusAbstractInterface::directPropertyWriteErrorsPeer_data()
+{
+ callErrorsPeer_data();
+}
+
+void tst_QDBusAbstractInterface::directPropertyWriteErrorsPeer()
+{
+ QFETCH(QString, path);
+ Pinger p = getPingerPeer(path);
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ // we shouldn't be able to get this value:
+ // but there's no direct way of verifying that the setting failed
+ if (p->isValid())
+ QCOMPARE(int(p->lastError().type()), int(QDBusError::NoError));
+ p->setStringProp("");
+ QTEST(p->lastError().name(), "errorName");
+}
+
QTEST_MAIN(tst_QDBusAbstractInterface)
#include "tst_qdbusabstractinterface.moc"
diff --git a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp
index 8e3a44b08b..d4a9dabdc4 100644
--- a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp
+++ b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp
@@ -86,6 +86,7 @@ public slots:
private slots:
void noConnection();
void connectToBus();
+ void connectToPeer();
void connect();
void send();
void sendWithGui();
@@ -94,9 +95,13 @@ private slots:
void registerObject_data();
void registerObject();
+ void registerObjectPeer_data();
+ void registerObjectPeer();
void registerObject2();
+ void registerObjectPeer2();
void registerQObjectChildren();
+ void registerQObjectChildrenPeer();
void callSelf();
void callSelfByAnotherName_data();
@@ -111,6 +116,7 @@ private slots:
public:
QString serviceName() const { return "com.trolltech.Qt.Autotests.QDBusConnection"; }
bool callMethod(const QDBusConnection &conn, const QString &path);
+ bool callMethodPeer(const QDBusConnection &conn, const QString &path);
};
class QDBusSpy: public QObject
@@ -259,6 +265,14 @@ void tst_QDBusConnection::connectToBus()
QVERIFY(!con.lastError().isValid());
}
+ QDBusConnection::disconnectFromPeer("bubu");
+
+ {
+ QDBusConnection con("bubu");
+ QVERIFY(con.isConnected());
+ QVERIFY(!con.lastError().isValid());
+ }
+
QDBusConnection::disconnectFromBus("bubu");
{
@@ -277,6 +291,65 @@ void tst_QDBusConnection::connectToBus()
}
}
+void tst_QDBusConnection::connectToPeer()
+{
+ {
+ QDBusConnection con = QDBusConnection::connectToPeer(
+ "", "newconn");
+ QVERIFY(!con.isConnected());
+ QVERIFY(con.lastError().isValid());
+ }
+
+ QDBusServer server("unix:tmpdir=/tmp", 0);
+
+ {
+ QDBusConnection con = QDBusConnection::connectToPeer(
+ "unix:abstract=/tmp/dbus-XXXXXXXXXX,guid=00000000000000000000000000000000", "newconn2");
+ QVERIFY(!con.isConnected());
+ QVERIFY(con.lastError().isValid());
+ }
+
+ {
+ QDBusConnection con = QDBusConnection::connectToPeer(
+ server.address(), "bubu");
+
+ QVERIFY(con.isConnected());
+ QVERIFY(!con.lastError().isValid());
+
+ QDBusConnection con2("foo");
+ QVERIFY(!con2.isConnected());
+ QVERIFY(!con2.lastError().isValid());
+
+ con2 = con;
+ QVERIFY(con.isConnected());
+ QVERIFY(con2.isConnected());
+ QVERIFY(!con.lastError().isValid());
+ QVERIFY(!con2.lastError().isValid());
+ }
+
+ {
+ QDBusConnection con("bubu");
+ QVERIFY(con.isConnected());
+ QVERIFY(!con.lastError().isValid());
+ }
+
+ QDBusConnection::disconnectFromBus("bubu");
+
+ {
+ QDBusConnection con("bubu");
+ QVERIFY(con.isConnected());
+ QVERIFY(!con.lastError().isValid());
+ }
+
+ QDBusConnection::disconnectFromPeer("bubu");
+
+ {
+ QDBusConnection con("bubu");
+ QVERIFY(!con.isConnected());
+ QVERIFY(!con.lastError().isValid());
+ }
+}
+
void tst_QDBusConnection::registerObject_data()
{
QTest::addColumn<QString>("path");
@@ -308,6 +381,106 @@ void tst_QDBusConnection::registerObject()
QVERIFY(!callMethod(con, path));
}
+class MyServer : public QDBusServer
+{
+ Q_OBJECT
+public:
+ MyServer(QString path, QString addr, QObject* parent) : QDBusServer(addr, parent),
+ m_path(path),
+ m_conn("none")
+ {
+ connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&)));
+ }
+
+ bool registerObject()
+ {
+ if( !m_conn.registerObject(m_path, &m_obj, QDBusConnection::ExportAllSlots) )
+ return false;
+ if(! (m_conn.objectRegisteredAt(m_path) == &m_obj))
+ return false;
+ return true;
+ }
+
+ void unregisterObject()
+ {
+ m_conn.unregisterObject(m_path);
+ }
+
+public slots:
+ void handleConnection(const QDBusConnection& c)
+ {
+ m_conn = c;
+ QVERIFY(isConnected());
+ QVERIFY(m_conn.isConnected());
+ QVERIFY(registerObject());
+ }
+
+private:
+ MyObject m_obj;
+ QString m_path;
+ QDBusConnection m_conn;
+};
+
+
+void tst_QDBusConnection::registerObjectPeer_data()
+{
+ QTest::addColumn<QString>("path");
+
+ QTest::newRow("/") << "/";
+ QTest::newRow("/p1") << "/p1";
+ QTest::newRow("/p2") << "/p2";
+ QTest::newRow("/p1/q") << "/p1/q";
+ QTest::newRow("/p1/q/r") << "/p1/q/r";
+}
+
+void tst_QDBusConnection::registerObjectPeer()
+{
+ QFETCH(QString, path);
+
+ MyServer server(path, "unix:tmpdir=/tmp", 0);
+
+ {
+ QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo");
+
+ QCoreApplication::processEvents();
+ QVERIFY(con.isConnected());
+
+ MyObject obj;
+ QVERIFY(callMethodPeer(con, path));
+ QCOMPARE(obj.path, path);
+ }
+
+ {
+ QDBusConnection con("foo");
+ QVERIFY(con.isConnected());
+ QVERIFY(callMethodPeer(con, path));
+ }
+
+ server.unregisterObject();
+
+ {
+ QDBusConnection con("foo");
+ QVERIFY(con.isConnected());
+ QVERIFY(!callMethodPeer(con, path));
+ }
+
+ server.registerObject();
+
+ {
+ QDBusConnection con("foo");
+ QVERIFY(con.isConnected());
+ QVERIFY(callMethodPeer(con, path));
+ }
+
+ QDBusConnection::disconnectFromPeer("foo");
+
+ {
+ QDBusConnection con("foo");
+ QVERIFY(!con.isConnected());
+ QVERIFY(!callMethodPeer(con, path));
+ }
+}
+
void tst_QDBusConnection::registerObject2()
{
QDBusConnection con = QDBusConnection::sessionBus();
@@ -401,6 +574,134 @@ void tst_QDBusConnection::registerObject2()
}
}
+class MyServer2 : public QDBusServer
+{
+ Q_OBJECT
+public:
+ MyServer2(QString addr, QObject* parent) : QDBusServer(addr, parent),
+ m_conn("none")
+ {
+ connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&)));
+ }
+
+ QDBusConnection connection()
+ {
+ return m_conn;
+ }
+
+public slots:
+ void handleConnection(const QDBusConnection& c)
+ {
+ m_conn = c;
+ QVERIFY(isConnected());
+ QVERIFY(m_conn.isConnected());
+ }
+
+private:
+ MyObject m_obj;
+ QDBusConnection m_conn;
+};
+
+void tst_QDBusConnection::registerObjectPeer2()
+{
+ MyServer2 server("unix:tmpdir=/tmp", 0);
+ QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo");
+ QCoreApplication::processEvents();
+ QVERIFY(con.isConnected());
+
+ QDBusConnection srv_con = server.connection();
+
+ // make sure nothing is using our paths:
+ QVERIFY(!callMethodPeer(srv_con, "/"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY(!callMethodPeer(srv_con, "/p2"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/q"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/q/r"));
+
+ {
+ // register one object at root:
+ MyObject obj;
+ QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots));
+ QVERIFY(callMethodPeer(srv_con, "/"));
+ qDebug() << obj.path;
+ QCOMPARE(obj.path, QString("/"));
+ }
+ // make sure it's gone
+ QVERIFY(!callMethodPeer(srv_con, "/"));
+
+ {
+ // register one at an element:
+ MyObject obj;
+ QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots));
+ QVERIFY(!callMethodPeer(srv_con, "/"));
+ QVERIFY(callMethodPeer(srv_con, "/p1"));
+ qDebug() << obj.path;
+ QCOMPARE(obj.path, QString("/p1"));
+
+ // re-register it somewhere else
+ QVERIFY(con.registerObject("/p2", &obj, QDBusConnection::ExportAllSlots));
+ QVERIFY(callMethodPeer(srv_con, "/p1"));
+ QCOMPARE(obj.path, QString("/p1"));
+ QVERIFY(callMethodPeer(srv_con, "/p2"));
+ QCOMPARE(obj.path, QString("/p2"));
+ }
+ // make sure it's gone
+ QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY(!callMethodPeer(srv_con, "/p2"));
+
+ {
+ // register at a deep path
+ MyObject obj;
+ QVERIFY(con.registerObject("/p1/q/r", &obj, QDBusConnection::ExportAllSlots));
+ QVERIFY(!callMethodPeer(srv_con, "/"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/q"));
+ QVERIFY(callMethodPeer(srv_con, "/p1/q/r"));
+ QCOMPARE(obj.path, QString("/p1/q/r"));
+ }
+ // make sure it's gone
+ QVERIFY(!callMethodPeer(srv_con, "/p1/q/r"));
+
+ {
+ MyObject obj;
+ QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots));
+ QVERIFY(callMethodPeer(srv_con, "/p1/q2"));
+ QCOMPARE(obj.path, QString("/p1/q2"));
+
+ // try unregistering
+ con.unregisterObject("/p1/q2");
+ QVERIFY(!callMethodPeer(srv_con, "/p1/q2"));
+
+ // register it again
+ QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots));
+ QVERIFY(callMethodPeer(srv_con, "/p1/q2"));
+ QCOMPARE(obj.path, QString("/p1/q2"));
+
+ // now try removing things around it:
+ con.unregisterObject("/p2");
+ QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unrelated object shouldn't affect
+
+ con.unregisterObject("/p1");
+ QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering just the parent shouldn't affect it
+
+ con.unregisterObject("/p1/q2/r");
+ QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering non-existing child shouldn't affect it either
+
+ con.unregisterObject("/p1/q");
+ QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (before) shouldn't affect
+
+ con.unregisterObject("/p1/r");
+ QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (after) shouldn't affect
+
+ // now remove it:
+ con.unregisterObject("/p1", QDBusConnection::UnregisterTree);
+ QVERIFY(!callMethodPeer(srv_con, "/p1/q2")); // we removed the full tree
+ }
+
+ QDBusConnection::disconnectFromPeer("foo");
+}
+
+
void tst_QDBusConnection::registerQObjectChildren()
{
// make sure no one is there
@@ -456,6 +757,68 @@ void tst_QDBusConnection::registerQObjectChildren()
QVERIFY(!callMethod(con, "/p1/c/cc"));
}
+void tst_QDBusConnection::registerQObjectChildrenPeer()
+{
+ MyServer2 server("unix:tmpdir=/tmp", 0);
+ QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo");
+ QCoreApplication::processEvents();
+ QVERIFY(con.isConnected());
+
+ QDBusConnection srv_con = server.connection();
+
+ QVERIFY(!callMethodPeer(srv_con, "/p1"));
+
+ {
+ MyObject obj, *a, *b, *c, *cc;
+
+ a = new MyObject(&obj);
+ a->setObjectName("a");
+
+ b = new MyObject(&obj);
+ b->setObjectName("b");
+
+ c = new MyObject(&obj);
+ c->setObjectName("c");
+
+ cc = new MyObject(c);
+ cc->setObjectName("cc");
+
+ con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots |
+ QDBusConnection::ExportChildObjects);
+
+ // make calls
+ QVERIFY(callMethodPeer(srv_con, "/p1"));
+ QCOMPARE(obj.callCount, 1);
+ QVERIFY(callMethodPeer(srv_con, "/p1/a"));
+ QCOMPARE(a->callCount, 1);
+ QVERIFY(callMethodPeer(srv_con, "/p1/b"));
+ QCOMPARE(b->callCount, 1);
+ QVERIFY(callMethodPeer(srv_con, "/p1/c"));
+ QCOMPARE(c->callCount, 1);
+ QVERIFY(callMethodPeer(srv_con, "/p1/c/cc"));
+ QCOMPARE(cc->callCount, 1);
+
+ QVERIFY(!callMethodPeer(srv_con, "/p1/d"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/c/abc"));
+
+ // pull an object, see if it goes away:
+ delete b;
+ QVERIFY(!callMethodPeer(srv_con, "/p1/b"));
+
+ delete c;
+ QVERIFY(!callMethodPeer(srv_con, "/p1/c"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc"));
+ }
+
+ QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/a"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/b"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/c"));
+ QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc"));
+
+ QDBusConnection::disconnectFromPeer("foo");
+}
+
bool tst_QDBusConnection::callMethod(const QDBusConnection &conn, const QString &path)
{
QDBusMessage msg = QDBusMessage::createMethodCall(conn.baseService(), path, "", "method");
@@ -475,6 +838,25 @@ bool tst_QDBusConnection::callMethod(const QDBusConnection &conn, const QString
return true;
}
+bool tst_QDBusConnection::callMethodPeer(const QDBusConnection &conn, const QString &path)
+{
+ QDBusMessage msg = QDBusMessage::createMethodCall("", path, "", "method");
+ QDBusMessage reply = conn.call(msg, QDBus::BlockWithGui);
+
+ if (reply.type() != QDBusMessage::ReplyMessage)
+ return false;
+ if (MyObject::path == path) {
+ QTest::compare_helper(true, "COMPARE()", __FILE__, __LINE__);
+ } else {
+ QTest::compare_helper(false, "Compared values are not the same",
+ QTest::toString(MyObject::path), QTest::toString(path),
+ "MyObject::path", "path", __FILE__, __LINE__);
+ return false;
+ }
+
+ return true;
+}
+
class TestObject : public QObject
{
Q_OBJECT
diff --git a/tests/auto/qdbusinterface/myobject.h b/tests/auto/qdbusinterface/myobject.h
new file mode 100644
index 0000000000..68b8d1a485
--- /dev/null
+++ b/tests/auto/qdbusinterface/myobject.h
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYOBJECT_H
+#define MYOBJECT_H
+
+#include <QtCore/QObject>
+#include <QtDBus/QtDBus>
+
+Q_DECLARE_METATYPE(QVariantList)
+
+class MyObject: public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "com.trolltech.QtDBus.MyObject")
+ Q_CLASSINFO("D-Bus Introspection", ""
+" <interface name=\"com.trolltech.QtDBus.MyObject\" >\n"
+" <property access=\"readwrite\" type=\"i\" name=\"prop1\" />\n"
+" <property name=\"complexProp\" type=\"ai\" access=\"readwrite\">\n"
+" <annotation name=\"com.trolltech.QtDBus.QtTypeName\" value=\"QList&lt;int&gt;\"/>\n"
+" </property>\n"
+" <signal name=\"somethingHappened\" >\n"
+" <arg direction=\"out\" type=\"s\" />\n"
+" </signal>\n"
+" <method name=\"ping\" >\n"
+" <arg direction=\"in\" type=\"v\" name=\"ping\" />\n"
+" <arg direction=\"out\" type=\"v\" name=\"ping\" />\n"
+" </method>\n"
+" <method name=\"ping_invokable\" >\n"
+" <arg direction=\"in\" type=\"v\" name=\"ping_invokable\" />\n"
+" <arg direction=\"out\" type=\"v\" name=\"ping_invokable\" />\n"
+" </method>\n"
+" <method name=\"ping\" >\n"
+" <arg direction=\"in\" type=\"v\" name=\"ping1\" />\n"
+" <arg direction=\"in\" type=\"v\" name=\"ping2\" />\n"
+" <arg direction=\"out\" type=\"v\" name=\"pong1\" />\n"
+" <arg direction=\"out\" type=\"v\" name=\"pong2\" />\n"
+" </method>\n"
+" <method name=\"ping_invokable\" >\n"
+" <arg direction=\"in\" type=\"v\" name=\"ping1_invokable\" />\n"
+" <arg direction=\"in\" type=\"v\" name=\"ping2_invokable\" />\n"
+" <arg direction=\"out\" type=\"v\" name=\"pong1_invokable\" />\n"
+" <arg direction=\"out\" type=\"v\" name=\"pong2_invokable\" />\n"
+" </method>\n"
+" <method name=\"ping\" >\n"
+" <arg direction=\"in\" type=\"ai\" name=\"ping\" />\n"
+" <arg direction=\"out\" type=\"ai\" name=\"ping\" />\n"
+" <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList&lt;int&gt;\"/>\n"
+" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList&lt;int&gt;\"/>\n"
+" </method>\n"
+" <method name=\"ping_invokable\" >\n"
+" <arg direction=\"in\" type=\"ai\" name=\"ping_invokable\" />\n"
+" <arg direction=\"out\" type=\"ai\" name=\"ping_invokable\" />\n"
+" <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList&lt;int&gt;\"/>\n"
+" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList&lt;int&gt;\"/>\n"
+" </method>\n"
+" </interface>\n"
+ "")
+ Q_PROPERTY(int prop1 READ prop1 WRITE setProp1)
+ Q_PROPERTY(QList<int> complexProp READ complexProp WRITE setComplexProp)
+
+public:
+ static int callCount;
+ static QVariantList callArgs;
+ MyObject()
+ {
+ QObject *subObject = new QObject(this);
+ subObject->setObjectName("subObject");
+ }
+
+ int m_prop1;
+ int prop1() const
+ {
+ ++callCount;
+ return m_prop1;
+ }
+ void setProp1(int value)
+ {
+ ++callCount;
+ m_prop1 = value;
+ }
+
+ QList<int> m_complexProp;
+ QList<int> complexProp() const
+ {
+ ++callCount;
+ return m_complexProp;
+ }
+ void setComplexProp(const QList<int> &value)
+ {
+ ++callCount;
+ m_complexProp = value;
+ }
+
+ Q_INVOKABLE void ping_invokable(QDBusMessage msg)
+ {
+ QDBusConnection sender = QDBusConnection::sender();
+ if (!sender.isConnected())
+ exit(1);
+
+ ++callCount;
+ callArgs = msg.arguments();
+
+ msg.setDelayedReply(true);
+ if (!sender.send(msg.createReply(callArgs)))
+ exit(1);
+ }
+
+public slots:
+
+ void ping(QDBusMessage msg)
+ {
+ QDBusConnection sender = QDBusConnection::sender();
+ if (!sender.isConnected())
+ exit(1);
+
+ ++callCount;
+ callArgs = msg.arguments();
+
+ msg.setDelayedReply(true);
+ if (!sender.send(msg.createReply(callArgs)))
+ exit(1);
+ }
+};
+
+#endif // INTERFACE_H
diff --git a/tests/auto/qdbusinterface/qdbusinterface.pro b/tests/auto/qdbusinterface/qdbusinterface.pro
index ac14ab7e37..0aca06ceb4 100644
--- a/tests/auto/qdbusinterface/qdbusinterface.pro
+++ b/tests/auto/qdbusinterface/qdbusinterface.pro
@@ -1,10 +1,11 @@
load(qttest_p4)
QT = core
contains(QT_CONFIG,dbus): {
- SOURCES += tst_qdbusinterface.cpp
- QT += dbus
+ TEMPLATE = subdirs
+ CONFIG += ordered
+ SUBDIRS = qmyserver test
} else {
- SOURCES += ../qdbusmarshall/dummy.cpp
+ SOURCES += ../qdbusmarshall/dummy.cpp
}
diff --git a/tests/auto/qdbusinterface/qmyserver/qmyserver.cpp b/tests/auto/qdbusinterface/qmyserver/qmyserver.cpp
new file mode 100644
index 0000000000..c68f7bfc5f
--- /dev/null
+++ b/tests/auto/qdbusinterface/qmyserver/qmyserver.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/QtCore>
+#include <QtDBus/QtDBus>
+
+#include "../myobject.h"
+
+static const char serviceName[] = "com.trolltech.autotests.qmyserver";
+static const char objectPath[] = "/com/trolltech/qmyserver";
+//static const char *interfaceName = serviceName;
+
+int MyObject::callCount = 0;
+QVariantList MyObject::callArgs;
+
+class MyServer : public QDBusServer
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "com.trolltech.autotests.qmyserver")
+
+public:
+ MyServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0)
+ : QDBusServer(addr, parent),
+ m_conn("none")
+ {
+ connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&)));
+ }
+
+public slots:
+ QString address() const
+ {
+ return QDBusServer::address();
+ }
+
+ bool isConnected() const
+ {
+ return m_conn.isConnected();
+ }
+
+ void emitSignal(const QString &interface, const QString &name, const QString &arg)
+ {
+ QDBusMessage msg = QDBusMessage::createSignal("/", interface, name);
+ msg << arg;
+ m_conn.send(msg);
+ }
+
+ void reset()
+ {
+ MyObject::callCount = 0;
+ obj.m_complexProp.clear();
+ }
+
+ int callCount()
+ {
+ return MyObject::callCount;
+ }
+
+ QVariantList callArgs()
+ {
+ qDebug() << "callArgs" << MyObject::callArgs.count();
+ return MyObject::callArgs;
+ }
+
+ void setProp1(int val)
+ {
+ obj.m_prop1 = val;
+ }
+
+ int prop1()
+ {
+ return obj.m_prop1;
+ }
+
+ void setComplexProp(QList<int> val)
+ {
+ obj.m_complexProp = val;
+ }
+
+ QList<int> complexProp()
+ {
+ return obj.m_complexProp;
+ }
+
+
+private slots:
+ void handleConnection(const QDBusConnection& con)
+ {
+ m_conn = con;
+ m_conn.registerObject("/", &obj, QDBusConnection::ExportAllProperties
+ | QDBusConnection::ExportAllSlots
+ | QDBusConnection::ExportAllInvokables);
+ }
+
+private:
+ QDBusConnection m_conn;
+ MyObject obj;
+};
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ QDBusConnection con = QDBusConnection::sessionBus();
+ if (!con.isConnected())
+ exit(1);
+
+ if (!con.registerService(serviceName))
+ exit(2);
+
+ MyServer server;
+ con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots);
+
+ printf("ready.\n");
+
+ return app.exec();
+}
+
+#include "qmyserver.moc" \ No newline at end of file
diff --git a/tests/auto/qdbusinterface/qmyserver/qmyserver.pro b/tests/auto/qdbusinterface/qmyserver/qmyserver.pro
new file mode 100644
index 0000000000..f4fe02c4eb
--- /dev/null
+++ b/tests/auto/qdbusinterface/qmyserver/qmyserver.pro
@@ -0,0 +1,5 @@
+SOURCES = qmyserver.cpp
+HEADERS = ../myobject.h
+TARGET = qmyserver
+QT += dbus
+QT -= gui
diff --git a/tests/auto/qdbusinterface/test/test.pro b/tests/auto/qdbusinterface/test/test.pro
new file mode 100644
index 0000000000..3252188b6e
--- /dev/null
+++ b/tests/auto/qdbusinterface/test/test.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+SOURCES += ../tst_qdbusinterface.cpp
+HEADERS += ../myobject.h
+TARGET = ../tst_qdbusinterface
+
+QT = core
+QT += dbus
diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
index 39f067740b..04b3d720b1 100644
--- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
+++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
/* -*- C++ -*-
*/
+
#include <qcoreapplication.h>
#include <qmetatype.h>
#include <QtTest/QtTest>
@@ -47,125 +48,15 @@
#include <QtDBus/QtDBus>
#include "../qdbusmarshall/common.h"
-
-Q_DECLARE_METATYPE(QVariantList)
+#include "myobject.h"
#define TEST_INTERFACE_NAME "com.trolltech.QtDBus.MyObject"
#define TEST_SIGNAL_NAME "somethingHappened"
-class MyObject: public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "com.trolltech.QtDBus.MyObject")
- Q_CLASSINFO("D-Bus Introspection", ""
-" <interface name=\"com.trolltech.QtDBus.MyObject\" >\n"
-" <property access=\"readwrite\" type=\"i\" name=\"prop1\" />\n"
-" <property name=\"complexProp\" type=\"ai\" access=\"readwrite\">\n"
-" <annotation name=\"com.trolltech.QtDBus.QtTypeName\" value=\"QList&lt;int&gt;\"/>\n"
-" </property>\n"
-" <signal name=\"somethingHappened\" >\n"
-" <arg direction=\"out\" type=\"s\" />\n"
-" </signal>\n"
-" <method name=\"ping\" >\n"
-" <arg direction=\"in\" type=\"v\" name=\"ping\" />\n"
-" <arg direction=\"out\" type=\"v\" name=\"ping\" />\n"
-" </method>\n"
-" <method name=\"ping_invokable\" >\n"
-" <arg direction=\"in\" type=\"v\" name=\"ping_invokable\" />\n"
-" <arg direction=\"out\" type=\"v\" name=\"ping_invokable\" />\n"
-" </method>\n"
-" <method name=\"ping\" >\n"
-" <arg direction=\"in\" type=\"v\" name=\"ping1\" />\n"
-" <arg direction=\"in\" type=\"v\" name=\"ping2\" />\n"
-" <arg direction=\"out\" type=\"v\" name=\"pong1\" />\n"
-" <arg direction=\"out\" type=\"v\" name=\"pong2\" />\n"
-" </method>\n"
-" <method name=\"ping_invokable\" >\n"
-" <arg direction=\"in\" type=\"v\" name=\"ping1_invokable\" />\n"
-" <arg direction=\"in\" type=\"v\" name=\"ping2_invokable\" />\n"
-" <arg direction=\"out\" type=\"v\" name=\"pong1_invokable\" />\n"
-" <arg direction=\"out\" type=\"v\" name=\"pong2_invokable\" />\n"
-" </method>\n"
-" <method name=\"ping\" >\n"
-" <arg direction=\"in\" type=\"ai\" name=\"ping\" />\n"
-" <arg direction=\"out\" type=\"ai\" name=\"ping\" />\n"
-" <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList&lt;int&gt;\"/>\n"
-" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList&lt;int&gt;\"/>\n"
-" </method>\n"
-" <method name=\"ping_invokable\" >\n"
-" <arg direction=\"in\" type=\"ai\" name=\"ping_invokable\" />\n"
-" <arg direction=\"out\" type=\"ai\" name=\"ping_invokable\" />\n"
-" <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList&lt;int&gt;\"/>\n"
-" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList&lt;int&gt;\"/>\n"
-" </method>\n"
-" </interface>\n"
- "")
- Q_PROPERTY(int prop1 READ prop1 WRITE setProp1)
- Q_PROPERTY(QList<int> complexProp READ complexProp WRITE setComplexProp)
-
-public:
- static int callCount;
- static QVariantList callArgs;
- MyObject()
- {
- QObject *subObject = new QObject(this);
- subObject->setObjectName("subObject");
- }
+static const char serviceName[] = "com.trolltech.autotests.qmyserver";
+static const char objectPath[] = "/com/trolltech/qmyserver";
+static const char *interfaceName = serviceName;
- int m_prop1;
- int prop1() const
- {
- ++callCount;
- return m_prop1;
- }
- void setProp1(int value)
- {
- ++callCount;
- m_prop1 = value;
- }
-
- QList<int> m_complexProp;
- QList<int> complexProp() const
- {
- ++callCount;
- return m_complexProp;
- }
- void setComplexProp(const QList<int> &value)
- {
- ++callCount;
- m_complexProp = value;
- }
-
- Q_INVOKABLE void ping_invokable(QDBusMessage msg)
- {
- QDBusConnection sender = QDBusConnection::sender();
- if (!sender.isConnected())
- exit(1);
-
- ++callCount;
- callArgs = msg.arguments();
-
- msg.setDelayedReply(true);
- if (!sender.send(msg.createReply(callArgs)))
- exit(1);
- }
-
-public slots:
-
- void ping(QDBusMessage msg)
- {
- QDBusConnection sender = QDBusConnection::sender();
- if (!sender.isConnected())
- exit(1);
-
- ++callCount;
- callArgs = msg.arguments();
-
- msg.setDelayedReply(true);
- if (!sender.send(msg.createReply(callArgs)))
- exit(1);
- }
-};
int MyObject::callCount = 0;
QVariantList MyObject::callArgs;
@@ -228,10 +119,70 @@ void emitSignal(const QString &interface, const QString &name, const QString &ar
QTest::qWait(1000);
}
+void emitSignalPeer(const QString &interface, const QString &name, const QString &arg)
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "emitSignal");
+ req << interface;
+ req << name;
+ req << arg;
+ QDBusConnection::sessionBus().send(req);
+
+ QTest::qWait(1000);
+}
+
+int callCountPeer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "callCount");
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+ return reply.arguments().at(0).toInt();
+}
+
+QVariantList callArgsPeer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "callArgs");
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+ return qdbus_cast<QVariantList>(reply.arguments().at(0));
+}
+
+void setProp1Peer(int val)
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "setProp1");
+ req << val;
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+}
+
+int prop1Peer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "prop1");
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+ return reply.arguments().at(0).toInt();
+}
+
+void setComplexPropPeer(QList<int> val)
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "setComplexProp");
+ req << qVariantFromValue(val);
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+}
+
+QList<int> complexPropPeer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "complexProp");
+ QDBusMessage reply = QDBusConnection::sessionBus().call(req);
+ return qdbus_cast<QList<int> >(reply.arguments().at(0));
+}
+
+void resetPeer()
+{
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "reset");
+ QDBusConnection::sessionBus().call(req);
+}
+
class tst_QDBusInterface: public QObject
{
Q_OBJECT
MyObject obj;
+
public slots:
void testServiceOwnerChanged(const QString &service)
{
@@ -241,6 +192,7 @@ public slots:
private slots:
void initTestCase();
+ void cleanupTestCase();
void notConnected();
void notValid();
@@ -254,14 +206,63 @@ private slots:
void invokeMethodWithMultiReturn();
void invokeMethodWithComplexReturn();
+ void introspectPeer();
+ void callMethodPeer();
+ void invokeMethodPeer();
+ void invokeMethodWithReturnPeer();
+ void invokeMethodWithMultiReturnPeer();
+ void invokeMethodWithComplexReturnPeer();
+
void signal();
+ void signalPeer();
void propertyRead();
void propertyWrite();
void complexPropertyRead();
void complexPropertyWrite();
+
+ void propertyReadPeer();
+ void propertyWritePeer();
+ void complexPropertyReadPeer();
+ void complexPropertyWritePeer();
+private:
+ QProcess proc;
};
+class WaitForQMyServer: public QObject
+{
+ Q_OBJECT
+public:
+ WaitForQMyServer();
+ bool ok();
+public Q_SLOTS:
+ void ownerChange(const QString &name)
+ {
+ if (name == serviceName)
+ loop.quit();
+ }
+
+private:
+ QEventLoop loop;
+};
+
+WaitForQMyServer::WaitForQMyServer()
+{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ if (!ok()) {
+ connect(con.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
+ SLOT(ownerChange(QString)));
+ QTimer::singleShot(2000, &loop, SLOT(quit()));
+ loop.exec();
+ }
+}
+
+bool WaitForQMyServer::ok()
+{
+ return QDBusConnection::sessionBus().isConnected() &&
+ QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName);
+}
+
void tst_QDBusInterface::initTestCase()
{
QDBusConnection con = QDBusConnection::sessionBus();
@@ -271,6 +272,39 @@ void tst_QDBusInterface::initTestCase()
con.registerObject("/", &obj, QDBusConnection::ExportAllProperties
| QDBusConnection::ExportAllSlots
| QDBusConnection::ExportAllInvokables);
+
+ // start peer server
+ #ifdef Q_OS_WIN
+ proc.start("qmyserver");
+ #else
+ proc.start("./qmyserver/qmyserver");
+ #endif
+ QVERIFY(proc.waitForStarted());
+
+ WaitForQMyServer w;
+ QVERIFY(w.ok());
+ //QTest::qWait(2000);
+
+ // get peer server address
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "address");
+ QDBusMessage rpl = con.call(req);
+ QVERIFY(rpl.type() == QDBusMessage::ReplyMessage);
+ QString address = rpl.arguments().at(0).toString();
+
+ // connect to peer server
+ QDBusConnection peercon = QDBusConnection::connectToPeer(address, "peer");
+ QVERIFY(peercon.isConnected());
+
+ QDBusMessage req2 = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "isConnected");
+ QDBusMessage rpl2 = con.call(req2);
+ QVERIFY(rpl2.type() == QDBusMessage::ReplyMessage);
+ QVERIFY(rpl2.arguments().at(0).toBool());
+}
+
+void tst_QDBusInterface::cleanupTestCase()
+{
+ proc.close();
+ proc.kill();
}
void tst_QDBusInterface::notConnected()
@@ -369,7 +403,7 @@ void tst_QDBusInterface::callMethod()
TEST_INTERFACE_NAME);
MyObject::callCount = 0;
-
+
// call a SLOT method
QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo")));
QCOMPARE(MyObject::callCount, 1);
@@ -388,7 +422,7 @@ void tst_QDBusInterface::callMethod()
dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().toString(), QString("foo"));
-
+
// call an INVOKABLE method
reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar")));
QCOMPARE(MyObject::callCount, 2);
@@ -416,7 +450,7 @@ void tst_QDBusInterface::invokeMethod()
TEST_INTERFACE_NAME);
MyObject::callCount = 0;
-
+
// make the SLOT call without a return type
QDBusVariant arg("foo");
QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_ARG(QDBusVariant, arg)));
@@ -428,7 +462,7 @@ void tst_QDBusInterface::invokeMethod()
QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
QCOMPARE(dv.variant().type(), QVariant::String);
QCOMPARE(dv.variant().toString(), QString("foo"));
-
+
// make the INVOKABLE call without a return type
QDBusVariant arg2("bar");
QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_ARG(QDBusVariant, arg2)));
@@ -465,7 +499,7 @@ void tst_QDBusInterface::invokeMethodWithReturn()
// verify that we got the reply as expected
QCOMPARE(retArg.variant(), arg.variant());
-
+
// make the INVOKABLE call without a return type
QDBusVariant arg2("bar");
QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg2)));
@@ -490,7 +524,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn()
MyObject::callCount = 0;
QDBusVariant retArg, retArg2;
-
+
// make the SLOT call without a return type
QDBusVariant arg("foo"), arg2("bar");
QVERIFY(QMetaObject::invokeMethod(&iface, "ping",
@@ -515,7 +549,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn()
// verify that we got the replies as expected
QCOMPARE(retArg.variant(), arg.variant());
QCOMPARE(retArg2.variant(), arg2.variant());
-
+
// make the INVOKABLE call without a return type
QDBusVariant arg3("hello"), arg4("world");
QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable",
@@ -550,7 +584,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn()
MyObject::callCount = 0;
QList<int> retArg;
-
+
// make the SLOT call without a return type
QList<int> arg = QList<int>() << 42 << -47;
QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg)));
@@ -564,7 +598,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn()
// verify that we got the reply as expected
QCOMPARE(retArg, arg);
-
+
// make the INVOKABLE call without a return type
QList<int> arg2 = QList<int>() << 24 << -74;
QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg2)));
@@ -580,6 +614,250 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn()
QCOMPARE(retArg, arg2);
}
+void tst_QDBusInterface::introspectPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ const QMetaObject *mo = iface.metaObject();
+
+ QCOMPARE(mo->methodCount() - mo->methodOffset(), 7);
+ QVERIFY(mo->indexOfSignal(TEST_SIGNAL_NAME "(QString)") != -1);
+
+ QCOMPARE(mo->propertyCount() - mo->propertyOffset(), 2);
+ QVERIFY(mo->indexOfProperty("prop1") != -1);
+ QVERIFY(mo->indexOfProperty("complexProp") != -1);
+}
+
+void tst_QDBusInterface::callMethodPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+
+ // call a SLOT method
+ QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo")));
+ QCOMPARE(callCountPeer(), 1);
+ QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
+
+ // verify what the callee received
+ QVariantList callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ QVariant v = callArgs.at(0);
+ QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), QString("foo"));
+
+ // verify reply
+ QCOMPARE(reply.arguments().count(), 1);
+ v = reply.arguments().at(0);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), QString("foo"));
+
+ // call an INVOKABLE method
+ reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar")));
+ QCOMPARE(callCountPeer(), 2);
+ QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
+
+ // verify what the callee received
+ callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ v = callArgs.at(0);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), QString("bar"));
+
+ // verify reply
+ QCOMPARE(reply.arguments().count(), 1);
+ v = reply.arguments().at(0);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), QString("bar"));
+}
+
+void tst_QDBusInterface::invokeMethodPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+
+ // make the SLOT call without a return type
+ QDBusVariant arg("foo");
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_ARG(QDBusVariant, arg)));
+ QCOMPARE(callCountPeer(), 1);
+
+ // verify what the callee received
+ QVariantList callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ QVariant v = callArgs.at(0);
+ QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), QString("foo"));
+
+ // make the INVOKABLE call without a return type
+ QDBusVariant arg2("bar");
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_ARG(QDBusVariant, arg2)));
+ QCOMPARE(callCountPeer(), 2);
+
+ // verify what the callee received
+ callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ v = callArgs.at(0);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), QString("bar"));
+}
+
+void tst_QDBusInterface::invokeMethodWithReturnPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+ QDBusVariant retArg;
+
+ // make the SLOT call without a return type
+ QDBusVariant arg("foo");
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg)));
+ QCOMPARE(callCountPeer(), 1);
+
+ // verify what the callee received
+ QVariantList callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ QVariant v = callArgs.at(0);
+ QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), arg.variant().toString());
+
+ // verify that we got the reply as expected
+ QCOMPARE(retArg.variant(), arg.variant());
+
+ // make the INVOKABLE call without a return type
+ QDBusVariant arg2("bar");
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg2)));
+ QCOMPARE(callCountPeer(), 2);
+
+ // verify what the callee received
+ callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ v = callArgs.at(0);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), arg2.variant().toString());
+
+ // verify that we got the reply as expected
+ QCOMPARE(retArg.variant(), arg2.variant());
+}
+
+void tst_QDBusInterface::invokeMethodWithMultiReturnPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+ QDBusVariant retArg, retArg2;
+
+ // make the SLOT call without a return type
+ QDBusVariant arg("foo"), arg2("bar");
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping",
+ Q_RETURN_ARG(QDBusVariant, retArg),
+ Q_ARG(QDBusVariant, arg),
+ Q_ARG(QDBusVariant, arg2),
+ Q_ARG(QDBusVariant&, retArg2)));
+ QCOMPARE(callCountPeer(), 1);
+
+ // verify what the callee received
+ QVariantList callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 2);
+ QVariant v = callArgs.at(0);
+ QDBusVariant dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), arg.variant().toString());
+
+ v = callArgs.at(1);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), arg2.variant().toString());
+
+ // verify that we got the replies as expected
+ QCOMPARE(retArg.variant(), arg.variant());
+ QCOMPARE(retArg2.variant(), arg2.variant());
+
+ // make the INVOKABLE call without a return type
+ QDBusVariant arg3("hello"), arg4("world");
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable",
+ Q_RETURN_ARG(QDBusVariant, retArg),
+ Q_ARG(QDBusVariant, arg3),
+ Q_ARG(QDBusVariant, arg4),
+ Q_ARG(QDBusVariant&, retArg2)));
+ QCOMPARE(callCountPeer(), 2);
+
+ // verify what the callee received
+ callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 2);
+ v = callArgs.at(0);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), arg3.variant().toString());
+
+ v = callArgs.at(1);
+ dv = qdbus_cast<QDBusVariant>(v);
+ QCOMPARE(dv.variant().type(), QVariant::String);
+ QCOMPARE(dv.variant().toString(), arg4.variant().toString());
+
+ // verify that we got the replies as expected
+ QCOMPARE(retArg.variant(), arg3.variant());
+ QCOMPARE(retArg2.variant(), arg4.variant());
+}
+
+void tst_QDBusInterface::invokeMethodWithComplexReturnPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+ QList<int> retArg;
+
+ // make the SLOT call without a return type
+ QList<int> arg = QList<int>() << 42 << -47;
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg)));
+ QCOMPARE(callCountPeer(), 1);
+
+ // verify what the callee received
+ QVariantList callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ QVariant v = callArgs.at(0);
+ QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>());
+ QCOMPARE(qdbus_cast<QList<int> >(v), arg);
+
+ // verify that we got the reply as expected
+ QCOMPARE(retArg, arg);
+
+ // make the INVOKABLE call without a return type
+ QList<int> arg2 = QList<int>() << 24 << -74;
+ QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg2)));
+ QCOMPARE(callCountPeer(), 2);
+
+ // verify what the callee received
+ callArgs = callArgsPeer();
+ QCOMPARE(callArgs.count(), 1);
+ v = callArgs.at(0);
+ QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>());
+ QCOMPARE(qdbus_cast<QList<int> >(v), arg2);
+
+ // verify that we got the reply as expected
+ QCOMPARE(retArg, arg2);
+}
+
void tst_QDBusInterface::signal()
{
QDBusConnection con = QDBusConnection::sessionBus();
@@ -621,6 +899,47 @@ void tst_QDBusInterface::signal()
}
}
+void tst_QDBusInterface::signalPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ QString arg = "So long and thanks for all the fish";
+ {
+ Spy spy;
+ spy.connect(&iface, SIGNAL(somethingHappened(QString)), SLOT(spySlot(QString)));
+
+ emitSignalPeer(TEST_INTERFACE_NAME, TEST_SIGNAL_NAME, arg);
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.received, arg);
+ }
+
+ QDBusInterface iface2(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+ {
+ Spy spy;
+ spy.connect(&iface, SIGNAL(somethingHappened(QString)), SLOT(spySlot(QString)));
+ spy.connect(&iface2, SIGNAL(somethingHappened(QString)), SLOT(spySlot(QString)));
+
+ emitSignalPeer(TEST_INTERFACE_NAME, TEST_SIGNAL_NAME, arg);
+ QCOMPARE(spy.count, 2);
+ QCOMPARE(spy.received, arg);
+ }
+
+ {
+ Spy spy, spy2;
+ spy.connect(&iface, SIGNAL(somethingHappened(QString)), SLOT(spySlot(QString)));
+ spy2.connect(&iface2, SIGNAL(somethingHappened(QString)), SLOT(spySlot(QString)));
+
+ emitSignalPeer(TEST_INTERFACE_NAME, TEST_SIGNAL_NAME, arg);
+ QCOMPARE(spy.count, 1);
+ QCOMPARE(spy.received, arg);
+ QCOMPARE(spy2.count, 1);
+ QCOMPARE(spy2.received, arg);
+ }
+}
+
void tst_QDBusInterface::propertyRead()
{
QDBusConnection con = QDBusConnection::sessionBus();
@@ -683,7 +1002,69 @@ void tst_QDBusInterface::complexPropertyWrite()
QCOMPARE(obj.m_complexProp, arg);
}
+void tst_QDBusInterface::propertyReadPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+ int arg = 42;
+ setProp1Peer(42);
+
+ QVariant v = iface.property("prop1");
+ QVERIFY(v.isValid());
+ QCOMPARE(v.userType(), int(QVariant::Int));
+ QCOMPARE(v.toInt(), arg);
+ QCOMPARE(callCountPeer(), 1);
+}
+
+void tst_QDBusInterface::propertyWritePeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+ int arg = 42;
+ setProp1Peer(0);
+
+ QVERIFY(iface.setProperty("prop1", arg));
+ QCOMPARE(callCountPeer(), 1);
+ QCOMPARE(prop1Peer(), arg);
+}
+
+void tst_QDBusInterface::complexPropertyReadPeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+ QList<int> arg = QList<int>() << 42 << -47;
+ setComplexPropPeer(arg);
+
+ QVariant v = iface.property("complexProp");
+ QVERIFY(v.isValid());
+ QCOMPARE(v.userType(), qMetaTypeId<QList<int> >());
+ QCOMPARE(v.value<QList<int> >(), arg);
+ QCOMPARE(callCountPeer(), 1);
+}
+
+void tst_QDBusInterface::complexPropertyWritePeer()
+{
+ QDBusConnection con("peer");
+ QDBusInterface iface(QString(), QLatin1String("/"),
+ TEST_INTERFACE_NAME, con);
+
+ resetPeer();
+ QList<int> arg = QList<int>() << -47 << 42;
+
+ QVERIFY(iface.setProperty("complexProp", qVariantFromValue(arg)));
+ QCOMPARE(callCountPeer(), 1);
+ QCOMPARE(complexPropPeer(), arg);
+}
+
QTEST_MAIN(tst_QDBusInterface)
#include "tst_qdbusinterface.moc"
-
diff --git a/tests/auto/qdbusmarshall/common.h b/tests/auto/qdbusmarshall/common.h
index 532394a10f..8f7f3c3da8 100644
--- a/tests/auto/qdbusmarshall/common.h
+++ b/tests/auto/qdbusmarshall/common.h
@@ -39,6 +39,22 @@
**
****************************************************************************/
#include <math.h> // isnan
+#include <qvariant.h>
+
+#ifdef Q_OS_UNIX
+# include <private/qcore_unix_p.h>
+
+static bool compareFileDescriptors(int fd1, int fd2)
+{
+ QT_STATBUF st1, st2;
+ if (QT_FSTAT(fd1, &st1) == -1 || QT_FSTAT(fd2, &st2) == -1) {
+ perror("fstat");
+ return false;
+ }
+
+ return (st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino);
+}
+#endif
Q_DECLARE_METATYPE(QVariant)
Q_DECLARE_METATYPE(QList<bool>)
@@ -77,6 +93,22 @@ Q_DECLARE_METATYPE(ObjectPathStringMap)
Q_DECLARE_METATYPE(LLDateTimeMap)
Q_DECLARE_METATYPE(SignatureStringMap)
+static bool compare(const QDBusUnixFileDescriptor &t1, const QDBusUnixFileDescriptor &t2)
+{
+ int fd1 = t1.fileDescriptor();
+ int fd2 = t2.fileDescriptor();
+ if ((fd1 == -1 || fd2 == -1) && fd1 != fd2) {
+ // one is valid, the other isn't
+ return false;
+ }
+
+#ifdef Q_OS_UNIX
+ return compareFileDescriptors(fd1, fd2);
+#else
+ return true;
+#endif
+}
+
struct MyStruct
{
int i;
@@ -130,6 +162,32 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, MyVariantMapStruct &ms
return arg;
}
+struct MyFileDescriptorStruct
+{
+ QDBusUnixFileDescriptor fd;
+
+ inline bool operator==(const MyFileDescriptorStruct &other) const
+ { return compare(fd, other.fd); }
+};
+Q_DECLARE_METATYPE(MyFileDescriptorStruct)
+Q_DECLARE_METATYPE(QList<MyFileDescriptorStruct>)
+
+QDBusArgument &operator<<(QDBusArgument &arg, const MyFileDescriptorStruct &ms)
+{
+ arg.beginStructure();
+ arg << ms.fd;
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &arg, MyFileDescriptorStruct &ms)
+{
+ arg.beginStructure();
+ arg >> ms.fd;
+ arg.endStructure();
+ return arg;
+}
+
void commonInit()
{
@@ -157,6 +215,8 @@ void commonInit()
qDBusRegisterMetaType<MyStruct>();
qDBusRegisterMetaType<MyVariantMapStruct>();
qDBusRegisterMetaType<QList<MyVariantMapStruct> >();
+ qDBusRegisterMetaType<MyFileDescriptorStruct>();
+ qDBusRegisterMetaType<QList<MyFileDescriptorStruct> >();
}
#ifdef USE_PRIVATE_CODE
#include "private/qdbusintrospection_p.h"
@@ -467,6 +527,8 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
return compare<QList<QDBusObjectPath> >(arg, v2);
else if (id == qMetaTypeId<QList<QDBusSignature> >())
return compare<QList<QDBusSignature> >(arg, v2);
+ else if (id == qMetaTypeId<QList<QDBusUnixFileDescriptor> >())
+ return compare<QList<QDBusUnixFileDescriptor> >(arg, v2);
else if (id == qMetaTypeId<QList<QDateTime> >())
return compare<QList<QDateTime> >(arg, v2);
@@ -511,6 +573,10 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
return compare<MyVariantMapStruct>(arg, v2);
else if (id == qMetaTypeId<QList<MyVariantMapStruct> >())
return compare<QList<MyVariantMapStruct> >(arg, v2);
+ else if (id == qMetaTypeId<MyFileDescriptorStruct>())
+ return compare<MyFileDescriptorStruct>(arg, v2);
+ else if (id == qMetaTypeId<QList<MyFileDescriptorStruct> >())
+ return compare<QList<MyFileDescriptorStruct> >(arg, v2);
}
qWarning() << "Unexpected QVariant type" << v2.userType()
@@ -563,6 +629,9 @@ template<> bool compare(const QVariant &v1, const QVariant &v2)
else if (id == qMetaTypeId<QDBusSignature>())
return qvariant_cast<QDBusSignature>(v1).signature() == qvariant_cast<QDBusSignature>(v2).signature();
+ else if (id == qMetaTypeId<QDBusUnixFileDescriptor>())
+ return compare(qvariant_cast<QDBusUnixFileDescriptor>(v1), qvariant_cast<QDBusUnixFileDescriptor>(v2));
+
else if (id == qMetaTypeId<QDBusVariant>())
return compare(qvariant_cast<QDBusVariant>(v1).variant(), qvariant_cast<QDBusVariant>(v2).variant());
diff --git a/tests/auto/qdbusmarshall/qdbusmarshall.pro b/tests/auto/qdbusmarshall/qdbusmarshall.pro
index f8e08754c9..ad40c0d0b2 100644
--- a/tests/auto/qdbusmarshall/qdbusmarshall.pro
+++ b/tests/auto/qdbusmarshall/qdbusmarshall.pro
@@ -3,6 +3,8 @@ contains(QT_CONFIG,dbus): {
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = qpong test
+
+ requires(contains(QT_CONFIG,private_tests))
} else {
SOURCES += dummy.cpp
}
diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
index 9bae6af1a3..737f0cf4a5 100644
--- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <QtDBus/QtDBus>
#include <QtDBus/private/qdbusutil_p.h>
+#include <QtDBus/private/qdbusconnection_p.h>
#include "common.h"
#include <limits>
@@ -93,7 +94,11 @@ private slots:
void receiveUnknownType();
private:
+ int fileDescriptorForTest();
+
QProcess proc;
+ QTemporaryFile tempFile;
+ bool fileDescriptorPassing;
};
class QDBusMessageSpy: public QObject
@@ -116,6 +121,7 @@ void tst_QDBusMarshall::initTestCase()
{
commonInit();
QDBusConnection con = QDBusConnection::sessionBus();
+ fileDescriptorPassing = con.connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing;
#ifdef Q_OS_WIN
proc.start("qpong");
#else
@@ -144,6 +150,15 @@ void tst_QDBusMarshall::cleanupTestCase()
proc.waitForFinished(200);
}
+int tst_QDBusMarshall::fileDescriptorForTest()
+{
+ if (!tempFile.isOpen()) {
+ tempFile.setFileTemplate(QDir::tempPath() + "/qdbusmarshalltestXXXXXX.tmp");
+ tempFile.open();
+ }
+ return tempFile.handle();
+}
+
void tst_QDBusMarshall::sendBasic_data()
{
QTest::addColumn<QVariant>("value");
@@ -167,6 +182,9 @@ void tst_QDBusMarshall::sendBasic_data()
QTest::newRow("signature") << qVariantFromValue(QDBusSignature("g")) << "g" << "[Signature: g]";
QTest::newRow("emptystring") << QVariant("") << "s" << "\"\"";
QTest::newRow("nullstring") << QVariant(QString()) << "s" << "\"\"";
+
+ if (fileDescriptorPassing)
+ QTest::newRow("file-descriptor") << qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())) << "h" << "[Unix FD: valid]";
#endif
}
@@ -255,6 +273,18 @@ void tst_QDBusMarshall::sendArrays_data()
<< std::numeric_limits<double>::quiet_NaN();
QTest::newRow("doublelist") << qVariantFromValue(doubles) << "ad" << "[Argument: ad {1.2, 2.2, 4.4, -inf, inf, nan}]";
+ QList<QDBusObjectPath> objectPaths;
+ QTest::newRow("emptyobjectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {}]";
+ objectPaths << QDBusObjectPath("/") << QDBusObjectPath("/foo");
+ QTest::newRow("objectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {[ObjectPath: /], [ObjectPath: /foo]}]";
+
+ if (fileDescriptorPassing) {
+ QList<QDBusUnixFileDescriptor> fileDescriptors;
+ QTest::newRow("emptyfiledescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {}]";
+ fileDescriptors << QDBusUnixFileDescriptor(fileDescriptorForTest()) << QDBusUnixFileDescriptor(1);
+ QTest::newRow("filedescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {[Unix FD: valid], [Unix FD: valid]}]";
+ }
+
QVariantList variants;
QTest::newRow("emptyvariantlist") << QVariant(variants) << "av" << "[Argument: av {}]";
variants << QString("Hello") << QByteArray("World") << 42 << -43.0 << 44U << Q_INT64_C(-45)
@@ -456,6 +486,12 @@ void tst_QDBusMarshall::sendMaps_data()
QTest::newRow("gs-map") << qVariantFromValue(gsmap) << "a{gs}"
<< "[Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]";
+ if (fileDescriptorPassing) {
+ svmap["zzfiledescriptor"] = qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest()));
+ QTest::newRow("sv-map1-fd") << qVariantFromValue(svmap) << "a{sv}"
+ << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]], \"zzfiledescriptor\" = [Variant(QDBusUnixFileDescriptor): [Unix FD: valid]]}]";
+ }
+
svmap.clear();
svmap["ismap"] = qVariantFromValue(ismap);
svmap["ssmap"] = qVariantFromValue(ssmap);
@@ -509,6 +545,18 @@ void tst_QDBusMarshall::sendStructs_data()
QTest::newRow("empty-list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {}]";
list << mvms;
QTest::newRow("list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]}]";
+
+ if (fileDescriptorPassing) {
+ MyFileDescriptorStruct fds;
+ fds.fd = QDBusUnixFileDescriptor(fileDescriptorForTest());
+ QTest::newRow("fdstruct") << qVariantFromValue(fds) << "(h)" << "[Argument: (h) [Unix FD: valid]]";
+
+ QList<MyFileDescriptorStruct> fdlist;
+ QTest::newRow("empty-list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {}]";
+
+ fdlist << fds;
+ QTest::newRow("list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {[Argument: (h) [Unix FD: valid]]}]";
+ }
}
void tst_QDBusMarshall::sendComplex_data()
@@ -642,6 +690,12 @@ void tst_QDBusMarshall::sendArgument_data()
arg << QString();
QTest::newRow("nullstring") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType);
+ if (fileDescriptorPassing) {
+ arg = QDBusArgument();
+ arg << QDBusUnixFileDescriptor(fileDescriptorForTest());
+ QTest::newRow("filedescriptor") << qVariantFromValue(arg) << "h" << int(QDBusArgument::BasicType);
+ }
+
arg = QDBusArgument();
arg << QDBusVariant(1);
QTest::newRow("variant") << qVariantFromValue(arg) << "v" << int(QDBusArgument::VariantType);
@@ -902,6 +956,27 @@ void tst_QDBusMarshall::sendCallErrors_data()
<< "Marshalling failed: Unregistered type UnregisteredType passed in arguments"
<< QString("QDBusMarshaller: type `UnregisteredType' (%1) is not registered with D-BUS. Use qDBusRegisterMetaType to register it")
.arg(qMetaTypeId<UnregisteredType>());
+
+ QTest::newRow("invalid-object-path-arg") << serviceName << objectPath << interfaceName << "ping"
+ << (QVariantList() << qVariantFromValue(QDBusObjectPath()))
+ << "org.freedesktop.DBus.Error.Failed"
+ << "Marshalling failed: Invalid object path passed in arguments"
+ << "";
+
+ QTest::newRow("invalid-signature-arg") << serviceName << objectPath << interfaceName << "ping"
+ << (QVariantList() << qVariantFromValue(QDBusSignature()))
+ << "org.freedesktop.DBus.Error.Failed"
+ << "Marshalling failed: Invalid signature passed in arguments"
+ << "";
+
+ // invalid file descriptor
+ if (fileDescriptorPassing) {
+ QTest::newRow("invalid-file-descriptor") << serviceName << objectPath << interfaceName << "ping"
+ << (QVariantList() << qVariantFromValue(QDBusUnixFileDescriptor(-1)))
+ << "org.freedesktop.DBus.Error.Failed"
+ << "Marshalling failed: Invalid file descriptor passed in arguments"
+ << "";
+ }
}
void tst_QDBusMarshall::sendCallErrors()
@@ -967,6 +1042,21 @@ typedef QScopedPointer<DBusConnection, DisconnectRawDBus> ScopedDBusConnection;
typedef QScopedPointer<DBusMessage, GenericUnref<DBusMessage, dbus_message_unref> > ScopedDBusMessage;
typedef QScopedPointer<DBusPendingCall, GenericUnref<DBusPendingCall, dbus_pending_call_unref> > ScopedDBusPendingCall;
+template <typename T> struct SetResetValue
+{
+ const T oldValue;
+ T &value;
+public:
+ SetResetValue(T &v, T newValue) : oldValue(v), value(v)
+ {
+ value = newValue;
+ }
+ ~SetResetValue()
+ {
+ value = oldValue;
+ }
+};
+
void tst_QDBusMarshall::receiveUnknownType()
{
#ifndef DBUS_TYPE_UNIX_FD
@@ -986,6 +1076,10 @@ void tst_QDBusMarshall::receiveUnknownType()
if (!dbus_connection_can_send_type(rawcon.data(), DBUS_TYPE_UNIX_FD))
QSKIP("Your session bus does not allow sending Unix file descriptors", SkipAll);
+ // make sure this QDBusConnection won't handle Unix file descriptors
+ QDBusConnection::ConnectionCapabilities &capabRef = QDBusConnectionPrivate::d(con)->capabilities;
+ SetResetValue<QDBusConnection::ConnectionCapabilities> resetter(capabRef, capabRef & ~QDBusConnection::UnixFileDescriptorPassing);
+
if (qstrcmp(QTest::currentDataTag(), "in-call") == 0) {
// create a call back to us containing a file descriptor
QDBusMessageSpy spy;
diff --git a/tests/auto/qdbusperformance/.gitignore b/tests/auto/qdbusperformance/.gitignore
deleted file mode 100644
index 4cd83993de..0000000000
--- a/tests/auto/qdbusperformance/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-tst_qdbusperformance
-server/server
diff --git a/tests/auto/qdbusperformance/qdbusperformance.pro b/tests/auto/qdbusperformance/qdbusperformance.pro
deleted file mode 100644
index 6880518d05..0000000000
--- a/tests/auto/qdbusperformance/qdbusperformance.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,dbus): {
- TEMPLATE = subdirs
- CONFIG += ordered
- SUBDIRS = server test
-} else {
- SOURCES += ../qdbusmarshall/dummy.cpp
-}
diff --git a/tests/auto/qdbusperformance/server/server.pro b/tests/auto/qdbusperformance/server/server.pro
deleted file mode 100644
index 30f81dd19f..0000000000
--- a/tests/auto/qdbusperformance/server/server.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-SOURCES = server.cpp
-HEADERS = ../serverobject.h
-TARGET = server
-CONFIG += qdbus
-QT -= gui
diff --git a/tests/auto/qdbusperformance/serverobject.h b/tests/auto/qdbusperformance/serverobject.h
deleted file mode 100644
index 6f85bb4e50..0000000000
--- a/tests/auto/qdbusperformance/serverobject.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef SERVEROBJECT_H
-#define SERVEROBJECT_H
-
-#include <QObject>
-#include <QtDBus/QtDBus>
-
-class ServerObject: public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "com.trolltech.autotests.Performance")
-public:
- ServerObject(const QString &objectPath, QDBusConnection conn, QObject *parent = 0)
- : QObject(parent)
- {
- conn.registerObject(objectPath, this, QDBusConnection::ExportAllSlots);
- }
-
-public slots:
- Q_NOREPLY void noReply(const QByteArray &)
- {
- // black hole
- }
- Q_NOREPLY void noReply(const QString &)
- {
- // black hole
- }
- Q_NOREPLY void noReply(const QDBusVariant &)
- {
- // black hole
- }
-
- int size(const QByteArray &data)
- {
- return data.size();
- }
- int size(const QString &data)
- {
- return data.size();
- }
- int size(const QDBusVariant &data)
- {
- QVariant v = data.variant();
- switch (v.type())
- {
- case QVariant::ByteArray:
- return v.toByteArray().size();
- case QVariant::StringList:
- return v.toStringList().size();
- case QVariant::String:
- default:
- return v.toString().size();
- }
- }
-
- QByteArray echo(const QByteArray &data)
- {
- return data;
- }
- QString echo(const QString &data)
- {
- return data;
- }
- QDBusVariant echo(const QDBusVariant &data)
- {
- return data;
- }
-
- void nothing()
- {
- }
-};
-
-#endif
diff --git a/tests/auto/qdbusperformance/test/test.pro b/tests/auto/qdbusperformance/test/test.pro
deleted file mode 100644
index 9f5712e9e2..0000000000
--- a/tests/auto/qdbusperformance/test/test.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-SOURCES += ../tst_qdbusperformance.cpp
-HEADERS += ../serverobject.h
-TARGET = ../tst_qdbusperformance
-
-QT = core
-CONFIG += qdbus
diff --git a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp b/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
deleted file mode 100644
index a5b4b98ad1..0000000000
--- a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtCore/QtCore>
-#include <QtTest/QtTest>
-#include <QtDBus/QtDBus>
-
-#include "./serverobject.h"
-
-static const char serviceName[] = "com.trolltech.autotests.performance";
-static const int runTime = 500;
-
-class tst_QDBusPerformance: public QObject
-{
- Q_OBJECT
- QProcess proc;
- QDBusInterface *target;
-
- QDBusInterface *remote;
- QDBusInterface *local;
-
- bool executeTest(const char *funcname, int size, const QVariant &data);
-
-public slots:
- void initTestCase_data();
- void initTestCase();
- void init();
-
-private slots:
- void callSpeed();
-
- void oneWay_data();
- void oneWay();
- void oneWayVariant_data();
- void oneWayVariant();
-
- void roundTrip_data();
- void roundTrip();
- void roundTripVariant_data();
- void roundTripVariant();
-};
-Q_DECLARE_METATYPE(QVariant)
-
-void tst_QDBusPerformance::initTestCase()
-{
- QDBusConnection con = QDBusConnection::sessionBus();
- QVERIFY(con.isConnected());
-
- QDBusServiceWatcher watcher(serviceName, con,
- QDBusServiceWatcher::WatchForRegistration);
- connect(&watcher, SIGNAL(serviceRegistered(QString)),
- &QTestEventLoop::instance(), SLOT(exitLoop()));
-
-#ifdef Q_OS_WIN
- proc.start("server");
-#else
- proc.start("./server/server");
-#endif
- QVERIFY(proc.waitForStarted());
-
- QTestEventLoop::instance().enterLoop(5);
- QVERIFY(con.interface()->isServiceRegistered(serviceName));
-
- remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this);
- QVERIFY(remote->isValid());
-
- new ServerObject("/", con, this);
- local = new QDBusInterface(con.baseService(), "/", "com.trolltech.autotests.Performance", con, this);
- QVERIFY(local->isValid());
-}
-
-void tst_QDBusPerformance::initTestCase_data()
-{
- QTest::addColumn<bool>("loopback");
-
- QTest::newRow("normal") << false;
- QTest::newRow("loopback") << true;
-}
-
-void tst_QDBusPerformance::init()
-{
- QFETCH_GLOBAL(bool, loopback);
- if (loopback)
- target = local;
- else
- target = remote;
-}
-
-void tst_QDBusPerformance::callSpeed()
-{
- QElapsedTimer timer;
-
- int callCount = 0;
- timer.start();
- while (timer.elapsed() < runTime) {
- QDBusReply<void> reply = target->call("nothing");
- QVERIFY(reply.isValid());
-
- ++callCount;
- }
- qDebug() << callCount << "calls in" << timer.elapsed() << "ms:"
- << (callCount * 1000.0 / timer.elapsed()) << "calls/sec";
-}
-
-bool tst_QDBusPerformance::executeTest(const char *funcname, int size, const QVariant &data)
-{
- QElapsedTimer timer;
-
- int callCount = 0;
- qint64 transferred = 0;
- timer.start();
- while (timer.elapsed() < runTime) {
- QDBusMessage reply = target->call(funcname, data);
- if (reply.type() != QDBusMessage::ReplyMessage)
- return false;
-
- transferred += size;
- ++callCount;
- }
- qDebug() << transferred << "bytes in" << timer.elapsed() << "ms"
- << "(in" << callCount << "calls):"
- << (transferred * 1000.0 / timer.elapsed() / 1024 / 1024) << "MB/s";
-
- return true;
-}
-
-void tst_QDBusPerformance::oneWay_data()
-{
- QTest::addColumn<QVariant>("data");
- QTest::addColumn<int>("size");
-
- QByteArray ba(256, 'a');
- while (ba.size() < 8193) {
- QTest::newRow(QString("%1-byteArray").arg(ba.size()).toAscii()) << qVariantFromValue(ba) << ba.size();
- ba += ba;
- }
-
- QString s(256, QLatin1Char('a'));
- while (s.size() < 8193) {
- QTest::newRow(QString("%1-string").arg(s.size()).toAscii()) << qVariantFromValue(s) << s.size();
- s += s;
- }
-}
-
-void tst_QDBusPerformance::oneWay()
-{
- QFETCH(QVariant, data);
- QFETCH(int, size);
-
- QVERIFY(executeTest("size", size, data));
-}
-
-void tst_QDBusPerformance::oneWayVariant_data()
-{
- oneWay_data();
-}
-
-void tst_QDBusPerformance::oneWayVariant()
-{
- QFETCH(QVariant, data);
- QFETCH(int, size);
-
- QVERIFY(executeTest("size", size, qVariantFromValue(QDBusVariant(data))));
-}
-
-void tst_QDBusPerformance::roundTrip_data()
-{
- oneWay_data();
-}
-
-void tst_QDBusPerformance::roundTrip()
-{
- QFETCH(QVariant, data);
- QFETCH(int, size);
-
- QVERIFY(executeTest("echo", size, data));
-}
-
-void tst_QDBusPerformance::roundTripVariant_data()
-{
- oneWay_data();
-}
-
-void tst_QDBusPerformance::roundTripVariant()
-{
- QFETCH(QVariant, data);
- QFETCH(int, size);
-
- QVERIFY(executeTest("echo", size, qVariantFromValue(QDBusVariant(data))));
-}
-
-QTEST_MAIN(tst_QDBusPerformance)
-#include "tst_qdbusperformance.moc"
diff --git a/tests/auto/qdbustype/qdbustype.pro b/tests/auto/qdbustype/qdbustype.pro
new file mode 100644
index 0000000000..e2f0c9017c
--- /dev/null
+++ b/tests/auto/qdbustype/qdbustype.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+QT = core
+contains(QT_CONFIG,dbus): {
+ SOURCES += tst_qdbustype.cpp
+ QT += dbus
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
+ LIBS_PRIVATE += $$QT_LIBS_DBUS
+} else {
+ SOURCES += ../qdbusmarshall/dummy.cpp
+}
diff --git a/tests/auto/qdbustype/tst_qdbustype.cpp b/tests/auto/qdbustype/tst_qdbustype.cpp
new file mode 100644
index 0000000000..676a9040be
--- /dev/null
+++ b/tests/auto/qdbustype/tst_qdbustype.cpp
@@ -0,0 +1,273 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QCoreApplication>
+
+#include <QtDBus/private/qdbusutil_p.h>
+
+#include <dbus/dbus.h>
+
+class tst_QDBusType : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void isValidFixedType_data();
+ void isValidFixedType();
+ void isValidBasicType_data();
+ void isValidBasicType();
+ void isValidSingleSignature_data();
+ void isValidSingleSignature();
+ void isValidArray_data();
+ void isValidArray();
+ void isValidSignature_data();
+ void isValidSignature();
+};
+
+enum { Invalid = false, Valid = true };
+
+static void addColumns()
+{
+ // All tests use these two columns only
+ QTest::addColumn<QString>("data");
+ QTest::addColumn<bool>("result");
+ QTest::addColumn<bool>("isValid");
+}
+
+// ---- type adds ---
+static void addFixedTypes()
+{
+ QTest::newRow("bool") << DBUS_TYPE_BOOLEAN_AS_STRING << true << true;
+ QTest::newRow("byte") << DBUS_TYPE_BYTE_AS_STRING << true << true;
+ QTest::newRow("int16") << DBUS_TYPE_INT16_AS_STRING << true << true;
+ QTest::newRow("uint16") << DBUS_TYPE_UINT16_AS_STRING << true << true;
+ QTest::newRow("int32") << DBUS_TYPE_INT32_AS_STRING << true << true;
+ QTest::newRow("uint32") << DBUS_TYPE_UINT32_AS_STRING << true << true;
+ QTest::newRow("int64") << DBUS_TYPE_INT64_AS_STRING << true << true;
+ QTest::newRow("uint64") << DBUS_TYPE_UINT64_AS_STRING << true << true;
+ QTest::newRow("double") << DBUS_TYPE_DOUBLE_AS_STRING << true << true;
+#ifdef DBUS_TYPE_UNIX_FD_AS_STRING
+ QTest::newRow("unixfd") << DBUS_TYPE_UNIX_FD_AS_STRING << true << true;
+#endif
+}
+
+static void addInvalidSingleLetterTypes()
+{
+ QChar nulString[] = { 0 };
+ QTest::newRow("nul") << QString(nulString, 1) << false << false;
+ QTest::newRow("tilde") << "~" << false << false;
+ QTest::newRow("struct-begin") << "(" << false << false;
+ QTest::newRow("struct-end") << ")" << false << false;
+ QTest::newRow("dict-entry-begin") << "{" << false << false;
+ QTest::newRow("dict-entry-end") << "}" << false << false;
+ QTest::newRow("array-no-element") << "a" << false << false;
+}
+
+static void addBasicTypes(bool basicsAreValid)
+{
+ addFixedTypes();
+ QTest::newRow("string") << DBUS_TYPE_STRING_AS_STRING << basicsAreValid << true;
+ QTest::newRow("object-path") << DBUS_TYPE_OBJECT_PATH_AS_STRING << basicsAreValid << true;
+ QTest::newRow("signature") << DBUS_TYPE_SIGNATURE_AS_STRING << basicsAreValid << true;
+}
+
+static void addVariant(bool variantIsValid)
+{
+ QTest::newRow("variant") << "v" << variantIsValid << true;
+}
+
+static void addSingleSignatures()
+{
+ addBasicTypes(Valid);
+ addVariant(Valid);
+ QTest::newRow("struct-1") << "(y)" << true;
+ QTest::newRow("struct-2") << "(yy)" << true;
+ QTest::newRow("struct-3") << "(yyv)" << true;
+
+ QTest::newRow("struct-nested-1") << "((y))" << true;
+ QTest::newRow("struct-nested-2") << "((yy))" << true;
+ QTest::newRow("struct-nested-3") << "(y(y))" << true;
+ QTest::newRow("struct-nested-4") << "((y)y)" << true;
+ QTest::newRow("struct-nested-5") << "(y(y)y)" << true;
+ QTest::newRow("struct-nested-6") << "((y)(y))" << true;
+
+ QTest::newRow("array-1") << "as" << true;
+ QTest::newRow("struct-array-1") << "(as)" << true;
+ QTest::newRow("struct-array-2") << "(yas)" << true;
+ QTest::newRow("struct-array-3") << "(asy)" << true;
+ QTest::newRow("struct-array-4") << "(yasy)" << true;
+
+ QTest::newRow("dict-1") << "a{sy}" << true;
+ QTest::newRow("dict-2") << "a{sv}" << true;
+ QTest::newRow("dict-struct-1") << "a{s(y)}" << true;
+ QTest::newRow("dict-struct-2") << "a{s(yyyy)}" << true;
+ QTest::newRow("dict-struct-array") << "a{s(ay)}" << true;
+ QTest::newRow("dict-array") << "a{sas}" << true;
+ QTest::newRow("dict-array-struct") << "a{sa(y)}" << true;
+
+ addInvalidSingleLetterTypes();
+ QTest::newRow("naked-dict-empty") << "{}" << false;
+ QTest::newRow("naked-dict-missing-value") << "{i}" << false;
+
+ QTest::newRow("dict-empty") << "a{}" << false;
+ QTest::newRow("dict-missing-value") << "a{i}" << false;
+ QTest::newRow("dict-non-basic-key") << "a{vi}" << false;
+ QTest::newRow("dict-struct-key") << "a{(y)y}" << false;
+ QTest::newRow("dict-missing-close") << "a{sv" << false;
+ QTest::newRow("dict-mismatched-close") << "a{sv)" << false;
+ QTest::newRow("dict-missing-value-close") << "a{s" << false;
+
+ QTest::newRow("empty-struct") << "()" << false;
+ QTest::newRow("struct-missing-close") << "(s" << false;
+ QTest::newRow("struct-nested-missing-close-1") << "((s)" << false;
+ QTest::newRow("struct-nested-missing-close-2") << "((s" << false;
+
+ QTest::newRow("struct-ending-array-no-element") << "(a)" << false;
+}
+
+static void addNakedDictEntry()
+{
+ QTest::newRow("naked-dict-entry") << "{sv}" << false;
+}
+
+// ---- tests ----
+
+void tst_QDBusType::isValidFixedType_data()
+{
+ addColumns();
+ addFixedTypes();
+ addBasicTypes(Invalid);
+ addVariant(Invalid);
+ addInvalidSingleLetterTypes();
+}
+
+void tst_QDBusType::isValidFixedType()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+ QFETCH(bool, isValid);
+ Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types");
+ Q_ASSERT(isValid || (!isValid && !result));
+
+ int type = data.at(0).unicode();
+ if (isValid)
+ QCOMPARE(bool(dbus_type_is_fixed(type)), result);
+ QCOMPARE(QDBusUtil::isValidFixedType(type), result);
+}
+
+void tst_QDBusType::isValidBasicType_data()
+{
+ addColumns();
+ addBasicTypes(Valid);
+ addVariant(Invalid);
+ addInvalidSingleLetterTypes();
+}
+
+void tst_QDBusType::isValidBasicType()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+ QFETCH(bool, isValid);
+ Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types");
+ Q_ASSERT(isValid || (!isValid && !result));
+
+ int type = data.at(0).unicode();
+ if (isValid)
+ QCOMPARE(bool(dbus_type_is_basic(type)), result);
+ QCOMPARE(QDBusUtil::isValidBasicType(type), result);
+}
+
+void tst_QDBusType::isValidSingleSignature_data()
+{
+ addColumns();
+ addSingleSignatures();
+ addNakedDictEntry();
+}
+
+void tst_QDBusType::isValidSingleSignature()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+
+ QCOMPARE(bool(dbus_signature_validate_single(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
+}
+
+void tst_QDBusType::isValidArray_data()
+{
+ addColumns();
+ addSingleSignatures();
+}
+
+void tst_QDBusType::isValidArray()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+
+ data.prepend("a");
+ QCOMPARE(bool(dbus_signature_validate_single(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
+
+ data.prepend("a");
+ QCOMPARE(bool(dbus_signature_validate_single(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
+}
+
+void tst_QDBusType::isValidSignature_data()
+{
+ isValidSingleSignature_data();
+}
+
+void tst_QDBusType::isValidSignature()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+
+ data.append(data);
+ if (data.at(0).unicode())
+ QCOMPARE(bool(dbus_signature_validate(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSignature(data), result);
+}
+
+QTEST_MAIN(tst_QDBusType)
+
+#include "tst_qdbustype.moc"
diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro
index 472e646f55..384c048f61 100644
--- a/tests/auto/qdir/qdir.pro
+++ b/tests/auto/qdir/qdir.pro
@@ -4,7 +4,7 @@ RESOURCES += qdir.qrc
QT = core
wince*|symbian {
- DirFiles.files = testdir testdata searchdir resources entrylist types tst_qdir.cpp
+ DirFiles.files = testdir testData searchdir resources entrylist types tst_qdir.cpp
DirFiles.path = .
DEPLOYMENT += DirFiles
}
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp
index 2fa0c24a3d..8112814e35 100644
--- a/tests/auto/qdir/tst_qdir.cpp
+++ b/tests/auto/qdir/tst_qdir.cpp
@@ -420,6 +420,9 @@ void tst_QDir::isRelativePath_data()
#endif
QTest::newRow("data2") << "somedir" << true;
QTest::newRow("data3") << "/somedir" << false;
+
+ QTest::newRow("resource0") << ":/prefix" << false;
+ QTest::newRow("resource1") << ":/prefix/foo.bar" << false;
}
void tst_QDir::isRelativePath()
@@ -571,6 +574,12 @@ void tst_QDir::entryList_data()
<< int(QDir::AllEntries | QDir::Writable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(','));
#endif
+ QTest::newRow("QDir::Files | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*")
+ << int(QDir::Files | QDir::Readable) << int(QDir::Name)
+ << filterLinks(QString("file,linktofile.lnk,writable").split(','));
+ QTest::newRow("QDir::Dirs | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*")
+ << int(QDir::Dirs | QDir::Readable) << int(QDir::Name)
+ << filterLinks(QString(".,..,directory,linktodirectory.lnk").split(','));
QTest::newRow("Namefilters b*") << SRCDIR "entrylist/" << QStringList("d*")
<< int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString("directory").split(','));
@@ -868,6 +877,8 @@ void tst_QDir::canonicalPath_data()
QTest::newRow("drive:\\..\\..") << QDir::toNativeSeparators(QDir::rootPath().append("../..")) << QDir::rootPath();
QTest::newRow("drive:") << QDir().canonicalPath().left(2) << QDir().canonicalPath();
#endif
+
+ QTest::newRow("resource") << ":/tst_qdir/resources/entryList" << ":/tst_qdir/resources/entryList";
}
void tst_QDir::canonicalPath()
@@ -1061,6 +1072,9 @@ tst_QDir::cleanPath_data()
QTest::newRow("data10") << "/:/" << "/:";
#endif
#endif
+
+ QTest::newRow("resource0") << ":/prefix/foo.bar" << ":/prefix/foo.bar";
+ QTest::newRow("resource1") << "://prefix/..//prefix/foo.bar" << ":/prefix/foo.bar";
}
@@ -1084,6 +1098,7 @@ void tst_QDir::absoluteFilePath_data()
QTest::newRow("2") << "/" << "passwd" << "/passwd";
QTest::newRow("3") << "relative" << "path" << QDir::currentPath() + "/relative/path";
QTest::newRow("4") << "" << "" << QDir::currentPath();
+ QTest::newRow("resource") << ":/prefix" << "foo.bar" << ":/prefix/foo.bar";
}
void tst_QDir::absoluteFilePath()
@@ -1112,6 +1127,7 @@ void tst_QDir::absolutePath_data()
QTest::newRow("4") << "c:/machine/share/dir1" << "c:/machine/share/dir1";
QTest::newRow("5") << "c:\\machine\\share\\dir1" << "c:/machine/share/dir1";
#endif
+ QTest::newRow("resource") << ":/prefix/foo.bar" << ":/prefix/foo.bar";
}
void tst_QDir::absolutePath()
@@ -1171,6 +1187,9 @@ void tst_QDir::relativeFilePath_data()
QTest::newRow("33") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar";
# endif
#endif
+
+ QTest::newRow("resource0") << ":/prefix" << "foo.bar" << "foo.bar";
+ QTest::newRow("resource1") << ":/prefix" << ":/prefix/foo.bar" << "foo.bar";
}
void tst_QDir::relativeFilePath()
@@ -1193,6 +1212,7 @@ void tst_QDir::filePath_data()
QTest::newRow("2") << "/" << "passwd" << "/passwd";
QTest::newRow("3") << "relative" << "path" << "relative/path";
QTest::newRow("4") << "" << "" << ".";
+ QTest::newRow("resource") << ":/prefix" << "foo.bar" << ":/prefix/foo.bar";
}
void tst_QDir::filePath()
@@ -1255,6 +1275,8 @@ void tst_QDir::exists2_data()
QTest::newRow("4") << "/testData" << false;
QTest::newRow("5") << "tst_qdir.cpp" << true;
QTest::newRow("6") << "/resources.cpp" << false;
+ QTest::newRow("resource0") << ":/prefix/foo.bar" << false;
+ QTest::newRow("resource1") << ":/tst_qdir/resources/entryList/file1.data" << true;
}
void tst_QDir::exists2()
@@ -1291,6 +1313,8 @@ void tst_QDir::dirName_data()
QTest::newRow("bslash1") << "\\winnt\\system32" << "system32";
QTest::newRow("bslash2") << "c:\\winnt\\system32\\kernel32.dll" << "kernel32.dll";
#endif
+
+ QTest::newRow("resource") << ":/prefix" << "prefix";
}
void tst_QDir::dirName()
@@ -1961,6 +1985,8 @@ void tst_QDir::isRelative_data()
foreach (QFileInfo root, QDir::drives()) {
QTest::newRow(root.absolutePath().toLocal8Bit()) << root.absolutePath() << false;
}
+
+ QTest::newRow("resource") << ":/prefix" << false;
}
void tst_QDir::isRelative()
diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp
index bdf0c3b32e..3691a90fec 100644
--- a/tests/auto/qdiriterator/tst_qdiriterator.cpp
+++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp
@@ -126,6 +126,7 @@ private slots:
void uncPaths_data();
void uncPaths();
#endif
+ void qtbug15421_hiddenDirs_hiddenFiles();
};
tst_QDirIterator::tst_QDirIterator()
@@ -173,6 +174,20 @@ tst_QDirIterator::tst_QDirIterator()
createLink("nothing", "entrylist/brokenlink.lnk");
# endif
#endif
+
+ createDirectory("qtbug15421_hiddenDirs_hiddenFiles");
+ createFile("qtbug15421_hiddenDirs_hiddenFiles/normalFile");
+ createFile("qtbug15421_hiddenDirs_hiddenFiles/.hiddenFile");
+ createDirectory("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory");
+ createDirectory("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory");
+ createFile("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/normalFile");
+ createFile("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/.hiddenFile");
+ createFile("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/normalFile");
+ createFile("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenFile");
+ createDirectory("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/normalDirectory");
+ createDirectory("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/.hiddenDirectory");
+ createDirectory("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/normalDirectory");
+ createDirectory("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenDirectory");
}
tst_QDirIterator::~tst_QDirIterator()
@@ -578,6 +593,46 @@ void tst_QDirIterator::uncPaths()
}
#endif
+void tst_QDirIterator::qtbug15421_hiddenDirs_hiddenFiles()
+{
+ // In Unix it is easy to create hidden files, but in Windows it requires
+ // a special call since hidden files need to be "marked" while in Unix
+ // anything starting by a '.' is a hidden file.
+ // For that reason this test is not run in Windows.
+#if defined Q_OS_WIN || Q_OS_WINCE
+ QSKIP("To create hidden files a special call is required in Windows.", SkipAll);
+#else
+ // Only files
+ {
+ int matches = 0;
+ int failures = 0;
+ QDirIterator di("qtbug15421_hiddenDirs_hiddenFiles", QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
+ while (di.hasNext()) {
+ ++matches;
+ QString filename = di.next();
+ if (QFileInfo(filename).isDir())
+ ++failures; // search was only supposed to find files
+ }
+ QCOMPARE(matches, 6);
+ QCOMPARE(failures, 0);
+ }
+ // Only directories
+ {
+ int matches = 0;
+ int failures = 0;
+ QDirIterator di("qtbug15421_hiddenDirs_hiddenFiles", QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
+ while (di.hasNext()) {
+ ++matches;
+ QString filename = di.next();
+ if (!QFileInfo(filename).isDir())
+ ++failures; // search was only supposed to find files
+ }
+ QCOMPARE(matches, 6);
+ QCOMPARE(failures, 0);
+ }
+#endif // Q_OS_WIN || Q_OS_WINCE
+}
+
QTEST_MAIN(tst_QDirIterator)
#include "tst_qdiriterator.moc"
diff --git a/tests/auto/qeventloop/qeventloop.pro b/tests/auto/qeventloop/qeventloop.pro
index f6c24ae02d..e7489faa2d 100644
--- a/tests/auto/qeventloop/qeventloop.pro
+++ b/tests/auto/qeventloop/qeventloop.pro
@@ -5,3 +5,4 @@ QT += network
win32:!wince*:LIBS += -luser32
+symbian:TARGET.CAPABILITY += NetworkServices \ No newline at end of file
diff --git a/tests/auto/qeventloop/tst_qeventloop.cpp b/tests/auto/qeventloop/tst_qeventloop.cpp
index 6860f194cf..fa2a34ecb2 100644
--- a/tests/auto/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/qeventloop/tst_qeventloop.cpp
@@ -602,8 +602,10 @@ public slots:
QTcpSocket *serverSocket = server->nextPendingConnection();
serverSocket->write(data, size);
serverSocket->flush();
+ QTest::qSleep(200); //allow the TCP/IP stack time to loopback the data, so our socket is ready to read
QCoreApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
testResult = dataArrived;
+ QCoreApplication::processEvents(); //check the deferred event is processed
serverSocket->close();
QThread::currentThread()->exit(0);
}
@@ -620,9 +622,11 @@ public:
if (tester->init())
exec();
testResult = tester->testResult;
+ dataArrived = tester->dataArrived;
delete tester;
}
bool testResult;
+ bool dataArrived;
};
void tst_QEventLoop::processEventsExcludeSocket()
@@ -631,6 +635,7 @@ void tst_QEventLoop::processEventsExcludeSocket()
thread.start();
QVERIFY(thread.wait());
QVERIFY(!thread.testResult);
+ QVERIFY(thread.dataArrived);
}
class TimerReceiver : public QObject
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 79539c9e33..688a92d04b 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -3294,13 +3294,18 @@ public:
static void ignore_invalid_parameter(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t) {}
AutoIgnoreInvalidParameter()
{
- old = _set_invalid_parameter_handler(ignore_invalid_parameter);
+ oldHandler = _set_invalid_parameter_handler(ignore_invalid_parameter);
+ //also disable the abort/retry/ignore popup
+ oldReportMode = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
}
~AutoIgnoreInvalidParameter()
{
- _set_invalid_parameter_handler(old);
+ //restore previous settings
+ _set_invalid_parameter_handler(oldHandler);
+ _CrtSetReportMode(_CRT_ASSERT, oldReportMode);
}
- _invalid_parameter_handler old;
+ _invalid_parameter_handler oldHandler;
+ int oldReportMode;
#endif
};
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 53781c9f0f..e8d0f575df 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -632,7 +632,12 @@ void tst_QFileSystemModel::filters_data()
QTest::addColumn<int>("rowCount");
#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
QTest::newRow("no dirs") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs) << QStringList() << 2;
- QTest::newRow("one dir - dotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1;
+ QTest::newRow("no dirs - dot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDot) << QStringList() << 1;
+ QTest::newRow("no dirs - dotdot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDotDot) << QStringList() << 1;
+ QTest::newRow("no dirs - dotanddotdot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 0;
+ QTest::newRow("one dir - dot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDot) << QStringList() << 2;
+ QTest::newRow("one dir - dotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotDot) << QStringList() << 2;
+ QTest::newRow("one dir - dotanddotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1;
QTest::newRow("one dir") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs) << QStringList() << 3;
QTest::newRow("no dir + hidden") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::Hidden) << QStringList() << 2;
QTest::newRow("dir+hid+files") << (QStringList() << "a" << "b" << "c") << QStringList() <<
@@ -650,7 +655,12 @@ void tst_QFileSystemModel::filters_data()
#else
QTest::qWait(3000); // We need to calm down a bit...
QTest::newRow("no dirs") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs) << QStringList() << 0;
- QTest::newRow("one dir - dotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1;
+ QTest::newRow("no dirs - dot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDot) << QStringList() << 1;
+ QTest::newRow("no dirs - dotdot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDotDot) << QStringList() << 1;
+ QTest::newRow("no dirs - dotanddotdot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 0;
+ QTest::newRow("one dir - dot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDot) << QStringList() << 2;
+ QTest::newRow("one dir - dotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotDot) << QStringList() << 2;
+ QTest::newRow("one dir - dotanddotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1;
QTest::newRow("one dir") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs) << QStringList() << 1;
QTest::newRow("no dir + hidden") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::Hidden) << QStringList() << 0;
QTest::newRow("dir+hid+files") << (QStringList() << "a" << "b" << "c") << QStringList() <<
@@ -699,10 +709,23 @@ void tst_QFileSystemModel::filters()
// Make sure that we do what QDir does
QDir xFactor(tmp);
QDir::Filters filters = (QDir::Filters)dirFilters;
+ QStringList dirEntries;
+
if (nameFilters.count() > 0)
- QCOMPARE(xFactor.entryList(nameFilters, filters).count(), rowCount);
+ dirEntries = xFactor.entryList(nameFilters, filters);
else
- QVERIFY(xFactor.entryList(filters).count() == rowCount);
+ dirEntries = xFactor.entryList(filters);
+
+ QCOMPARE(dirEntries.count(), rowCount);
+
+ QStringList modelEntries;
+
+ for (int i = 0; i < rowCount; ++i)
+ modelEntries.append(model->data(model->index(i, 0, root), QFileSystemModel::FileNameRole).toString());
+
+ qSort(dirEntries);
+ qSort(modelEntries);
+ QCOMPARE(dirEntries, modelEntries);
#ifdef Q_OS_LINUX
if (files.count() >= 3 && rowCount >= 3 && rowCount != 5) {
diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp
index 1b4b503fbc..78157d84ff 100644
--- a/tests/auto/qftp/tst_qftp.cpp
+++ b/tests/auto/qftp/tst_qftp.cpp
@@ -50,6 +50,10 @@
#include <time.h>
#include <stdlib.h>
#include <QNetworkProxy>
+#include <QNetworkConfiguration>
+#include <qnetworkconfigmanager.h>
+#include <QNetworkSession>
+#include <QtNetwork/private/qnetworksession_p.h>
#include "../network-settings.h"
@@ -62,7 +66,9 @@
#define SRCDIR ""
#endif
-
+#ifndef QT_NO_BEARERMANAGEMENT
+Q_DECLARE_METATYPE(QNetworkConfiguration)
+#endif
class tst_QFtp : public QObject
{
@@ -148,6 +154,10 @@ private:
void renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete );
QFtp *ftp;
+#ifndef QT_NO_BEARERMANAGEMENT
+ QSharedPointer<QNetworkSession> networkSessionExplicit;
+ QSharedPointer<QNetworkSession> networkSessionImplicit;
+#endif
QList<int> ids; // helper to make sure that all expected signals are emitted
int current_id;
@@ -186,9 +196,9 @@ private:
const int bytesTotal_init = -10;
const int bytesDone_init = -10;
-tst_QFtp::tst_QFtp()
+tst_QFtp::tst_QFtp() :
+ ftp(0)
{
- Q_SET_DEFAULT_IAP
}
tst_QFtp::~tst_QFtp()
@@ -199,33 +209,62 @@ void tst_QFtp::initTestCase_data()
{
QTest::addColumn<bool>("setProxy");
QTest::addColumn<int>("proxyType");
+ QTest::addColumn<bool>("setSession");
- QTest::newRow("WithoutProxy") << false << 0;
- QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
+ QTest::newRow("WithoutProxy") << false << 0 << false;
+ QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy) << false;
//### doesn't work well yet.
//QTest::newRow("WithHttpProxy") << true << int(QNetworkProxy::HttpProxy);
+
+#ifndef QT_NO_BEARERMANAGEMENT
+ QTest::newRow("WithoutProxyWithSession") << false << 0 << true;
+ QTest::newRow("WithSocks5ProxyAndSession") << true << int(QNetworkProxy::Socks5Proxy) << true;
+#endif
}
void tst_QFtp::initTestCase()
{
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager manager;
+ networkSessionImplicit = QSharedPointer<QNetworkSession>(new QNetworkSession(manager.defaultConfiguration()));
+ networkSessionImplicit->open();
+ QVERIFY(networkSessionImplicit->waitForOpened(60000)); //there may be user prompt on 1st connect
+#endif
}
void tst_QFtp::cleanupTestCase()
{
+#ifndef QT_NO_BEARERMANAGEMENT
+ networkSessionExplicit.clear();
+ networkSessionImplicit.clear();
+#endif
}
void tst_QFtp::init()
{
QFETCH_GLOBAL(bool, setProxy);
+ QFETCH_GLOBAL(int, proxyType);
+ QFETCH_GLOBAL(bool, setSession);
if (setProxy) {
- QFETCH_GLOBAL(int, proxyType);
if (proxyType == QNetworkProxy::Socks5Proxy) {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
} else if (proxyType == QNetworkProxy::HttpProxy) {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
}
}
+#ifndef QT_NO_BEARERMANAGEMENT
+ if (setSession) {
+ networkSessionExplicit = networkSessionImplicit;
+ if (!networkSessionExplicit->isOpen()) {
+ networkSessionExplicit->open();
+ QVERIFY(networkSessionExplicit->waitForOpened(30000));
+ }
+ } else {
+ networkSessionExplicit.clear();
+ }
+#endif
+ delete ftp;
ftp = 0;
ids.clear();
@@ -262,10 +301,20 @@ void tst_QFtp::init()
void tst_QFtp::cleanup()
{
+ if (ftp) {
+ delete ftp;
+ ftp = 0;
+ }
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
}
+
+ delete ftp;
+ ftp = 0;
+#ifndef QT_NO_BEARERMANAGEMENT
+ networkSessionExplicit.clear();
+#endif
}
void tst_QFtp::connectToHost_data()
@@ -289,6 +338,7 @@ void tst_QFtp::connectToHost()
QTestEventLoop::instance().enterLoop( 61 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -337,6 +387,7 @@ void tst_QFtp::connectToUnresponsiveHost()
QVERIFY( it.value().success == 0 );
delete ftp;
+ ftp = 0;
}
void tst_QFtp::login_data()
@@ -369,6 +420,7 @@ void tst_QFtp::login()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -415,6 +467,7 @@ void tst_QFtp::close()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -482,6 +535,7 @@ void tst_QFtp::list()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -542,6 +596,7 @@ void tst_QFtp::cd()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
QFAIL( "Network operation timed out" );
}
@@ -617,6 +672,7 @@ void tst_QFtp::get()
QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -743,6 +799,7 @@ void tst_QFtp::put()
break;
}
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -775,6 +832,7 @@ void tst_QFtp::put()
break;
}
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -792,6 +850,7 @@ void tst_QFtp::put()
QTestEventLoop::instance().enterLoop( timestep );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -860,6 +919,7 @@ void tst_QFtp::mkdir()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -884,6 +944,7 @@ void tst_QFtp::mkdir()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -903,6 +964,7 @@ void tst_QFtp::mkdir()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -942,6 +1004,7 @@ void tst_QFtp::mkdir2()
QVERIFY(commandFinishedSpy.at(3).at(1).toBool());
delete ftp;
+ ftp = 0;
}
void tst_QFtp::mkdir2Slot(int id, bool)
@@ -1019,6 +1082,7 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri
QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1043,6 +1107,7 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1087,6 +1152,7 @@ void tst_QFtp::rename()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1273,6 +1339,7 @@ void tst_QFtp::commandSequence()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1330,6 +1397,7 @@ void tst_QFtp::abort()
break;
}
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1367,6 +1435,7 @@ void tst_QFtp::abort()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1425,6 +1494,7 @@ void tst_QFtp::bytesAvailable()
ftp->readAll();
QVERIFY( ftp->bytesAvailable() == 0 );
delete ftp;
+ ftp = 0;
}
void tst_QFtp::activeMode()
@@ -1497,6 +1567,7 @@ void tst_QFtp::proxy()
QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
QFAIL( "Network operation timed out" );
}
@@ -1512,7 +1583,6 @@ void tst_QFtp::proxy()
}
}
-
void tst_QFtp::binaryAscii()
{
QString file = "asciifile%1.txt";
@@ -1531,6 +1601,8 @@ void tst_QFtp::binaryAscii()
addCommand(QFtp::Close, ftp->close());
QTestEventLoop::instance().enterLoop( 30 );
+ delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1551,6 +1623,8 @@ void tst_QFtp::binaryAscii()
addCommand(QFtp::Close, ftp->close());
QTestEventLoop::instance().enterLoop( 30 );
+ delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1573,6 +1647,7 @@ void tst_QFtp::binaryAscii()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1868,6 +1943,11 @@ void tst_QFtp::dataTransferProgress( qint64 done, qint64 total )
QFtp *tst_QFtp::newFtp()
{
QFtp *nFtp = new QFtp( this );
+#ifndef QT_NO_BEARERMANAGEMENT
+ if (networkSessionExplicit) {
+ nFtp->setProperty("_q_networksession", QVariant::fromValue(networkSessionExplicit));
+ }
+#endif
connect( nFtp, SIGNAL(commandStarted(int)),
SLOT(commandStarted(int)) );
connect( nFtp, SIGNAL(commandFinished(int,bool)),
@@ -1920,6 +2000,7 @@ bool tst_QFtp::fileExists( const QString &host, quint16 port, const QString &use
inFileDirExistsFunction = TRUE;
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
// ### make this test work
qWarning("tst_QFtp::fileExists: Network operation timed out");
@@ -1970,6 +2051,7 @@ bool tst_QFtp::dirExists( const QString &host, quint16 port, const QString &user
inFileDirExistsFunction = TRUE;
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
// ### make this test work
// QFAIL( "Network operation timed out" );
@@ -1996,8 +2078,11 @@ void tst_QFtp::doneSignal()
ftp.close();
done_success = 0;
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
+ connect(&ftp, SIGNAL(done(bool)), &(QTestEventLoop::instance()), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(61);
+ if (QTestEventLoop::instance().timeout())
+ QFAIL("Network operation timed out");
+
QTest::qWait(200);
QCOMPARE(spy.count(), 1);
diff --git a/tests/auto/qfuture/tst_qfuture.cpp b/tests/auto/qfuture/tst_qfuture.cpp
index fa4ccb526b..8afdf48fc3 100644
--- a/tests/auto/qfuture/tst_qfuture.cpp
+++ b/tests/auto/qfuture/tst_qfuture.cpp
@@ -81,6 +81,7 @@ private slots:
void voidConversions();
#ifndef QT_NO_EXCEPTIONS
void exceptions();
+ void exceptions_QTBUG18149();
#endif
};
@@ -1431,6 +1432,33 @@ void tst_QFuture::exceptions()
}
+
+void tst_QFuture::exceptions_QTBUG18149()
+{
+ class MyClass
+ {
+ public:
+ ~MyClass()
+ {
+ QFuture<void> f = createExceptionFuture();
+ bool caught = false;
+ try {
+ f.waitForFinished();
+ } catch (Exception &) {
+ caught = true;
+ }
+ QVERIFY(caught);
+ }
+ };
+
+ try {
+ MyClass m;
+ throw 0;
+ } catch (int) {}
+
+}
+
+
#endif // QT_NO_EXCEPTIONS
#include "tst_qfuture.moc"
diff --git a/tests/auto/qfuture/versioncheck.h b/tests/auto/qfuture/versioncheck.h
index 0cf7b76a85..32a33c871f 100644
--- a/tests/auto/qfuture/versioncheck.h
+++ b/tests/auto/qfuture/versioncheck.h
@@ -47,3 +47,7 @@
#if defined(Q_CC_MSVC) && _MSC_VER < 1400
#define QT_NO_CONCURRENT_TEST
#endif
+
+#if defined(Q_CC_NOKIAX86)
+#define QT_NO_CONCURRENT_TEST
+#endif
diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp
index 1c0aa9e6cf..ffa0d002c3 100644
--- a/tests/auto/qglyphs/tst_qglyphs.cpp
+++ b/tests/auto/qglyphs/tst_qglyphs.cpp
@@ -52,6 +52,7 @@ class tst_QGlyphs: public QObject
{
Q_OBJECT
+#if !defined(QT_NO_RAWFONT)
private slots:
void initTestCase();
void cleanupTestCase();
@@ -75,8 +76,12 @@ private slots:
private:
int m_testFontId;
QFont m_testFont;
+#endif // QT_NO_RAWFONT
+
};
+#if !defined(QT_NO_RAWFONT)
+
Q_DECLARE_METATYPE(QGlyphs);
void tst_QGlyphs::initTestCase()
@@ -116,7 +121,7 @@ static QGlyphs make_dummy_indexes()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
- glyphs.setFont(font);
+ glyphs.setFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
@@ -141,7 +146,7 @@ void tst_QGlyphs::copyConstructor()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
- glyphs.setFont(font);
+ glyphs.setFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
}
@@ -180,14 +185,16 @@ void tst_QGlyphs::equalsOperator_data()
positions[2] += QPointF(1, 1);
busted.setPositions(positions);
+
QTest::newRow("Different positions") << one << busted << false;
}
{
QGlyphs busted(two);
- QFont font = busted.font();
- font.setPointSize(font.pointSize() * 2);
- busted.setFont(font);
+
+ QFont font;
+ font.setPixelSize(busted.font().pixelSize() * 2);
+ busted.setFont(QRawFont::fromFont(font));
QTest::newRow("Different fonts") << one << busted << false;
}
@@ -288,7 +295,7 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QGlyphs glyphs;
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(glyphPositions);
- glyphs.setFont(m_testFont);
+ glyphs.setFont(QRawFont::fromFont(m_testFont));
QPixmap image(1000, 1000);
image.fill(Qt::white);
@@ -568,6 +575,8 @@ void tst_QGlyphs::drawRightToLeft()
}
+#endif // QT_NO_RAWFONT
+
QTEST_MAIN(tst_QGlyphs)
#include "tst_qglyphs.moc"
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 7b33081e78..55d6fc97cd 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -1093,6 +1093,9 @@ void tst_QGraphicsAnchorLayout::setSpacing()
#ifdef Q_WS_MAC
QTest::qWait(200);
#endif
+
+ // 21x21
+ QCOMPARE(p->size(), QSizeF(41, 41));
QCOMPARE(a->geometry(), QRectF(0, 0, 20, 20));
QCOMPARE(b->geometry(), QRectF(21, 0, 20, 20));
QCOMPARE(c->geometry(), QRectF(0, 21, 41, 20));
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 269b576d68..f8bf7a1b3c 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -66,6 +66,7 @@
#include <QPushButton>
#include <QLineEdit>
#include <QGraphicsLinearLayout>
+#include <float.h>
#include "../../shared/util.h"
@@ -449,6 +450,8 @@ private slots:
void scroll();
void focusHandling_data();
void focusHandling();
+ void touchEventPropagation_data();
+ void touchEventPropagation();
void deviceCoordinateCache_simpleRotations();
// task specific tests below me
@@ -10637,6 +10640,80 @@ void tst_QGraphicsItem::focusHandling()
QCOMPARE(scene.focusItem(), focusableUnder);
}
+void tst_QGraphicsItem::touchEventPropagation_data()
+{
+ QTest::addColumn<QGraphicsItem::GraphicsItemFlag>("flag");
+ QTest::addColumn<int>("expectedCount");
+
+ QTest::newRow("ItemIsPanel")
+ << QGraphicsItem::ItemIsPanel << 0;
+ QTest::newRow("ItemStopsClickFocusPropagation")
+ << QGraphicsItem::ItemStopsClickFocusPropagation << 1;
+ QTest::newRow("ItemStopsFocusHandling")
+ << QGraphicsItem::ItemStopsFocusHandling << 1;
+}
+
+void tst_QGraphicsItem::touchEventPropagation()
+{
+ QFETCH(QGraphicsItem::GraphicsItemFlag, flag);
+ QFETCH(int, expectedCount);
+
+ class Testee : public QGraphicsRectItem
+ {
+ public:
+ int touchBeginEventCount;
+
+ Testee()
+ : QGraphicsRectItem(0, 0, 100, 100)
+ , touchBeginEventCount(0)
+ {
+ setAcceptTouchEvents(true);
+ setFlag(QGraphicsItem::ItemIsFocusable, false);
+ }
+
+ bool sceneEvent(QEvent *ev)
+ {
+ if (ev->type() == QEvent::TouchBegin)
+ ++touchBeginEventCount;
+
+ return QGraphicsRectItem::sceneEvent(ev);
+ }
+ };
+
+ Testee *touchEventReceiver = new Testee;
+ QGraphicsItem *topMost = new QGraphicsRectItem(touchEventReceiver->boundingRect());
+
+ QGraphicsScene scene;
+ scene.addItem(topMost);
+ scene.addItem(touchEventReceiver);
+
+ topMost->setAcceptTouchEvents(true);
+ topMost->setZValue(FLT_MAX);
+ topMost->setFlag(QGraphicsItem::ItemIsFocusable, false);
+ topMost->setFlag(flag, true);
+
+ QGraphicsView view(&scene);
+ view.setSceneRect(touchEventReceiver->boundingRect());
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(touchEventReceiver->touchBeginEventCount, 0);
+
+ QTouchEvent::TouchPoint tp(0);
+ tp.setState(Qt::TouchPointPressed);
+ tp.setScenePos(view.sceneRect().center());
+ tp.setLastScenePos(view.sceneRect().center());
+
+ QList<QTouchEvent::TouchPoint> touchPoints;
+ touchPoints << tp;
+
+ sendMousePress(&scene, tp.scenePos());
+ QTouchEvent touchBegin(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, touchPoints);
+
+ qApp->sendEvent(&scene, &touchBegin);
+ QCOMPARE(touchEventReceiver->touchBeginEventCount, expectedCount);
+}
+
void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations()
{
// Make sure we don't invalidate the cache when applying simple
@@ -11176,6 +11253,6 @@ void tst_QGraphicsItem::QTBUG_16374_crashInDestructor()
view.show();
QTest::qWaitForWindowShown(&view);
}
-
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp
index 979f03df64..29ea07460e 100644
--- a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -62,6 +62,7 @@ private slots:
void compressLayoutRequest();
void automaticReparenting();
void verifyActivate();
+ void invalidate();
void constructors();
void alternativeLayoutItems();
void ownership();
@@ -95,6 +96,14 @@ void tst_QGraphicsLayout::sizeHints()
}
+enum FunctionType {
+ SetGeometry = 0,
+ Invalidate,
+ NumFunctionTypes
+};
+
+
+
class TestGraphicsWidget : public QGraphicsWidget {
public:
TestGraphicsWidget(QGraphicsWidget *parent = 0) : QGraphicsWidget(parent)
@@ -108,9 +117,28 @@ public:
int eventCount(QEvent::Type type) {
return m_eventCount.value(int(type));
}
+
void clearEventCount() {
m_eventCount.clear();
}
+
+ void clearCounters() {
+ m_eventCount.clear();
+ functionCount.clear();
+ }
+
+ void setGeometry(const QRectF &rect)
+ {
+ QGraphicsWidget::setGeometry(rect);
+ ++(functionCount[SetGeometry]);
+ }
+
+ void callUpdateGeometry()
+ {
+ // updateGeometry() is protected
+ QGraphicsWidget::updateGeometry();
+ }
+ QMap<FunctionType, int> functionCount;
private:
QMap<int, int> m_eventCount;
};
@@ -122,6 +150,8 @@ void tst_QGraphicsLayout::compressLayoutRequest()
TestGraphicsWidget *tw = new TestGraphicsWidget();
scene.addItem(tw);
view.show();
+
+ QTest::qWaitForWindowShown(&view);
QGraphicsLinearLayout *lout = new QGraphicsLinearLayout(tw);
for (int i = 0; i < 4; ++i) {
QGraphicsWidget *gw = new QGraphicsWidget(tw);
@@ -217,17 +247,27 @@ class TestLayout : public QGraphicsLinearLayout
TestLayout(QGraphicsLayoutItem *parent = 0)
: QGraphicsLinearLayout(parent)
{
- m_count = 0;
+ setContentsMargins(0,0,0,0);
+ setSpacing(0);
}
- void setGeometry(const QRectF &rect) {
-
- ++m_count;
+ void setGeometry(const QRectF &rect)
+ {
+ ++(functionCount[SetGeometry]);
QGraphicsLinearLayout::setGeometry(rect);
}
+ void invalidate()
+ {
+ ++(functionCount[Invalidate]);
+ QGraphicsLinearLayout::invalidate();
+ }
+
+ void clearCounters() {
+ functionCount.clear();
+ }
- int m_count;
+ QMap<FunctionType, int> functionCount;
};
void tst_QGraphicsLayout::verifyActivate()
@@ -242,13 +282,278 @@ void tst_QGraphicsLayout::verifyActivate()
lout->addItem(w);
window->setLayout(lout);
- QCOMPARE(lout->m_count, 0);
+ QCOMPARE(lout->functionCount[SetGeometry], 0);
window->setVisible(false);
- QCOMPARE(lout->m_count, 0);
+ QCOMPARE(lout->functionCount[SetGeometry], 0);
window->setVisible(true);
// on polish or the first time a widget is shown, the widget is resized.
- QCOMPARE(lout->m_count, 1);
+ QCOMPARE(lout->functionCount[SetGeometry], 1);
+
+}
+
+static void clearAllCounters(TestGraphicsWidget *widget)
+{
+ if (!widget)
+ return;
+ widget->clearCounters();
+ TestLayout *layout = static_cast<TestLayout *>(widget->layout());
+ if (layout) {
+ layout->clearCounters();
+ for (int i = layout->count() - 1; i >=0; --i) {
+ QGraphicsLayoutItem *item = layout->itemAt(i);
+ if (item->isLayout()) {
+ // ### Not used ATM
+ //TestLayout *lay = static_cast<TestLayout*>(static_cast<QGraphicsLayout*>(item));
+ //clearAllCounters(lay);
+ } else {
+ TestGraphicsWidget *wid = static_cast<TestGraphicsWidget *>(item);
+ clearAllCounters(wid);
+ }
+ }
+ }
+}
+
+static void activateAndReset(TestGraphicsWidget *widget)
+{
+ QApplication::sendPostedEvents();
+ QApplication::processEvents();
+ if (widget->layout())
+ widget->layout()->activate();
+ clearAllCounters(widget);
+}
+
+
+void tst_QGraphicsLayout::invalidate()
+{
+ QGraphicsLayout::setInstantInvalidatePropagation(true);
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ TestGraphicsWidget *a = new TestGraphicsWidget;
+ a->setData(0, QString("a"));
+ scene.addItem(a);
+ TestLayout *alay = new TestLayout(a);
+ TestGraphicsWidget *b = new TestGraphicsWidget;
+ b->setData(0, QString("b"));
+ alay->addItem(b);
+ TestLayout *blay = new TestLayout(b);
+ TestGraphicsWidget *e = new TestGraphicsWidget;
+ e->setData(0, QString("e"));
+ blay->addItem(e);
+
+
+ TestGraphicsWidget *c = new TestGraphicsWidget;
+ c->setData(0, QString("c"));
+ alay->addItem(c);
+ TestLayout *clay = new TestLayout(c);
+ TestGraphicsWidget *f = new TestGraphicsWidget;
+ f->setData(0, QString("f"));
+ clay->addItem(f);
+
+ TestGraphicsWidget *d = new TestGraphicsWidget;
+ d->setData(0, QString("d"));
+ alay->addItem(d);
+ TestLayout *dlay = new TestLayout(d);
+ TestGraphicsWidget *g = new TestGraphicsWidget;
+ g->setData(0, QString("g"));
+ dlay->addItem(g);
+
+ view.show();
+
+ {
+ clearAllCounters(a);
+
+ QCoreApplication::sendPostedEvents();
+ QCoreApplication::processEvents();
+
+ alay->activate();
+ QCOMPARE(alay->isActivated(), true);
+ QCOMPARE(blay->isActivated(), true);
+ QCOMPARE(clay->isActivated(), true);
+ QCOMPARE(dlay->isActivated(), true);
+ }
+
+ {
+ clearAllCounters(a);
+ e->callUpdateGeometry();
+ QCOMPARE(alay->isActivated(), false);
+ QCOMPARE(blay->isActivated(), false);
+ QCOMPARE(clay->isActivated(), true);
+ QCOMPARE(dlay->isActivated(), true);
+ QCOMPARE(a->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(b->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(d->eventCount(QEvent::LayoutRequest), 0);
+
+ // should only invalidate ascendants of e
+ QCOMPARE(blay->functionCount[Invalidate], 1);
+ QCOMPARE(alay->functionCount[Invalidate], 1);
+ // not siblings
+ QCOMPARE(clay->functionCount[Invalidate], 0);
+ QCOMPARE(dlay->functionCount[Invalidate], 0);
+
+ QApplication::sendPostedEvents();
+ QCOMPARE(a->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(b->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(d->eventCount(QEvent::LayoutRequest), 0);
+ }
+
+ {
+ activateAndReset(a);
+ f->callUpdateGeometry();
+ QCOMPARE(alay->isActivated(), false);
+ QCOMPARE(blay->isActivated(), true);
+ QCOMPARE(clay->isActivated(), false);
+ QCOMPARE(dlay->isActivated(), true);
+
+ QCoreApplication::sendPostedEvents();
+ QCOMPARE(a->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(b->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(d->eventCount(QEvent::LayoutRequest), 0);
+
+ QCOMPARE(a->functionCount[SetGeometry], 1);
+ QCOMPARE(alay->functionCount[SetGeometry], 1);
+
+ QCOMPARE(b->functionCount[SetGeometry], 1);
+ QCOMPARE(c->functionCount[SetGeometry], 1);
+ QCOMPARE(d->functionCount[SetGeometry], 1);
+ // Since nothing really changed, blay and dlay don't need
+ // to be resized.
+ QCOMPARE(blay->functionCount[SetGeometry], 0);
+ QCOMPARE(clay->functionCount[SetGeometry], 1);
+ QCOMPARE(dlay->functionCount[SetGeometry], 0);
+
+ QCOMPARE(f->functionCount[SetGeometry], 1);
+
+ QCOMPARE(a->size(), QSizeF(150, 50));
+ }
+
+ {
+ activateAndReset(a);
+ f->setPreferredSize(QSizeF(60,50));
+ QCOMPARE(alay->isActivated(), false);
+ QCOMPARE(blay->isActivated(), true);
+ QCOMPARE(clay->isActivated(), false);
+ QCOMPARE(dlay->isActivated(), true);
+
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 0);
+ QCoreApplication::sendPostedEvents();
+ QCOMPARE(a->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(b->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(d->eventCount(QEvent::LayoutRequest), 0);
+
+ QCOMPARE(a->functionCount[SetGeometry], 1);
+ QCOMPARE(alay->functionCount[SetGeometry], 1);
+
+ QCOMPARE(b->functionCount[SetGeometry], 1);
+ QCOMPARE(c->functionCount[SetGeometry], 1);
+ QCOMPARE(d->functionCount[SetGeometry], 1);
+ // f actually got wider, need to rearrange its siblings
+ QCOMPARE(blay->functionCount[SetGeometry], 1);
+ QCOMPARE(clay->functionCount[SetGeometry], 1);
+ QCOMPARE(dlay->functionCount[SetGeometry], 1);
+
+ QCOMPARE(e->functionCount[SetGeometry], 1);
+ QCOMPARE(f->functionCount[SetGeometry], 1);
+ QCOMPARE(g->functionCount[SetGeometry], 1);
+
+ QVERIFY(e->size().width() < f->size().width());
+ QVERIFY(g->size().width() < f->size().width());
+ }
+
+ {
+ // resize f so much that it'll force a resize of the top widget
+ // this will currently generate two setGeometry() calls on the child layout
+ // of the top widget.
+ activateAndReset(a);
+ f->setPreferredSize(QSizeF());
+ f->setMinimumSize(QSizeF(200,50));
+ QCOMPARE(alay->isActivated(), false);
+ QCOMPARE(blay->isActivated(), true);
+ QCOMPARE(clay->isActivated(), false);
+ QCOMPARE(dlay->isActivated(), true);
+
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 0);
+ QCoreApplication::sendPostedEvents();
+ QCOMPARE(a->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(b->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(d->eventCount(QEvent::LayoutRequest), 0);
+
+ QCOMPARE(a->functionCount[SetGeometry], 1);
+
+ /* well, ideally one call to setGeometry(), but it will currently
+ * get two calls to setGeometry():
+ * 1. The first LayoutRequest will call activate() - that will call
+ * setGeometry() on the layout. This geometry will be based on
+ * the widget geometry which is not correct at this moment.
+ * (it is still 150 wide)
+ * 2. Next, we check if the widget is top level, and then we call
+ * parentWidget->resize(parentWidget->size());
+ * This will be adjusted to be minimum 200 pixels wide.
+ * The new size will then be propagated down to the layout
+ *
+ */
+ QCOMPARE(alay->functionCount[SetGeometry], 2);
+
+ QCOMPARE(b->functionCount[SetGeometry], 2);
+ QCOMPARE(c->functionCount[SetGeometry], 2);
+ QCOMPARE(d->functionCount[SetGeometry], 2);
+ // f actually got wider, need to rearrange its siblings
+ QCOMPARE(blay->functionCount[SetGeometry], 1);
+ QCOMPARE(clay->functionCount[SetGeometry], 1);
+ QCOMPARE(dlay->functionCount[SetGeometry], 1);
+
+ QCOMPARE(e->functionCount[SetGeometry], 1);
+ QCOMPARE(f->functionCount[SetGeometry], 1);
+ QCOMPARE(g->functionCount[SetGeometry], 1);
+
+ QVERIFY(e->size().width() < f->size().width());
+ QVERIFY(g->size().width() < f->size().width());
+ }
+
+ {
+ f->setPreferredSize(QSizeF());
+ f->setMinimumSize(QSizeF());
+ a->adjustSize();
+ activateAndReset(a);
+ // update two different leaf widgets,
+ // eventCount and functionCount should never be >= 2
+ e->callUpdateGeometry();
+ g->callUpdateGeometry();
+ QCOMPARE(alay->isActivated(), false);
+ QCOMPARE(blay->isActivated(), false);
+ QCOMPARE(clay->isActivated(), true);
+ QCOMPARE(dlay->isActivated(), false);
+
+ QCoreApplication::sendPostedEvents();
+ QCOMPARE(a->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(b->eventCount(QEvent::LayoutRequest), 1);
+ QCOMPARE(c->eventCount(QEvent::LayoutRequest), 0);
+ QCOMPARE(d->eventCount(QEvent::LayoutRequest), 1);
+
+ QCOMPARE(a->functionCount[SetGeometry], 1);
+ QCOMPARE(alay->functionCount[SetGeometry], 1);
+
+ QCOMPARE(b->functionCount[SetGeometry], 1);
+ QCOMPARE(c->functionCount[SetGeometry], 1);
+ QCOMPARE(d->functionCount[SetGeometry], 1);
+ // f actually got wider, need to rearrange its siblings
+ QCOMPARE(blay->functionCount[SetGeometry], 1);
+ QCOMPARE(clay->functionCount[SetGeometry], 0);
+ QCOMPARE(dlay->functionCount[SetGeometry], 1);
+
+ QCOMPARE(e->functionCount[SetGeometry], 1);
+ QCOMPARE(f->functionCount[SetGeometry], 0);
+ QCOMPARE(g->functionCount[SetGeometry], 1);
+
+ }
+
+ QGraphicsLayout::setInstantInvalidatePropagation(false);
}
class Layout : public QGraphicsLayout
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 62ba1b4981..8f8ac67d09 100644
--- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -94,6 +94,7 @@ private slots:
void itemSpacing();
void setStretchFactor_data();
void setStretchFactor();
+ void testStretch();
void defaultStretchFactors_data();
void defaultStretchFactors();
void sizeHint_data();
@@ -667,6 +668,10 @@ void tst_QGraphicsLinearLayout::invalidate()
layout.setContentsMargins(0, 0, 0, 0);
view.show();
widget->show();
+ //QTest::qWait(1000);
+ QTest::qWaitForWindowShown(&view);
+ qApp->processEvents();
+ layout.layoutRequest = 0;
layout.setContentsMargins(1, 2, 3, 4);
QApplication::sendPostedEvents(0, 0);
@@ -1130,6 +1135,41 @@ void tst_QGraphicsLinearLayout::setStretchFactor()
delete widget;
}
+void tst_QGraphicsLinearLayout::testStretch()
+{
+ QGraphicsScene scene;
+ QGraphicsView *view = new QGraphicsView(&scene);
+ QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window);
+
+ scene.addItem(form);
+ form->setMinimumSize(600, 600);
+ form->setMaximumSize(600, 600);
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, form);
+ QGraphicsWidget *w1 = new RectWidget;
+ w1->setPreferredSize(100,100);
+ w1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ QGraphicsWidget *w2 = new RectWidget;
+ w2->setPreferredSize(200,200);
+ w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ layout->setSpacing(0);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addItem(w1);
+ layout->addStretch(2);
+ layout->addItem(w2);
+ QCOMPARE(layout->count(), 2);
+ QVERIFY(layout->itemAt(0) == w1);
+ QVERIFY(layout->itemAt(1) == w2);
+ layout->activate();
+
+ //view->setSceneRect(-50, -50, 800, 800);
+ //view->show();
+ //QTest::qWaitForWindowShown(view);
+ //QTest::qWait(5000);
+ QCOMPARE(form->geometry().size(), QSizeF(600,600));
+ QCOMPARE(w1->geometry(), QRectF(0, 0, 100, 100));
+ QCOMPARE(w2->geometry(), QRectF(400, 0, 200, 200));
+}
+
void tst_QGraphicsLinearLayout::defaultStretchFactors_data()
{
QTest::addColumn<Qt::Orientation>("orientation");
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index 9434a0b6a4..903d7e796c 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -225,6 +225,10 @@ void tst_QGraphicsTransform::rotation()
rotation.setAngle(90);
QCOMPARE(transform2D(rotation).map(QPointF(10, 10)), QPointF(10, 10));
QCOMPARE(transform2D(rotation).map(QPointF(20, 10)), QPointF(10, 20));
+
+ rotation.setOrigin(QVector3D(0, 0, 0));
+ rotation.setAngle(qQNaN());
+ QCOMPARE(transform2D(rotation).map(QPointF(20, 10)), QPointF(20, 10));
}
Q_DECLARE_METATYPE(Qt::Axis);
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index e8e2e23a9e..887026caf4 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -186,7 +186,6 @@ private slots:
void task250119_shortcutContext();
void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems();
void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems();
- void QT_BUG_13865_doublePaintWhenAddingASubItem();
};
@@ -3367,46 +3366,6 @@ void tst_QGraphicsWidget::QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems()
//This should not crash
}
-
-struct GreenWidget : public QGraphicsWidget
-{
- GreenWidget() : count(0)
- {
- }
-
- void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * )
- {
- count++;
- painter->setPen(Qt::green);
- painter->drawRect(option->rect.adjusted(0,0,-1,-1));
- }
-
- int count;
-};
-
-void tst_QGraphicsWidget::QT_BUG_13865_doublePaintWhenAddingASubItem()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QGraphicsWidget *widget = new QGraphicsWidget;
- widget->resize(100, 100);
- scene.addItem(widget);
- QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(widget);
-
- view.show();
- QTest::qWaitForWindowShown(&view);
- QApplication::processEvents();
-
-
- GreenWidget *sub = new GreenWidget;
- layout->addItem(sub);
-
- QTest::qWait(100);
- QCOMPARE(sub->count, 1); //it should only be painted once
-
-}
-
-
QTEST_MAIN(tst_QGraphicsWidget)
#include "tst_qgraphicswidget.moc"
diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp
index ee2fe0d0f1..af0631e1f5 100644
--- a/tests/auto/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp
@@ -62,6 +62,12 @@
#include <private/qthread_p.h>
#include <QTcpServer>
+#ifndef QT_NO_BEARERMANAGEMENT
+#include <QtNetwork/qnetworkconfigmanager.h>
+#include <QtNetwork/qnetworkconfiguration.h>
+#include <QtNetwork/qnetworksession.h>
+#endif
+
#include <time.h>
#include <qlibrary.h>
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
@@ -126,6 +132,7 @@ private slots:
void raceCondition();
void threadSafety();
+ void threadSafetyAsynchronousAPI();
void multipleSameLookups();
void multipleDifferentLookups_data();
@@ -133,6 +140,8 @@ private slots:
void cache();
+ void abortHostLookup();
+ void abortHostLookupInDifferentThread();
protected slots:
void resultsReady(const QHostInfo &);
@@ -142,6 +151,11 @@ private:
bool lookupDone;
int lookupsDoneCounter;
QHostInfo lookupResults;
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QScopedPointer<QNetworkSession> networkSession;
+#endif
};
// Testing get/set functions
@@ -182,6 +196,21 @@ tst_QHostInfo::~tst_QHostInfo()
void tst_QHostInfo::initTestCase()
{
+#ifndef QT_NO_BEARERMANAGEMENT
+ //start the default network
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
+
+#ifdef Q_OS_SYMBIAN
+ ipv6Available = true;
+ ipv6LookupsAvailable = true;
+#else
ipv6Available = false;
ipv6LookupsAvailable = false;
#if !defined(QT_NO_GETADDRINFO)
@@ -204,6 +233,7 @@ void tst_QHostInfo::initTestCase()
}
}
#endif
+#endif
QTcpServer server;
if (server.listen(QHostAddress("::1"))) {
@@ -237,18 +267,14 @@ void tst_QHostInfo::lookupIPv4_data()
QTest::addColumn<QString>("addresses");
QTest::addColumn<int>("err");
-#ifdef Q_OS_SYMBIAN
// Test server lookup
QTest::newRow("lookup_01") << QtNetworkSettings::serverName() << QtNetworkSettings::serverIP().toString() << int(QHostInfo::NoError);
- QTest::newRow("literal_ip4") << QtNetworkSettings::serverIP().toString() << QtNetworkSettings::serverIP().toString() << int(QHostInfo::NoError);
- QTest::newRow("multiple_ip4") << "multi.dev.troll.no" << "1.2.3.4 1.2.3.5 10.3.3.31" << int(QHostInfo::NoError);
-#else
QTest::newRow("empty") << "" << "" << int(QHostInfo::HostNotFound);
QTest::newRow("single_ip4") << "lupinella.troll.no" << lupinellaIp << int(QHostInfo::NoError);
QTest::newRow("multiple_ip4") << "multi.dev.troll.no" << "1.2.3.4 1.2.3.5 10.3.3.31" << int(QHostInfo::NoError);
QTest::newRow("literal_ip4") << lupinellaIp << lupinellaIp << int(QHostInfo::NoError);
-#endif
+
QTest::newRow("notfound") << "this-name-does-not-exist-hopefully." << "" << int(QHostInfo::HostNotFound);
QTest::newRow("idn-ace") << "xn--alqualond-34a.troll.no" << "10.3.3.55" << int(QHostInfo::NoError);
@@ -290,7 +316,11 @@ void tst_QHostInfo::lookupIPv6_data()
QTest::addColumn<QString>("addresses");
QTest::addColumn<int>("err");
- QTest::newRow("ip6") << "www.ipv6-net.org" << "62.93.217.177 2001:618:1401:0:0:0:0:4" << int(QHostInfo::NoError);
+ QTest::newRow("ipv6-net") << "www.ipv6-net.org" << "62.93.217.177 2001:618:1401:0:0:0:0:4" << int(QHostInfo::NoError);
+ QTest::newRow("ipv6-test") << "ipv6-test.dev.troll.no" << "2001:638:a00:2:0:0:0:2" << int(QHostInfo::NoError);
+ QTest::newRow("dns6-test") << "dns6-test-dev.troll.no" << "2001:470:1f01:115:0:0:0:10" << int(QHostInfo::NoError);
+ QTest::newRow("multi-dns6") << "multi-dns6-test-dev.troll.no" << "2001:470:1f01:115:0:0:0:11 2001:470:1f01:115:0:0:0:12" << int(QHostInfo::NoError);
+ QTest::newRow("dns46-test") << "dns46-test-dev.troll.no" << "10.3.4.90 2001:470:1f01:115:0:0:0:13" << int(QHostInfo::NoError);
// avoid using real IPv6 addresses here because this will do a DNS query
// real addresses are between 2000:: and 3fff:ffff:ffff:ffff:ffff:ffff:ffff
@@ -310,7 +340,7 @@ void tst_QHostInfo::lookupIPv6()
lookupDone = false;
QHostInfo::lookupHost(hostname, this, SLOT(resultsReady(const QHostInfo&)));
- QTestEventLoop::instance().enterLoop(3);
+ QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(lookupDone);
@@ -337,7 +367,7 @@ void tst_QHostInfo::reverseLookup_data()
// ### Use internal DNS instead. Discussed with Andreas.
//QTest::newRow("classical.hexago.com") << QString("2001:5c0:0:2::24") << QStringList(QString("classical.hexago.com")) << 0;
- QTest::newRow("origin.cisco.com") << QString("12.159.148.94") << QStringList(QString("origin.cisco.com")) << 0;
+ QTest::newRow("gitorious.org") << QString("87.238.52.168") << QStringList(QString("gitorious.org")) << 0;
QTest::newRow("bogus-name") << QString("1::2::3::4") << QStringList() << 1;
}
@@ -411,6 +441,8 @@ protected:
inline void run()
{
QHostInfo info = QHostInfo::fromName("qt.nokia.com");
+ QCOMPARE(info.error(), QHostInfo::NoError);
+ QVERIFY(info.addresses().count() > 0);
QCOMPARE(info.addresses().at(0).toString(), QString("87.238.50.178"));
}
};
@@ -418,7 +450,7 @@ protected:
void tst_QHostInfo::threadSafety()
{
const int nattempts = 5;
-#if defined(Q_OS_WINCE)
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
const int runs = 10;
#else
const int runs = 100;
@@ -432,6 +464,56 @@ void tst_QHostInfo::threadSafety()
}
}
+class LookupReceiver : public QObject
+{
+ Q_OBJECT
+public slots:
+ void start();
+ void resultsReady(const QHostInfo&);
+public:
+ QHostInfo result;
+ int numrequests;
+};
+
+void LookupReceiver::start()
+{
+ for (int i=0;i<numrequests;i++)
+ QHostInfo::lookupHost(QString("qt.nokia.com"), this, SLOT(resultsReady(const QHostInfo&)));
+}
+
+void LookupReceiver::resultsReady(const QHostInfo &info)
+{
+ result = info;
+ numrequests--;
+ if (numrequests == 0 || info.error() != QHostInfo::NoError)
+ QThread::currentThread()->quit();
+}
+
+void tst_QHostInfo::threadSafetyAsynchronousAPI()
+{
+ const int nattempts = 10;
+ const int lookupsperthread = 10;
+ QList<QThread*> threads;
+ QList<LookupReceiver*> receivers;
+ for (int i = 0; i < nattempts; ++i) {
+ QThread* thread = new QThread;
+ LookupReceiver* receiver = new LookupReceiver;
+ receiver->numrequests = lookupsperthread;
+ receivers.append(receiver);
+ receiver->moveToThread(thread);
+ connect(thread, SIGNAL(started()), receiver, SLOT(start()));
+ thread->start();
+ threads.append(thread);
+ }
+ for (int k = threads.count() - 1; k >= 0; --k)
+ QVERIFY(threads.at(k)->wait(60000));
+ foreach (LookupReceiver* receiver, receivers) {
+ QCOMPARE(receiver->result.error(), QHostInfo::NoError);
+ QCOMPARE(receiver->result.addresses().at(0).toString(), QString("87.238.50.178"));
+ QCOMPARE(receiver->numrequests, 0);
+ }
+}
+
// this test is for the multi-threaded QHostInfo rewrite. It is about getting results at all,
// not about getting correct IPs
void tst_QHostInfo::multipleSameLookups()
@@ -478,8 +560,9 @@ void tst_QHostInfo::multipleDifferentLookups()
QElapsedTimer timer;
timer.start();
- while (timer.elapsed() < 10000 && lookupsDoneCounter < repeats*COUNT) {
+ while (timer.elapsed() < 60000 && lookupsDoneCounter < repeats*COUNT) {
QTestEventLoop::instance().enterLoop(2);
+ //qDebug() << "t:" << timer.elapsed();
}
QCOMPARE(lookupsDoneCounter, repeats*COUNT);
}
@@ -520,7 +603,7 @@ void tst_QHostInfo::cache()
QVERIFY(result.addresses().isEmpty());
// the slot should have been called 2 times.
- QVERIFY(lookupsDoneCounter == 2);
+ QCOMPARE(lookupsDoneCounter, 2);
}
void tst_QHostInfo::resultsReady(const QHostInfo &hi)
@@ -531,5 +614,52 @@ void tst_QHostInfo::resultsReady(const QHostInfo &hi)
QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection);
}
+void tst_QHostInfo::abortHostLookup()
+{
+ //reset counter
+ lookupsDoneCounter = 0;
+ bool valid = false;
+ int id = -1;
+ QHostInfo result = qt_qhostinfo_lookup("qt.nokia.com", this, SLOT(resultsReady(QHostInfo)), &valid, &id);
+ QVERIFY(!valid);
+ //it is assumed that the DNS request/response in the backend is slower than it takes to call abort
+ QHostInfo::abortHostLookup(id);
+ QTestEventLoop::instance().enterLoop(5);
+ QCOMPARE(lookupsDoneCounter, 0);
+}
+
+class LookupAborter : public QObject
+{
+ Q_OBJECT
+public slots:
+ void abort()
+ {
+ QHostInfo::abortHostLookup(id);
+ QThread::currentThread()->quit();
+ }
+public:
+ int id;
+};
+
+void tst_QHostInfo::abortHostLookupInDifferentThread()
+{
+ //reset counter
+ lookupsDoneCounter = 0;
+ bool valid = false;
+ int id = -1;
+ QHostInfo result = qt_qhostinfo_lookup("qt.nokia.com", this, SLOT(resultsReady(QHostInfo)), &valid, &id);
+ QVERIFY(!valid);
+ QThread thread;
+ LookupAborter aborter;
+ aborter.id = id;
+ aborter.moveToThread(&thread);
+ connect(&thread, SIGNAL(started()), &aborter, SLOT(abort()));
+ //it is assumed that the DNS request/response in the backend is slower than it takes to schedule the thread and call abort
+ thread.start();
+ QVERIFY(thread.wait(5000));
+ QTestEventLoop::instance().enterLoop(5);
+ QCOMPARE(lookupsDoneCounter, 0);
+}
+
QTEST_MAIN(tst_QHostInfo)
#include "tst_qhostinfo.moc"
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index 0b7213916b..ba1f8c8cca 100644
--- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -195,8 +195,8 @@ void tst_QHttpNetworkConnection::head()
QCOMPARE(reply->statusCode(), statusCode);
QCOMPARE(reply->reasonPhrase(), statusString);
- // only check it if it is set
- if (reply->contentLength() != -1)
+ // only check it if it is set and expected
+ if (reply->contentLength() != -1 && contentLength != -1)
QCOMPARE(reply->contentLength(), qint64(contentLength));
QVERIFY(reply->isFinished());
@@ -219,8 +219,8 @@ void tst_QHttpNetworkConnection::get_data()
QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962;
QTest::newRow("success-external") << "http://" << "www.ietf.org" << "/rfc/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962;
- QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << 997 + QtNetworkSettings::serverName().size();
- QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << 930 + QtNetworkSettings::serverName().size();
+ QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << -1;
+ QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << -1;
}
void tst_QHttpNetworkConnection::get()
@@ -255,8 +255,8 @@ void tst_QHttpNetworkConnection::get()
QCOMPARE(reply->statusCode(), statusCode);
QCOMPARE(reply->reasonPhrase(), statusString);
- // only check it if it is set
- if (reply->contentLength() != -1)
+ // only check it if it is set and expected
+ if (reply->contentLength() != -1 && contentLength != -1)
QCOMPARE(reply->contentLength(), qint64(contentLength));
stopWatch.start();
@@ -270,7 +270,12 @@ void tst_QHttpNetworkConnection::get()
} while (!reply->isFinished());
QVERIFY(reply->isFinished());
- QCOMPARE(ba.size(), downloadSize);
+ //do not require server generated error pages to be a fixed size
+ if (downloadSize != -1)
+ QCOMPARE(ba.size(), downloadSize);
+ //but check against content length if it was sent
+ if (reply->contentLength() != -1)
+ QCOMPARE(ba.size(), (int)reply->contentLength());
delete reply;
}
@@ -385,7 +390,7 @@ void tst_QHttpNetworkConnection::post_data()
QTest::addColumn<int>("downloadSize");
QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/cgi-bin/echo.cgi" << ushort(80) << false << "7 bytes" << 200 << "OK" << 7 << 7;
- QTest::newRow("failure-internal") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << 997 + QtNetworkSettings::serverName().size();
+ QTest::newRow("failure-internal") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << -1;
}
void tst_QHttpNetworkConnection::post()
@@ -429,13 +434,16 @@ void tst_QHttpNetworkConnection::post()
QCOMPARE(reply->reasonPhrase(), statusString);
qint64 cLen = reply->contentLength();
- if (cLen==-1) {
- // HTTP 1.1 server may respond with chunked encoding and in that
- // case contentLength is not present in reply -> verify that it is the case
- QByteArray transferEnc = reply->headerField("Transfer-Encoding");
- QCOMPARE(transferEnc, QByteArray("chunked"));
- } else {
- QCOMPARE(cLen, qint64(contentLength));
+ if (contentLength != -1) {
+ // only check the content length if test expected it to be set
+ if (cLen==-1) {
+ // HTTP 1.1 server may respond with chunked encoding and in that
+ // case contentLength is not present in reply -> verify that it is the case
+ QByteArray transferEnc = reply->headerField("Transfer-Encoding");
+ QCOMPARE(transferEnc, QByteArray("chunked"));
+ } else {
+ QCOMPARE(cLen, qint64(contentLength));
+ }
}
stopWatch.start();
@@ -449,7 +457,12 @@ void tst_QHttpNetworkConnection::post()
} while (!reply->isFinished());
QVERIFY(reply->isFinished());
- QCOMPARE(ba.size(), downloadSize);
+ //don't require fixed size for generated error pages
+ if (downloadSize != -1)
+ QCOMPARE(ba.size(), downloadSize);
+ //but do compare with content length if possible
+ if (cLen != -1)
+ QCOMPARE(ba.size(), (int)cLen);
delete reply;
}
@@ -630,7 +643,8 @@ void tst_QHttpNetworkConnection::compression()
QCOMPARE(reply->statusCode(), statusCode);
QCOMPARE(reply->reasonPhrase(), statusString);
bool isLengthOk = (reply->contentLength() == qint64(contentLength)
- || reply->contentLength() == qint64(downloadSize));
+ || reply->contentLength() == qint64(downloadSize)
+ || reply->contentLength() == -1); //apache2 does not send content-length for compressed pages
QVERIFY(isLengthOk);
diff --git a/tests/auto/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/qhttpsocketengine/qhttpsocketengine.pro
index d76ebb6f10..6df619200b 100644
--- a/tests/auto/qhttpsocketengine/qhttpsocketengine.pro
+++ b/tests/auto/qhttpsocketengine/qhttpsocketengine.pro
@@ -2,7 +2,7 @@ load(qttest_p4)
SOURCES += tst_qhttpsocketengine.cpp
-include(../qnativesocketengine/qsocketengine.pri)
+include(../platformsocketengine/platformsocketengine.pri)
MOC_DIR=tmp
diff --git a/tests/auto/qidentityproxymodel/qidentityproxymodel.pro b/tests/auto/qidentityproxymodel/qidentityproxymodel.pro
new file mode 100644
index 0000000000..f529e20c7f
--- /dev/null
+++ b/tests/auto/qidentityproxymodel/qidentityproxymodel.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+INCLUDEPATH += $$PWD/../modeltest
+
+SOURCES += tst_qidentityproxymodel.cpp ../modeltest/dynamictreemodel.cpp ../modeltest/modeltest.cpp
+HEADERS += ../modeltest/dynamictreemodel.h ../modeltest/modeltest.h
diff --git a/tests/auto/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/qidentityproxymodel/tst_qidentityproxymodel.cpp
new file mode 100644
index 0000000000..cfc3f1a6a8
--- /dev/null
+++ b/tests/auto/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -0,0 +1,334 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+
+#include <QtCore>
+#include <QtGui>
+
+#include "dynamictreemodel.h"
+#include "qidentityproxymodel.h"
+
+//TESTED CLASS=
+//TESTED_FILES=
+
+Q_DECLARE_METATYPE(QModelIndex)
+
+class tst_QIdentityProxyModel : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ tst_QIdentityProxyModel();
+ virtual ~tst_QIdentityProxyModel();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void insertRows();
+ void removeRows();
+ void moveRows();
+ void reset();
+
+protected:
+ void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex());
+
+private:
+ QStandardItemModel *m_model;
+ QIdentityProxyModel *m_proxy;
+};
+
+tst_QIdentityProxyModel::tst_QIdentityProxyModel()
+ : m_model(0), m_proxy(0)
+{
+
+}
+
+tst_QIdentityProxyModel::~tst_QIdentityProxyModel()
+{
+
+}
+
+void tst_QIdentityProxyModel::initTestCase()
+{
+ qRegisterMetaType<QModelIndex>("QModelIndex");
+
+ m_model = new QStandardItemModel(0, 1);
+ m_proxy = new QIdentityProxyModel();
+}
+
+void tst_QIdentityProxyModel::cleanupTestCase()
+{
+ delete m_proxy;
+ delete m_model;
+}
+
+void tst_QIdentityProxyModel::init()
+{
+}
+
+void tst_QIdentityProxyModel::cleanup()
+{
+ m_model->clear();
+ m_model->insertColumns(0, 1);
+}
+
+void tst_QIdentityProxyModel::verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent)
+{
+ const int rows = model->rowCount(parent);
+ const int columns = model->columnCount(parent);
+ const QModelIndex proxyParent = m_proxy->mapFromSource(parent);
+
+ QVERIFY(m_proxy->mapToSource(proxyParent) == parent);
+ QVERIFY(rows == m_proxy->rowCount(proxyParent));
+ QVERIFY(columns == m_proxy->columnCount(proxyParent));
+
+ for (int row = 0; row < rows; ++row) {
+ for (int column = 0; column < columns; ++column) {
+ const QModelIndex idx = model->index(row, column, parent);
+ const QModelIndex proxyIdx = m_proxy->mapFromSource(idx);
+ QVERIFY(proxyIdx.model() == m_proxy);
+ QVERIFY(m_proxy->mapToSource(proxyIdx) == idx);
+ QVERIFY(proxyIdx.isValid());
+ QVERIFY(proxyIdx.row() == row);
+ QVERIFY(proxyIdx.column() == column);
+ QVERIFY(proxyIdx.parent() == proxyParent);
+ QVERIFY(proxyIdx.data() == idx.data());
+ QVERIFY(proxyIdx.flags() == idx.flags());
+ const int childCount = m_proxy->rowCount(proxyIdx);
+ const bool hasChildren = m_proxy->hasChildren(proxyIdx);
+ QVERIFY(model->hasChildren(idx) == hasChildren);
+ QVERIFY((childCount > 0) == hasChildren);
+
+ if (hasChildren)
+ verifyIdentity(model, idx);
+ }
+ }
+}
+
+/*
+ tests
+*/
+
+void tst_QIdentityProxyModel::insertRows()
+{
+ QStandardItem *parentItem = m_model->invisibleRootItem();
+ for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
+ parentItem->appendRow(item);
+ parentItem = item;
+ }
+
+ m_proxy->setSourceModel(m_model);
+
+ 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)));
+
+ QStandardItem *item = new QStandardItem(QString("new item"));
+ parentItem->appendRow(item);
+
+ QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size());
+ QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size());
+
+ QVERIFY(modelBeforeSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>()));
+ QVERIFY(modelBeforeSpy.first().at(1) == proxyBeforeSpy.first().at(1));
+ QVERIFY(modelBeforeSpy.first().at(2) == proxyBeforeSpy.first().at(2));
+
+ QVERIFY(modelAfterSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>()));
+ QVERIFY(modelAfterSpy.first().at(1) == proxyAfterSpy.first().at(1));
+ QVERIFY(modelAfterSpy.first().at(2) == proxyAfterSpy.first().at(2));
+
+ verifyIdentity(m_model);
+
+}
+
+void tst_QIdentityProxyModel::removeRows()
+{
+ QStandardItem *parentItem = m_model->invisibleRootItem();
+ for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
+ parentItem->appendRow(item);
+ parentItem = item;
+ }
+
+ m_proxy->setSourceModel(m_model);
+
+ 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)));
+
+ const QModelIndex topLevel = m_model->index(0, 0, QModelIndex());
+ const QModelIndex secondLevel = m_model->index(0, 0, topLevel);
+ const QModelIndex thirdLevel = m_model->index(0, 0, secondLevel);
+
+ QVERIFY(thirdLevel.isValid());
+
+ m_model->removeRow(0, secondLevel);
+
+ QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size());
+ QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size());
+
+ QVERIFY(modelBeforeSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>()));
+ QVERIFY(modelBeforeSpy.first().at(1) == proxyBeforeSpy.first().at(1));
+ QVERIFY(modelBeforeSpy.first().at(2) == proxyBeforeSpy.first().at(2));
+
+ QVERIFY(modelAfterSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>()));
+ QVERIFY(modelAfterSpy.first().at(1) == proxyAfterSpy.first().at(1));
+ QVERIFY(modelAfterSpy.first().at(2) == proxyAfterSpy.first().at(2));
+
+ verifyIdentity(m_model);
+}
+
+void tst_QIdentityProxyModel::moveRows()
+{
+ DynamicTreeModel model;
+
+ {
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(9);
+ insertCommand.doCommand();
+ }
+ {
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(QList<int>() << 5);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(9);
+ insertCommand.doCommand();
+ }
+
+ m_proxy->setSourceModel(&model);
+
+ 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)));
+
+ {
+ ModelMoveCommand moveCommand(&model, 0);
+ moveCommand.setAncestorRowNumbers(QList<int>() << 5);
+ moveCommand.setStartRow(3);
+ moveCommand.setEndRow(4);
+ moveCommand.setDestRow(1);
+ moveCommand.doCommand();
+ }
+
+ QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size());
+ QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size());
+
+ QVERIFY(modelBeforeSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>()));
+ QVERIFY(modelBeforeSpy.first().at(1) == proxyBeforeSpy.first().at(1));
+ QVERIFY(modelBeforeSpy.first().at(2) == proxyBeforeSpy.first().at(2));
+ QVERIFY(modelBeforeSpy.first().at(3).value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().at(3).value<QModelIndex>()));
+ QVERIFY(modelBeforeSpy.first().at(4) == proxyBeforeSpy.first().at(4));
+
+ QVERIFY(modelAfterSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>()));
+ QVERIFY(modelAfterSpy.first().at(1) == proxyAfterSpy.first().at(1));
+ QVERIFY(modelAfterSpy.first().at(2) == proxyAfterSpy.first().at(2));
+ QVERIFY(modelAfterSpy.first().at(3).value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().at(3).value<QModelIndex>()));
+ QVERIFY(modelAfterSpy.first().at(4) == proxyAfterSpy.first().at(4));
+
+ verifyIdentity(&model);
+
+ m_proxy->setSourceModel(0);
+}
+
+void tst_QIdentityProxyModel::reset()
+{
+ DynamicTreeModel model;
+
+ {
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(9);
+ insertCommand.doCommand();
+ }
+ {
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(QList<int>() << 5);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(9);
+ insertCommand.doCommand();
+ }
+
+ m_proxy->setSourceModel(&model);
+
+ verifyIdentity(&model);
+
+ QSignalSpy modelBeforeSpy(&model, SIGNAL(modelAboutToBeReset()));
+ QSignalSpy modelAfterSpy(&model, SIGNAL(modelReset()));
+ QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(modelAboutToBeReset()));
+ QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(modelReset()));
+
+ {
+ ModelResetCommandFixed resetCommand(&model, 0);
+ resetCommand.setAncestorRowNumbers(QList<int>() << 5);
+ resetCommand.setStartRow(3);
+ resetCommand.setEndRow(4);
+ resetCommand.setDestRow(1);
+ resetCommand.doCommand();
+ }
+
+ QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size());
+ QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size());
+
+ verifyIdentity(&model);
+ m_proxy->setSourceModel(0);
+}
+
+QTEST_MAIN(tst_QIdentityProxyModel)
+#include "tst_qidentityproxymodel.moc"
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 6e20fb23c4..d91b068c5f 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -101,6 +101,7 @@ private slots:
void testDifferentModels();
void testValidRangesInSelectionsAfterReset();
+ void testChainedSelectionClear();
private:
QAbstractItemModel *model;
@@ -2655,5 +2656,58 @@ void tst_QItemSelectionModel::testValidRangesInSelectionsAfterReset()
model.setStringList(strings);
}
+class DuplicateItemSelectionModel : public QItemSelectionModel
+{
+ Q_OBJECT
+public:
+ DuplicateItemSelectionModel(QItemSelectionModel *target, QAbstractItemModel *model, QObject *parent = 0)
+ : QItemSelectionModel(model, parent), m_target(target)
+ {
+
+ }
+
+ void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
+ {
+ QItemSelectionModel::select(selection, command);
+ m_target->select(selection, command);
+ }
+
+ using QItemSelectionModel::select;
+
+private:
+ QItemSelectionModel *m_target;
+
+};
+
+void tst_QItemSelectionModel::testChainedSelectionClear()
+{
+ QStringListModel model(QStringList() << "Apples" << "Pears");
+
+ QItemSelectionModel selectionModel(&model, 0);
+ DuplicateItemSelectionModel duplicate(&selectionModel, &model, 0);
+
+ duplicate.select(model.index(0, 0), QItemSelectionModel::Select);
+
+ {
+ QModelIndexList selectedIndexes = selectionModel.selection().indexes();
+ QModelIndexList duplicatedIndexes = duplicate.selection().indexes();
+
+ QVERIFY(selectedIndexes.size() == duplicatedIndexes.size());
+ QVERIFY(selectedIndexes.size() == 1);
+ QVERIFY(selectedIndexes.first() == model.index(0, 0));
+ }
+
+ duplicate.clearSelection();
+
+ {
+ QModelIndexList selectedIndexes = selectionModel.selection().indexes();
+ QModelIndexList duplicatedIndexes = duplicate.selection().indexes();
+
+ QVERIFY(selectedIndexes.size() == duplicatedIndexes.size());
+ QVERIFY(selectedIndexes.size() == 0);
+ }
+
+}
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 9176174cd8..f45481ca8a 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -282,6 +282,12 @@ private slots:
void validateAndSet();
#endif
+ void bidiVisualMovement_data();
+ void bidiVisualMovement();
+
+ void bidiLogicalMovement_data();
+ void bidiLogicalMovement();
+
protected slots:
#ifdef QT3_SUPPORT
void lostFocus();
@@ -3760,5 +3766,135 @@ void tst_QLineEdit::QTBUG13520_textNotVisible()
}
+void tst_QLineEdit::bidiVisualMovement_data()
+{
+ QTest::addColumn<QString>("logical");
+ QTest::addColumn<int>("basicDir");
+ QTest::addColumn<IntList>("positionList");
+
+ QTest::newRow("Latin text")
+ << QString::fromUtf8("abc")
+ << (int) QChar::DirL
+ << (IntList() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text, one item")
+ << QString::fromUtf8("\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text after Latin text")
+ << QString::fromUtf8("abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("Latin text after Hebrew text")
+ << QString::fromUtf8("\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("LTR, 3 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("RTL, 3 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("LTR, 4 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+ QTest::newRow("RTL, 4 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+}
+
+void tst_QLineEdit::bidiVisualMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+ QFETCH(IntList, positionList);
+
+ QLineEdit le;
+ le.setText(logical);
+
+ le.setCursorMoveStyle(QTextCursor::Visual);
+ le.setCursorPosition(0);
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Right);
+ } else
+ QTest::keyClick(&le, Qt::Key_Left);
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ QVERIFY(i == positionList.size());
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Left);
+ } else
+ {
+ QTest::keyClick(&le, Qt::Key_Right);
+ }
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
+void tst_QLineEdit::bidiLogicalMovement_data()
+{
+ bidiVisualMovement_data();
+}
+
+void tst_QLineEdit::bidiLogicalMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+
+ QLineEdit le;
+ le.setText(logical);
+
+ le.setCursorMoveStyle(QTextCursor::Logical);
+ le.setCursorPosition(0);
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Right);
+ } else
+ QTest::keyClick(&le, Qt::Key_Left);
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Left);
+ } else
+ {
+ QTest::keyClick(&le, Qt::Key_Right);
+ }
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index b6e69a0296..ee03386844 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -1893,7 +1893,8 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick()
QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount());
- QPoint p = view.visualRect(model.index(model.rowCount() - 1)).center() + QPoint(0, 20);
+ const QRect itemRect = view.visualRect(model.index(model.rowCount() - 1));
+ QPoint p = view.visualRect(model.index(model.rowCount() - 1)).center() + QPoint(0, itemRect.height());
//first the left button
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
QVERIFY(!view.selectionModel()->hasSelection());
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 4f0de4c8da..2ffc9e923b 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -140,6 +140,11 @@ private slots:
#endif
void ampm();
+ void currency();
+ void quoteString();
+ void uiLanguages();
+ void weekendDays();
+ void listPatterns();
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
@@ -181,6 +186,7 @@ void tst_QLocale::ctor()
QCOMPARE(l.language(), QLocale::C);
QCOMPARE(l.country(), QLocale::AnyCountry);
}
+ TEST_CTOR(AnyLanguage, AnyCountry, default_lang, default_country)
TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry)
TEST_CTOR(Aymara, AnyCountry, default_lang, default_country)
TEST_CTOR(Aymara, France, default_lang, default_country)
@@ -306,6 +312,7 @@ void tst_QLocale::ctor()
TEST_CTOR("en@", English, UnitedStates)
TEST_CTOR("en.@", English, UnitedStates)
TEST_CTOR("en_", English, UnitedStates)
+ TEST_CTOR("en_U", English, UnitedStates)
TEST_CTOR("en_.", English, UnitedStates)
TEST_CTOR("en_.@", English, UnitedStates)
TEST_CTOR("en.bla", English, UnitedStates)
@@ -316,6 +323,8 @@ void tst_QLocale::ctor()
TEST_CTOR("en_GB.bla", English, UnitedKingdom)
TEST_CTOR("en_GB@.bla", English, UnitedKingdom)
TEST_CTOR("en_GB@bla", English, UnitedKingdom)
+ TEST_CTOR("en-GB", English, UnitedKingdom)
+ TEST_CTOR("en-GB@bla", English, UnitedKingdom)
QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal);
TEST_CTOR("no", Norwegian, Norway)
@@ -326,13 +335,38 @@ void tst_QLocale::ctor()
TEST_CTOR("nn_NO", NorwegianNynorsk, Norway)
TEST_CTOR("es_ES", Spanish, Spain)
TEST_CTOR("es_419", Spanish, LatinAmericaAndTheCaribbean)
+ TEST_CTOR("es-419", Spanish, LatinAmericaAndTheCaribbean)
// test default countries for languages
+ TEST_CTOR("zh", Chinese, China)
+ TEST_CTOR("zh-Hans", Chinese, China)
TEST_CTOR("mn", Mongolian, Mongolia)
TEST_CTOR("ne", Nepali, Nepal)
#undef TEST_CTOR
+#define TEST_CTOR(req_lc, exp_lang, exp_script, exp_country) \
+ { \
+ QLocale l(req_lc); \
+ QVERIFY2(l.language() == QLocale::exp_lang \
+ && l.script() == QLocale::exp_script \
+ && l.country() == QLocale::exp_country, \
+ QString("requested: \"" + QString(req_lc) + "\", got: " \
+ + QLocale::languageToString(l.language()) \
+ + "/" + QLocale::scriptToString(l.script()) \
+ + "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ }
+
+ TEST_CTOR("zh_CN", Chinese, AnyScript, China)
+ TEST_CTOR("zh_Hans_CN", Chinese, SimplifiedHanScript, China)
+ TEST_CTOR("zh_Hans", Chinese, SimplifiedHanScript, China)
+ TEST_CTOR("zh_Hant", Chinese, TraditionalHanScript, HongKong)
+ TEST_CTOR("zh_Hans_MO", Chinese, SimplifiedHanScript, Macau)
+ TEST_CTOR("zh_Hant_MO", Chinese, TraditionalHanScript, Macau)
+ TEST_CTOR("az_Latn_AZ", Azerbaijani, LatinScript, Azerbaijan)
+ TEST_CTOR("ha_Arab_NG", Hausa, ArabicScript, Nigeria)
+ TEST_CTOR("ha_Latn_NG", Hausa, LatinScript, Nigeria)
+#undef TEST_CTOR
}
void tst_QLocale::emptyCtor()
@@ -405,11 +439,12 @@ void tst_QLocale::emptyCtor()
TEST_CTOR("nb_NO", "nb_NO")
TEST_CTOR("nn_NO", "nn_NO")
+ TEST_CTOR("DE", "de_DE");
+ TEST_CTOR("EN", "en_US");
+
TEST_CTOR("en/", defaultLoc)
- TEST_CTOR("DE", defaultLoc);
TEST_CTOR("asdfghj", defaultLoc);
TEST_CTOR("123456", defaultLoc);
- TEST_CTOR("EN", defaultLoc);
#undef TEST_CTOR
#endif
@@ -1095,6 +1130,11 @@ void tst_QLocale::macDefaultLocale()
const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat);
QVERIFY(timeString.contains(QString("1:02:03")));
+ QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234.00"));
+ QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), QString("($1,234.00)"));
+ QCOMPARE(locale.toCurrencyString(double(1234.56)), QString("$1,234.56"));
+ QCOMPARE(locale.toCurrencyString(double(-1234.56)), QString("($1,234.56)"));
+
// Depending on the configured time zone, the time string might not
// contain a GMT specifier. (Sometimes it just names the zone, like "CEST")
if (timeString.contains(QString("GMT"))) {
@@ -1107,12 +1147,23 @@ void tst_QLocale::macDefaultLocale()
expectedGMTSpecifier.append(QString("0%1").arg(qAbs(diff)));
else
expectedGMTSpecifier.append(QString("%1").arg(qAbs(diff)));
- QVERIFY(timeString.contains(expectedGMTSpecifier));
+ QVERIFY2(timeString.contains(expectedGMTSpecifier), qPrintable(
+ QString("timeString `%1', expectedGMTSpecifier `%2'")
+ .arg(timeString)
+ .arg(expectedGMTSpecifier)
+ ));
}
QCOMPARE(locale.dayName(1), QString("Monday"));
QCOMPARE(locale.dayName(7), QString("Sunday"));
QCOMPARE(locale.monthName(1), QString("January"));
QCOMPARE(locale.monthName(12), QString("December"));
+ QCOMPARE(locale.firstDayOfWeek(), Qt::Sunday);
+ QCOMPARE(locale.quoteString("string"), QString::fromUtf8("\xe2\x80\x9c" "string" "\xe2\x80\x9d"));
+ QCOMPARE(locale.quoteString("string", QLocale::AlternateQuotation), QString::fromUtf8("\xe2\x80\x98" "string" "\xe2\x80\x99"));
+
+ QList<Qt::DayOfWeek> days;
+ days << Qt::Monday << Qt::Tuesday << Qt::Wednesday << Qt::Thursday << Qt::Friday;
+ QCOMPARE(locale.weekdays(), days);
}
@@ -1768,6 +1819,7 @@ void tst_QLocale::measurementSystems_data()
void tst_QLocale::measurementSystems()
{
+ QSKIP("Meh, skip the test as we do not reread the environment variables anymore", SkipAll);
QFETCH(QString, localeName);
QFETCH(int, mSystem);
@@ -1829,6 +1881,7 @@ void tst_QLocale::systemMeasurementSystems_data()
void tst_QLocale::systemMeasurementSystems()
{
+ QSKIP("Meh, skip the test as we do not reread the environment variables anymore", SkipAll);
// Theoretically, we could include HPUX in this test, but its setenv implementation
// stinks. It's called putenv, and it requires you to keep the variable you pass
// to it around forever.
@@ -1951,6 +2004,7 @@ void tst_QLocale::queryMeasureSystem_data()
void tst_QLocale::queryMeasureSystem()
{
+ QSKIP("Meh, skip the test as we do not reread the environment variables anymore", SkipAll);
// Theoretically, we could include HPUX in this test, but its setenv implementation
// stinks. It's called putenv, and it requires you to keep the variable you pass
// to it around forever.
@@ -2066,6 +2120,10 @@ void tst_QLocale::monthName()
QCOMPARE(ru.monthName(1, QLocale::LongFormat), QString::fromUtf8("\321\217\320\275\320\262\320\260\321\200\321\217"));
QCOMPARE(ru.monthName(1, QLocale::ShortFormat), QString::fromUtf8("\321\217\320\275\320\262\56"));
QCOMPARE(ru.monthName(1, QLocale::NarrowFormat), QString::fromUtf8("\320\257"));
+
+ // check that our CLDR scripts handle surrogate pairs correctly
+ QLocale dsrt("en-Dsrt-US");
+ QCOMPARE(dsrt.monthName(1, QLocale::LongFormat), QString::fromUtf8("\xf0\x90\x90\x96\xf0\x90\x90\xb0\xf0\x90\x91\x8c\xf0\x90\x90\xb7\xf0\x90\x90\xad\xf0\x90\x90\xaf\xf0\x90\x91\x89\xf0\x90\x90\xa8"));
}
void tst_QLocale::standaloneMonthName()
@@ -2123,5 +2181,102 @@ void tst_QLocale::symbianSystemLocale()
}
#endif
+void tst_QLocale::currency()
+{
+ const QLocale c(QLocale::C);
+ QCOMPARE(c.toCurrencyString(qulonglong(1234)), QString("1234"));
+ QCOMPARE(c.toCurrencyString(qlonglong(-1234)), QString("-1234"));
+ QCOMPARE(c.toCurrencyString(double(1234.56)), QString("1234.56"));
+ QCOMPARE(c.toCurrencyString(double(-1234.56)), QString("-1234.56"));
+
+ const QLocale ru_RU("ru_RU");
+ QCOMPARE(ru_RU.toCurrencyString(qulonglong(1234)), QString::fromUtf8("1234\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+ QCOMPARE(ru_RU.toCurrencyString(qlonglong(-1234)), QString::fromUtf8("-1234\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+ QCOMPARE(ru_RU.toCurrencyString(double(1234.56)), QString::fromUtf8("1234,56\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+ QCOMPARE(ru_RU.toCurrencyString(double(-1234.56)), QString::fromUtf8("-1234,56\xc2\xa0\xd1\x80\xd1\x83\xd0\xb1."));
+
+ const QLocale de_DE("de_DE");
+ QCOMPARE(de_DE.toCurrencyString(qulonglong(1234)), QString::fromUtf8("1234\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(qulonglong(1234), QLatin1String("BAZ")), QString::fromUtf8("1234\xc2\xa0" "BAZ"));
+ QCOMPARE(de_DE.toCurrencyString(qlonglong(-1234)), QString::fromUtf8("-1234\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(qlonglong(-1234), QLatin1String("BAZ")), QString::fromUtf8("-1234\xc2\xa0" "BAZ"));
+ QCOMPARE(de_DE.toCurrencyString(double(1234.56)), QString::fromUtf8("1234,56\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(double(-1234.56)), QString::fromUtf8("-1234,56\xc2\xa0\xe2\x82\xac"));
+ QCOMPARE(de_DE.toCurrencyString(double(-1234.56), QLatin1String("BAZ")), QString::fromUtf8("-1234,56\xc2\xa0" "BAZ"));
+
+ const QLocale system = QLocale::system();
+ QVERIFY(system.toCurrencyString(1, QLatin1String("FOO")).contains(QLatin1String("FOO")));
+}
+
+void tst_QLocale::quoteString()
+{
+ const QString someText("text");
+ const QLocale c(QLocale::C);
+ QCOMPARE(c.quoteString(someText), QString::fromUtf8("\x22" "text" "\x22"));
+ QCOMPARE(c.quoteString(someText, QLocale::AlternateQuotation), QString::fromUtf8("\x27" "text" "\x27"));
+
+ const QLocale de_CH("de_CH");
+ QCOMPARE(de_CH.quoteString(someText), QString::fromUtf8("\xc2\xab" "text" "\xc2\xbb"));
+ QCOMPARE(de_CH.quoteString(someText, QLocale::AlternateQuotation), QString::fromUtf8("\xe2\x80\xb9" "text" "\xe2\x80\xba"));
+
+}
+
+void tst_QLocale::uiLanguages()
+{
+ const QLocale c(QLocale::C);
+ QCOMPARE(c.uiLanguages().size(), 1);
+ QCOMPARE(c.uiLanguages().at(0), QLatin1String("C"));
+
+ const QLocale en_US("en_US");
+ QCOMPARE(en_US.uiLanguages().size(), 1);
+ QCOMPARE(en_US.uiLanguages().at(0), QLatin1String("en-US"));
+
+ const QLocale ru_RU("ru_RU");
+ QCOMPARE(ru_RU.uiLanguages().size(), 1);
+ QCOMPARE(ru_RU.uiLanguages().at(0), QLatin1String("ru-RU"));
+}
+
+void tst_QLocale::weekendDays()
+{
+ const QLocale c(QLocale::C);
+ QList<Qt::DayOfWeek> days;
+ days << Qt::Monday << Qt::Tuesday << Qt::Wednesday << Qt::Thursday << Qt::Friday;
+ QCOMPARE(c.weekdays(), days);
+}
+
+void tst_QLocale::listPatterns()
+{
+ QStringList sl1;
+ QStringList sl2;
+ sl2 << "aaa";
+ QStringList sl3;
+ sl3 << "aaa" << "bbb";
+ QStringList sl4;
+ sl4 << "aaa" << "bbb" << "ccc";
+ QStringList sl5;
+ sl5 << "aaa" << "bbb" << "ccc" << "ddd";
+
+ const QLocale c(QLocale::C);
+ QCOMPARE(c.createSeparatedList(sl1), QString(""));
+ QCOMPARE(c.createSeparatedList(sl2), QString("aaa"));
+ QCOMPARE(c.createSeparatedList(sl3), QString("aaa, bbb"));
+ QCOMPARE(c.createSeparatedList(sl4), QString("aaa, bbb, ccc"));
+ QCOMPARE(c.createSeparatedList(sl5), QString("aaa, bbb, ccc, ddd"));
+
+ const QLocale en_US("en_US");
+ QCOMPARE(en_US.createSeparatedList(sl1), QString(""));
+ QCOMPARE(en_US.createSeparatedList(sl2), QString("aaa"));
+ QCOMPARE(en_US.createSeparatedList(sl3), QString("aaa and bbb"));
+ QCOMPARE(en_US.createSeparatedList(sl4), QString("aaa, bbb, and ccc"));
+ QCOMPARE(en_US.createSeparatedList(sl5), QString("aaa, bbb, ccc, and ddd"));
+
+ const QLocale zh_CN("zh_CN");
+ QCOMPARE(zh_CN.createSeparatedList(sl1), QString(""));
+ QCOMPARE(zh_CN.createSeparatedList(sl2), QString("aaa"));
+ QCOMPARE(zh_CN.createSeparatedList(sl3), QString::fromUtf8("aaa" "\xe5\x92\x8c" "bbb"));
+ QCOMPARE(zh_CN.createSeparatedList(sl4), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe5\x92\x8c" "ccc"));
+ QCOMPARE(zh_CN.createSeparatedList(sl5), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe3\x80\x81" "ccc" "\xe5\x92\x8c" "ddd"));
+}
+
QTEST_APPLESS_MAIN(tst_QLocale)
#include "tst_qlocale.moc"
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index a6d44272c8..77a5574b9c 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -391,6 +391,8 @@ void tst_QLocalSocket::listenAndConnect()
QVERIFY(socket->fullServerName().contains(name));
sockets.append(socket);
if (canListen) {
+ QVERIFY(socket->waitForConnected());
+ QVERIFY(socket->isValid());
QCOMPARE(socket->errorString(), QString("Unknown error"));
QCOMPARE(socket->error(), QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::ConnectedState);
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index 5621c4732b..f1a909a941 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -175,6 +175,9 @@ private slots:
void metaMethod();
+ void indexOfMethod_data();
+ void indexOfMethod();
+
signals:
void value6Changed();
void value7Changed(const QString &);
@@ -1087,5 +1090,31 @@ void tst_QMetaObject::metaMethod()
QCOMPARE(obj.slotResult, QString("sl13"));
}
+void tst_QMetaObject::indexOfMethod_data()
+{
+ QTest::addColumn<QObject *>("object");
+ QTest::addColumn<QByteArray>("name");
+ QTest::addColumn<bool>("isSignal");
+ QTest::newRow("indexOfMethod_data") << (QObject*)this << QByteArray("indexOfMethod_data()") << false;
+ QTest::newRow("deleteLater") << (QObject*)this << QByteArray("deleteLater()") << false;
+ QTest::newRow("value6changed") << (QObject*)this << QByteArray("value6Changed()") << true;
+ QTest::newRow("value7changed") << (QObject*)this << QByteArray("value7Changed(QString)") << true;
+ QTest::newRow("destroyed") << (QObject*)this << QByteArray("destroyed()") << true;
+ QTest::newRow("destroyed2") << (QObject*)this << QByteArray("destroyed(QObject*)") << true;
+}
+
+void tst_QMetaObject::indexOfMethod()
+{
+ QFETCH(QObject *, object);
+ QFETCH(QByteArray, name);
+ QFETCH(bool, isSignal);
+ int idx = object->metaObject()->indexOfMethod(name);
+ QVERIFY(idx >= 0);
+ QCOMPARE(object->metaObject()->method(idx).signature(), name.constData());
+ QCOMPARE(object->metaObject()->indexOfSlot(name), isSignal ? -1 : idx);
+ QCOMPARE(object->metaObject()->indexOfSignal(name), !isSignal ? -1 : idx);
+}
+
+
QTEST_MAIN(tst_QMetaObject)
#include "tst_qmetaobject.moc"
diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp
index e1ad2d2243..c3b3575bf8 100644
--- a/tests/auto/qmutex/tst_qmutex.cpp
+++ b/tests/auto/qmutex/tst_qmutex.cpp
@@ -129,27 +129,57 @@ void tst_QMutex::tryLock()
testsTurn.release();
threadsTurn.acquire();
+ QVERIFY(!normalMutex.tryLock(0));
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(normalMutex.tryLock(0));
+ QVERIFY(timer.elapsed() < 1000);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(!normalMutex.tryLock(0));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
}
};
Thread thread;
thread.start();
+ // thread can't acquire lock
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = 1000
testsTurn.acquire();
normalMutex.lock();
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
threadsTurn.release();
+ // thread can acquire lock, timeout = 1000
testsTurn.acquire();
QVERIFY(lockCount.testAndSetRelaxed(1, 0));
normalMutex.unlock();
threadsTurn.release();
+ // thread can't acquire lock, timeout = 0
testsTurn.acquire();
normalMutex.lock();
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
threadsTurn.release();
+ // thread can acquire lock, timeout = 0
testsTurn.acquire();
QVERIFY(lockCount.testAndSetRelaxed(1, 0));
normalMutex.unlock();
@@ -190,6 +220,7 @@ void tst_QMutex::tryLock()
timer.start();
QVERIFY(!recursiveMutex.tryLock(1000));
QVERIFY(timer.elapsed() >= 1000);
+ QVERIFY(!recursiveMutex.tryLock(0));
testsTurn.release();
threadsTurn.acquire();
@@ -206,12 +237,47 @@ void tst_QMutex::tryLock()
testsTurn.release();
threadsTurn.acquire();
+ QVERIFY(!recursiveMutex.tryLock(0));
+ QVERIFY(!recursiveMutex.tryLock(0));
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(recursiveMutex.tryLock(0));
+ QVERIFY(timer.elapsed() < 1000);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.tryLock(0));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
}
};
Thread thread;
thread.start();
+ // thread can't acquire lock
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = 1000
testsTurn.acquire();
recursiveMutex.lock();
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
@@ -219,6 +285,7 @@ void tst_QMutex::tryLock()
QVERIFY(lockCount.testAndSetRelaxed(1, 2));
threadsTurn.release();
+ // thread can acquire lock, timeout = 1000
testsTurn.acquire();
QVERIFY(lockCount.testAndSetRelaxed(2, 1));
recursiveMutex.unlock();
@@ -226,6 +293,7 @@ void tst_QMutex::tryLock()
recursiveMutex.unlock();
threadsTurn.release();
+ // thread can't acquire lock, timeout = 0
testsTurn.acquire();
recursiveMutex.lock();
QVERIFY(lockCount.testAndSetRelaxed(0, 1));
@@ -233,6 +301,7 @@ void tst_QMutex::tryLock()
QVERIFY(lockCount.testAndSetRelaxed(1, 2));
threadsTurn.release();
+ // thread can acquire lock, timeout = 0
testsTurn.acquire();
QVERIFY(lockCount.testAndSetRelaxed(2, 1));
recursiveMutex.unlock();
diff --git a/tests/auto/qnativesocketengine/.gitignore b/tests/auto/qnativesocketengine/.gitignore
deleted file mode 100644
index 4700e5e2f5..0000000000
--- a/tests/auto/qnativesocketengine/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qnativesocketengine
diff --git a/tests/auto/qnativesocketengine/qnativesocketengine.pro b/tests/auto/qnativesocketengine/qnativesocketengine.pro
deleted file mode 100644
index 0275d378da..0000000000
--- a/tests/auto/qnativesocketengine/qnativesocketengine.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-load(qttest_p4)
-SOURCES += tst_qnativesocketengine.cpp
-
-include(../qnativesocketengine/qsocketengine.pri)
-
-requires(contains(QT_CONFIG,private_tests))
-
-MOC_DIR=tmp
-
-QT = core network
-
-symbian: TARGET.CAPABILITY = NetworkServices
-
diff --git a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp
index 42bb069f77..f7c5ca151d 100644
--- a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp
+++ b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp
@@ -58,6 +58,7 @@ public:
tst_QNetworkAccessManager_And_QProgressDialog();
private slots:
void downloadCheck();
+ void downloadCheck_data();
};
class DownloadCheckWidget : public QWidget
@@ -72,9 +73,14 @@ public:
QMetaObject::invokeMethod(this, "go", Qt::QueuedConnection);
}
bool lateReadyRead;
+ bool zeroCopy;
public slots:
void go()
{
+ QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"));
+ if (zeroCopy)
+ request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 10*1024*1024);
+
QNetworkReply *reply = netmanager.get(
QNetworkRequest(
QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile")
@@ -106,20 +112,30 @@ public slots:
QTestEventLoop::instance().exitLoop();
}
-
private:
QProgressDialog progressDlg;
QNetworkAccessManager netmanager;
};
+
tst_QNetworkAccessManager_And_QProgressDialog::tst_QNetworkAccessManager_And_QProgressDialog()
{
Q_SET_DEFAULT_IAP
}
+void tst_QNetworkAccessManager_And_QProgressDialog::downloadCheck_data()
+{
+ QTest::addColumn<bool>("useZeroCopy");
+ QTest::newRow("with-zeroCopy") << true;
+ QTest::newRow("without-zeroCopy") << false;
+}
+
void tst_QNetworkAccessManager_And_QProgressDialog::downloadCheck()
{
+ QFETCH(bool, useZeroCopy);
+
DownloadCheckWidget widget;
+ widget.zeroCopy = useZeroCopy;
widget.show();
// run and exit on finished()
QTestEventLoop::instance().enterLoop(10);
diff --git a/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro b/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro
index 77ad34754c..ae0941e964 100644
--- a/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro
+++ b/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT -= gui
QT += network
SOURCES += tst_qnetworkcachemetadata.cpp
diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
index adcfd93655..c31eac7445 100644
--- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
+++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
@@ -52,7 +52,7 @@
*/
#include <QNetworkAccessManager>
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -73,7 +73,7 @@ private slots:
void isRoamingAvailable();
private:
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -85,7 +85,7 @@ private:
void tst_QNetworkConfiguration::initTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -158,7 +158,7 @@ void tst_QNetworkConfiguration::initTestCase()
void tst_QNetworkConfiguration::cleanupTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
index 443fd182a4..7787608485 100644
--- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
+++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
@@ -45,7 +45,7 @@
#include <QtNetwork/qnetworkconfiguration.h>
#include <QtNetwork/qnetworkconfigmanager.h>
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -67,7 +67,7 @@ private slots:
void configurationFromIdentifier();
private:
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -79,7 +79,7 @@ private:
void tst_QNetworkConfigurationManager::initTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -153,7 +153,7 @@ void tst_QNetworkConfigurationManager::initTestCase()
void tst_QNetworkConfigurationManager::cleanupTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
index 91dfe4774f..9a58482de0 100644
--- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -182,6 +182,14 @@ void tst_QNetworkCookie::parseSingleCookie_data()
cookie.setValue("\"\\\"a, b; c\\\"\"");
QTest::newRow("with-value-with-special5") << "a = \"\\\"a, b; c\\\"\"" << cookie;
+ cookie.setValue("b c");
+ QTest::newRow("with-value-with-whitespace") << "a = b c" << cookie;
+
+ cookie.setValue("\"b\"");
+ QTest::newRow("quoted-value") << "a = \"b\"" << cookie;
+ cookie.setValue("\"b c\"");
+ QTest::newRow("quoted-value-with-whitespace") << "a = \"b c\"" << cookie;
+
cookie.setValue("b");
cookie.setSecure(true);
QTest::newRow("secure") << "a=b;secure" << cookie;
@@ -707,6 +715,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
cookie.setDomain("!@#$%^&*();:."); // the ';' is actually problematic, because it is a separator
list = QList<QNetworkCookie>();
QTest::newRow("domain-non-alpha-numeric") << "NonAlphNumDomName=NonAlphNumDomValue; domain=!@#$%^&*()" << list;
+ QTest::newRow("expiration-3digit1") << "a=b; expires=123" << list; // used to ASSERT
}
void tst_QNetworkCookie::parseMultipleCookies()
diff --git a/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro b/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro
index 3b13087836..c05171dac7 100644
--- a/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro
+++ b/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT -= gui
QT += network
SOURCES += tst_qnetworkdiskcache.cpp
diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index e974fcc7a3..78b5f1b1aa 100644
--- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -46,6 +46,8 @@
#include "../../shared/util.h"
#define EXAMPLE_URL "http://user:pass@www.example.com/#foo"
+//cached objects are organized into these many subdirs
+#define NUM_SUBDIRECTORIES 16
class tst_QNetworkDiskCache : public QObject
{
@@ -176,10 +178,10 @@ void tst_QNetworkDiskCache::initTestCase()
cache.clear();
QString s = QDir::tempPath() + "/diskCache/";
QDir dir;
- dir.rmdir(s + "http");
- dir.rmdir(s + "https");
+ dir.rmdir(s + "data7"); // the number is the internal cache version
dir.rmdir(s + "prepared");
dir.rmdir(s);
+ dir.rmdir(s + "http"); // delete directory used by 4.7 and earlier (would make the tests fail)
}
// This will be called after the last test function is executed.
@@ -277,16 +279,16 @@ void tst_QNetworkDiskCache::clear()
QVERIFY(cache.cacheSize() > qint64(0));
QString cacheDirectory = cache.cacheDirectory();
- QCOMPARE(countFiles(cacheDirectory).count(), 3);
+ QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
cache.clear();
- QCOMPARE(countFiles(cacheDirectory).count(), 2);
+ QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2);
// don't delete files that it didn't create
- QTemporaryFile file(cacheDirectory + "/cache_XXXXXX");
+ QTemporaryFile file(cacheDirectory + "/XXXXXX");
if (file.open()) {
- QCOMPARE(countFiles(cacheDirectory).count(), 3);
+ QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
cache.clear();
- QCOMPARE(countFiles(cacheDirectory).count(), 3);
+ QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
}
}
@@ -309,20 +311,11 @@ void tst_QNetworkDiskCache::data_data()
// public QIODevice* data(QUrl const& url)
void tst_QNetworkDiskCache::data()
{
-#ifdef Q_OS_SYMBIAN
- QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll);
-#endif
QFETCH(QNetworkCacheMetaData, data);
SubQNetworkDiskCache cache;
QUrl url(EXAMPLE_URL);
cache.setupWithOne(url, data);
- // flush the cache
- QTemporaryFile file(cache.cacheDirectory() + "/cache_XXXXXX.cache");
- if (file.open()) {
- cache.call_fileMetaData(file.fileName());
- }
-
for (int i = 0; i < 3; ++i) {
QIODevice *d = cache.data(url);
QVERIFY(d);
@@ -362,9 +355,9 @@ void tst_QNetworkDiskCache::remove()
QUrl url(EXAMPLE_URL);
cache.setupWithOne(url);
QString cacheDirectory = cache.cacheDirectory();
- QCOMPARE(countFiles(cacheDirectory).count(), 3);
+ QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3);
cache.remove(url);
- QCOMPARE(countFiles(cacheDirectory).count(), 2);
+ QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2);
}
void tst_QNetworkDiskCache::setCacheDirectory_data()
@@ -388,9 +381,6 @@ void tst_QNetworkDiskCache::setCacheDirectory()
// public void updateMetaData(QNetworkCacheMetaData const& metaData)
void tst_QNetworkDiskCache::updateMetaData()
{
-#ifdef Q_OS_SYMBIAN
- QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll);
-#endif
QUrl url(EXAMPLE_URL);
SubQNetworkDiskCache cache;
cache.setupWithOne(url);
@@ -414,7 +404,7 @@ void tst_QNetworkDiskCache::fileMetaData()
QString cacheDirectory = cache.cacheDirectory();
QStringList list = countFiles(cacheDirectory);
- QCOMPARE(list.count(), 3);
+ QCOMPARE(list.count(), NUM_SUBDIRECTORIES + 3);
foreach(QString fileName, list) {
QFileInfo info(fileName);
if (info.isFile()) {
@@ -491,7 +481,7 @@ void tst_QNetworkDiskCache::oldCacheVersionFile()
if (pass == 0) {
QString name;
{
- QTemporaryFile file(cache.cacheDirectory() + "/cache_XXXXXX.cache");
+ QTemporaryFile file(cache.cacheDirectory() + "/XXXXXX.d");
file.setAutoRemove(false);
QVERIFY(file.open());
QDataStream out(&file);
@@ -507,7 +497,7 @@ void tst_QNetworkDiskCache::oldCacheVersionFile()
QVERIFY(!QFile::exists(name));
} else {
QStringList files = countFiles(cache.cacheDirectory());
- QCOMPARE(files.count(), 3);
+ QCOMPARE(files.count(), NUM_SUBDIRECTORIES + 3);
// find the file
QString cacheFile;
foreach (QString file, files) {
diff --git a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
index 0d7c68ea8f..c630ecab93 100644
--- a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -45,6 +45,8 @@
#include <qcoreapplication.h>
#include <qnetworkinterface.h>
#include <qtcpsocket.h>
+#include <QNetworkConfigurationManager>
+#include <QNetworkSession>
#include "../network-settings.h"
//TESTED_FILES=qnetworkinterface.cpp qnetworkinterface.h qnetworkinterface_unix.cpp qnetworkinterface_win.cpp
@@ -58,23 +60,52 @@ public:
virtual ~tst_QNetworkInterface();
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void dump();
void loopbackIPv4();
void loopbackIPv6();
void localAddress();
void interfaceFromXXX();
void copyInvalidInterface();
+
+private:
+#ifndef QT_NO_BEARER_MANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QScopedPointer<QNetworkSession> networkSession;
+#endif
};
tst_QNetworkInterface::tst_QNetworkInterface()
{
- Q_SET_DEFAULT_IAP
}
tst_QNetworkInterface::~tst_QNetworkInterface()
{
}
+void tst_QNetworkInterface::initTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
+}
+
+void tst_QNetworkInterface::cleanupTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ if (networkSession && networkSession->isOpen()) {
+ networkSession->close();
+ }
+#endif
+}
void tst_QNetworkInterface::dump()
{
@@ -127,10 +158,6 @@ void tst_QNetworkInterface::loopbackIPv4()
void tst_QNetworkInterface::loopbackIPv6()
{
-#ifdef Q_OS_SYMBIAN
- QSKIP( "Symbian: IPv6 is not yet supported", SkipAll );
-#else
-
QList<QHostAddress> all = QNetworkInterface::allAddresses();
bool loopbackfound = false;
@@ -144,7 +171,6 @@ void tst_QNetworkInterface::loopbackIPv6()
anyIPv6 = true;
QVERIFY(!anyIPv6 || loopbackfound);
-#endif
}
void tst_QNetworkInterface::localAddress()
diff --git a/tests/auto/qnetworkproxyfactory/qnetworkproxyfactory.pro b/tests/auto/qnetworkproxyfactory/qnetworkproxyfactory.pro
index f05c423087..17ad403ba7 100644
--- a/tests/auto/qnetworkproxyfactory/qnetworkproxyfactory.pro
+++ b/tests/auto/qnetworkproxyfactory/qnetworkproxyfactory.pro
@@ -7,5 +7,5 @@ QT = core network
SOURCES += tst_qnetworkproxyfactory.cpp
-symbian: TARGET.CAPABILITY = NetworkServices
+symbian: TARGET.CAPABILITY = NetworkServices ReadUserData
diff --git a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
index 2baee27d5f..82a4193e9d 100644
--- a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
+++ b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
@@ -41,20 +41,60 @@
#include <QtTest/QTest>
+#include <QtTest/QTestEventLoop>
#include <qcoreapplication.h>
#include <qdebug.h>
#include <qnetworkproxy.h>
+#include <QNetworkConfiguration>
+#include <QNetworkConfigurationManager>
+#include <QNetworkSession>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QList>
+
+Q_DECLARE_METATYPE(QNetworkConfiguration);
+Q_DECLARE_METATYPE(QList<QNetworkProxy>);
class tst_QNetworkProxyFactory : public QObject {
Q_OBJECT
+
+public:
+ tst_QNetworkProxyFactory();
+
+ class QDebugProxyFactory : public QNetworkProxyFactory
+ {
+ public:
+ virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery())
+ {
+ returnedList = QNetworkProxyFactory::systemProxyForQuery(query);
+ requestCounter++;
+ return returnedList;
+ }
+ QList<QNetworkProxy> returnedList;
+ int requestCounter;
+ };
+
private slots:
void systemProxyForQuery() const;
+#ifndef QT_NO_BEARERMANAGEMENT
+ void fromConfigurations();
+ void inNetworkAccessManager_data();
+ void inNetworkAccessManager();
+#endif
private:
QString formatProxyName(const QNetworkProxy & proxy) const;
+ QDebugProxyFactory *factory;
};
+tst_QNetworkProxyFactory::tst_QNetworkProxyFactory()
+{
+ factory = new QDebugProxyFactory;
+ QNetworkProxyFactory::setApplicationProxyFactory(factory);
+}
+
QString tst_QNetworkProxyFactory::formatProxyName(const QNetworkProxy & proxy) const
{
QString proxyName;
@@ -96,5 +136,109 @@ void tst_QNetworkProxyFactory::systemProxyForQuery() const
QFAIL("One or more system proxy lookup failures occurred.");
}
+#ifndef QT_NO_BEARERMANAGEMENT
+
+//Purpose of this test is just to check systemProxyForQuery doesn't hang or crash
+//with any given configuration including no configuration.
+//We can't test it returns the right proxies without implementing the native proxy code
+//again here, which would be testing our implementation against itself.
+//Therefore it's just testing that something valid is returned (at least a NoProxy entry)
+void tst_QNetworkProxyFactory::fromConfigurations()
+{
+ QNetworkConfigurationManager manager;
+ QList<QNetworkProxy> proxies;
+ QUrl url(QLatin1String("http://qt.nokia.com"));
+ //get from known configurations
+ foreach (QNetworkConfiguration config, manager.allConfigurations()) {
+ QNetworkProxyQuery query(config, url, QNetworkProxyQuery::UrlRequest);
+ proxies = QNetworkProxyFactory::systemProxyForQuery(query);
+ QVERIFY(!proxies.isEmpty());
+ foreach (QNetworkProxy proxy, proxies) {
+ qDebug() << config.name() << " - " << config.identifier() << " - " << formatProxyName(proxy);
+ }
+ }
+
+ //get from default configuration
+ QNetworkProxyQuery defaultquery(url, QNetworkProxyQuery::UrlRequest);
+ proxies = QNetworkProxyFactory::systemProxyForQuery(defaultquery);
+ QVERIFY(!proxies.isEmpty());
+ foreach (QNetworkProxy proxy, proxies) {
+ qDebug() << "default - " << formatProxyName(proxy);
+ }
+
+ //get from active configuration
+ QNetworkSession session(manager.defaultConfiguration());
+ session.open();
+ QVERIFY(session.waitForOpened(30000));
+ proxies = QNetworkProxyFactory::systemProxyForQuery(defaultquery);
+ QVERIFY(!proxies.isEmpty());
+ foreach (QNetworkProxy proxy, proxies) {
+ qDebug() << "active - " << formatProxyName(proxy);
+ }
+
+ //get from known configurations while there is one active
+ foreach (QNetworkConfiguration config, manager.allConfigurations()) {
+ QNetworkProxyQuery query(config, url, QNetworkProxyQuery::UrlRequest);
+ proxies = QNetworkProxyFactory::systemProxyForQuery(query);
+ QVERIFY(!proxies.isEmpty());
+ foreach (QNetworkProxy proxy, proxies) {
+ qDebug() << config.name() << " - " << config.identifier() << " - " << formatProxyName(proxy);
+ }
+ }
+}
+
+void tst_QNetworkProxyFactory::inNetworkAccessManager_data()
+{
+ QTest::addColumn<QNetworkConfiguration>("config");
+ QTest::addColumn<QList<QNetworkProxy> >("proxies");
+ QNetworkConfigurationManager manager;
+ //get from known configurations
+ foreach (QNetworkConfiguration config, manager.allConfigurations()) {
+ QNetworkProxyQuery query(config, QUrl(QString("http://qt.nokia.com")), QNetworkProxyQuery::UrlRequest);
+ QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(query);
+ QTest::newRow(config.name().toUtf8()) << config << proxies;
+ }
+}
+
+//Purpose of this test is to check that QNetworkAccessManager uses the proxy from the configuration it
+//has been given. Needs two or more working configurations to be a good test.
+void tst_QNetworkProxyFactory::inNetworkAccessManager()
+{
+ QFETCH(QNetworkConfiguration, config);
+ QFETCH(QList<QNetworkProxy>, proxies);
+
+ int count = factory->requestCounter;
+
+ QNetworkAccessManager manager;
+ manager.setConfiguration(config);
+
+ //using an internet server, because cellular APs won't have a route to the test server.
+ QNetworkRequest req(QUrl(QString("http://qt.nokia.com")));
+ QNetworkReply *reply = manager.get(req);
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(30);
+ delete reply;
+
+ if (count == factory->requestCounter) {
+ //RND phones are preconfigured with several test access points which won't work without a matching SIM
+ //If the network fails to start, QNAM won't ask the factory for proxies so we can't test.
+ QSKIP("network configuration didn't start", SkipSingle);
+ }
+
+ qDebug() << "testing network configuration for" << config.name();
+ foreach (QNetworkProxy proxy, factory->returnedList) {
+ qDebug() << formatProxyName(proxy);
+ }
+ qDebug() << " <vs> ";
+ foreach (QNetworkProxy proxy, proxies) {
+ qDebug() << formatProxyName(proxy);
+ }
+ if (config.type() != QNetworkConfiguration::InternetAccessPoint)
+ QEXPECT_FAIL("","QNetworkProxyFactory::systemProxyForQuery doesn't work for service networks yet", Continue);
+ QCOMPARE(factory->returnedList, proxies);
+}
+
+#endif //QT_NO_BEARERMANAGEMENT
+
QTEST_MAIN(tst_QNetworkProxyFactory)
#include "tst_qnetworkproxyfactory.moc"
diff --git a/tests/auto/qnetworkreply/image1.jpg b/tests/auto/qnetworkreply/image1.jpg
new file mode 100644
index 0000000000..dba31c1901
--- /dev/null
+++ b/tests/auto/qnetworkreply/image1.jpg
Binary files differ
diff --git a/tests/auto/qnetworkreply/image2.jpg b/tests/auto/qnetworkreply/image2.jpg
new file mode 100644
index 0000000000..72936e2de6
--- /dev/null
+++ b/tests/auto/qnetworkreply/image2.jpg
Binary files differ
diff --git a/tests/auto/qnetworkreply/image3.jpg b/tests/auto/qnetworkreply/image3.jpg
new file mode 100644
index 0000000000..cede519938
--- /dev/null
+++ b/tests/auto/qnetworkreply/image3.jpg
Binary files differ
diff --git a/tests/auto/qnetworkreply/test/test.pro b/tests/auto/qnetworkreply/test/test.pro
index 7efc2fb24b..d1f6707f6f 100644
--- a/tests/auto/qnetworkreply/test/test.pro
+++ b/tests/auto/qnetworkreply/test/test.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT -= gui
SOURCES += ../tst_qnetworkreply.cpp
TARGET = ../tst_qnetworkreply
@@ -15,24 +16,21 @@ win32 {
QT = core network
RESOURCES += ../qnetworkreply.qrc
-wince*: {
- addFiles.files = ../empty ../rfc3252.txt ../resource
- addFiles.path = .
- DEPLOYMENT += addFiles
-}
-
-symbian:{
- addFiles.files = ../empty ../rfc3252.txt ../resource ../bigfile
+symbian|wince*:{
+ # For cross compiled targets, reference data files need to be deployed
+ addFiles.files = ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg
addFiles.path = .
DEPLOYMENT += addFiles
certFiles.files = ../certs
certFiles.path = .
DEPLOYMENT += certFiles
+}
+symbian:{
# Symbian toolchain does not support correct include semantics
INCLUDEPATH+=..\\..\\..\\..\\include\\QtNetwork\\private
# bigfile test case requires more heap
- TARGET.EPOCHEAPSIZE="0x100 0x1000000"
+ TARGET.EPOCHEAPSIZE="0x100 0x10000000"
TARGET.CAPABILITY="ALL -TCB"
}
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 610ca1f91f..95f2f8a9a5 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -47,6 +47,7 @@
#include <QtCore/QEventLoop>
#include <QtCore/QFile>
#include <QtCore/QSharedPointer>
+#include <QtCore/QScopedPointer>
#include <QtCore/QTemporaryFile>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
@@ -60,10 +61,17 @@
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
#include <QtNetwork/qnetworkcookie.h>
+#include <QtNetwork/QHttpPart>
+#include <QtNetwork/QHttpMultiPart>
#ifndef QT_NO_OPENSSL
#include <QtNetwork/qsslerror.h>
#include <QtNetwork/qsslconfiguration.h>
#endif
+#ifndef QT_NO_BEARERMANAGEMENT
+#include <QtNetwork/qnetworkconfigmanager.h>
+#include <QtNetwork/qnetworkconfiguration.h>
+#include <QtNetwork/qnetworksession.h>
+#endif
#include <time.h>
@@ -83,6 +91,11 @@ Q_DECLARE_METATYPE(QNetworkProxyQuery)
Q_DECLARE_METATYPE(QList<QNetworkProxy>)
Q_DECLARE_METATYPE(QNetworkReply::NetworkError)
Q_DECLARE_METATYPE(QBuffer*)
+Q_DECLARE_METATYPE(QHttpMultiPart *)
+Q_DECLARE_METATYPE(QList<QFile*>) // for multiparts
+#ifndef QT_NO_OPENSSL
+Q_DECLARE_METATYPE(QSslConfiguration)
+#endif
class QNetworkReplyPtr: public QSharedPointer<QNetworkReply>
{
@@ -133,12 +146,19 @@ class tst_QNetworkReply: public QObject
QSslConfiguration storedSslConfiguration;
QList<QSslError> storedExpectedSslErrors;
#endif
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QScopedPointer<QNetworkSession> networkSession;
+#endif
public:
tst_QNetworkReply();
~tst_QNetworkReply();
QString runSimpleRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request,
QNetworkReplyPtr &reply, const QByteArray &data = QByteArray());
+ QString runMultipartRequest(const QNetworkRequest &request, QNetworkReplyPtr &reply,
+ QHttpMultiPart *multiPart, const QByteArray &verb);
QString runCustomRequest(const QNetworkRequest &request, QNetworkReplyPtr &reply,
const QByteArray &verb, QIODevice *data);
@@ -185,10 +205,14 @@ private Q_SLOTS:
void putToHttp();
void putToHttpSynchronous_data();
void putToHttpSynchronous();
+ void putToHttpMultipart_data();
+ void putToHttpMultipart();
void postToHttp_data();
void postToHttp();
void postToHttpSynchronous_data();
void postToHttpSynchronous();
+ void postToHttpMultipart_data();
+ void postToHttpMultipart();
void deleteFromHttp_data();
void deleteFromHttp();
void putGetDeleteGetFromHttp_data();
@@ -309,6 +333,8 @@ private Q_SLOTS:
void ignoreSslErrorsList();
void ignoreSslErrorsListWithSlot_data();
void ignoreSslErrorsListWithSlot();
+ void sslConfiguration_data();
+ void sslConfiguration();
#endif
void getAndThenDeleteObject_data();
@@ -337,6 +363,8 @@ private Q_SLOTS:
void qtbug15311doubleContentLength();
+ void qtbug18232gzipContentLengthZero();
+
void synchronousRequest_data();
void synchronousRequest();
#ifndef QT_NO_OPENSSL
@@ -416,16 +444,23 @@ public:
QTcpSocket *client; // always the last one that was received
QByteArray dataToTransmit;
QByteArray receivedData;
+ QSemaphore ready;
bool doClose;
bool doSsl;
bool multiple;
int totalConnections;
- MiniHttpServer(const QByteArray &data, bool ssl = false)
+ MiniHttpServer(const QByteArray &data, bool ssl = false, QThread *thread = 0)
: client(0), dataToTransmit(data), doClose(true), doSsl(ssl),
multiple(false), totalConnections(0)
{
listen();
+ if (thread) {
+ connect(thread, SIGNAL(started()), this, SLOT(threadStartedSlot()));
+ moveToThread(thread);
+ thread->start();
+ ready.acquire();
+ }
}
protected:
@@ -502,6 +537,11 @@ public slots:
disconnect(client, 0, this, 0);
}
}
+
+ void threadStartedSlot()
+ {
+ ready.release();
+ }
};
class MyCookieJar: public QNetworkCookieJar
@@ -1099,6 +1139,38 @@ void tst_QNetworkReply::storeSslConfiguration()
}
#endif
+QString tst_QNetworkReply::runMultipartRequest(const QNetworkRequest &request,
+ QNetworkReplyPtr &reply,
+ QHttpMultiPart *multiPart,
+ const QByteArray &verb)
+{
+ if (verb == "POST")
+ reply = manager.post(request, multiPart);
+ else
+ reply = manager.put(request, multiPart);
+
+ // the code below is copied from tst_QNetworkReply::runSimpleRequest, see below
+ reply->setParent(this);
+ connect(reply, SIGNAL(finished()), SLOT(finished()));
+ connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(gotError()));
+ multiPart->setParent(reply);
+
+ returnCode = Timeout;
+ loop = new QEventLoop;
+ QTimer::singleShot(25000, loop, SLOT(quit()));
+ int code = returnCode == Timeout ? loop->exec() : returnCode;
+ delete loop;
+ loop = 0;
+
+ switch (code) {
+ case Failure:
+ return "Request failed: " + reply->errorString();
+ case Timeout:
+ return "Network timeout";
+ }
+ return QString();
+}
+
QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op,
const QNetworkRequest &request,
QNetworkReplyPtr &reply,
@@ -1206,6 +1278,18 @@ void tst_QNetworkReply::initTestCase()
#endif
QDir::setSearchPaths("srcdir", QStringList() << SRCDIR);
+#ifndef QT_NO_OPENSSL
+ QSslSocket::defaultCaCertificates(); //preload certificates
+#endif
+#ifndef QT_NO_BEARERMANAGEMENT
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
}
void tst_QNetworkReply::cleanupTestCase()
@@ -1213,6 +1297,9 @@ void tst_QNetworkReply::cleanupTestCase()
#if !defined Q_OS_WIN
QFile::remove(wronlyFileName);
#endif
+ if (networkSession && networkSession->isOpen()) {
+ networkSession->close();
+ }
}
void tst_QNetworkReply::init()
@@ -1572,7 +1659,7 @@ void tst_QNetworkReply::getErrors()
QNetworkRequest request(url);
#if defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
- if (qstrcmp(QTest::currentDataTag(), "empty-scheme-host") == 0)
+ if (qstrcmp(QTest::currentDataTag(), "empty-scheme-host") == 0 && QFileInfo(url).isAbsolute())
QTest::ignoreMessage(QtWarningMsg, "QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
#endif
@@ -1591,7 +1678,8 @@ void tst_QNetworkReply::getErrors()
QFETCH(int, error);
#if defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
- QEXPECT_FAIL("empty-scheme-host", "this is expected to fail on Windows and Symbian, QTBUG-17731", Abort);
+ if (QFileInfo(url).isAbsolute())
+ QEXPECT_FAIL("empty-scheme-host", "this is expected to fail on Windows and Symbian, QTBUG-17731", Abort);
#endif
QEXPECT_FAIL("ftp-is-dir", "QFtp cannot provide enough detail", Abort);
// the line below is not necessary
@@ -1797,6 +1885,7 @@ void tst_QNetworkReply::postToHttp()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply;
QFETCH(QByteArray, data);
@@ -1823,6 +1912,7 @@ void tst_QNetworkReply::postToHttpSynchronous()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
request.setAttribute(
QNetworkRequest::SynchronousRequestAttribute,
@@ -1844,6 +1934,307 @@ void tst_QNetworkReply::postToHttpSynchronous()
QCOMPARE(uploadedData, md5sum.toHex());
}
+void tst_QNetworkReply::postToHttpMultipart_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QHttpMultiPart *>("multiPart");
+ QTest::addColumn<QByteArray>("expectedReplyData");
+ QTest::addColumn<QByteArray>("contentType");
+
+ QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/multipart.cgi");
+ QByteArray expectedData;
+
+
+ // empty parts
+
+ QHttpMultiPart *emptyMultiPart = new QHttpMultiPart;
+ QTest::newRow("empty") << url << emptyMultiPart << expectedData << QByteArray("mixed");
+
+ QHttpMultiPart *emptyRelatedMultiPart = new QHttpMultiPart;
+ emptyRelatedMultiPart->setContentType(QHttpMultiPart::RelatedType);
+ QTest::newRow("empty-related") << url << emptyRelatedMultiPart << expectedData << QByteArray("related");
+
+ QHttpMultiPart *emptyAlternativeMultiPart = new QHttpMultiPart;
+ emptyAlternativeMultiPart->setContentType(QHttpMultiPart::AlternativeType);
+ QTest::newRow("empty-alternative") << url << emptyAlternativeMultiPart << expectedData << QByteArray("alternative");
+
+
+ // text-only parts
+
+ QHttpPart textPart;
+ textPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
+ textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""));
+ textPart.setBody("7 bytes");
+ QHttpMultiPart *multiPart1 = new QHttpMultiPart;
+ multiPart1->setContentType(QHttpMultiPart::FormDataType);
+ multiPart1->append(textPart);
+ expectedData = "key: text, value: 7 bytes\n";
+ QTest::newRow("text") << url << multiPart1 << expectedData << QByteArray("form-data");
+
+ QHttpMultiPart *customMultiPart = new QHttpMultiPart;
+ customMultiPart->append(textPart);
+ expectedData = "header: Content-Type, value: 'text/plain'\n"
+ "header: Content-Disposition, value: 'form-data; name=\"text\"'\n"
+ "content: 7 bytes\n"
+ "\n";
+ QTest::newRow("text-custom") << url << customMultiPart << expectedData << QByteArray("custom");
+
+ QHttpPart textPart2;
+ textPart2.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
+ textPart2.setRawHeader("myRawHeader", "myValue");
+ textPart2.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text2\""));
+ textPart2.setBody("some more bytes");
+ textPart2.setBodyDevice((QIODevice *) 1); // test whether setting and unsetting of the device works
+ textPart2.setBodyDevice(0);
+ QHttpMultiPart *multiPart2 = new QHttpMultiPart;
+ multiPart2->setContentType(QHttpMultiPart::FormDataType);
+ multiPart2->append(textPart);
+ multiPart2->append(textPart2);
+ expectedData = "key: text2, value: some more bytes\n"
+ "key: text, value: 7 bytes\n";
+ QTest::newRow("text-text") << url << multiPart2 << expectedData << QByteArray("form-data");
+
+
+ QHttpPart textPart3;
+ textPart3.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
+ textPart3.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text3\""));
+ textPart3.setRawHeader("Content-Location", "http://my.test.location.tld");
+ textPart3.setBody("even more bytes");
+ QHttpMultiPart *multiPart3 = new QHttpMultiPart;
+ multiPart3->setContentType(QHttpMultiPart::AlternativeType);
+ multiPart3->append(textPart);
+ multiPart3->append(textPart2);
+ multiPart3->append(textPart3);
+ expectedData = "header: Content-Type, value: 'text/plain'\n"
+ "header: Content-Disposition, value: 'form-data; name=\"text\"'\n"
+ "content: 7 bytes\n"
+ "\n"
+ "header: Content-Type, value: 'text/plain'\n"
+ "header: myRawHeader, value: 'myValue'\n"
+ "header: Content-Disposition, value: 'form-data; name=\"text2\"'\n"
+ "content: some more bytes\n"
+ "\n"
+ "header: Content-Type, value: 'text/plain'\n"
+ "header: Content-Disposition, value: 'form-data; name=\"text3\"'\n"
+ "header: Content-Location, value: 'http://my.test.location.tld'\n"
+ "content: even more bytes\n\n";
+ QTest::newRow("text-text-text") << url << multiPart3 << expectedData << QByteArray("alternative");
+
+
+
+ // text and image parts
+
+ QHttpPart imagePart11;
+ imagePart11.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+ imagePart11.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage\""));
+ imagePart11.setRawHeader("Content-Location", "http://my.test.location.tld");
+ imagePart11.setRawHeader("Content-ID", "my@id.tld");
+ QFile *file11 = new QFile(SRCDIR "/image1.jpg");
+ file11->open(QIODevice::ReadOnly);
+ imagePart11.setBodyDevice(file11);
+ QHttpMultiPart *imageMultiPart1 = new QHttpMultiPart(QHttpMultiPart::FormDataType);
+ imageMultiPart1->append(imagePart11);
+ file11->setParent(imageMultiPart1);
+ expectedData = "key: testImage, value: 87ef3bb319b004ba9e5e9c9fa713776e\n"; // md5 sum of file
+ QTest::newRow("image") << url << imageMultiPart1 << expectedData << QByteArray("form-data");
+
+ QHttpPart imagePart21;
+ imagePart21.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+ imagePart21.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage1\""));
+ imagePart21.setRawHeader("Content-Location", "http://my.test.location.tld");
+ imagePart21.setRawHeader("Content-ID", "my@id.tld");
+ QFile *file21 = new QFile(SRCDIR "/image1.jpg");
+ file21->open(QIODevice::ReadOnly);
+ imagePart21.setBodyDevice(file21);
+ QHttpMultiPart *imageMultiPart2 = new QHttpMultiPart();
+ imageMultiPart2->setContentType(QHttpMultiPart::FormDataType);
+ imageMultiPart2->append(textPart);
+ imageMultiPart2->append(imagePart21);
+ file21->setParent(imageMultiPart2);
+ QHttpPart imagePart22;
+ imagePart22.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+ imagePart22.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage2\""));
+ QFile *file22 = new QFile(SRCDIR "/image2.jpg");
+ file22->open(QIODevice::ReadOnly);
+ imagePart22.setBodyDevice(file22);
+ imageMultiPart2->append(imagePart22);
+ file22->setParent(imageMultiPart2);
+ expectedData = "key: testImage1, value: 87ef3bb319b004ba9e5e9c9fa713776e\n"
+ "key: text, value: 7 bytes\n"
+ "key: testImage2, value: 483761b893f7fb1bd2414344cd1f3dfb\n";
+ QTest::newRow("text-image-image") << url << imageMultiPart2 << expectedData << QByteArray("form-data");
+
+
+ QHttpPart imagePart31;
+ imagePart31.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+ imagePart31.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage1\""));
+ imagePart31.setRawHeader("Content-Location", "http://my.test.location.tld");
+ imagePart31.setRawHeader("Content-ID", "my@id.tld");
+ QFile *file31 = new QFile(SRCDIR "/image1.jpg");
+ file31->open(QIODevice::ReadOnly);
+ imagePart31.setBodyDevice(file31);
+ QHttpMultiPart *imageMultiPart3 = new QHttpMultiPart(QHttpMultiPart::FormDataType);
+ imageMultiPart3->append(imagePart31);
+ file31->setParent(imageMultiPart3);
+ QHttpPart imagePart32;
+ imagePart32.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+ imagePart32.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage2\""));
+ QFile *file32 = new QFile(SRCDIR "/image2.jpg");
+ file32->open(QIODevice::ReadOnly);
+ imagePart32.setBodyDevice(file31); // check that resetting works
+ imagePart32.setBodyDevice(file32);
+ imageMultiPart3->append(imagePart32);
+ file32->setParent(imageMultiPart3);
+ QHttpPart imagePart33;
+ imagePart33.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+ imagePart33.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage3\""));
+ QFile *file33 = new QFile(SRCDIR "/image3.jpg");
+ file33->open(QIODevice::ReadOnly);
+ imagePart33.setBodyDevice(file33);
+ imageMultiPart3->append(imagePart33);
+ file33->setParent(imageMultiPart3);
+ expectedData = "key: testImage1, value: 87ef3bb319b004ba9e5e9c9fa713776e\n"
+ "key: testImage2, value: 483761b893f7fb1bd2414344cd1f3dfb\n"
+ "key: testImage3, value: ab0eb6fd4fcf8b4436254870b4513033\n";
+ QTest::newRow("3-images") << url << imageMultiPart3 << expectedData << QByteArray("form-data");
+
+
+ // note: nesting multiparts is not working currently; for that, the outputDevice would need to be public
+
+// QHttpPart imagePart41;
+// imagePart41.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+// QFile *file41 = new QFile(SRCDIR "/image1.jpg");
+// file41->open(QIODevice::ReadOnly);
+// imagePart41.setBodyDevice(file41);
+//
+// QHttpMultiPart *innerMultiPart = new QHttpMultiPart();
+// innerMultiPart->setContentType(QHttpMultiPart::FormDataType);
+// textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant());
+// innerMultiPart->append(textPart);
+// innerMultiPart->append(imagePart41);
+// textPart2.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant());
+// innerMultiPart->append(textPart2);
+//
+// QHttpPart nestedPart;
+// nestedPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"nestedMessage"));
+// nestedPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("multipart/alternative; boundary=\"" + innerMultiPart->boundary() + "\""));
+// innerMultiPart->outputDevice()->open(QIODevice::ReadOnly);
+// nestedPart.setBodyDevice(innerMultiPart->outputDevice());
+//
+// QHttpMultiPart *outerMultiPart = new QHttpMultiPart;
+// outerMultiPart->setContentType(QHttpMultiPart::FormDataType);
+// outerMultiPart->append(textPart);
+// outerMultiPart->append(nestedPart);
+// outerMultiPart->append(textPart2);
+// expectedData = "nothing"; // the CGI.pm module running on the test server does not understand nested multiparts
+// openFiles.clear();
+// openFiles << file41;
+// QTest::newRow("nested") << url << outerMultiPart << expectedData << openFiles;
+
+
+ // test setting large chunks of content with a byte array instead of a device (DISCOURAGED because of high memory consumption,
+ // but we need to test that the behavior is correct)
+ QHttpPart imagePart51;
+ imagePart51.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
+ imagePart51.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"testImage\""));
+ QFile *file51 = new QFile(SRCDIR "/image1.jpg");
+ file51->open(QIODevice::ReadOnly);
+ QByteArray imageData = file51->readAll();
+ file51->close();
+ delete file51;
+ imagePart51.setBody("7 bytes"); // check that resetting works
+ imagePart51.setBody(imageData);
+ QHttpMultiPart *imageMultiPart5 = new QHttpMultiPart;
+ imageMultiPart5->setContentType(QHttpMultiPart::FormDataType);
+ imageMultiPart5->append(imagePart51);
+ expectedData = "key: testImage, value: 87ef3bb319b004ba9e5e9c9fa713776e\n"; // md5 sum of file
+ QTest::newRow("image-as-content") << url << imageMultiPart5 << expectedData << QByteArray("form-data");
+}
+
+void tst_QNetworkReply::postToHttpMultipart()
+{
+ QFETCH(QUrl, url);
+
+ static QSet<QByteArray> boundaries;
+
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply;
+
+ QFETCH(QHttpMultiPart *, multiPart);
+ QFETCH(QByteArray, expectedReplyData);
+ QFETCH(QByteArray, contentType);
+
+ // hack for testing the setting of the content-type header by hand:
+ if (contentType == "custom") {
+ QByteArray contentType("multipart/custom; boundary=\"" + multiPart->boundary() + "\"");
+ request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
+ }
+
+ QVERIFY2(! boundaries.contains(multiPart->boundary()), "boundary '" + multiPart->boundary() + "' has been created twice");
+ boundaries.insert(multiPart->boundary());
+
+ RUN_REQUEST(runMultipartRequest(request, reply, multiPart, "POST"));
+ multiPart->deleteLater();
+
+ QCOMPARE(reply->url(), url);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok
+
+ QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string
+ QVERIFY(multiPart->boundary().count() < 70);
+ QByteArray replyData = reply->readAll();
+
+ expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n");
+// QEXPECT_FAIL("nested", "the server does not understand nested multipart messages", Continue); // see above
+ QCOMPARE(replyData, expectedReplyData);
+}
+
+void tst_QNetworkReply::putToHttpMultipart_data()
+{
+ postToHttpMultipart_data();
+}
+
+void tst_QNetworkReply::putToHttpMultipart()
+{
+ QSKIP("test server script cannot handle PUT data yet", SkipAll);
+ QFETCH(QUrl, url);
+
+ static QSet<QByteArray> boundaries;
+
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply;
+
+ QFETCH(QHttpMultiPart *, multiPart);
+ QFETCH(QByteArray, expectedReplyData);
+ QFETCH(QByteArray, contentType);
+
+ // hack for testing the setting of the content-type header by hand:
+ if (contentType == "custom") {
+ QByteArray contentType("multipart/custom; boundary=\"" + multiPart->boundary() + "\"");
+ request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
+ }
+
+ QVERIFY2(! boundaries.contains(multiPart->boundary()), "boundary '" + multiPart->boundary() + "' has been created twice");
+ boundaries.insert(multiPart->boundary());
+
+ RUN_REQUEST(runMultipartRequest(request, reply, multiPart, "PUT"));
+ multiPart->deleteLater();
+
+ QCOMPARE(reply->url(), url);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok
+
+ QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string
+ QVERIFY(multiPart->boundary().count() < 70);
+ QByteArray replyData = reply->readAll();
+
+ expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n");
+// QEXPECT_FAIL("nested", "the server does not understand nested multipart messages", Continue); // see above
+ QCOMPARE(replyData, expectedReplyData);
+}
+
void tst_QNetworkReply::deleteFromHttp_data()
{
QTest::addColumn<QUrl>("url");
@@ -2855,16 +3246,16 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
QTest::newRow("must-revalidate,200,prefer-network")
<< reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true;
QTest::newRow("must-revalidate,200,prefer-cache")
- << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false;
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << false << true;
QTest::newRow("must-revalidate,200,always-cache")
- << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false;
+ << reply200 << "" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false;
QTest::newRow("must-revalidate,304,prefer-network")
<< reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << true;
QTest::newRow("must-revalidate,304,prefer-cache")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << true;
QTest::newRow("must-revalidate,304,always-cache")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false;
+ << reply304 << "" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false;
//
// Partial content
@@ -3281,8 +3672,7 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket()
QString socketname = "networkreplytest";
QLocalServer server;
if (!server.listen(socketname)) {
- if (QFile::exists(server.fullServerName()))
- QFile::remove(server.fullServerName());
+ QLocalServer::removeServer(socketname);
QVERIFY(server.listen(socketname));
}
QLocalSocket active;
@@ -3327,7 +3717,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
{
#if defined(Q_OS_WINCE) || defined (Q_OS_SYMBIAN)
QSKIP("Currently no stdin/out supported for Windows CE / Symbian OS", SkipAll);
-#endif
+#else
#ifdef Q_OS_WIN
if (qstrcmp(QTest::currentDataTag(), "small") == 0)
@@ -3365,6 +3755,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
QByteArray contents = file.readAll();
QCOMPARE(contents, data);
#endif
+#endif
}
void tst_QNetworkReply::ioPutToFtpFromFile_data()
@@ -3478,6 +3869,8 @@ void tst_QNetworkReply::ioPostToHttpFromFile()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
+
QNetworkReplyPtr reply = manager.post(request, &sourceFile);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -3554,8 +3947,10 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
socketpair.endPoints[0]->write(data);
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
+
manager.setProxy(proxy);
- QNetworkReplyPtr reply = manager.post(QNetworkRequest(url), socketpair.endPoints[1]);
+ QNetworkReplyPtr reply = manager.post(request, socketpair.endPoints[1]);
socketpair.endPoints[0]->close();
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -3628,6 +4023,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
request.setAttribute(
QNetworkRequest::SynchronousRequestAttribute,
true);
@@ -3657,7 +4053,8 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfFileToEnd()
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi";
QNetworkRequest request(url);
- QNetworkReplyPtr reply = manager.post(QNetworkRequest(url), &sourceFile);
+ request.setRawHeader("Content-Type", "application/octet-stream");
+ QNetworkReplyPtr reply = manager.post(request, &sourceFile);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
@@ -3683,6 +4080,7 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfFileFiveBytes()
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi";
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
// only send 5 bytes
request.setHeader(QNetworkRequest::ContentLengthHeader, 5);
QVERIFY(request.header(QNetworkRequest::ContentLengthHeader).isValid());
@@ -3714,6 +4112,7 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfQBufferFiveBytes()
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi";
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply = manager.post(request, &uploadBuffer);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -3743,6 +4142,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag()
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi";
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
// disallow buffering
request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true);
request.setHeader(QNetworkRequest::ContentLengthHeader, data.size());
@@ -3805,6 +4205,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress()
// create the request
QUrl url = QUrl(QString("https://127.0.0.1:%1/").arg(server.serverPort()));
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply = manager.post(request, &sourceFile);
QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
connect(&server, SIGNAL(newEncryptedConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -3823,14 +4224,8 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress()
// some progress should have been made
QVERIFY(!spy.isEmpty());
QList<QVariant> args = spy.last();
- qDebug() << "tst_QNetworkReply::ioPostToHttpsUploadProgress"
- << args.at(0).toLongLong()
- << sourceFile.size()
- << spy.size();
QVERIFY(args.at(0).toLongLong() > 0);
- // FIXME this is where it messes up
- QEXPECT_FAIL("", "Either the readBufferSize of QSslSocket is broken or we do upload too much. Hm.", Abort);
QVERIFY(args.at(0).toLongLong() != sourceFile.size());
incomingSocket->setReadBufferSize(32*1024);
@@ -3879,6 +4274,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp_data()
void tst_QNetworkReply::ioGetFromBuiltinHttp()
{
+ QSKIP("Limiting is broken right now, check QTBUG-15065", SkipAll);
QFETCH(bool, https);
QFETCH(int, bufferSize);
@@ -3917,7 +4313,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
QTime loopTime;
loopTime.start();
- QTestEventLoop::instance().enterLoop(11);
+ QTestEventLoop::instance().enterLoop(30);
const int elapsedTime = loopTime.elapsed();
server.wait();
reader.wrapUp();
@@ -3949,10 +4345,9 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
const int minRate = rate * 1024 * (100-allowedDeviation) / 100;
const int maxRate = rate * 1024 * (100+allowedDeviation) / 100;
qDebug() << minRate << "<="<< server.transferRate << "<=" << maxRate << "?";
- QVERIFY(server.transferRate >= minRate);
QEXPECT_FAIL("http+limited", "Limiting is broken right now, check QTBUG-15065", Continue);
QEXPECT_FAIL("https+limited", "Limiting is broken right now, check QTBUG-15065", Continue);
- QVERIFY(server.transferRate <= maxRate);
+ QVERIFY(server.transferRate >= minRate && server.transferRate <= maxRate);
}
}
@@ -3968,6 +4363,7 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress()
// create the request
QUrl url = QUrl(QString("http://127.0.0.1:%1/").arg(server.serverPort()));
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply = manager.post(request, &sourceFile);
QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
connect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -4027,6 +4423,7 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress()
// create the request
QUrl url = QUrl(QString("http://127.0.0.1:%1/").arg(server.serverPort()));
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply = manager.post(request, &buffer);
QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
connect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -4373,6 +4770,7 @@ void tst_QNetworkReply::receiveCookiesFromHttp()
QByteArray data = cookieString.toLatin1() + '\n';
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply;
RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::PostOperation, request, reply, data));
@@ -4400,7 +4798,7 @@ void tst_QNetworkReply::receiveCookiesFromHttpSynchronous()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi");
QNetworkRequest request(url);
-
+ request.setRawHeader("Content-Type", "application/octet-stream");
request.setAttribute(
QNetworkRequest::SynchronousRequestAttribute,
true);
@@ -4577,17 +4975,24 @@ void tst_QNetworkReply::httpProxyCommands()
QNetworkProxy proxy(QNetworkProxy::HttpProxy, "127.0.0.1", proxyServer.serverPort());
manager.setProxy(proxy);
- QNetworkReplyPtr reply = manager.get(QNetworkRequest(url));
- manager.setProxy(QNetworkProxy());
+ QNetworkRequest request(url);
+ request.setRawHeader("User-Agent", "QNetworkReplyAutoTest/1.0");
+ QNetworkReplyPtr reply = manager.get(request);
+ //clearing the proxy here causes the test to fail.
+ //the proxy isn't used until after the bearer has been started
+ //which is correct in general, because system proxy isn't known until that time.
+ //removing this line is safe, as the proxy is also reset by the cleanup() function
+ //manager.setProxy(QNetworkProxy());
// wait for the finished signal
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTestEventLoop::instance().enterLoop(1);
+ QTestEventLoop::instance().enterLoop(15);
QVERIFY(!QTestEventLoop::instance().timeout());
//qDebug() << reply->error() << reply->errorString();
+ //qDebug() << proxyServer.receivedData;
// we don't really care if the request succeeded
// especially since it won't succeed in the HTTPS case
@@ -4595,6 +5000,12 @@ void tst_QNetworkReply::httpProxyCommands()
QString receivedHeader = proxyServer.receivedData.left(expectedCommand.length());
QCOMPARE(receivedHeader, expectedCommand);
+
+ //QTBUG-17223 - make sure the user agent from the request is sent to proxy server even for CONNECT
+ int uapos = proxyServer.receivedData.indexOf("User-Agent");
+ int uaend = proxyServer.receivedData.indexOf("\r\n", uapos);
+ QByteArray uaheader = proxyServer.receivedData.mid(uapos, uaend - uapos);
+ QCOMPARE(uaheader, QByteArray("User-Agent: QNetworkReplyAutoTest/1.0"));
}
class ProxyChangeHelper : public QObject {
@@ -4616,6 +5027,26 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous_data()
httpProxyCommands_data();
}
+struct QThreadCleanup
+{
+ static inline void cleanup(QThread *thread)
+ {
+ thread->quit();
+ if (thread->wait(3000))
+ delete thread;
+ else
+ qWarning("thread hung, leaking memory so test can finish");
+ }
+};
+
+struct QDeleteLaterCleanup
+{
+ static inline void cleanup(QObject *o)
+ {
+ o->deleteLater();
+ }
+};
+
void tst_QNetworkReply::httpProxyCommandsSynchronous()
{
QFETCH(QUrl, url);
@@ -4625,11 +5056,9 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous()
// when using synchronous commands, we need a different event loop for
// the server thread, because the client is never returning to the
// event loop
- MiniHttpServer proxyServer(responseToSend);
- QThread serverThread;
- proxyServer.moveToThread(&serverThread);
- serverThread.start();
- QNetworkProxy proxy(QNetworkProxy::HttpProxy, "127.0.0.1", proxyServer.serverPort());
+ QScopedPointer<QThread, QThreadCleanup> serverThread(new QThread);
+ QScopedPointer<MiniHttpServer, QDeleteLaterCleanup> proxyServer(new MiniHttpServer(responseToSend, false, serverThread.data()));
+ QNetworkProxy proxy(QNetworkProxy::HttpProxy, "127.0.0.1", proxyServer->serverPort());
manager.setProxy(proxy);
QNetworkRequest request(url);
@@ -4642,8 +5071,6 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous()
QNetworkReplyPtr reply = manager.get(request);
QVERIFY(reply->isFinished()); // synchronous
manager.setProxy(QNetworkProxy());
- serverThread.quit();
- serverThread.wait(3000);
//qDebug() << reply->error() << reply->errorString();
@@ -4651,7 +5078,7 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous()
// especially since it won't succeed in the HTTPS case
// so just check that the command was correct
- QString receivedHeader = proxyServer.receivedData.left(expectedCommand.length());
+ QString receivedHeader = proxyServer->receivedData.left(expectedCommand.length());
QCOMPARE(receivedHeader, expectedCommand);
}
@@ -5034,6 +5461,37 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot()
QCOMPARE(reply->error(), expectedNetworkError);
}
+void tst_QNetworkReply::sslConfiguration_data()
+{
+ QTest::addColumn<QSslConfiguration>("configuration");
+ QTest::addColumn<bool>("works");
+
+ QTest::newRow("empty") << QSslConfiguration() << false;
+ QSslConfiguration conf = QSslConfiguration::defaultConfiguration();
+ QTest::newRow("default") << conf << false; // does not contain test server cert
+ QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(SRCDIR "/certs/qt-test-server-cacert.pem");
+ conf.setCaCertificates(testServerCert);
+ QTest::newRow("set-root-cert") << conf << true;
+ conf.setProtocol(QSsl::SecureProtocols);
+ QTest::newRow("secure") << conf << true;
+}
+
+void tst_QNetworkReply::sslConfiguration()
+{
+ QNetworkRequest request(QUrl("https://" + QtNetworkSettings::serverName() + "/index.html"));
+ QFETCH(QSslConfiguration, configuration);
+ request.setSslConfiguration(configuration);
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QFETCH(bool, works);
+ QNetworkReply::NetworkError expectedError = works ? QNetworkReply::NoError : QNetworkReply::SslHandshakeFailedError;
+ QCOMPARE(reply->error(), expectedError);
+}
+
#endif // QT_NO_OPENSSL
void tst_QNetworkReply::getAndThenDeleteObject_data()
@@ -5144,7 +5602,7 @@ void tst_QNetworkReply::getFromHttpIntoBuffer()
// FIXME we really need to consolidate all those server implementations
class GetFromHttpIntoBuffer2Server : QObject {
- Q_OBJECT;
+ Q_OBJECT
qint64 dataSize;
qint64 dataSent;
QTcpServer server;
@@ -5266,6 +5724,7 @@ public:
void finishedSlot() {
// We should have already received all readyRead
+ QVERIFY(!bytesAvailableList.isEmpty());
QVERIFY(bytesAvailableList.last() == uploadSize);
}
};
@@ -5411,7 +5870,7 @@ void tst_QNetworkReply::getFromUnreachableIp()
QNetworkReplyPtr reply = manager.get(request);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTestEventLoop::instance().enterLoop(5);
+ QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(reply->error() != QNetworkReply::NoError);
@@ -5541,6 +6000,25 @@ void tst_QNetworkReply::qtbug15311doubleContentLength()
QCOMPARE(reply->readAll(), QByteArray("ABC"));
}
+void tst_QNetworkReply::qtbug18232gzipContentLengthZero()
+{
+ QByteArray response("HTTP/1.0 200 OK\r\nContent-Encoding: gzip\r\nContent-Length: 0\r\n\r\n");
+ MiniHttpServer server(response);
+ server.doClose = true;
+
+ QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(reply->isFinished());
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->size(), qint64(0));
+ QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(0));
+ QCOMPARE(reply->readAll(), QByteArray());
+}
+
void tst_QNetworkReply::synchronousRequest_data()
{
QTest::addColumn<QUrl>("url");
@@ -5578,7 +6056,7 @@ void tst_QNetworkReply::synchronousRequest_data()
<< QString("text/plain");
QTest::newRow("simple-file")
- << QUrl(QString::fromLatin1("file:///" SRCDIR "/rfc3252.txt"))
+ << QUrl::fromLocalFile(SRCDIR "/rfc3252.txt")
<< QString("file:" SRCDIR "/rfc3252.txt")
<< true
<< QString();
diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
index 3315836d90..13ceddabfc 100644
--- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
@@ -48,7 +48,7 @@
#include <QtNetwork/qnetworkconfigmanager.h>
#include <QtNetwork/qnetworksession.h>
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -105,7 +105,7 @@ private:
int inProcessSessionManagementCount;
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -140,7 +140,7 @@ void tst_QNetworkSession::initTestCase()
testsToRun["userChoiceSession"] = true;
testsToRun["sessionOpenCloseStop"] = true;
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -226,7 +226,7 @@ void tst_QNetworkSession::cleanupTestCase()
"inProcessSessionManagement()");
}
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 0e5a087877..a7e8d79345 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -135,7 +135,7 @@ private slots:
void disconnectByMetaMethod();
void disconnectNotSignalMetaMethod();
void autoConnectionBehavior();
-
+ void baseDestroyed();
protected:
};
@@ -3946,5 +3946,34 @@ void tst_QObject::autoConnectionBehavior()
delete receiver;
}
+class BaseDestroyed : public QObject
+{ Q_OBJECT
+ QList<QString> fooList;
+ bool destroyed;
+public:
+ BaseDestroyed() : destroyed(false)
+ { fooList << "a" << "b"; }
+ ~BaseDestroyed()
+ {
+ QVERIFY(!destroyed);
+ destroyed = true;
+ }
+
+public slots:
+ void slotUseList()
+ {
+ QVERIFY(!destroyed);
+ fooList << "c" << "d";
+ }
+};
+
+void tst_QObject::baseDestroyed()
+{
+ BaseDestroyed d;
+ connect(&d, SIGNAL(destroyed()), &d, SLOT(slotUseList()));
+ //When d goes out of scope, slotUseList should not be called as the BaseDestroyed has
+ // already been destroyed while ~QObject emit destroyed
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index c21514b9c6..984443490f 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -72,11 +72,13 @@
#include <qgraphicsscene.h>
#include <qgraphicsproxywidget.h>
#include <qlayout.h>
+#include <qfontdatabase.h>
#if defined(Q_OS_SYMBIAN)
# define SRCDIR "."
#endif
+Q_DECLARE_METATYPE(QGradientStops)
Q_DECLARE_METATYPE(QLine)
Q_DECLARE_METATYPE(QRect)
Q_DECLARE_METATYPE(QSize)
@@ -189,6 +191,7 @@ private slots:
void fillRect_stretchToDeviceMode();
void monoImages();
+ void linearGradientSymmetry_data();
void linearGradientSymmetry();
void gradientInterpolation();
@@ -264,6 +267,8 @@ private slots:
void QTBUG17053_zeroDashPattern();
+ void drawTextOutsideGuiThread();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -3983,8 +3988,42 @@ static QLinearGradient inverseGradient(QLinearGradient g)
return g2;
}
+void tst_QPainter::linearGradientSymmetry_data()
+{
+ QTest::addColumn<QGradientStops>("stops");
+
+ if (sizeof(qreal) != sizeof(float)) {
+ QGradientStops stops;
+ stops << qMakePair(qreal(0.0), QColor(Qt::blue));
+ stops << qMakePair(qreal(0.2), QColor(220, 220, 220, 0));
+ stops << qMakePair(qreal(0.6), QColor(Qt::red));
+ stops << qMakePair(qreal(0.9), QColor(220, 220, 220, 255));
+ stops << qMakePair(qreal(1.0), QColor(Qt::black));
+ QTest::newRow("multiple stops") << stops;
+ }
+
+ {
+ QGradientStops stops;
+ stops << qMakePair(qreal(0.0), QColor(Qt::blue));
+ stops << qMakePair(qreal(1.0), QColor(Qt::black));
+ QTest::newRow("two stops") << stops;
+ }
+
+ if (sizeof(qreal) != sizeof(float)) {
+ QGradientStops stops;
+ stops << qMakePair(qreal(0.3), QColor(Qt::blue));
+ stops << qMakePair(qreal(0.6), QColor(Qt::black));
+ QTest::newRow("two stops 2") << stops;
+ }
+}
+
void tst_QPainter::linearGradientSymmetry()
{
+#ifdef Q_WS_QWS
+ QSKIP("QWS has limited resolution in the gradient color table", SkipAll);
+#else
+ QFETCH(QGradientStops, stops);
+
QImage a(64, 8, QImage::Format_ARGB32_Premultiplied);
QImage b(64, 8, QImage::Format_ARGB32_Premultiplied);
@@ -3992,11 +4031,7 @@ void tst_QPainter::linearGradientSymmetry()
b.fill(0);
QLinearGradient gradient(QRectF(b.rect()).topLeft(), QRectF(b.rect()).topRight());
- gradient.setColorAt(0.0, Qt::blue);
- gradient.setColorAt(0.2, QColor(220, 220, 220, 0));
- gradient.setColorAt(0.6, Qt::red);
- gradient.setColorAt(0.9, QColor(220, 220, 220, 255));
- gradient.setColorAt(1.0, Qt::black);
+ gradient.setStops(stops);
QPainter pa(&a);
pa.fillRect(a.rect(), gradient);
@@ -4008,6 +4043,7 @@ void tst_QPainter::linearGradientSymmetry()
b = b.mirrored(true);
QCOMPARE(a, b);
+#endif
}
void tst_QPainter::gradientInterpolation()
@@ -4706,6 +4742,44 @@ void tst_QPainter::QTBUG17053_zeroDashPattern()
QCOMPARE(image, original);
}
+class TextDrawerThread : public QThread
+{
+public:
+ void run();
+ QImage rendering;
+};
+
+void TextDrawerThread::run()
+{
+ rendering = QImage(100, 100, QImage::Format_ARGB32_Premultiplied);
+ rendering.fill(0);
+ QPainter p(&rendering);
+ p.fillRect(10, 10, 100, 100, Qt::blue);
+ p.setPen(Qt::green);
+ p.drawText(20, 20, "some text");
+ p.end();
+}
+
+void tst_QPainter::drawTextOutsideGuiThread()
+{
+ if (!QFontDatabase::supportsThreadedFontRendering())
+ QSKIP("No threaded font rendering", SkipAll);
+
+ QImage referenceRendering(100, 100, QImage::Format_ARGB32_Premultiplied);
+ referenceRendering.fill(0);
+ QPainter p(&referenceRendering);
+ p.fillRect(10, 10, 100, 100, Qt::blue);
+ p.setPen(Qt::green);
+ p.drawText(20, 20, "some text");
+ p.end();
+
+ TextDrawerThread t;
+ t.start();
+ t.wait();
+
+ QCOMPARE(referenceRendering, t.rendering);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp
index 86adabb4b4..c2e64e0da0 100644
--- a/tests/auto/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp
@@ -426,6 +426,10 @@ void tst_QPainterPath::intersects_QRectF_data()
QTest::newRow("horizontal line") << linePath(0, 0, 10, 0) << QRectF(1, -1, 2, 2) << true;
QTest::newRow("vertical line") << linePath(0, 0, 0, 10) << QRectF(-1, 1, 2, 2) << true;
+
+ path = QPainterPath();
+ path.addEllipse(QRectF(-5000.0, -5000.0, 1500000.0, 1500000.0));
+ QTest::newRow("huge ellipse, qreal=float crash") << path << QRectF(1100000.35, 1098000.2, 1500000.0, 1500000.0) << true;
}
void tst_QPainterPath::intersects_QRectF()
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 198a2755bb..976178a7f3 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -196,6 +196,8 @@ private slots:
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG)
void vgImageReadBack();
#endif
+
+ void drawPixmapWhilePainterOpen();
};
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
@@ -1337,7 +1339,7 @@ void tst_QPixmap::toSymbianCFbsBitmap()
void tst_QPixmap::onlyNullPixmapsOutsideGuiThread()
{
-#if !defined(Q_WS_WIN)
+#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
class Thread : public QThread
{
public:
@@ -1370,7 +1372,7 @@ void tst_QPixmap::onlyNullPixmapsOutsideGuiThread()
thread.wait();
#endif
-#endif // !defined(Q_WS_WIN)
+#endif // !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
}
void tst_QPixmap::refUnref()
@@ -1897,5 +1899,64 @@ void tst_QPixmap::vgImageReadBack()
}
#endif // Symbian & OpenVG
+class PixmapWidget : public QWidget
+{
+public:
+ PixmapWidget(QPixmap &pixmap) : QWidget(0), m_pixmap(pixmap)
+ {
+ resize(pixmap.width(), pixmap.height());
+ }
+
+protected:
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter p(this);
+ p.drawPixmap(0, 0, m_pixmap);
+ }
+
+private:
+ QPixmap &m_pixmap;
+};
+
+void tst_QPixmap::drawPixmapWhilePainterOpen()
+{
+ const int delay = 1000;
+ const int size = 100;
+ const QColor colors[] = { Qt::red, Qt::blue, Qt::green };
+
+ QPixmap pix(size, size);
+ pix.fill(colors[0]);
+
+ PixmapWidget w(pix);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ QTest::qWait(delay);
+
+ QPainter p(&pix);
+ p.fillRect(0, 0, size, size, colors[1]);
+ w.update();
+ QTest::qWait(delay);
+
+ p.fillRect(0, 0, size, size, colors[2]);
+ w.update();
+ QTest::qWait(delay);
+
+ QPixmap actual = QPixmap::grabWindow(w.effectiveWinId(), 0, 0, size, size);
+
+ // If we captured some bogus content with grabWindow(), the comparison makes no sense
+ // because it cannot prove the feature is broken.
+ QPixmap guard(size, size);
+ bool matchesColors = false;
+ for (size_t i = 0; i < sizeof(colors) / sizeof(const QColor); ++i) {
+ guard.fill(colors[i]);
+ matchesColors |= lenientCompare(actual, guard);
+ }
+ if (!matchesColors) {
+ QSKIP("Skipping verification due to grabWindow() issue", SkipSingle);
+ } else {
+ QVERIFY(lenientCompare(actual, pix));
+ }
+}
+
QTEST_MAIN(tst_QPixmap)
#include "tst_qpixmap.moc"
diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
index d3e4fd0258..8da5ba5d9a 100644
--- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
@@ -150,6 +150,7 @@ private slots:
void lineWrapProperty();
void selectionChanged();
void blockCountChanged();
+ void insertAndScrollToBottom();
private:
void createSelection();
@@ -1504,5 +1505,22 @@ void tst_QPlainTextEdit::blockCountChanged()
}
+void tst_QPlainTextEdit::insertAndScrollToBottom()
+{
+ ed->setPlainText("First Line");
+ ed->show();
+ QString text;
+ for(int i = 0; i < 2000; ++i) {
+ text += QLatin1String("this is another line of text to be appended. It is quite long and will probably wrap around, meaning the number of lines is larger than the number of blocks in the text.\n");
+ }
+ QTextCursor cursor = ed->textCursor();
+ cursor.beginEditBlock();
+ cursor.insertText(text);
+ cursor.endEditBlock();
+ ed->verticalScrollBar()->setValue(ed->verticalScrollBar()->maximum());
+ QCOMPARE(ed->verticalScrollBar()->value(), ed->verticalScrollBar()->maximum());
+}
+
+
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"
diff --git a/tests/auto/qpluginloader/tst_qpluginloader.cpp b/tests/auto/qpluginloader/tst_qpluginloader.cpp
index 591ef5ee52..76c2f6e5b3 100644
--- a/tests/auto/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/qpluginloader/tst_qpluginloader.cpp
@@ -370,15 +370,15 @@ if (sizeof(void*) == 8) {
QPluginLoader lib1(SRCDIR "elftest/corrupt1.elf64.so");
QCOMPARE(lib1.load(), false);
- QVERIFY(lib1.errorString().contains("not an ELF object"));
+ QVERIFY(lib1.errorString().contains("not a valid Qt plugin"));
QPluginLoader lib2(SRCDIR "elftest/corrupt2.elf64.so");
QCOMPARE(lib2.load(), false);
- QVERIFY(lib2.errorString().contains("invalid"));
+ QVERIFY(lib2.errorString().contains("not a valid Qt plugin"));
QPluginLoader lib3(SRCDIR "elftest/corrupt3.elf64.so");
QCOMPARE(lib3.load(), false);
- QVERIFY(lib3.errorString().contains("invalid"));
+ QVERIFY(lib3.errorString().contains("not a valid Qt plugin"));
} else if (sizeof(void*) == 4) {
QPluginLoader libW(SRCDIR "elftest/corrupt3.elf64.so");
QCOMPARE(libW.load(), false);
diff --git a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
index ea06295f06..98d48900a5 100644
--- a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
+++ b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
@@ -43,10 +43,6 @@
#include <QObject>
#include <QProcessEnvironment>
-// Note:
-// in cross-platform tests, ALWAYS use UPPERCASE variable names
-// That's because on Windows, the variables are uppercased
-
class tst_QProcessEnvironment: public QObject
{
Q_OBJECT
@@ -56,6 +52,8 @@ private slots:
void insert();
void emptyNull();
void toStringList();
+ void keys();
+ void insertEnv();
void caseSensitivity();
void systemEnvironment();
@@ -154,13 +152,65 @@ void tst_QProcessEnvironment::toStringList()
QVERIFY(result.contains("HELLO=World"));
}
+void tst_QProcessEnvironment::keys()
+{
+ QProcessEnvironment e;
+ QVERIFY(e.isEmpty());
+ QVERIFY(e.keys().isEmpty());
+
+ e.insert("FOO", "bar");
+ QStringList result = e.keys();
+ QCOMPARE(result.length(), 1);
+ QCOMPARE(result.at(0), QString("FOO"));
+
+ e.clear();
+ e.insert("BAZ", "");
+ result = e.keys();
+ QCOMPARE(result.at(0), QString("BAZ"));
+
+ e.insert("FOO", "bar");
+ e.insert("A", "bc");
+ e.insert("HELLO", "World");
+ result = e.keys();
+ QCOMPARE(result.length(), 4);
+
+ // order is not specified, so use contains()
+ QVERIFY(result.contains("FOO"));
+ QVERIFY(result.contains("BAZ"));
+ QVERIFY(result.contains("A"));
+ QVERIFY(result.contains("HELLO"));
+}
+
+void tst_QProcessEnvironment::insertEnv()
+{
+ QProcessEnvironment e;
+ e.insert("FOO", "bar");
+ e.insert("A", "bc");
+ e.insert("Hello", "World");
+
+ QProcessEnvironment e2;
+ e2.insert("FOO2", "bar2");
+ e2.insert("A2", "bc2");
+ e2.insert("Hello", "Another World");
+
+ e.insert(e2);
+ QStringList keys = e.keys();
+ QCOMPARE(keys.length(), 5);
+
+ QCOMPARE(e.value("FOO"), QString("bar"));
+ QCOMPARE(e.value("A"), QString("bc"));
+ QCOMPARE(e.value("Hello"), QString("Another World"));
+ QCOMPARE(e.value("FOO2"), QString("bar2"));
+ QCOMPARE(e.value("A2"), QString("bc2"));
+}
+
void tst_QProcessEnvironment::caseSensitivity()
{
QProcessEnvironment e;
e.insert("foo", "bar");
#ifdef Q_OS_WIN
- // on Windows, it's uppercased
+ // Windows is case-insensitive, but case-preserving
QVERIFY(e.contains("foo"));
QVERIFY(e.contains("FOO"));
QVERIFY(e.contains("FoO"));
@@ -169,8 +219,12 @@ void tst_QProcessEnvironment::caseSensitivity()
QCOMPARE(e.value("FOO"), QString("bar"));
QCOMPARE(e.value("FoO"), QString("bar"));
+ // Per Windows, this overwrites the value, but keeps the name's original capitalization
+ e.insert("Foo", "Bar");
+
QStringList list = e.toStringList();
- QCOMPARE(list.at(0), QString("FOO=bar"));
+ QCOMPARE(list.length(), 1);
+ QCOMPARE(list.at(0), QString("foo=Bar"));
#else
// otherwise, it's case sensitive
QVERIFY(e.contains("foo"));
@@ -182,6 +236,7 @@ void tst_QProcessEnvironment::caseSensitivity()
QCOMPARE(e.value("foo"), QString("bar"));
QStringList list = e.toStringList();
+ QCOMPARE(list.length(), 2);
QVERIFY(list.contains("foo=bar"));
QVERIFY(list.contains("FOO=baz"));
#endif
diff --git a/tests/auto/qrawfont/qrawfont.pro b/tests/auto/qrawfont/qrawfont.pro
new file mode 100644
index 0000000000..ccdccfb0eb
--- /dev/null
+++ b/tests/auto/qrawfont/qrawfont.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+QT = core gui
+
+SOURCES += \
+ tst_qrawfont.cpp
+
+INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
+
+wince*|symbian*: {
+ DEFINES += SRCDIR=\\\"\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
diff --git a/tests/auto/qrawfont/testfont.ttf b/tests/auto/qrawfont/testfont.ttf
new file mode 100644
index 0000000000..d6042d2e58
--- /dev/null
+++ b/tests/auto/qrawfont/testfont.ttf
Binary files differ
diff --git a/tests/auto/qrawfont/testfont_bold_italic.ttf b/tests/auto/qrawfont/testfont_bold_italic.ttf
new file mode 100644
index 0000000000..9f65ac8df7
--- /dev/null
+++ b/tests/auto/qrawfont/testfont_bold_italic.ttf
Binary files differ
diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp
new file mode 100644
index 0000000000..4b42c74bb7
--- /dev/null
+++ b/tests/auto/qrawfont/tst_qrawfont.cpp
@@ -0,0 +1,814 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <qrawfont.h>
+#include <private/qrawfont_p.h>
+
+class tst_QRawFont: public QObject
+{
+ Q_OBJECT
+
+#if !defined(QT_NO_RAWFONT)
+private slots:
+ void invalidRawFont();
+
+ void explicitRawFontNotLoadedInDatabase_data();
+ void explicitRawFontNotLoadedInDatabase();
+
+ void explicitRawFontNotAvailableInSystem_data();
+ void explicitRawFontNotAvailableInSystem();
+
+ void correctFontData_data();
+ void correctFontData();
+
+ void glyphIndices();
+
+ void advances_data();
+ void advances();
+
+ void textLayout();
+
+ void fontTable_data();
+ void fontTable();
+
+ void supportedWritingSystems_data();
+ void supportedWritingSystems();
+
+ void supportsCharacter_data();
+ void supportsCharacter();
+
+ void supportsUcs4Character_data();
+ void supportsUcs4Character();
+
+ void fromFont_data();
+ void fromFont();
+
+ void copyConstructor_data();
+ void copyConstructor();
+
+ void detach_data();
+ void detach();
+
+ void unsupportedWritingSystem_data();
+ void unsupportedWritingSystem();
+#endif // QT_NO_RAWFONT
+};
+
+#if !defined(QT_NO_RAWFONT)
+Q_DECLARE_METATYPE(QFont::HintingPreference)
+Q_DECLARE_METATYPE(QFont::Style)
+Q_DECLARE_METATYPE(QFont::Weight)
+Q_DECLARE_METATYPE(QFontDatabase::WritingSystem)
+
+void tst_QRawFont::invalidRawFont()
+{
+ QRawFont font;
+ QVERIFY(!font.isValid());
+ QCOMPARE(font.pixelSize(), 0.0);
+ QVERIFY(font.familyName().isEmpty());
+ QCOMPARE(font.style(), QFont::StyleNormal);
+ QCOMPARE(font.weight(), -1);
+ QCOMPARE(font.ascent(), 0.0);
+ QCOMPARE(font.descent(), 0.0);
+ QVERIFY(font.glyphIndexesForString(QLatin1String("Test")).isEmpty());
+}
+
+void tst_QRawFont::explicitRawFontNotLoadedInDatabase_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::explicitRawFontNotLoadedInDatabase()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QRawFont font(QLatin1String(SRCDIR "testfont.ttf"), 10, hintingPreference);
+ QVERIFY(font.isValid());
+
+ QVERIFY(!QFontDatabase().families().contains(font.familyName()));
+}
+
+void tst_QRawFont::explicitRawFontNotAvailableInSystem_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::explicitRawFontNotAvailableInSystem()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QRawFont rawfont(QLatin1String(SRCDIR "testfont.ttf"), 10, hintingPreference);
+
+ {
+ QFont font(rawfont.familyName(), 10);
+
+ QVERIFY(!font.exactMatch());
+ QVERIFY(font.family() != QFontInfo(font).family());
+ }
+}
+
+void tst_QRawFont::correctFontData_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QString>("expectedFamilyName");
+ QTest::addColumn<QFont::Style>("style");
+ QTest::addColumn<QFont::Weight>("weight");
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+ QTest::addColumn<qreal>("unitsPerEm");
+ QTest::addColumn<qreal>("pixelSize");
+
+ int hintingPreferences[] = {
+ int(QFont::PreferDefaultHinting),
+ int(QFont::PreferNoHinting),
+ int(QFont::PreferVerticalHinting),
+ int(QFont::PreferFullHinting),
+ -1
+ };
+ int *hintingPreference = hintingPreferences;
+
+ while (*hintingPreference >= 0) {
+ QString fileName = QLatin1String(SRCDIR "testfont.ttf");
+ QString title = fileName
+ + QLatin1String(": hintingPreference=")
+ + QString::number(*hintingPreference);
+
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QString::fromLatin1("QtBidiTestFont")
+ << QFont::StyleNormal
+ << QFont::Normal
+ << QFont::HintingPreference(*hintingPreference)
+ << 1000.0
+ << 10.0;
+
+ fileName = QLatin1String(SRCDIR "testfont_bold_italic.ttf");
+ title = fileName
+ + QLatin1String(": hintingPreference=")
+ + QString::number(*hintingPreference);
+
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QString::fromLatin1("QtBidiTestFont")
+ << QFont::StyleItalic
+ << QFont::Bold
+ << QFont::HintingPreference(*hintingPreference)
+ << 1000.0
+ << 10.0;
+
+ ++hintingPreference;
+ }
+}
+
+void tst_QRawFont::correctFontData()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QString, expectedFamilyName);
+ QFETCH(QFont::Style, style);
+ QFETCH(QFont::Weight, weight);
+ QFETCH(QFont::HintingPreference, hintingPreference);
+ QFETCH(qreal, unitsPerEm);
+ QFETCH(qreal, pixelSize);
+
+ QRawFont font(fileName, 10, hintingPreference);
+ QVERIFY(font.isValid());
+
+ QCOMPARE(font.familyName(), expectedFamilyName);
+ QCOMPARE(font.style(), style);
+ QCOMPARE(font.weight(), int(weight));
+ QCOMPARE(font.hintingPreference(), hintingPreference);
+ QCOMPARE(font.unitsPerEm(), unitsPerEm);
+ QCOMPARE(font.pixelSize(), pixelSize);
+}
+
+void tst_QRawFont::glyphIndices()
+{
+ QRawFont font(QLatin1String(SRCDIR "testfont.ttf"), 10);
+ QVERIFY(font.isValid());
+
+ QVector<quint32> glyphIndices = font.glyphIndexesForString(QLatin1String("Foobar"));
+ QVector<quint32> expectedGlyphIndices;
+ expectedGlyphIndices << 44 << 83 << 83 << 70 << 69 << 86;
+
+ QCOMPARE(glyphIndices, expectedGlyphIndices);
+}
+
+void tst_QRawFont::advances_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::advances()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QRawFont font(QLatin1String(SRCDIR "testfont.ttf"), 10, hintingPreference);
+ QVERIFY(font.isValid());
+
+ QRawFontPrivate *font_d = QRawFontPrivate::get(font);
+ QVERIFY(font_d->fontEngine != 0);
+
+ QVector<quint32> glyphIndices;
+ glyphIndices << 44 << 83 << 83 << 70 << 69 << 86; // "Foobar"
+
+ bool supportsSubPixelPositions = font_d->fontEngine->supportsSubPixelPositions();
+ QVector<QPointF> advances = font.advancesForGlyphIndexes(glyphIndices);
+ for (int i=0; i<glyphIndices.size(); ++i) {
+ QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0));
+ if (supportsSubPixelPositions)
+ QVERIFY(advances.at(i).x() > 8.0);
+
+ QVERIFY(qFuzzyIsNull(advances.at(i).y()));
+ }
+}
+
+void tst_QRawFont::textLayout()
+{
+ QFontDatabase fontDatabase;
+ int id = fontDatabase.addApplicationFont(SRCDIR "testfont.ttf");
+ QVERIFY(id >= 0);
+
+ QString familyName = QString::fromLatin1("QtBidiTestFont");
+ QFont font(familyName);
+ font.setPixelSize(18.0);
+ QCOMPARE(QFontInfo(font).family(), familyName);
+
+ QTextLayout layout(QLatin1String("Foobar"));
+ layout.setFont(font);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphs> glyphss = layout.glyphs();
+ QCOMPARE(glyphss.size(), 1);
+
+ QGlyphs glyphs = glyphss.at(0);
+
+ QRawFont rawFont = glyphs.font();
+ QVERIFY(rawFont.isValid());
+ QCOMPARE(rawFont.familyName(), familyName);
+ QCOMPARE(rawFont.pixelSize(), 18.0);
+
+ QVector<quint32> expectedGlyphIndices;
+ expectedGlyphIndices << 44 << 83 << 83 << 70 << 69 << 86;
+
+ QCOMPARE(glyphs.glyphIndexes(), expectedGlyphIndices);
+
+ QVERIFY(fontDatabase.removeApplicationFont(id));
+}
+
+void tst_QRawFont::fontTable_data()
+{
+ QTest::addColumn<QByteArray>("tagName");
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+ QTest::addColumn<int>("offset");
+ QTest::addColumn<quint32>("expectedValue");
+
+ QTest::newRow("Head table, magic number, default hinting")
+ << QByteArray("head")
+ << QFont::PreferDefaultHinting
+ << 12
+ << (QSysInfo::ByteOrder == QSysInfo::BigEndian
+ ? 0x5F0F3CF5
+ : 0xF53C0F5F);
+
+ QTest::newRow("Head table, magic number, no hinting")
+ << QByteArray("head")
+ << QFont::PreferNoHinting
+ << 12
+ << (QSysInfo::ByteOrder == QSysInfo::BigEndian
+ ? 0x5F0F3CF5
+ : 0xF53C0F5F);
+
+ QTest::newRow("Head table, magic number, vertical hinting")
+ << QByteArray("head")
+ << QFont::PreferVerticalHinting
+ << 12
+ << (QSysInfo::ByteOrder == QSysInfo::BigEndian
+ ? 0x5F0F3CF5
+ : 0xF53C0F5F);
+
+ QTest::newRow("Head table, magic number, full hinting")
+ << QByteArray("head")
+ << QFont::PreferFullHinting
+ << 12
+ << (QSysInfo::ByteOrder == QSysInfo::BigEndian
+ ? 0x5F0F3CF5
+ : 0xF53C0F5F);
+}
+
+void tst_QRawFont::fontTable()
+{
+ QFETCH(QByteArray, tagName);
+ QFETCH(QFont::HintingPreference, hintingPreference);
+ QFETCH(int, offset);
+ QFETCH(quint32, expectedValue);
+
+ QRawFont font(QString::fromLatin1(SRCDIR "testfont.ttf"), 10, hintingPreference);
+ QVERIFY(font.isValid());
+
+ QByteArray table = font.fontTable(tagName);
+ QVERIFY(!table.isEmpty());
+
+ const quint32 *value = reinterpret_cast<const quint32 *>(table.constData() + offset);
+ QCOMPARE(*value, expectedValue);
+}
+
+typedef QList<QFontDatabase::WritingSystem> WritingSystemList;
+Q_DECLARE_METATYPE(WritingSystemList)
+
+void tst_QRawFont::supportedWritingSystems_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<WritingSystemList>("writingSystems");
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ for (int hintingPreference=QFont::PreferDefaultHinting;
+ hintingPreference<=QFont::PreferFullHinting;
+ ++hintingPreference) {
+
+ QTest::newRow(qPrintable(QString::fromLatin1("testfont.ttf, hintingPreference=%1")
+ .arg(hintingPreference)))
+ << QString::fromLatin1(SRCDIR "testfont.ttf")
+ << (QList<QFontDatabase::WritingSystem>()
+ << QFontDatabase::Latin
+ << QFontDatabase::Hebrew
+ << QFontDatabase::Vietnamese) // Vietnamese uses same unicode bits as Latin
+ << QFont::HintingPreference(hintingPreference);
+
+ QTest::newRow(qPrintable(QString::fromLatin1("testfont_bold_italic.ttf, hintingPreference=%1")
+ .arg(hintingPreference)))
+ << QString::fromLatin1(SRCDIR "testfont_bold_italic.ttf")
+ << (QList<QFontDatabase::WritingSystem>()
+ << QFontDatabase::Latin
+ << QFontDatabase::Hebrew
+ << QFontDatabase::Devanagari
+ << QFontDatabase::Vietnamese) // Vietnamese uses same unicode bits as Latin
+ << QFont::HintingPreference(hintingPreference);
+ }
+}
+
+void tst_QRawFont::supportedWritingSystems()
+{
+ QFETCH(QString, fileName);
+ QFETCH(WritingSystemList, writingSystems);
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QRawFont font(fileName, 10, hintingPreference);
+ QVERIFY(font.isValid());
+
+ WritingSystemList actualWritingSystems = font.supportedWritingSystems();
+ QCOMPARE(actualWritingSystems.size(), writingSystems.size());
+
+ foreach (QFontDatabase::WritingSystem writingSystem, writingSystems)
+ QVERIFY(actualWritingSystems.contains(writingSystem));
+}
+
+void tst_QRawFont::supportsCharacter_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+ QTest::addColumn<QChar>("character");
+ QTest::addColumn<bool>("shouldBeSupported");
+
+ const char *fileNames[2] = {
+ SRCDIR "testfont.ttf",
+ SRCDIR "testfont_bold_italic.ttf"
+ };
+
+ for (int hintingPreference=QFont::PreferDefaultHinting;
+ hintingPreference<=QFont::PreferFullHinting;
+ ++hintingPreference) {
+
+ for (int i=0; i<2; ++i) {
+ QString fileName = QLatin1String(fileNames[i]);
+
+ // Latin text
+ for (char ch='!'; ch<='~'; ++ch) {
+ QString title = QString::fromLatin1("%1, character=0x%2, hintingPreference=%3")
+ .arg(fileName).arg(QString::number(ch, 16)).arg(hintingPreference);
+
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QFont::HintingPreference(hintingPreference)
+ << QChar::fromLatin1(ch)
+ << true;
+ }
+
+ // Hebrew text
+ for (quint16 ch=0x05D0; ch<=0x05EA; ++ch) {
+ QString title = QString::fromLatin1("%1, character=0x%2, hintingPreference=%3")
+ .arg(fileName).arg(QString::number(ch, 16)).arg(hintingPreference);
+
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QFont::HintingPreference(hintingPreference)
+ << QChar(ch)
+ << true;
+ }
+
+ QTest::newRow(qPrintable(QString::fromLatin1("Missing character, %1, hintingPreference=%2")
+ .arg(fileName).arg(hintingPreference)))
+ << fileName
+ << QFont::HintingPreference(hintingPreference)
+ << QChar(0xD8)
+ << false;
+ }
+ }
+}
+
+void tst_QRawFont::supportsCharacter()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QFont::HintingPreference, hintingPreference);
+ QFETCH(QChar, character);
+ QFETCH(bool, shouldBeSupported);
+
+ QRawFont font(fileName, 10, hintingPreference);
+ QVERIFY(font.isValid());
+
+ QCOMPARE(font.supportsCharacter(character), shouldBeSupported);
+}
+
+void tst_QRawFont::supportsUcs4Character_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+ QTest::addColumn<quint32>("ucs4");
+ QTest::addColumn<bool>("shouldBeSupported");
+
+ // Gothic text
+ for (int hintingPreference=QFont::PreferDefaultHinting;
+ hintingPreference<=QFont::PreferFullHinting;
+ ++hintingPreference) {
+ for (quint32 ch=0x10330; ch<=0x1034A; ++ch) {
+ {
+ QString fileName = QString::fromLatin1(SRCDIR "testfont.ttf");
+ QString title = QString::fromLatin1("%1, character=0x%2, hintingPreference=%3")
+ .arg(fileName).arg(QString::number(ch, 16)).arg(hintingPreference);
+
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QFont::HintingPreference(hintingPreference)
+ << ch
+ << true;
+ }
+
+ {
+ QString fileName = QString::fromLatin1(SRCDIR "testfont_bold_italic.ttf");
+ QString title = QString::fromLatin1("%1, character=0x%2, hintingPreference=%3")
+ .arg(fileName).arg(QString::number(ch, 16)).arg(hintingPreference);
+
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QFont::HintingPreference(hintingPreference)
+ << ch
+ << false;
+ }
+ }
+ }
+}
+
+void tst_QRawFont::supportsUcs4Character()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QFont::HintingPreference, hintingPreference);
+ QFETCH(quint32, ucs4);
+ QFETCH(bool, shouldBeSupported);
+
+ QRawFont font(fileName, 10, hintingPreference);
+ QVERIFY(font.isValid());
+
+ QCOMPARE(font.supportsCharacter(ucs4), shouldBeSupported);
+}
+
+void tst_QRawFont::fromFont_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+ QTest::addColumn<QString>("familyName");
+ QTest::addColumn<QFontDatabase::WritingSystem>("writingSystem");
+
+ for (int i=QFont::PreferDefaultHinting; i<=QFont::PreferFullHinting; ++i) {
+ QString titleBase = QString::fromLatin1("%2, hintingPreference=%1, writingSystem=%3")
+ .arg(i);
+ {
+ QString fileName = QString::fromLatin1(SRCDIR "testfont.ttf");
+ QFontDatabase::WritingSystem writingSystem = QFontDatabase::Any;
+
+ QString title = titleBase.arg(fileName).arg(writingSystem);
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QFont::HintingPreference(i)
+ << "QtBidiTestFont"
+ << writingSystem;
+ }
+
+ {
+ QString fileName = QString::fromLatin1(SRCDIR "testfont.ttf");
+ QFontDatabase::WritingSystem writingSystem = QFontDatabase::Hebrew;
+
+ QString title = titleBase.arg(fileName).arg(writingSystem);
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QFont::HintingPreference(i)
+ << "QtBidiTestFont"
+ << writingSystem;
+ }
+
+ {
+ QString fileName = QString::fromLatin1(SRCDIR "testfont.ttf");
+ QFontDatabase::WritingSystem writingSystem = QFontDatabase::Latin;
+
+ QString title = titleBase.arg(fileName).arg(writingSystem);
+ QTest::newRow(qPrintable(title))
+ << fileName
+ << QFont::HintingPreference(i)
+ << "QtBidiTestFont"
+ << writingSystem;
+ }
+ }
+}
+
+void tst_QRawFont::fromFont()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QFont::HintingPreference, hintingPreference);
+ QFETCH(QString, familyName);
+ QFETCH(QFontDatabase::WritingSystem, writingSystem);
+
+ QFontDatabase fontDatabase;
+ int id = fontDatabase.addApplicationFont(fileName);
+ QVERIFY(id >= 0);
+
+ QFont font(familyName);
+ font.setHintingPreference(hintingPreference);
+ font.setPixelSize(26.0);
+
+ QRawFont rawFont = QRawFont::fromFont(font, writingSystem);
+ QVERIFY(rawFont.isValid());
+ QCOMPARE(rawFont.familyName(), familyName);
+ QCOMPARE(rawFont.pixelSize(), 26.0);
+
+ QVERIFY(fontDatabase.removeApplicationFont(id));
+}
+
+void tst_QRawFont::copyConstructor_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting preference") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting preference") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::copyConstructor()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ {
+ QString rawFontFamilyName;
+ qreal rawFontPixelSize;
+ qreal rawFontAscent;
+ qreal rawFontDescent;
+ int rawFontTableSize;
+
+ QRawFont outerRawFont;
+ {
+ QRawFont rawFont(QString::fromLatin1(SRCDIR "testfont.ttf"), 11, hintingPreference);
+ QVERIFY(rawFont.isValid());
+
+ rawFontFamilyName = rawFont.familyName();
+ rawFontPixelSize = rawFont.pixelSize();
+ rawFontAscent = rawFont.ascent();
+ rawFontDescent = rawFont.descent();
+ rawFontTableSize = rawFont.fontTable("glyf").size();
+ QVERIFY(rawFontTableSize > 0);
+
+ {
+ QRawFont otherRawFont(rawFont);
+ QVERIFY(otherRawFont.isValid());
+ QCOMPARE(otherRawFont.pixelSize(), rawFontPixelSize);
+ QCOMPARE(otherRawFont.familyName(), rawFontFamilyName);
+ QCOMPARE(otherRawFont.hintingPreference(), hintingPreference);
+ QCOMPARE(otherRawFont.ascent(), rawFontAscent);
+ QCOMPARE(otherRawFont.descent(), rawFontDescent);
+ QCOMPARE(otherRawFont.fontTable("glyf").size(), rawFontTableSize);
+ }
+
+ {
+ QRawFont otherRawFont = rawFont;
+ QVERIFY(otherRawFont.isValid());
+ QCOMPARE(otherRawFont.pixelSize(), rawFontPixelSize);
+ QCOMPARE(otherRawFont.familyName(), rawFontFamilyName);
+ QCOMPARE(otherRawFont.hintingPreference(), hintingPreference);
+ QCOMPARE(otherRawFont.ascent(), rawFontAscent);
+ QCOMPARE(otherRawFont.descent(), rawFontDescent);
+ QCOMPARE(otherRawFont.fontTable("glyf").size(), rawFontTableSize);
+ }
+
+ outerRawFont = rawFont;
+ }
+
+ QVERIFY(outerRawFont.isValid());
+ QCOMPARE(outerRawFont.pixelSize(), rawFontPixelSize);
+ QCOMPARE(outerRawFont.familyName(), rawFontFamilyName);
+ QCOMPARE(outerRawFont.hintingPreference(), hintingPreference);
+ QCOMPARE(outerRawFont.ascent(), rawFontAscent);
+ QCOMPARE(outerRawFont.descent(), rawFontDescent);
+ QCOMPARE(outerRawFont.fontTable("glyf").size(), rawFontTableSize);
+ }
+}
+
+void tst_QRawFont::detach_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting preference") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting preference") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::detach()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ {
+ QString rawFontFamilyName;
+ qreal rawFontPixelSize;
+ qreal rawFontAscent;
+ qreal rawFontDescent;
+ int rawFontTableSize;
+
+ QRawFont outerRawFont;
+ {
+ QRawFont rawFont(QString::fromLatin1(SRCDIR "testfont.ttf"), 11, hintingPreference);
+ QVERIFY(rawFont.isValid());
+
+ rawFontFamilyName = rawFont.familyName();
+ rawFontPixelSize = rawFont.pixelSize();
+ rawFontAscent = rawFont.ascent();
+ rawFontDescent = rawFont.descent();
+ rawFontTableSize = rawFont.fontTable("glyf").size();
+ QVERIFY(rawFontTableSize > 0);
+
+ {
+ QRawFont otherRawFont(rawFont);
+
+ otherRawFont.loadFromFile(QLatin1String(SRCDIR "testfont.ttf"),
+ rawFontPixelSize, hintingPreference);
+
+ QVERIFY(otherRawFont.isValid());
+ QCOMPARE(otherRawFont.pixelSize(), rawFontPixelSize);
+ QCOMPARE(otherRawFont.familyName(), rawFontFamilyName);
+ QCOMPARE(otherRawFont.hintingPreference(), hintingPreference);
+ QCOMPARE(otherRawFont.ascent(), rawFontAscent);
+ QCOMPARE(otherRawFont.descent(), rawFontDescent);
+ QCOMPARE(otherRawFont.fontTable("glyf").size(), rawFontTableSize);
+ }
+
+ {
+ QRawFont otherRawFont = rawFont;
+
+ otherRawFont.loadFromFile(QLatin1String(SRCDIR "testfont.ttf"),
+ rawFontPixelSize, hintingPreference);
+
+ QVERIFY(otherRawFont.isValid());
+ QCOMPARE(otherRawFont.pixelSize(), rawFontPixelSize);
+ QCOMPARE(otherRawFont.familyName(), rawFontFamilyName);
+ QCOMPARE(otherRawFont.hintingPreference(), hintingPreference);
+ QCOMPARE(otherRawFont.ascent(), rawFontAscent);
+ QCOMPARE(otherRawFont.descent(), rawFontDescent);
+ QCOMPARE(otherRawFont.fontTable("glyf").size(), rawFontTableSize);
+ }
+
+ outerRawFont = rawFont;
+
+ rawFont.loadFromFile(QLatin1String(SRCDIR "testfont.ttf"), rawFontPixelSize,
+ hintingPreference);
+ }
+
+ QVERIFY(outerRawFont.isValid());
+ QCOMPARE(outerRawFont.pixelSize(), rawFontPixelSize);
+ QCOMPARE(outerRawFont.familyName(), rawFontFamilyName);
+ QCOMPARE(outerRawFont.hintingPreference(), hintingPreference);
+ QCOMPARE(outerRawFont.ascent(), rawFontAscent);
+ QCOMPARE(outerRawFont.descent(), rawFontDescent);
+ QCOMPARE(outerRawFont.fontTable("glyf").size(), rawFontTableSize);
+ }
+}
+
+void tst_QRawFont::unsupportedWritingSystem_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting preference") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting preference") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::unsupportedWritingSystem()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QFontDatabase fontDatabase;
+ int id = fontDatabase.addApplicationFont(QLatin1String(SRCDIR "testfont.ttf"));
+
+ QFont font("QtBidiTestFont");
+ font.setHintingPreference(hintingPreference);
+ font.setPixelSize(12.0);
+
+ QRawFont rawFont = QRawFont::fromFont(font, QFontDatabase::Any);
+ QCOMPARE(rawFont.familyName(), QString::fromLatin1("QtBidiTestFont"));
+ QCOMPARE(rawFont.pixelSize(), 12.0);
+
+ rawFont = QRawFont::fromFont(font, QFontDatabase::Hebrew);
+ QCOMPARE(rawFont.familyName(), QString::fromLatin1("QtBidiTestFont"));
+ QCOMPARE(rawFont.pixelSize(), 12.0);
+
+ QString arabicText = QFontDatabase::writingSystemSample(QFontDatabase::Arabic);
+
+ QTextLayout layout;
+ layout.setFont(font);
+ layout.setText(arabicText);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphs> glyphss = layout.glyphs();
+ QCOMPARE(glyphss.size(), 1);
+
+ QGlyphs glyphs = glyphss.at(0);
+ QRawFont layoutFont = glyphs.font();
+ QVERIFY(layoutFont.familyName() != QString::fromLatin1("QtBidiTestFont"));
+ QCOMPARE(layoutFont.pixelSize(), 12.0);
+
+ rawFont = QRawFont::fromFont(font, QFontDatabase::Arabic);
+ QCOMPARE(rawFont.familyName(), layoutFont.familyName());
+ QCOMPARE(rawFont.pixelSize(), 12.0);
+
+ fontDatabase.removeApplicationFont(id);
+}
+
+#endif // QT_NO_RAWFONT
+
+QTEST_MAIN(tst_QRawFont)
+#include "tst_qrawfont.moc"
+
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 1a9db8f7fe..b613405a6d 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -5818,6 +5818,7 @@ void tst_QScriptEngine::dateConversionJSQt()
QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate);
QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString();
jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z")
+ jsUTCDateStr.append("Z"); // append the timezone specifier again
if (qtUTCDateStr != jsUTCDateStr)
QFAIL(qPrintable(jsDate.toString()));
secs += 2*60*60;
@@ -5832,6 +5833,7 @@ void tst_QScriptEngine::dateConversionQtJS()
QScriptValue jsDate = eng.newDate(qtDate);
QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString();
jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z")
+ jsUTCDateStr.append("Z"); // append the timezone specifier again
QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate);
if (jsUTCDateStr != qtUTCDateStr)
QFAIL(qPrintable(qtDate.toString()));
diff --git a/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp b/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp
index d47eb2429b..0978293d4f 100644
--- a/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp
+++ b/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp
@@ -276,8 +276,11 @@ bool TestConfigParser::isKnownSymbol(const QString &symbol)
<< "Q_OS_SOLARIS"
<< "Q_OS_WINCE"
<< "Q_OS_SYMBIAN"
+ << "Q_OS_MAC"
+ << "Q_OS_WIN"
<< "Q_CC_MSVC"
<< "Q_CC_MINGW"
+ << "Q_CC_INTEL"
;
}
return knownSymbols.contains(symbol);
@@ -299,12 +302,21 @@ bool TestConfigParser::isDefined(const QString &symbol)
#ifdef Q_OS_SYMBIAN
<< "Q_OS_SYMBIAN"
#endif
+#ifdef Q_OS_MAC
+ << "Q_OS_MAC"
+#endif
+#ifdef Q_OS_WIN
+ << "Q_OS_WIN"
+#endif
#ifdef Q_CC_MSVC
<< "Q_CC_MSVC"
#endif
#ifdef Q_CC_MINGW
<< "Q_CC_MINGW"
#endif
+#ifdef Q_CC_INTEL
+ << "Q_CC_INTEL"
+#endif
;
}
return definedSymbols.contains(symbol);
diff --git a/tests/auto/qscriptv8testsuite/skip.txt b/tests/auto/qscriptv8testsuite/skip.txt
index 3c2cc53fa4..9658c2b794 100644
--- a/tests/auto/qscriptv8testsuite/skip.txt
+++ b/tests/auto/qscriptv8testsuite/skip.txt
@@ -15,3 +15,17 @@ mul-exhaustive | Demands too much memory on WinCE
[Q_OS_SYMBIAN]
nested-repetition-count-overflow | Demands too much memory on Symbian
unicode-test | Demands too much memory on Symbian
+
+[Q_CC_INTEL]
+math-min-max | Unresolved failures with intel compiler
+negate-zero | Unresolved failures with intel compiler
+smi-negative-zero | Unresolved failures with intel compiler
+str-to-num | Unresolved failures with intel compiler
+to-precision | Unresolved failures with intel compiler
+
+[Q_OS_MAC]
+smi-negative-zero | Unresolved failures on Mac OS X (Cocoa)
+to-precision | Unresolved failures on Mac OS X (Cocoa)
+
+[Q_OS_WIN]
+to-precision | Unresolved failures on Windows
diff --git a/tests/auto/qsemaphore/tst_qsemaphore.cpp b/tests/auto/qsemaphore/tst_qsemaphore.cpp
index ba2175a383..9fc6de138e 100644
--- a/tests/auto/qsemaphore/tst_qsemaphore.cpp
+++ b/tests/auto/qsemaphore/tst_qsemaphore.cpp
@@ -244,6 +244,8 @@ void tst_QSemaphore::tryAcquireWithTimeout()
QSemaphore semaphore;
QTime time;
+#define QVERIFYGE(a,b) {int e = a; if (a<b) qDebug() << #a << "=" << e << " !>= " << #b << "=" << b; QVERIFY(e>=b);}
+#define QVERIFYLE(a,b) {int e = a; if (b<a) qDebug() << #a << "=" << e << " !<= " << #b << "=" << b; QVERIFY(e<=b);}
QCOMPARE(semaphore.available(), 0);
@@ -251,69 +253,69 @@ void tst_QSemaphore::tryAcquireWithTimeout()
QCOMPARE(semaphore.available(), 1);
time.start();
QVERIFY(!semaphore.tryAcquire(2, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 1);
semaphore.release();
QCOMPARE(semaphore.available(), 2);
time.start();
QVERIFY(!semaphore.tryAcquire(3, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 2);
semaphore.release(10);
QCOMPARE(semaphore.available(), 12);
time.start();
QVERIFY(!semaphore.tryAcquire(100, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 12);
semaphore.release(10);
QCOMPARE(semaphore.available(), 22);
time.start();
QVERIFY(!semaphore.tryAcquire(100, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 22);
time.start();
QVERIFY(semaphore.tryAcquire(1, timeout));
- QVERIFY(time.elapsed() <= timeout);
+ QVERIFYLE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 21);
time.start();
QVERIFY(semaphore.tryAcquire(1, timeout));
- QVERIFY(time.elapsed() <= timeout);
+ QVERIFYLE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 20);
time.start();
QVERIFY(semaphore.tryAcquire(10, timeout));
- QVERIFY(time.elapsed() <= timeout);
+ QVERIFYLE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 10);
time.start();
QVERIFY(semaphore.tryAcquire(10, timeout));
- QVERIFY(time.elapsed() <= timeout);
+ QVERIFYLE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 0);
// should not be able to acquire more
time.start();
QVERIFY(!semaphore.tryAcquire(1, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 0);
time.start();
QVERIFY(!semaphore.tryAcquire(1, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 0);
time.start();
QVERIFY(!semaphore.tryAcquire(10, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 0);
time.start();
QVERIFY(!semaphore.tryAcquire(10, timeout));
- QVERIFY(time.elapsed() >= timeout);
+ QVERIFYGE(time.elapsed(), timeout);
QCOMPARE(semaphore.available(), 0);
}
diff --git a/tests/auto/qsocketnotifier/qsocketnotifier.pro b/tests/auto/qsocketnotifier/qsocketnotifier.pro
index c43c96aa74..27484c89f7 100644
--- a/tests/auto/qsocketnotifier/qsocketnotifier.pro
+++ b/tests/auto/qsocketnotifier/qsocketnotifier.pro
@@ -4,7 +4,7 @@ QT = core network
requires(contains(QT_CONFIG,private_tests))
-include(../qnativesocketengine/qsocketengine.pri)
+include(../platformsocketengine/platformsocketengine.pri)
symbian: TARGET.CAPABILITY = NetworkServices
diff --git a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp
index 0b7e7efc70..f966e7fec0 100644
--- a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp
+++ b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp
@@ -46,7 +46,18 @@
#include <QtCore/QSocketNotifier>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
+#ifdef Q_OS_SYMBIAN
+#include <private/qsymbiansocketengine_p.h>
+#define NATIVESOCKETENGINE QSymbianSocketEngine
+#else
#include <private/qnativesocketengine_p.h>
+#define NATIVESOCKETENGINE QNativeSocketEngine
+#endif
+#ifdef Q_OS_UNIX
+#include <private/qnet_unix_p.h>
+#endif
+#include <limits>
+#include <select.h>
class tst_QSocketNotifier : public QObject
{
@@ -58,6 +69,8 @@ public:
private slots:
void unexpectedDisconnection();
void mixingWithTimers();
+ void posixSockets();
+ void bogusFds();
};
tst_QSocketNotifier::tst_QSocketNotifier()
@@ -71,10 +84,10 @@ class UnexpectedDisconnectTester : public QObject
{
Q_OBJECT
public:
- QNativeSocketEngine *readEnd1, *readEnd2;
+ NATIVESOCKETENGINE *readEnd1, *readEnd2;
int sequence;
- UnexpectedDisconnectTester(QNativeSocketEngine *s1, QNativeSocketEngine *s2)
+ UnexpectedDisconnectTester(NATIVESOCKETENGINE *s1, NATIVESOCKETENGINE *s2)
: readEnd1(s1), readEnd2(s2), sequence(0)
{
QSocketNotifier *notifier1 =
@@ -108,6 +121,9 @@ signals:
void tst_QSocketNotifier::unexpectedDisconnection()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("Symbian socket engine pseudo descriptors can't be used for QSocketNotifier", SkipAll);
+#else
/*
Given two sockets and two QSocketNotifiers registered on each
their socket. If both sockets receive data, and the first slot
@@ -124,7 +140,7 @@ void tst_QSocketNotifier::unexpectedDisconnection()
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost, 0));
- QNativeSocketEngine readEnd1;
+ NATIVESOCKETENGINE readEnd1;
readEnd1.initialize(QAbstractSocket::TcpSocket);
bool b = readEnd1.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd1.waitForWrite());
@@ -135,7 +151,7 @@ void tst_QSocketNotifier::unexpectedDisconnection()
QTcpSocket *writeEnd1 = server.nextPendingConnection();
QVERIFY(writeEnd1 != 0);
- QNativeSocketEngine readEnd2;
+ NATIVESOCKETENGINE readEnd2;
readEnd2.initialize(QAbstractSocket::TcpSocket);
b = readEnd2.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd2.waitForWrite());
@@ -157,10 +173,14 @@ void tst_QSocketNotifier::unexpectedDisconnection()
UnexpectedDisconnectTester tester(&readEnd1, &readEnd2);
+ QTimer timer;
+ timer.setSingleShot(true);
+ timer.start(30000);
do {
// we have to wait until sequence value changes
// as any event can make us jump out processing
QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
+ QVERIFY(timer.isActive); //escape if test would hang
} while(tester.sequence <= 0);
QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState);
@@ -173,6 +193,7 @@ void tst_QSocketNotifier::unexpectedDisconnection()
writeEnd1->close();
writeEnd2->close();
server.close();
+#endif
}
class MixingWithTimersHelper : public QObject
@@ -237,5 +258,99 @@ void tst_QSocketNotifier::mixingWithTimers()
QCOMPARE(helper.socketActivated, true);
}
+void tst_QSocketNotifier::posixSockets()
+{
+#ifndef Q_OS_UNIX
+ QSKIP("test only for posix", SkipAll);
+#else
+
+ QTcpServer server;
+ QVERIFY(server.listen(QHostAddress::LocalHost, 0));
+
+ int posixSocket = qt_safe_socket(AF_INET, SOCK_STREAM, 0);
+ sockaddr_in addr;
+ addr.sin_addr.s_addr = htonl(0x7f000001);
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(server.serverPort());
+ qt_safe_connect(posixSocket, (const struct sockaddr*)&addr, sizeof(sockaddr_in));
+ QVERIFY(server.waitForNewConnection(5000));
+ QScopedPointer<QTcpSocket> passive(server.nextPendingConnection());
+
+ ::fcntl(posixSocket, F_SETFL, ::fcntl(posixSocket, F_GETFL) | O_NONBLOCK);
+
+ {
+ QSocketNotifier rn(posixSocket, QSocketNotifier::Read);
+ connect(&rn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QSignalSpy readSpy(&rn, SIGNAL(activated(int)));
+ QSocketNotifier wn(posixSocket, QSocketNotifier::Write);
+ connect(&wn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QSignalSpy writeSpy(&wn, SIGNAL(activated(int)));
+ QSocketNotifier en(posixSocket, QSocketNotifier::Exception);
+ connect(&en, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QSignalSpy errorSpy(&en, SIGNAL(activated(int)));
+
+ passive->write("hello",6);
+ passive->waitForBytesWritten(5000);
+
+ QTestEventLoop::instance().enterLoop(3);
+ QCOMPARE(readSpy.count(), 1);
+ QCOMPARE(writeSpy.count(), 0);
+ QCOMPARE(errorSpy.count(), 0);
+
+ char buffer[100];
+ qt_safe_read(posixSocket, buffer, 100);
+ QCOMPARE(buffer, "hello");
+
+ qt_safe_write(posixSocket, "goodbye", 8);
+
+ QTestEventLoop::instance().enterLoop(3);
+ QCOMPARE(readSpy.count(), 1);
+ QCOMPARE(writeSpy.count(), 1);
+ QCOMPARE(errorSpy.count(), 0);
+ QCOMPARE(passive->readAll(), QByteArray("goodbye",8));
+ }
+ qt_safe_close(posixSocket);
+#endif
+}
+
+void tst_QSocketNotifier::bogusFds()
+{
+#ifndef Q_OS_WIN
+ QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error");
+#endif
+ QSocketNotifier max(std::numeric_limits<int>::max(), QSocketNotifier::Read);
+ QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Invalid socket specified");
+#ifndef Q_OS_WIN
+ QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error");
+#endif
+ QSocketNotifier min(std::numeric_limits<int>::min(), QSocketNotifier::Write);
+#ifndef Q_OS_WIN
+ QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error");
+#endif
+ //bogus magic number is the first pseudo socket descriptor from symbian socket engine.
+ QSocketNotifier bogus(0x40000000, QSocketNotifier::Exception);
+ QSocketNotifier largestlegal(FD_SETSIZE - 1, QSocketNotifier::Read);
+
+ QSignalSpy maxspy(&max, SIGNAL(activated(int)));
+ QSignalSpy minspy(&min, SIGNAL(activated(int)));
+ QSignalSpy bogspy(&bogus, SIGNAL(activated(int)));
+ QSignalSpy llspy(&largestlegal, SIGNAL(activated(int)));
+
+ //generate some unrelated socket activity
+ QTcpServer server;
+ QVERIFY(server.listen(QHostAddress::LocalHost));
+ connect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTcpSocket client;
+ client.connectToHost(QHostAddress::LocalHost, server.serverPort());
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(server.hasPendingConnections());
+
+ //check no activity on bogus notifiers
+ QCOMPARE(maxspy.count(), 0);
+ QCOMPARE(minspy.count(), 0);
+ QCOMPARE(bogspy.count(), 0);
+ QCOMPARE(llspy.count(), 0);
+}
+
QTEST_MAIN(tst_QSocketNotifier)
#include <tst_qsocketnotifier.moc>
diff --git a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro
index 171d428e15..c82c62d3e8 100644
--- a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro
+++ b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro
@@ -2,7 +2,7 @@ load(qttest_p4)
SOURCES += tst_qsocks5socketengine.cpp
-include(../qnativesocketengine/qsocketengine.pri)
+include(../platformsocketengine/platformsocketengine.pri)
MOC_DIR=tmp
diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
index 910d437374..bd19afb8ec 100644
--- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
+++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
@@ -179,8 +179,8 @@ void tst_QSoftKeyManager::handleCommand()
// QTest::keyPress(&w, Qt::Key_Context1);
// QTest::keyPress(&w, Qt::Key_Context2);
- simulateSymbianCommand(6000);
- simulateSymbianCommand(6001);
+ simulateSymbianCommand(s60CommandStart); //0 = LSK position
+ simulateSymbianCommand(s60CommandStart + 2); //2 = RSK position
QApplication::processEvents();
@@ -205,28 +205,32 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates()
w.show();
QApplication::processEvents();
- QSignalSpy spy0(w.actions()[0], SIGNAL(triggered())); //restore defaults action
- QSignalSpy spy1(w.actions()[1], SIGNAL(triggered())); //disabled help action
+ //According to StandardButton enum in QDialogButtonBox the Help action
+ //is inserted before RestoreDefaults and thus help action is in index 0
+ QSignalSpy spy0(w.actions()[0], SIGNAL(triggered())); //disabled help action
+ QSignalSpy spy1(w.actions()[1], SIGNAL(triggered())); //restore defaults action
//Verify that enabled button gets all the action trigger signals and
//disabled button gets none.
for (int i = 0; i < 10; i++) {
- //simulate "Restore Defaults" softkey press
- simulateSymbianCommand(s60CommandStart);
//simulate "help" softkey press
- simulateSymbianCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart);
+ //simulate "Restore Defaults" softkey press
+ simulateSymbianCommand(s60CommandStart + 2);
}
QApplication::processEvents();
- QCOMPARE(spy0.count(), 10);
- QCOMPARE(spy1.count(), 0);
+ //Restore defaults button is enabled and its signals are recorded to spy1
+ QCOMPARE(spy0.count(), 0);
+ QCOMPARE(spy1.count(), 10);
+
spy0.clear();
spy1.clear();
for (int i = 0; i < 10; i++) {
- //simulate "Restore Defaults" softkey press
- simulateSymbianCommand(s60CommandStart);
//simulate "help" softkey press
- simulateSymbianCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart);
+ //simulate "Restore Defaults" softkey press
+ simulateSymbianCommand(s60CommandStart + 2);
//switch enabled button to disabled and vice versa
pBHelp->setEnabled(!pBHelp->isEnabled());
pBDefaults->setEnabled(!pBDefaults->isEnabled());
@@ -261,7 +265,7 @@ void tst_QSoftKeyManager::noMergingOverWindowBoundary()
//Verify that both base softkeys emit triggered signals
simulateSymbianCommand(s60CommandStart);
- simulateSymbianCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart + 2);
QCOMPARE(baseLeftSpy.count(), 1);
QCOMPARE(baseRightSpy.count(), 1);
@@ -275,7 +279,7 @@ void tst_QSoftKeyManager::noMergingOverWindowBoundary()
QApplication::processEvents();
simulateSymbianCommand(s60CommandStart);
- simulateSymbianCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart + 2);
QCOMPARE(baseLeftSpy.count(), 0);
QCOMPARE(baseRightSpy.count(), 0);
@@ -291,7 +295,7 @@ void tst_QSoftKeyManager::noMergingOverWindowBoundary()
QApplication::processEvents();
simulateSymbianCommand(s60CommandStart);
- simulateSymbianCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart + 2);
QCOMPARE(baseLeftSpy.count(), 0);
QCOMPARE(baseRightSpy.count(), 0);
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index d26f0cd0f5..8e7f39335c 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -149,7 +149,6 @@ private slots:
void testMultipleProxiesWithSelection();
void mapSelectionFromSource();
- void testResetInternalData();
void filteredColumns();
protected:
@@ -3183,142 +3182,6 @@ void tst_QSortFilterProxyModel::taskQTBUG_10287_unnecessaryMapCreation()
// No assert failure, it passes.
}
-/**
- * A proxy which changes the background color for items ending in 'y' or 'r'
- */
-class CustomDataProxy : public QSortFilterProxyModel
-{
- Q_OBJECT
-
-public:
- CustomDataProxy(QObject *parent = 0)
- : QSortFilterProxyModel(parent)
- {
- setDynamicSortFilter(true);
- }
-
- void setSourceModel(QAbstractItemModel *sourceModel)
- {
- // It would be possible to use only the modelReset signal of the source model to clear
- // the data in *this, however, this requires that the slot is connected
- // before QSortFilterProxyModel::setSourceModel is called, and even then depends
- // on the order of invokation of slots being the same as the order of connection.
- // ie, not reliable.
-// connect(sourceModel, SIGNAL(modelReset()), SLOT(resetInternalData()));
- QSortFilterProxyModel::setSourceModel(sourceModel);
- // Making the connect after the setSourceModel call clears the data too late.
-// connect(sourceModel, SIGNAL(modelReset()), SLOT(resetInternalData()));
-
- // This could be done in data(), but the point is to need to cache something in the proxy
- // which needs to be cleared on reset.
- for (int i = 0; i < sourceModel->rowCount(); ++i)
- {
- if (sourceModel->index(i, 0).data().toString().endsWith(QLatin1Char('y')))
- {
- m_backgroundColours.insert(i, Qt::blue);
- } else if (sourceModel->index(i, 0).data().toString().endsWith(QLatin1Char('r')))
- {
- m_backgroundColours.insert(i, Qt::red);
- }
- }
- }
-
- QVariant data(const QModelIndex &index, int role) const
- {
- if (role != Qt::BackgroundRole)
- return QSortFilterProxyModel::data(index, role);
- return m_backgroundColours.value(index.row());
- }
-
-private slots:
- void resetInternalData()
- {
- m_backgroundColours.clear();
- }
-
-private:
- QHash<int, QColor> m_backgroundColours;
-};
-
-class ModelObserver : public QObject
-{
- Q_OBJECT
-public:
- ModelObserver(QAbstractItemModel *model, QObject *parent = 0)
- : QObject(parent), m_model(model)
- {
- connect(m_model, SIGNAL(modelAboutToBeReset()), SLOT(modelAboutToBeReset()));
- connect(m_model, SIGNAL(modelReset()), SLOT(modelReset()));
- }
-
-public slots:
- void modelAboutToBeReset()
- {
- int reds = 0, blues = 0;
- for (int i = 0; i < m_model->rowCount(); ++i)
- {
- QColor color = m_model->index(i, 0).data(Qt::BackgroundRole).value<QColor>();
- if (color == Qt::blue)
- ++blues;
- if (color == Qt::red)
- ++reds;
- }
- QCOMPARE(blues, 11);
- QCOMPARE(reds, 4);
- }
-
- void modelReset()
- {
- int reds = 0, blues = 0;
- for (int i = 0; i < m_model->rowCount(); ++i)
- {
- QColor color = m_model->index(i, 0).data(Qt::BackgroundRole).value<QColor>();
- if (color == Qt::blue)
- ++blues;
- if (color == Qt::red)
- ++reds;
- }
- QCOMPARE(reds, 0);
- QCOMPARE(blues, 0);
- }
-
-private:
- QAbstractItemModel * const m_model;
-
-};
-
-void tst_QSortFilterProxyModel::testResetInternalData()
-{
-
- QStringListModel model(QStringList() << "Monday"
- << "Tuesday"
- << "Wednesday"
- << "Thursday"
- << "Friday"
- << "January"
- << "February"
- << "March"
- << "April"
- << "May"
- << "Saturday"
- << "June"
- << "Sunday"
- << "July"
- << "August"
- << "September"
- << "October"
- << "November"
- << "December");
-
- CustomDataProxy proxy;
- proxy.setSourceModel(&model);
-
- ModelObserver observer(&proxy);
-
- // Cause the source model to reset.
- model.setStringList(QStringList() << "Spam" << "Eggs");
-}
-
class FilteredColumnProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 288b29c0d4..be2087dfc8 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -928,13 +928,12 @@ void tst_QSqlQuery::record()
QSqlQuery q( db );
QVERIFY( q.record().isEmpty() );
QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) );
- QSqlRecord rec = q.record();
QCOMPARE( q.record().fieldName( 0 ).toLower(), QString( "id" ) );
QCOMPARE( q.record().fieldName( 1 ).toLower(), QString( "t_varchar" ) );
QCOMPARE( q.record().fieldName( 2 ).toLower(), QString( "t_char" ) );
- QVERIFY( !q.record().value( 0 ).isValid() );
- QVERIFY( !q.record().value( 1 ).isValid() );
- QVERIFY( !q.record().value( 2 ).isValid() );
+ QCOMPARE(q.record().value(0), QVariant(q.record().field(0).type()));
+ QCOMPARE(q.record().value(1), QVariant(q.record().field(1).type()));
+ QCOMPARE(q.record().value(2), QVariant(q.record().field(2).type()));
QVERIFY( q.next() );
QVERIFY( q.next() );
diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
index e876764c2a..9507e54f29 100644
--- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -428,9 +428,9 @@ void tst_QSqlQueryModel::record()
QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id"));
QCOMPARE(rec.fieldName(1), isToUpper ? QString("NAME") : QString("name"));
QCOMPARE(rec.fieldName(2), isToUpper ? QString("TITLE") : QString("title"));
- QCOMPARE(rec.value(0), QVariant());
- QCOMPARE(rec.value(1), QVariant());
- QCOMPARE(rec.value(2), QVariant());
+ QCOMPARE(rec.value(0), QVariant(rec.field(0).type()));
+ QCOMPARE(rec.value(1), QVariant(rec.field(1).type()));
+ QCOMPARE(rec.value(2), QVariant(rec.field(2).type()));
rec = model.record(0);
QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id"));
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index bf68375865..b91d0254ea 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -569,9 +569,9 @@ void tst_QSqlTableModel::insertMultiRecords()
QVERIFY(model.insertRow(2));
- QCOMPARE(model.data(model.index(2, 0)), QVariant());
- QCOMPARE(model.data(model.index(2, 1)), QVariant());
- QCOMPARE(model.data(model.index(2, 2)), QVariant());
+ QCOMPARE(model.data(model.index(2, 0)), QVariant(model.record().field(0).type()));
+ QCOMPARE(model.data(model.index(2, 1)), QVariant(model.record().field(1).type()));
+ QCOMPARE(model.data(model.index(2, 2)), QVariant(model.record().field(2).type()));
QVERIFY(model.insertRow(3));
QVERIFY(model.insertRow(0));
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem
new file mode 100644
index 0000000000..3945aea91e
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDzCCAnigAwIBAgIQBH7L6fylX3vQnq424QyuHjANBgkqhkiG9w0BAQUFADBf
+MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50
+ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20w
+HhcNMTEwMzI0MTMwNjI1WhcNMTEwNDIzMTMwNjI1WjBfMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEB
+BQADgY0AMIGJAoGBAOeAGV2FbGnT4rLjTvCNEEDjj0/iIUATa6RT8WKF2PVaOzbE
+oceiODx6hTStvBnCgs+h/d3eVKgp+uAyBde5sW/HlOwHrNgKF3ZDvxegzIOEHaVI
+ndNtBpFS3UyOEkO0NxfioBatNRYpeTRU/DVmazu3yvzgrV1V2mDsrNngVWxJAgMB
+AAGjgcswgcgwHQYDVR0OBBYEFHcF1eqRpm7B78aY8ZjseN6zSYbvMIGYBgNVHSME
+gZAwgY2AFHcF1eqRpm7B78aY8ZjseN6zSYbvoWOkYTBfMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb22CEAR+y+n8pV970J6uNuEM
+rh4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBEb1iF+EbhAJli5Sj2
++iEdJ5xMP8R6FtgqAYknqXD8+tyEyXxJXdN186qdAWuTD9N22AUqi61BPWxUkufW
+xH8FYMEHdFCkitvYE0321+GT5pJz6ON/d5Co+wusumt7T5oSjzj8Ax9V+nmo3Nkb
+dSANM4/Lnc6moijcpJZq+GC1ng==
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem
new file mode 100644
index 0000000000..4b8d0599d2
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDjCCAnegAwIBAgIRAPXIavNhYvE6ZPVPbclYfAYwDQYJKoZIhvcNAQEFBQAw
+XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOd3d3Lmdvb2dsZS5jb20w
+HhcNMTEwMzI0MTMwNzExWhcNMTEwNDIzMTMwNzExWjBeMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRcwFQYDVQQDEw53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEF
+AAOBjQAwgYkCgYEAy1fNDFl65Njfcd1EUJeaxvyiKln+JKlqUmk1x4mrE1BQoa0C
+QZaiXAF21rDhivWejZWBiEQ4IWbg3b12ANY74G1KqAfLC4BNKS9UP94hy18vezRA
+pFc+m/HAClwc8AdACpl8eZpQW8cMgdvnMBMZTrQkgV0JYykX+uDD9Tb+QNUCAwEA
+AaOByzCByDAdBgNVHQ4EFgQUSelG6IVRj2ZQbp049zkQ0X/Po9wwgZgGA1UdIwSB
+kDCBjYAUSelG6IVRj2ZQbp049zkQ0X/Po9yhYqRgMF4xCzAJBgNVBAYTAkFVMRMw
+EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0
+eSBMdGQxFzAVBgNVBAMTDnd3dy5nb29nbGUuY29tghEA9chq82Fi8Tpk9U9tyVh8
+BjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBALQyDC/AMQMNj2fa6E8L
+umILCklWJwG1K1p/1bUAgm0CB8zm94n1xrh/ZK4+HS+k2a9OQmvLRbFyJn8Wua8p
+3UU0267UNkCanA1FKHuO3Mo18wLvjMLWjjCQ4g1C9IvJx6P+8EFDQFG+MJBV/w2k
+gJXXVl3q1T1dvahIgfav9QBL
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem
new file mode 100644
index 0000000000..e47ece60dd
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDETCCAnqgAwIBAgIRANdVj9r18RBbshMoK3B3KaMwDQYJKoZIhvcNAQEFBQAw
+XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29t
+MB4XDTExMDMyNDEzMDg0MloXDTExMDQyMzEzMDg0MlowXzELMAkGA1UEBhMCQVUx
+EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg
+UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tMIGfMA0GCSqGSIb3DQEB
+AQUAA4GNADCBiQKBgQCosFLKRvGtxjvdAjWdEAHYycFTa4VtdpXmCNhNHf2xbeLn
+xzde10KjEe44pQxNI+UUD1rJkyuH6wUfloyefn0D2Mu+MvusmvOEzFosa4EDbK9s
+BAAlsSiyJgrp/GgbEPq/XOl4XJRBIVP1WC6LllduNbskFCipDqS+HQwifXmmwQID
+AQABo4HMMIHJMB0GA1UdDgQWBBSEgWnsoYtd5GEx/MGJvKxuIuROJzCBmQYDVR0j
+BIGRMIGOgBSEgWnsoYtd5GEx/MGJvKxuIuROJ6FjpGEwXzELMAkGA1UEBhMCQVUx
+EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg
+UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tghEA11WP2vXxEFuyEygr
+cHcpozAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAKNpIrzTOxIykKZt
+EE6HU2nW1lrWUkIMjwjL8ntw7QI4JLMDN1ADVIxWaGTeQ+U/eXFou6dDNAYVAijK
+ONDXgOItxW2YvSw0wOZsZj6INX2x88/0yRH+19TqaL/r+Y1D1h/0zefkHgfXufnY
+Ex7BHju/rGBTp6R1mr+Tlh1tewva
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem
new file mode 100644
index 0000000000..64c7d41516
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDzCCAnigAwIBAgIQOSpDTw4H3x+KowXeNODCKTANBgkqhkiG9w0BAQUFADBf
+MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50
+ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w
+HhcNMTEwMzI0MTMwOTE1WhcNMTEwNDIzMTMwOTE1WjBfMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB
+BQADgY0AMIGJAoGBANO2gz9x2H92xz5OvZSEul9gHxqqd+kdjeoS2exyvjC9wzqb
+gYXqNmAsbtNp4WmieEQFd0riCAEkIAn8JpHTCsMHN4rHhS+W+4D5a/drI2jfnZEF
+orNYJG1PHSQV/rvh6d7wkVdT+0SYOjrFTAA2biGWaK3W9ztf2yX577w+uQtBAgMB
+AAGjgcswgcgwHQYDVR0OBBYEFJjDp8Prs7oReRmskIeFixp0vDkGMIGYBgNVHSME
+gZAwgY2AFJjDp8Prs7oReRmskIeFixp0vDkGoWOkYTBfMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CEDkqQ08OB98fiqMF3jTg
+wikwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAZyo0Q3leeM1+lxeCd
+Wp0ZYHMSW11ANc6nuMWOmJC+nIQGlyGiP3IqeUvIfekwboV638bahVPwcl2HYWsS
+/l01Bgyd25Zn6VTQBfMK01dILyxscjVwdHuojzYBN05sl+qkVoqQr5EroQQbgDc9
+6I88p6Kjajv3IusCwfK6wlqISw==
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem
new file mode 100644
index 0000000000..c7ddbf2839
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDzCCAnigAwIBAgIQPnXO1GtpMCEhiDCuhqgqcTANBgkqhkiG9w0BAQUFADBf
+MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50
+ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w
+HhcNMTEwMzI0MTMwOTQ4WhcNMTEwNDIzMTMwOTQ4WjBfMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB
+BQADgY0AMIGJAoGBALkiHG9TgTw/00CMW8D23NBDAa3331AL5kTkAaXbAWg2R/1o
+yKQfXq3hgHbyWGPccUT+tU6FmaBf3bIndLK7iGx81RGzGgXeoQ5mpgnJ50iCeW73
+G99VlVwutPia7d9qqui84YdcG9t+P2Fuxv+xRqAB6lKOaa4qTPIbH50PgwOvAgMB
+AAGjgcswgcgwHQYDVR0OBBYEFBWJrs8bnZ5fikfaLbTxK0ssj69MMIGYBgNVHSME
+gZAwgY2AFBWJrs8bnZ5fikfaLbTxK0ssj69MoWOkYTBfMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CED51ztRraTAhIYgwroao
+KnEwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCIfqqs1a7RzdmV8U00
+v/xAsxscKvQvmu6BK+HwvY5iL2pSwXTYgRLJLoj5QGOd3mmgOFsyW3BPSCP1+fVE
+M1ROhU2u8wHub+hGGds18Fx6F4yZjdh8pNUoOUR9A0Ym+VDJr2p50oUNTTy0RbH8
+9ns/gbemx84cjF9DD2G5stQhYg==
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem
new file mode 100644
index 0000000000..bc2be2adcf
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDETCCAnqgAwIBAgIRAOkCi5V45BXcGnEKK4gVREcwDQYJKoZIhvcNAQEFBQAw
+XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29t
+MB4XDTExMDMyNDEzMTAxNloXDTExMDQyMzEzMTAxNlowXzELMAkGA1UEBhMCQVUx
+EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg
+UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tMIGfMA0GCSqGSIb3DQEB
+AQUAA4GNADCBiQKBgQDFq06qqRl86pP7GRX3m7FMMSaSU6zlNGAo+WPoRfYAzB6x
+5KpvlfxMCo3T/nWtInX3Bw9TBWCZSweQ2GEjggO0irjw5UX3MiToLxK+rwzWztm9
+H3LBxTWR0cOOa78kRFvNQ1onvNHbs8fJzXjG7b2IJDOIwG1HAT1LK80oPXZc1wID
+AQABo4HMMIHJMB0GA1UdDgQWBBTiGNxw0ImW/wfW0mD3eA65PY5CAzCBmQYDVR0j
+BIGRMIGOgBTiGNxw0ImW/wfW0mD3eA65PY5CA6FjpGEwXzELMAkGA1UEBhMCQVUx
+EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg
+UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tghEA6QKLlXjkFdwacQor
+iBVERzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAHdb1QY/oxuro/4x
+GX9jbm930ysoeXkWZSKVtVxoxrPIferu8jVpb1SLRjGcMnmjJoNWNFpvnbZgoYei
+f3wdSWun7ndyQBh61k8eM7UABDOUXUHOsHuHj7s1koMKtet4gykmMfd6VxBkwBvN
+ZXOll4X+TKe8nrxbnGUByIwQaRM+
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem
new file mode 100644
index 0000000000..19d4353fab
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDGjCCAoOgAwIBAgIRAJI51TSPQNFpWnRUcOHyP0MwDQYJKoZIhvcNAQEFBQAw
+YjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEu
+b3JnMB4XDTExMDMyNDEzMTA0NFoXDTExMDQyMzEzMTA0NFowYjELMAkGA1UEBhMC
+QVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdp
+dHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnMIGfMA0GCSqG
+SIb3DQEBAQUAA4GNADCBiQKBgQC1lsoAcZTwF8Pf0E9do5avLdobB/O7EhhrCMs2
+/EMO07aIlrLwl3UP/Fmu/cAkKuX8Mx+Eif9x+XT3ZqGKGYKiqPTJcNfeZvgwbn0j
+wXDtEo4DuURrwtBU9okS+v4dF6F4RtHQKAGcsXoOjhR7ah71kve+PG2GG0sJ167V
+klK1xwIDAQABo4HPMIHMMB0GA1UdDgQWBBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxjCB
+nAYDVR0jBIGUMIGRgBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxqFmpGQwYjELMAkGA1UE
+BhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdp
+ZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnghEAkjnV
+NI9A0WladFRw4fI/QzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACeE
+DHMQ+LWEuoa/6z2EgrgM1k9rvBbUtCR+rjTuyzVW4OLXdpiVwZPOAiKphpq7q8Sb
+TQ3zwsCoPLLJk5VolwcPfcD8Y2/tYK3NCYl+HzGxxnzPDFVaZM5Jh8RI861Hc00D
+hVoQaptPK/V/lr0KEevqjhusAdFZbwlWA923zASa
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem
new file mode 100644
index 0000000000..aedf3f7010
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDjCCAnegAwIBAgIRALC3Ez7Qlvm1b66RyHS9OsAwDQYJKoZIhvcNAQEFBQAw
+XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMObG9naW4ubGl2ZS5jb20w
+HhcNMTEwMzI0MTMxMTA2WhcNMTEwNDIzMTMxMTA2WjBeMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRcwFQYDVQQDEw5sb2dpbi5saXZlLmNvbTCBnzANBgkqhkiG9w0BAQEF
+AAOBjQAwgYkCgYEA3OVNj9ijzMewvDeZYzgCWoKtyjclyIHxrQfHZpcexaKbxUap
+1MtF6L0ayjtRWpiBYuPteUSy/Ja4Oh6zZz8K6z5rVgXhmy3xPIYuOoWaTKEOhb0Z
+oHTBtGh8aWWai1XWw37HIm2FP8cmfgdH4lZwVvpTZIUxYidsyqyjB9IrhiMCAwEA
+AaOByzCByDAdBgNVHQ4EFgQU4CcQcIvEhJC0tqHlNFMkv6MlDN4wgZgGA1UdIwSB
+kDCBjYAU4CcQcIvEhJC0tqHlNFMkv6MlDN6hYqRgMF4xCzAJBgNVBAYTAkFVMRMw
+EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0
+eSBMdGQxFzAVBgNVBAMTDmxvZ2luLmxpdmUuY29tghEAsLcTPtCW+bVvrpHIdL06
+wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAMNzIStXDNSNQ8ayxrcj
+4RrUMsHWUG/6XPrgfYqCP5TfPGAa5qBfNb9LfUbiS4b0flJVN1RlHVwwRo0yf9v4
+LGg0dSuPQAOWlLeUR1GminO1jHZw7E4dYfR7QEmiiOgaQU+CbxLsf5vCaKInN9Gu
+jv/5xytVCbMoLoZ4EBVb0tka
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem
new file mode 100644
index 0000000000..d179b29288
--- /dev/null
+++ b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDjCCAnegAwIBAgIRANjzX063hystqwaS4xU4L7AwDQYJKoZIhvcNAQEFBQAw
+XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOZ2xvYmFsIHRydXN0ZWUw
+HhcNMTEwMzI0MTMxMTM3WhcNMTEwNDIzMTMxMTM3WjBeMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRcwFQYDVQQDEw5nbG9iYWwgdHJ1c3RlZTCBnzANBgkqhkiG9w0BAQEF
+AAOBjQAwgYkCgYEArHCVym7AEZDBhDkrUSG3Q94a+caNcCk5fE6ltZHiZHv096xr
+cixHYvSGvms780bkI+oot2xI/e9awwkV+7VjWNvr0HrajzBWeimwk+myjP+3ddMY
+Kmr0eI6bmvmPHtOFJE5Ar8/62FwD0wlLogRIx56JtXcCpkiUQktJVPz2gtMCAwEA
+AaOByzCByDAdBgNVHQ4EFgQUUJwC/qSGBmcB+DVrd43ovRLdLmQwgZgGA1UdIwSB
+kDCBjYAUUJwC/qSGBmcB+DVrd43ovRLdLmShYqRgMF4xCzAJBgNVBAYTAkFVMRMw
+EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0
+eSBMdGQxFzAVBgNVBAMTDmdsb2JhbCB0cnVzdGVlghEA2PNfTreHKy2rBpLjFTgv
+sDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACAYxI+r3+JNelL6SBB0
+Pda3LkbCm+schP64NBYDdGl2Kus2b2QZ83T7xENBFEhyNoXvc6pRI4/Oh6JDxmG1
+7WmqOVStS/4JeAu6ygiyI1ImRKq2/MvJx/kaKh6IiXanB5nW1U+fhDV6kMOEfpwV
+i6FBibpHboPQoqzPPRe7qHSL
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
index 1e3a8ddb4b..57f2fa8c04 100644
--- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
@@ -111,6 +111,8 @@ private slots:
void nulInSan();
void largeSerialNumber();
void largeExpirationDate();
+ void blacklistedCertificates();
+
// ### add tests for certificate bundles (multiple certificates concatenated into a single
// structure); both PEM and DER formatted
#endif
@@ -817,6 +819,15 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489
QCOMPARE(cert.expiryDate().toUTC(), QDateTime(QDate(2051, 8, 29), QTime(9, 53, 41), Qt::UTC));
}
+void tst_QSslCertificate::blacklistedCertificates()
+{
+ QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath("more-certificates/blacklisted*.pem", QSsl::Pem, QRegExp::Wildcard);
+ QVERIFY2(blacklistedCerts.count() > 0, "Please run this test from the source directory");
+ for (int a = 0; a < blacklistedCerts.count(); a++) {
+ QVERIFY(! blacklistedCerts.at(a).isValid());
+ }
+}
+
#endif // QT_NO_OPENSSL
QTEST_MAIN(tst_QSslCertificate)
diff --git a/tests/auto/qsslkey/tst_qsslkey.cpp b/tests/auto/qsslkey/tst_qsslkey.cpp
index e7b474078d..86da09e96b 100644
--- a/tests/auto/qsslkey/tst_qsslkey.cpp
+++ b/tests/auto/qsslkey/tst_qsslkey.cpp
@@ -108,10 +108,8 @@ tst_QSslKey::tst_QSslKey()
#ifdef Q_WS_MAC
// applicationDirPath() points to a path inside the app bundle on Mac.
QDir dir(qApp->applicationDirPath() + QLatin1String("/../../../keys"));
-#elif defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
- QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds?
#else
- QDir dir(qApp->applicationDirPath() + QLatin1String("/keys"));
+ QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds?
#endif
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
QRegExp rx(QLatin1String("^(rsa|dsa)-(pub|pri)-(\\d+)\\.(pem|der)$"));
diff --git a/tests/auto/qsslsocket/certs/fake-login.live.com.key b/tests/auto/qsslsocket/certs/fake-login.live.com.key
new file mode 100644
index 0000000000..692a7bd85d
--- /dev/null
+++ b/tests/auto/qsslsocket/certs/fake-login.live.com.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDOtxdvMa0VHUQYG5q7Tsi1Jj4qKEJppyZEkmuRXOi0fDbd1SwE
+bwHrLGMvDO6OMrYBbq3WDNrtnIfF9CvzUOEch+gjr4hEVQqecU5fb45Wor7yNel3
+/C/gxfbzuXHrsj/gUjNghL2i10+c2NW+hUo/sWO6OusaBT6d6s7ee+YBcQIDAQAB
+AoGAb8cVhu0HuLkgjyCuJMbPRRUu3ED02Iin6sB6JhplQuNAD+grayJTmUVhRJnr
+jTziqhedLHe7Em1oBaSo92MutfMpXvWiccSlbNygI61VgmrJpVB+qIN5H9cQc9ql
+Zymc+nIPa1+i5rsrOzlpUytTh7AsbZ27QG4tQXR/kQejEiECQQD6BgTxBeT8D7x9
+DuukoBaSCkLwx7U7P1NXx15EI3lA1nO51t6UHfvk/jGPp8Sl4wv4alJ7AQxr5uQ/
+vC3kzA/1AkEA06gNu10se8pe3n8qL2RRt+FmVjHkQdD9Mm2Dx9oWCs2A4wOSOrlo
+6/nKYF1CaQNYn9HgsNbHVEUpnICVO18qDQJBALEw/uOJ1+TDikPfBSWgxx4s45Ad
+GNWqZXh6NNZ5hX9r/IwiOZAjR9fcRmeW8IjYRi2BvH6sGY+HDRAWXzgdXtkCQCma
+dOiJTf8fLjqp4E7kdzOfuI/kyqstOze4Uxjrgz2oW1dEEnA8laUcumzqp+0gXUE8
+7d+UuCWWWrGKjMrYz9kCQQDh5E5+b6Djn082Jo6gvyuXWC5eXju6IdmihlJ2SMzD
+s2y3IDjOUtTeQQRDymLneteMz0ha79KeUp6VnAvZCOVe
+-----END RSA PRIVATE KEY-----
diff --git a/tests/auto/qsslsocket/certs/fake-login.live.com.pem b/tests/auto/qsslsocket/certs/fake-login.live.com.pem
new file mode 100644
index 0000000000..429f95187c
--- /dev/null
+++ b/tests/auto/qsslsocket/certs/fake-login.live.com.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDjCCAnegAwIBAgIRALC3Ez7Qlvm1b66RyHS9OsAwDQYJKoZIhvcNAQEFBQAw
+XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMObG9naW4ubGl2ZS5jb20w
+HhcNMTEwMzI1MTMyODUwWhcNMTEwNDI0MTMyODUwWjBeMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMRcwFQYDVQQDEw5sb2dpbi5saXZlLmNvbTCBnzANBgkqhkiG9w0BAQEF
+AAOBjQAwgYkCgYEAzrcXbzGtFR1EGBuau07ItSY+KihCaacmRJJrkVzotHw23dUs
+BG8B6yxjLwzujjK2AW6t1gza7ZyHxfQr81DhHIfoI6+IRFUKnnFOX2+OVqK+8jXp
+d/wv4MX287lx67I/4FIzYIS9otdPnNjVvoVKP7FjujrrGgU+nerO3nvmAXECAwEA
+AaOByzCByDAdBgNVHQ4EFgQUpSOEcmtkQITvBdM2IDfcXnJ0FCAwgZgGA1UdIwSB
+kDCBjYAUpSOEcmtkQITvBdM2IDfcXnJ0FCChYqRgMF4xCzAJBgNVBAYTAkFVMRMw
+EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0
+eSBMdGQxFzAVBgNVBAMTDmxvZ2luLmxpdmUuY29tghEAsLcTPtCW+bVvrpHIdL06
+wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAD+2HT4GSHHKCdbl9VkX
+zsl+D+drMm2b0ksxz9SgPihP7aW50EEIJDEEihNMTa27mhpeOXHc/sLqDi4ECUao
+/0Ns/5uoVuAIrAKCydmtPsonVFh9XWjyrfUzPOHAc9p2bmJ1i9a3kTsLB6jlrVDO
+VufGzsowHlHZ0TtKf5omojU5
+-----END CERTIFICATE-----
diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro
index aeeae8ff8b..77517e05bc 100644
--- a/tests/auto/qsslsocket/qsslsocket.pro
+++ b/tests/auto/qsslsocket/qsslsocket.pro
@@ -23,8 +23,8 @@ wince* {
DEPLOYMENT += certFiles
} else:symbian {
DEFINES += QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
- TARGET.EPOCHEAPSIZE="0x100 0x1000000"
- TARGET.CAPABILITY=NetworkServices
+ TARGET.EPOCHEAPSIZE="0x100 0x3000000"
+ TARGET.CAPABILITY=NetworkServices ReadUserData
certFiles.files = certs ssl.tar.gz
certFiles.path = .
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 6fbedfa202..507af5ebd5 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -67,6 +67,7 @@ typedef QList<QSslError::SslError> SslErrorList;
Q_DECLARE_METATYPE(SslErrorList)
Q_DECLARE_METATYPE(QSslError)
Q_DECLARE_METATYPE(QSsl::SslProtocol)
+Q_DECLARE_METATYPE(QSslConfiguration)
#endif
#if defined Q_OS_HPUX && defined Q_CC_GNU
@@ -152,6 +153,8 @@ private slots:
void setLocalCertificate();
void setPrivateKey();
void setSocketDescriptor();
+ void setSslConfiguration_data();
+ void setSslConfiguration();
void waitForEncrypted();
void waitForConnectedEncryptedReadyRead();
void startClientEncryption();
@@ -185,6 +188,7 @@ private slots:
void ignoreSslErrorsListWithSlot();
void readFromClosedSocket();
void writeBigChunk();
+ void blacklistedCertificates();
void setEmptyDefaultConfiguration();
static void exitLoop()
@@ -533,6 +537,8 @@ void tst_QSslSocket::sslErrors()
QSslSocketPtr socket = newSocket();
socket->connectToHostEncrypted(host, port);
+ if (!socket->waitForConnected())
+ QEXPECT_FAIL("imap.trolltech.com", "server not open to internet", Continue);
socket->waitForEncrypted(5000);
SslErrorList output;
@@ -541,7 +547,7 @@ void tst_QSslSocket::sslErrors()
}
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
- if (output.last() == QSslError::CertificateUntrusted)
+ if (output.count() && output.last() == QSslError::CertificateUntrusted)
output.takeLast();
#endif
QCOMPARE(output, expected);
@@ -650,7 +656,7 @@ void tst_QSslSocket::sessionCipher()
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
QVERIFY(socket->sessionCipher().isNull());
socket->connectToHost(QtNetworkSettings::serverName(), 443 /* https */);
- QVERIFY(socket->waitForConnected(5000));
+ QVERIFY(socket->waitForConnected(10000));
QVERIFY(socket->sessionCipher().isNull());
socket->startClientEncryption();
QVERIFY(socket->waitForEncrypted(5000));
@@ -684,7 +690,7 @@ void tst_QSslSocket::localCertificate()
socket->setPrivateKey(QLatin1String(SRCDIR "certs/fluke.key"));
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
- QVERIFY(socket->waitForEncrypted(5000));
+ QVERIFY(socket->waitForEncrypted(10000));
}
void tst_QSslSocket::mode()
@@ -857,9 +863,16 @@ class SslServer : public QTcpServer
{
Q_OBJECT
public:
- SslServer() : socket(0), protocol(QSsl::TlsV1) { }
+ SslServer(const QString &keyFile = SRCDIR "certs/fluke.key", const QString &certFile = SRCDIR "certs/fluke.cert")
+ : socket(0),
+ protocol(QSsl::TlsV1),
+ m_keyFile(keyFile),
+ m_certFile(certFile) { }
QSslSocket *socket;
QSsl::SslProtocol protocol;
+ QString m_keyFile;
+ QString m_certFile;
+
protected:
void incomingConnection(int socketDescriptor)
{
@@ -867,13 +880,13 @@ protected:
socket->setProtocol(protocol);
connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
- QFile file(SRCDIR "certs/fluke.key");
+ QFile file(m_keyFile);
QVERIFY(file.open(QIODevice::ReadOnly));
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
QVERIFY(!key.isNull());
socket->setPrivateKey(key);
- QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(m_certFile);
QVERIFY(!localCert.isEmpty());
QVERIFY(localCert.first().handle());
socket->setLocalCertificate(localCert.first());
@@ -918,13 +931,15 @@ void tst_QSslSocket::protocolServerSide_data()
QTest::newRow("ssl3-tls1") << QSsl::SslV3 << QSsl::TlsV1 << false;
QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true;
QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << true;
- QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << true;
+ QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << false; // we wont set a SNI header here because we connect to a
+ // numerical IP, so OpenSSL will send a SSL 2 handshake
QTest::newRow("tls1-ssl2") << QSsl::TlsV1 << QSsl::SslV2 << false;
QTest::newRow("tls1-ssl3") << QSsl::TlsV1 << QSsl::SslV3 << false;
QTest::newRow("tls1-tls1ssl3") << QSsl::TlsV1 << QSsl::TlsV1SslV3 << true;
QTest::newRow("tls1-secure") << QSsl::TlsV1 << QSsl::SecureProtocols << true;
- QTest::newRow("tls1-any") << QSsl::TlsV1 << QSsl::AnyProtocol << true;
+ QTest::newRow("tls1-any") << QSsl::TlsV1 << QSsl::AnyProtocol << false; // we wont set a SNI header here because we connect to a
+ // numerical IP, so OpenSSL will send a SSL 2 handshake
QTest::newRow("tls1ssl3-ssl2") << QSsl::TlsV1SslV3 << QSsl::SslV2 << false;
QTest::newRow("tls1ssl3-ssl3") << QSsl::TlsV1SslV3 << QSsl::SslV3 << true;
@@ -1036,6 +1051,39 @@ void tst_QSslSocket::setSocketDescriptor()
QVERIFY(client->localPort() != 0);
}
+void tst_QSslSocket::setSslConfiguration_data()
+{
+ QTest::addColumn<QSslConfiguration>("configuration");
+ QTest::addColumn<bool>("works");
+
+ QTest::newRow("empty") << QSslConfiguration() << false;
+ QSslConfiguration conf = QSslConfiguration::defaultConfiguration();
+ QTest::newRow("default") << conf << false; // does not contain test server cert
+ QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
+ conf.setCaCertificates(testServerCert);
+ QTest::newRow("set-root-cert") << conf << true;
+ conf.setProtocol(QSsl::SecureProtocols);
+ QTest::newRow("secure") << conf << true;
+}
+
+void tst_QSslSocket::setSslConfiguration()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ QFETCH(QSslConfiguration, configuration);
+ socket->setSslConfiguration(configuration);
+ this->socket = socket;
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+ QFETCH(bool, works);
+ QCOMPARE(socket->waitForEncrypted(10000), works);
+ if (works) {
+ socket->disconnectFromHost();
+ QVERIFY2(socket->waitForDisconnected(), qPrintable(socket->errorString()));
+ }
+}
+
void tst_QSslSocket::waitForEncrypted()
{
if (!QSslSocket::supportsSsl())
@@ -1708,7 +1756,7 @@ void tst_QSslSocket::disconnectFromHostWhenConnecting()
QCOMPARE(state, socket->state());
QVERIFY(socket->state() == QAbstractSocket::HostLookupState ||
socket->state() == QAbstractSocket::ConnectingState);
- QVERIFY(socket->waitForDisconnected(5000));
+ QVERIFY(socket->waitForDisconnected(10000));
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
// we did not call close, so the socket must be still open
QVERIFY(socket->isOpen());
@@ -1937,6 +1985,38 @@ void tst_QSslSocket::writeBigChunk()
socket->close();
}
+void tst_QSslSocket::blacklistedCertificates()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ SslServer server(SRCDIR "certs/fake-login.live.com.key", SRCDIR "certs/fake-login.live.com.pem");
+ QSslSocket *receiver = new QSslSocket(this);
+ connect(receiver, SIGNAL(readyRead()), SLOT(exitLoop()));
+
+ // connect two sockets to each other:
+ QVERIFY(server.listen(QHostAddress::LocalHost));
+ receiver->connectToHost("127.0.0.1", server.serverPort());
+ QVERIFY(receiver->waitForConnected(5000));
+ QVERIFY(server.waitForNewConnection(0));
+
+ QSslSocket *sender = server.socket;
+ QVERIFY(sender);
+ QVERIFY(sender->state() == QAbstractSocket::ConnectedState);
+ receiver->setObjectName("receiver");
+ sender->setObjectName("sender");
+ receiver->startClientEncryption();
+
+ connect(receiver, SIGNAL(sslErrors(QList<QSslError>)), SLOT(exitLoop()));
+ connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop()));
+ enterLoop(1);
+ QList<QSslError> sslErrors = receiver->sslErrors();
+ QVERIFY(sslErrors.count() > 0);
+ // there are more errors (self signed cert and hostname mismatch), but we only care about the blacklist error
+ QCOMPARE(sslErrors.at(0).error(), QSslError::CertificateBlacklisted);
+}
+
void tst_QSslSocket::setEmptyDefaultConfiguration()
{
// used to produce a crash in QSslConfigurationPrivate::deepCopyDefaultConfiguration, QTBUG-13265
@@ -1948,8 +2028,9 @@ void tst_QSslSocket::setEmptyDefaultConfiguration()
QSslConfiguration::setDefaultConfiguration(emptyConf);
QSslSocketPtr socket = newSocket();
+ connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
-
+ QVERIFY2(!socket->waitForEncrypted(4000), qPrintable(socket->errorString()));
}
#endif // QT_NO_OPENSSL
diff --git a/tests/auto/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro
index ea62865bc3..53020eb892 100644
--- a/tests/auto/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro
+++ b/tests/auto/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro
@@ -17,17 +17,9 @@ win32 {
wince* {
DEFINES += SRCDIR=\\\"./\\\"
-
- certFiles.files = certs ssl.tar.gz
- certFiles.path = .
- DEPLOYMENT += certFiles
} else:symbian {
TARGET.EPOCHEAPSIZE="0x100 0x1000000"
- TARGET.CAPABILITY=NetworkServices
-
- certFiles.files = certs ssl.tar.gz
- certFiles.path = .
- DEPLOYMENT += certFiles
+ TARGET.CAPABILITY=NetworkServices ReadUserData
INCLUDEPATH *= $$MW_LAYER_SYSTEMINCLUDE # Needed for e32svr.h in S^3 envs
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
diff --git a/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
index abdd55001e..6d3590af84 100644
--- a/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
+++ b/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
@@ -217,6 +217,13 @@ void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMe
socket3->setCaCertificates(QList<QSslCertificate>());
socket3->connectToHostEncrypted(host, 443);
QVERIFY(!socket3->waitForEncrypted());
+
+ // setting empty SSL configuration explicitly -> should not work
+ QSslSocketPtr socket4 = newSocket();
+ this->socket = socket4;
+ socket4->setSslConfiguration(QSslConfiguration());
+ socket4->connectToHostEncrypted(host, 443);
+ QVERIFY(!socket4->waitForEncrypted());
}
#endif // QT_NO_OPENSSL
diff --git a/tests/auto/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro
index 13990cb24b..3452a92fe2 100644
--- a/tests/auto/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro
+++ b/tests/auto/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro
@@ -17,17 +17,9 @@ win32 {
wince* {
DEFINES += SRCDIR=\\\"./\\\"
-
- certFiles.files = certs ssl.tar.gz
- certFiles.path = .
- DEPLOYMENT += certFiles
} else:symbian {
TARGET.EPOCHEAPSIZE="0x100 0x1000000"
- TARGET.CAPABILITY=NetworkServices
-
- certFiles.files = certs ssl.tar.gz
- certFiles.path = .
- DEPLOYMENT += certFiles
+ TARGET.CAPABILITY=NetworkServices ReadUserData
INCLUDEPATH *= $$MW_LAYER_SYSTEMINCLUDE # Needed for e32svr.h in S^3 envs
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
diff --git a/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp b/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp
index 5003b5c490..14a7c3badb 100644
--- a/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp
+++ b/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp
@@ -218,6 +218,18 @@ void tst_QSslSocket_onDemandCertificates_static::onDemandRootCertLoadingStaticMe
this->socket = socket3;
socket3->connectToHostEncrypted(host, 443);
QVERIFY(!socket3->waitForEncrypted());
+
+ QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates());
+
+ // setting empty default configuration -> should not work
+ QSslConfiguration conf;
+ QSslConfiguration originalDefaultConf = QSslConfiguration::defaultConfiguration();
+ QSslConfiguration::setDefaultConfiguration(conf);
+ QSslSocketPtr socket4 = newSocket();
+ this->socket = socket4;
+ socket4->connectToHostEncrypted(host, 443);
+ QVERIFY(!socket4->waitForEncrypted(4000));
+ QSslConfiguration::setDefaultConfiguration(originalDefaultConf); // restore old behaviour for run with proxies etc.
}
#endif // QT_NO_OPENSSL
diff --git a/tests/auto/qstring/qstring.pro b/tests/auto/qstring/qstring.pro
index e980042351..1c123adcca 100644
--- a/tests/auto/qstring/qstring.pro
+++ b/tests/auto/qstring/qstring.pro
@@ -7,3 +7,5 @@ QT = core
DEFINES += QT_NO_CAST_TO_ASCII
CONFIG += parallel_test
+
+contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index ad7515b3e0..37a899c250 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -222,6 +222,8 @@ private slots:
void task262677remove();
void QTBUG10404_compareRef();
void QTBUG9281_arg_locale();
+
+ void toUpperLower_icu();
};
typedef QList<int> IntList;
@@ -697,11 +699,11 @@ void tst_QString::acc_01()
QVERIFY(a<=c);
QVERIFY(!(c<=a));
QVERIFY(!(d<=a));
- QCOMPARE(a+b,(QString)"ABCABC");
- QCOMPARE(a +"XXXX",(QString)"ABCXXXX");
- QCOMPARE(a+'X',(QString)"ABCX");
- QCOMPARE("XXXX"+a,(QString)"XXXXABC");
- QCOMPARE('X'+a,(QString)"XABC");
+ QCOMPARE(QString(a+b),(QString)"ABCABC");
+ QCOMPARE(QString(a+"XXXX"),(QString)"ABCXXXX");
+ QCOMPARE(QString(a+'X'),(QString)"ABCX");
+ QCOMPARE(QString("XXXX"+a),(QString)"XXXXABC");
+ QCOMPARE(QString('X'+a),(QString)"XABC");
a = (const char*)0;
QVERIFY(a.isNull());
QVERIFY(*a.toLatin1().constData() == '\0');
@@ -1060,12 +1062,12 @@ void tst_QString::indexOf_data()
QString veryBigHaystack(500, 'a');
veryBigHaystack += 'B';
QTest::newRow("BoyerMooreStressTest") << veryBigHaystack << veryBigHaystack << 0 << true << 0;
- QTest::newRow("BoyerMooreStressTest2") << veryBigHaystack + 'c' << veryBigHaystack << 0 << true << 0;
- QTest::newRow("BoyerMooreStressTest3") << 'c' + veryBigHaystack << veryBigHaystack << 0 << true << 1;
- QTest::newRow("BoyerMooreStressTest4") << veryBigHaystack << veryBigHaystack + 'c' << 0 << true << -1;
- QTest::newRow("BoyerMooreStressTest5") << veryBigHaystack << 'c' + veryBigHaystack << 0 << true << -1;
- QTest::newRow("BoyerMooreStressTest6") << 'd' + veryBigHaystack << 'c' + veryBigHaystack << 0 << true << -1;
- QTest::newRow("BoyerMooreStressTest6") << veryBigHaystack + 'c' << 'c' + veryBigHaystack << 0 << true << -1;
+ QTest::newRow("BoyerMooreStressTest2") << QString(veryBigHaystack + 'c') << veryBigHaystack << 0 << true << 0;
+ QTest::newRow("BoyerMooreStressTest3") << QString('c' + veryBigHaystack) << veryBigHaystack << 0 << true << 1;
+ QTest::newRow("BoyerMooreStressTest4") << veryBigHaystack << QString(veryBigHaystack + 'c') << 0 << true << -1;
+ QTest::newRow("BoyerMooreStressTest5") << veryBigHaystack << QString('c' + veryBigHaystack) << 0 << true << -1;
+ QTest::newRow("BoyerMooreStressTest6") << QString('d' + veryBigHaystack) << QString('c' + veryBigHaystack) << 0 << true << -1;
+ QTest::newRow("BoyerMooreStressTest6") << QString(veryBigHaystack + 'c') << QString('c' + veryBigHaystack) << 0 << true << -1;
QTest::newRow("BoyerMooreInsensitiveStressTest") << veryBigHaystack << veryBigHaystack << 0 << false << 0;
@@ -1175,14 +1177,14 @@ void tst_QString::indexOf2_data()
QString whale = "a5zby6cx7dw8evf9ug0th1si2rj3qkp4lomn";
QString minnow = "zby";
QTest::newRow( "data40" ) << whale << minnow << 2;
- QTest::newRow( "data41" ) << (whale + whale) << minnow << 2;
- QTest::newRow( "data42" ) << (minnow + whale) << minnow << 0;
+ QTest::newRow( "data41" ) << QString(whale + whale) << minnow << 2;
+ QTest::newRow( "data42" ) << QString(minnow + whale) << minnow << 0;
QTest::newRow( "data43" ) << whale << whale << 0;
- QTest::newRow( "data44" ) << (whale + whale) << whale << 0;
- QTest::newRow( "data45" ) << whale << (whale + whale) << -1;
- QTest::newRow( "data46" ) << (whale + whale) << (whale + whale) << 0;
- QTest::newRow( "data47" ) << (whale + whale) << (whale + minnow) << -1;
- QTest::newRow( "data48" ) << (minnow + whale) << whale << (int)minnow.length();
+ QTest::newRow( "data44" ) << QString(whale + whale) << whale << 0;
+ QTest::newRow( "data45" ) << whale << QString(whale + whale) << -1;
+ QTest::newRow( "data46" ) << QString(whale + whale) << QString(whale + whale) << 0;
+ QTest::newRow( "data47" ) << QString(whale + whale) << QString(whale + minnow) << -1;
+ QTest::newRow( "data48" ) << QString(minnow + whale) << whale << (int)minnow.length();
}
void tst_QString::indexOf2()
@@ -1603,6 +1605,11 @@ void tst_QString::toUpper()
QCOMPARE( lower.toUpper(), upper);
+#ifdef QT_USE_ICU
+ // test doesn't work with ICU support, since QChar is unaware of any locale
+ QEXPECT_FAIL("", "test doesn't work with ICU support, since QChar is unaware of any locale", Continue);
+ QVERIFY(false);
+#else
for (int i = 0; i < 65536; ++i) {
QString str(1, QChar(i));
QString upper = str.toUpper();
@@ -1610,6 +1617,7 @@ void tst_QString::toUpper()
if (upper.length() == 1)
QVERIFY(upper == QString(1, QChar(i).toUpper()));
}
+#endif
}
void tst_QString::toLower()
@@ -1631,7 +1639,7 @@ void tst_QString::toLower()
QCOMPARE( QString("`ABYZ{").toLower(), QString("`abyz{"));
QCOMPARE( QString("`abyz{").toLower(), QString("`abyz{"));
- QCOMPARE( QString(1, QChar(0x130)).toLower(), QString(1, QChar(0x69)) + QChar(0x307));
+ QCOMPARE( QString(1, QChar(0x130)).toLower(), QString(QString(1, QChar(0x69)) + QChar(0x307)));
QString lower;
lower += QChar(QChar::highSurrogate(0x10428));
@@ -1641,6 +1649,11 @@ void tst_QString::toLower()
upper += QChar(QChar::lowSurrogate(0x10400));
QCOMPARE( upper.toLower(), lower);
+#ifdef QT_USE_ICU
+ // test doesn't work with ICU support, since QChar is unaware of any locale
+ QEXPECT_FAIL("", "test doesn't work with ICU support, since QChar is unaware of any locale", Continue);
+ QVERIFY(false);
+#else
for (int i = 0; i < 65536; ++i) {
QString str(1, QChar(i));
QString lower = str.toLower();
@@ -1648,6 +1661,7 @@ void tst_QString::toLower()
if (lower.length() == 1)
QVERIFY(str.toLower() == QString(1, QChar(i).toLower()));
}
+#endif
}
void tst_QString::trimmed()
@@ -4352,6 +4366,8 @@ void tst_QString::localeAwareCompare()
#elif defined (Q_WS_MAC)
QSKIP("Setting the locale is not supported on OS X (you can set the C locale, but that won't affect CFStringCompare which is used to compare strings)", SkipAll);
+#elif defined(QT_USE_ICU)
+ QLocale::setDefault(QLocale(locale));
#else
if (!locale.isEmpty()) {
const char *newLocale = setlocale(LC_ALL, locale.toLatin1());
@@ -4363,6 +4379,11 @@ void tst_QString::localeAwareCompare()
}
#endif
+#ifdef QT_USE_ICU
+ // ### for c1, ICU disagrees with libc on how to compare
+ QEXPECT_FAIL("c1", "ICU disagrees with test", Abort);
+#endif
+
int testres = QString::localeAwareCompare(s1, s2);
if (result < 0) {
QVERIFY(testres < 0);
@@ -5065,6 +5086,40 @@ void tst_QString::QTBUG9281_arg_locale()
QLocale::setDefault(QLocale::C);
}
+void tst_QString::toUpperLower_icu()
+{
+#ifndef QT_USE_ICU
+ QSKIP("Qt was built without ICU support", SkipAll);
+#endif
+
+ QString s = QString::fromLatin1("i");
+
+ QCOMPARE(s.toUpper(), QString::fromLatin1("I"));
+ QCOMPARE(s.toLower(), QString::fromLatin1("i"));
+
+ QLocale::setDefault(QLocale(QLocale::Turkish, QLocale::Turkey));
+
+ // turkish locale has a capital I with a dot (U+0130, utf8 c4b0)
+
+ QCOMPARE(s.toUpper(), QString::fromUtf8("\xc4\xb0"));
+ QCOMPARE(QString::fromUtf8("\xc4\xb0").toLower(), s);
+
+ // nothing should happen here
+ QCOMPARE(s.toLower(), s);
+ QCOMPARE(QString::fromLatin1("I").toUpper(), QString::fromLatin1("I"));
+
+ // U+0131, utf8 c4b1 is the lower-case i without a dot
+ QString sup = QString::fromUtf8("\xc4\xb1");
+
+ QCOMPARE(sup.toUpper(), QString::fromLatin1("I"));
+ QCOMPARE(QString::fromLatin1("I").toLower(), sup);
+
+ // nothing should happen here
+ QCOMPARE(sup.toLower(), sup);
+ QCOMPARE(QString::fromLatin1("i").toLower(), QString::fromLatin1("i"));
+
+ // the cleanup function will restore the default locale
+}
QTEST_APPLESS_MAIN(tst_QString)
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp
index f3c0ea97dc..d7a32bfc38 100644
--- a/tests/auto/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/qstringbuilder1/stringbuilder.cpp
@@ -137,4 +137,60 @@ void runScenario()
string = QString::fromLatin1(LITERAL);
QCOMPARE(QByteArray(qPrintable(string P string)), QByteArray(string.toLatin1() + string.toLatin1()));
+
+
+
+ //QByteArray
+ {
+ QByteArray ba = LITERAL;
+ QByteArray superba = ba P ba P LITERAL;
+ QCOMPARE(superba, QByteArray(LITERAL LITERAL LITERAL));
+
+ QByteArray testWith0 = ba P "test\0with\0zero" P ba;
+ QCOMPARE(testWith0, QByteArray(LITERAL "test" LITERAL));
+
+ QByteArray ba2 = ba P '\0' + LITERAL;
+ QCOMPARE(ba2, QByteArray(LITERAL "\0" LITERAL, ba.size()*2+1));
+
+ const char *mmh = "test\0foo";
+ QCOMPARE(QByteArray(ba P mmh P ba), testWith0);
+
+ QByteArray raw = QByteArray::fromRawData(UTF8_LITERAL_EXTRA, UTF8_LITERAL_LEN);
+ QByteArray r = "hello" P raw;
+ QByteArray r2 = "hello" UTF8_LITERAL;
+ QCOMPARE(r, r2);
+ r2 = QByteArray("hello\0") P UTF8_LITERAL;
+ QCOMPARE(r, r2);
+ }
+
+ //operator QString +=
+ {
+ QString str = QString::fromUtf8(UTF8_LITERAL);
+ str += QLatin1String(LITERAL) P str;
+ QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL));
+#ifndef QT_NO_CAST_FROM_ASCII
+ str = (QString::fromUtf8(UTF8_LITERAL) += QLatin1String(LITERAL) P UTF8_LITERAL);
+ QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL));
+#endif
+ }
+
+ //operator QByteArray +=
+ {
+ QByteArray ba = UTF8_LITERAL;
+ ba += QByteArray(LITERAL) P UTF8_LITERAL;
+ QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL));
+ ba += LITERAL P QByteArray::fromRawData(UTF8_LITERAL_EXTRA, UTF8_LITERAL_LEN);
+ QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL LITERAL UTF8_LITERAL));
+ QByteArray withZero = QByteArray(LITERAL "\0" LITERAL, LITERAL_LEN*2+1);
+ QByteArray ba2 = withZero;
+ ba2 += ba2 P withZero;
+ QCOMPARE(ba2, QByteArray(withZero + withZero + withZero));
+#ifndef QT_NO_CAST_TO_ASCII
+ ba = UTF8_LITERAL;
+ ba2 = (ba += QLatin1String(LITERAL) + QString::fromUtf8(UTF8_LITERAL));
+ QCOMPARE(ba2, ba);
+ QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL));
+#endif
+ }
+
}
diff --git a/tests/auto/qstringlist/tst_qstringlist.cpp b/tests/auto/qstringlist/tst_qstringlist.cpp
index 283c17f78c..d8db00a9d3 100644
--- a/tests/auto/qstringlist/tst_qstringlist.cpp
+++ b/tests/auto/qstringlist/tst_qstringlist.cpp
@@ -78,6 +78,8 @@ private slots:
void join() const;
void join_data() const;
void joinEmptiness() const;
+
+ void initializeList() const;
};
extern const char email[];
@@ -321,5 +323,16 @@ void tst_QStringList::joinEmptiness() const
QVERIFY(string.isNull());
}
+void tst_QStringList::initializeList() const
+{
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ QStringList v1{QLatin1String("hello"),"world",QString::fromLatin1("plop")};
+ QCOMPARE(v1, (QStringList() << "hello" << "world" << "plop"));
+ QCOMPARE(v1, (QStringList{"hello","world","plop"}));
+#else
+ QSKIP("Require C++0x support, pass the right flag to the compiler", SkipAll);
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_QStringList)
#include "tst_qstringlist.moc"
diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp
index ad5d7ff0ff..5c319f0a9e 100644
--- a/tests/auto/qstyle/tst_qstyle.cpp
+++ b/tests/auto/qstyle/tst_qstyle.cpp
@@ -272,6 +272,18 @@ void tst_QStyle::drawItemPixmap()
QPixmap p(QString(SRCDIR) + "/task_25863.png", "PNG");
QPixmap actualPix = QPixmap::grabWidget(testWidget);
+
+#ifdef Q_OS_SYMBIAN
+ // QPixmap cannot be assumed to be exactly same, unless it is created from exactly same content.
+ // In Symbian, pixmap format might get "optimized" depending on how QPixmap is created.
+ // Therefore, force the content to specific format and compare QImages.
+ // Then re-create the QPixmaps and compare those.
+ QImage i1 = p.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ p = QPixmap::fromImage(i1);
+ QImage i2 = actualPix.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ actualPix = QPixmap::fromImage(i2);
+ QVERIFY(i1 == i2);
+#endif
QVERIFY(pixmapsAreEqual(&actualPix,&p));
testWidget->hide();
}
diff --git a/tests/auto/qtablewidget/tst_qtablewidget.cpp b/tests/auto/qtablewidget/tst_qtablewidget.cpp
index d17e06484b..40aece4b36 100644
--- a/tests/auto/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/qtablewidget/tst_qtablewidget.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
+#include "../../shared/util.h"
#include <qeventloop.h>
#include <qlist.h>
#include <qpair.h>
@@ -1472,7 +1473,7 @@ void tst_QTableWidget::task219380_removeLastRow()
testWidget->removeRow(19); //we remove the last row
//we make sure the editor is at the cell position
- QCOMPARE(testWidget->cellWidget(18, 0)->geometry(), testWidget->visualItemRect(&item));
+ QTRY_COMPARE(testWidget->cellWidget(18, 0)->geometry(), testWidget->visualItemRect(&item));
}
void tst_QTableWidget::task262056_sortDuplicate()
diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
index f287450fc7..2f1adb48f7 100644
--- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
@@ -2418,6 +2418,7 @@ void tst_QtConcurrentMap::incrementalResults() {}
void tst_QtConcurrentMap::stressTest() {}
void tst_QtConcurrentMap::throttling() {}
void tst_QtConcurrentMap::stlContainers() {}
+void tst_QtConcurrentMap::qFutureAssignmentLeak() { }
void tst_QtConcurrentMap::noDetatch() {}
QTEST_NOOP_MAIN
diff --git a/tests/auto/qtcpserver/crashingServer/crashingServer.pro b/tests/auto/qtcpserver/crashingServer/crashingServer.pro
index 0bea655187..700e9520ec 100644
--- a/tests/auto/qtcpserver/crashingServer/crashingServer.pro
+++ b/tests/auto/qtcpserver/crashingServer/crashingServer.pro
@@ -6,3 +6,4 @@ DESTDIR = ./
# This means the auto test works on some machines for MinGW. No dialog stalls
# the application.
win32-g++*:CONFIG += console
+symbian: TARGET.CAPABILITY += NetworkServices ReadUserData
diff --git a/tests/auto/qtcpserver/qtcpserver.pro b/tests/auto/qtcpserver/qtcpserver.pro
index a3744a2c7f..e123cfe73b 100644
--- a/tests/auto/qtcpserver/qtcpserver.pro
+++ b/tests/auto/qtcpserver/qtcpserver.pro
@@ -1,6 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = test crashingServer
-symbian: TARGET.CAPABILITY = NetworkServices
-
diff --git a/tests/auto/qtcpserver/test/test.pro b/tests/auto/qtcpserver/test/test.pro
index e91ba20a13..65e1d82613 100644
--- a/tests/auto/qtcpserver/test/test.pro
+++ b/tests/auto/qtcpserver/test/test.pro
@@ -13,9 +13,10 @@ wince*: {
}
symbian {
- crashApp.files = $$QT_BUILD_TREE/examples/widgets/wiggly/$${BUILD_DIR}/crashingServer.exe
- crashApp.path = .
- DEPLOYMENT += crashApp
+ crashApp.files = $$QT_BUILD_TREE/examples/widgets/wiggly/$${BUILD_DIR}/crashingServer.exe
+ crashApp.path = .
+ DEPLOYMENT += crashApp
+ TARGET.CAPABILITY += NetworkServices ReadUserData
}
TARGET = ../tst_qtcpserver
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp
index 3d377a4877..2cd870f0fa 100644
--- a/tests/auto/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp
@@ -70,6 +70,9 @@
Q_DECLARE_METATYPE(QNetworkProxy)
Q_DECLARE_METATYPE(QList<QNetworkProxy>)
+#include <QNetworkSession>
+#include <QNetworkConfiguration>
+#include <QNetworkConfigurationManager>
#include "../network-settings.h"
//TESTED_CLASS=
@@ -86,6 +89,7 @@ public:
public slots:
void initTestCase_data();
+ void initTestCase();
void init();
void cleanup();
private slots:
@@ -93,6 +97,7 @@ private slots:
void constructing();
void clientServerLoop();
void ipv6Server();
+ void ipv6ServerMapped();
void crashTests();
void maxPendingConnections();
void listenError();
@@ -107,6 +112,11 @@ private slots:
void proxyFactory();
void qtbug14268_peek();
+
+private:
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkSession *networkSession;
+#endif
};
// Testing get/set functions
@@ -141,6 +151,16 @@ void tst_QTcpServer::initTestCase_data()
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
}
+void tst_QTcpServer::initTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager man;
+ networkSession = new QNetworkSession(man.defaultConfiguration(), this);
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened());
+#endif
+}
+
void tst_QTcpServer::init()
{
QFETCH_GLOBAL(bool, setProxy);
@@ -190,7 +210,7 @@ void tst_QTcpServer::clientServerLoop()
QTcpSocket client;
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(server.serverAddress() == QHostAddress::Any))
+ if (!(server.serverAddress() == QHostAddress::Any) && !(server.serverAddress() == QHostAddress::AnyIPv6))
serverAddress = server.serverAddress();
client.connectToHost(serverAddress, server.serverPort());
@@ -222,9 +242,6 @@ void tst_QTcpServer::clientServerLoop()
//----------------------------------------------------------------------------------
void tst_QTcpServer::ipv6Server()
{
-#if defined(Q_OS_SYMBIAN)
- QSKIP("Symbian: IPv6 is not yet supported", SkipAll);
-#endif
//### need to enter the event loop for the server to get the connection ?? ( windows)
QTcpServer server;
if (!server.listen(QHostAddress::LocalHostIPv6, 8944)) {
@@ -244,6 +261,42 @@ void tst_QTcpServer::ipv6Server()
QTcpSocket *serverSocket = 0;
QVERIFY((serverSocket = server.nextPendingConnection()));
+ serverSocket->close();
+ delete serverSocket;
+}
+
+//----------------------------------------------------------------------------------
+void tst_QTcpServer::ipv6ServerMapped()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ QTcpServer server;
+ QVERIFY(server.listen(QHostAddress::LocalHost));
+
+ // let's try the normal case
+ QTcpSocket client1;
+ client1.connectToHost("127.0.0.1", server.serverPort());
+ QVERIFY(server.waitForNewConnection(5000));
+ delete server.nextPendingConnection();
+
+ // let's try the mapped one in the nice format
+ QTcpSocket client2;
+ client2.connectToHost("::ffff:127.0.0.1", server.serverPort());
+ QVERIFY(server.waitForNewConnection(5000));
+ delete server.nextPendingConnection();
+
+ // let's try the mapped in hex format
+ QTcpSocket client3;
+ client3.connectToHost("::ffff:7F00:0001", server.serverPort());
+ QVERIFY(server.waitForNewConnection(5000));
+ delete server.nextPendingConnection();
+
+ // However connecting to the v6 localhost should not work
+ QTcpSocket client4;
+ client4.connectToHost("::1", server.serverPort());
+ QVERIFY(!server.waitForNewConnection(5000));
}
//----------------------------------------------------------------------------------
@@ -377,9 +430,13 @@ void tst_QTcpServer::waitForConnectionTest()
void tst_QTcpServer::setSocketDescriptor()
{
QTcpServer server;
+#ifdef Q_OS_SYMBIAN
+ QTest::ignoreMessage(QtWarningMsg, "QSymbianSocketEngine::initialize - socket descriptor not found");
+#endif
QVERIFY(!server.setSocketDescriptor(42));
QCOMPARE(server.serverError(), QAbstractSocket::UnsupportedSocketOperationError);
-
+#ifndef Q_OS_SYMBIAN
+ //adopting Open C sockets is not supported, neither is adopting externally created RSocket
#ifdef Q_OS_WIN
// ensure winsock is started
WSADATA wsaData;
@@ -402,6 +459,7 @@ void tst_QTcpServer::setSocketDescriptor()
#ifdef Q_OS_WIN
WSACleanup();
#endif
+#endif
}
//----------------------------------------------------------------------------------
@@ -493,6 +551,9 @@ void tst_QTcpServer::addressReusable()
void tst_QTcpServer::setNewSocketDescriptorBlocking()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("open C ioctls on Qt sockets not supported", SkipAll);
+#else
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
QFETCH_GLOBAL(int, proxyType);
@@ -507,6 +568,7 @@ void tst_QTcpServer::setNewSocketDescriptorBlocking()
socket.connectToHost(QHostAddress::LocalHost, server.serverPort());
QVERIFY(server.waitForNewConnection(5000));
QVERIFY(server.ok);
+#endif
}
void tst_QTcpServer::invalidProxy_data()
diff --git a/tests/auto/qtcpsocket/qtcpsocket.pro b/tests/auto/qtcpsocket/qtcpsocket.pro
index 8b1f6642e2..5dfff5bb88 100644
--- a/tests/auto/qtcpsocket/qtcpsocket.pro
+++ b/tests/auto/qtcpsocket/qtcpsocket.pro
@@ -6,4 +6,3 @@ wince*|symbian|vxworks* : SUBDIRS = test
requires(contains(QT_CONFIG,private_tests))
-symbian: TARGET.CAPABILITY = NetworkServices
diff --git a/tests/auto/qtcpsocket/stressTest/stressTest.pro b/tests/auto/qtcpsocket/stressTest/stressTest.pro
index 9a653c6373..adf021783b 100644
--- a/tests/auto/qtcpsocket/stressTest/stressTest.pro
+++ b/tests/auto/qtcpsocket/stressTest/stressTest.pro
@@ -9,4 +9,5 @@ DESTDIR = ./
MOC_DIR = .moc/
TMP_DIR = .tmp/
+symbian: TARGET.CAPABILITY = NetworkServices
diff --git a/tests/auto/qtcpsocket/test/test.pro b/tests/auto/qtcpsocket/test/test.pro
index c4369dfd8a..7bf5ba0074 100644
--- a/tests/auto/qtcpsocket/test/test.pro
+++ b/tests/auto/qtcpsocket/test/test.pro
@@ -11,7 +11,10 @@ wince*: {
QT += network
vxworks:QT -= gui
-symbian: TARGET.EPOCHEAPSIZE="0x100 0x1000000"
+symbian: {
+ TARGET.EPOCHEAPSIZE="0x100 0x3000000"
+ TARGET.CAPABILITY = NetworkServices ReadUserData
+}
TARGET = tst_qtcpsocket
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 21092c4949..f83c4cf99c 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -106,6 +106,7 @@ Q_DECLARE_METATYPE(QList<QNetworkProxy>)
//TESTED_FILES=
QT_FORWARD_DECLARE_CLASS(QTcpSocket)
+QT_FORWARD_DECLARE_CLASS(SocketPair)
class tst_QTcpSocket : public QObject
{
@@ -138,6 +139,7 @@ public slots:
void init();
void cleanup();
private slots:
+ void socketsConstructedBeforeEventLoop();
void constructing();
void setInvalidSocketDescriptor();
void setSocketDescriptor();
@@ -221,6 +223,8 @@ protected slots:
void abortiveClose_abortSlot();
void remoteCloseErrorSlot();
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth);
+ void earlySocketBytesSent(qint64 bytes);
+ void earlySocketReadyRead();
private:
QByteArray expectedReplyIMAP();
@@ -243,6 +247,10 @@ private:
bool gotClosedSignal;
int numConnections;
static int loopLevel;
+
+ SocketPair *earlyConstructedSockets;
+ int earlyBytesWrittenCount;
+ int earlyReadyReadCount;
};
enum ProxyTests {
@@ -296,8 +304,16 @@ public:
tst_QTcpSocket::tst_QTcpSocket()
{
- Q_SET_DEFAULT_IAP
tmpSocket = 0;
+
+ //This code relates to the socketsConstructedBeforeEventLoop test case
+ earlyConstructedSockets = new SocketPair;
+ QVERIFY(earlyConstructedSockets->create());
+ earlyBytesWrittenCount = 0;
+ earlyReadyReadCount = 0;
+ connect(earlyConstructedSockets->endPoints[0], SIGNAL(readyRead()), this, SLOT(earlySocketReadyRead()));
+ connect(earlyConstructedSockets->endPoints[1], SIGNAL(bytesWritten(qint64)), this, SLOT(earlySocketBytesSent(qint64)));
+ earlyConstructedSockets->endPoints[1]->write("hello work");
}
tst_QTcpSocket::~tst_QTcpSocket()
@@ -336,7 +352,9 @@ void tst_QTcpSocket::init()
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
QFETCH_GLOBAL(int, proxyType);
- QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString();
+ QList<QHostAddress> addresses = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses();
+ QVERIFY2(addresses.count() > 0, "failed to get ip address for test server");
+ QString fluke = addresses.first().toString();
QNetworkProxy proxy;
switch (proxyType) {
@@ -397,6 +415,33 @@ void tst_QTcpSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthent
//----------------------------------------------------------------------------------
+void tst_QTcpSocket::socketsConstructedBeforeEventLoop()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ QFETCH_GLOBAL(bool, ssl);
+ if (setProxy || ssl)
+ return;
+ //This test checks that sockets constructed before QCoreApplication::exec() still emit signals
+ //see construction code in the tst_QTcpSocket constructor
+ enterLoop(3);
+ QCOMPARE(earlyBytesWrittenCount, 1);
+ QCOMPARE(earlyReadyReadCount, 1);
+ earlyConstructedSockets->endPoints[0]->close();
+ earlyConstructedSockets->endPoints[1]->close();
+}
+
+void tst_QTcpSocket::earlySocketBytesSent(qint64 bytes)
+{
+ earlyBytesWrittenCount++;
+}
+
+void tst_QTcpSocket::earlySocketReadyRead()
+{
+ earlyReadyReadCount++;
+}
+
+//----------------------------------------------------------------------------------
+
void tst_QTcpSocket::constructing()
{
QTcpSocket *socket = newSocket();
@@ -431,6 +476,9 @@ void tst_QTcpSocket::setInvalidSocketDescriptor()
{
QTcpSocket *socket = newSocket();
QCOMPARE(socket->socketDescriptor(), -1);
+#ifdef Q_OS_SYMBIAN
+ QTest::ignoreMessage(QtWarningMsg, "QSymbianSocketEngine::initialize - socket descriptor not found");
+#endif
QVERIFY(!socket->setSocketDescriptor(-5, QTcpSocket::UnconnectedState));
QCOMPARE(socket->socketDescriptor(), -1);
@@ -443,6 +491,9 @@ void tst_QTcpSocket::setInvalidSocketDescriptor()
void tst_QTcpSocket::setSocketDescriptor()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("adopting open c socket handles is not supported", SkipAll);
+#else
QFETCH_GLOBAL(bool, setProxy);
if (setProxy)
return; // this test doesn't make sense with proxies
@@ -483,6 +534,7 @@ void tst_QTcpSocket::setSocketDescriptor()
#ifdef Q_OS_WIN
delete dummy;
#endif
+#endif
}
//----------------------------------------------------------------------------------
@@ -605,14 +657,14 @@ void tst_QTcpSocket::timeoutConnect()
// Port 1357 is configured to drop packets on the test server
socket->connectToHost(address, 1357);
- QVERIFY(timer.elapsed() < 50);
- QVERIFY(!socket->waitForConnected(200));
+ QVERIFY(timer.elapsed() < 150);
+ QVERIFY(!socket->waitForConnected(1000)); //200ms is too short when using SOCKS proxy authentication
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError));
timer.start();
socket->connectToHost(address, 1357);
- QVERIFY(timer.elapsed() < 50);
+ QVERIFY(timer.elapsed() < 150);
QTimer::singleShot(50, &QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
@@ -975,6 +1027,9 @@ void tst_QTcpSocket::disconnectWhileConnecting_data()
void tst_QTcpSocket::disconnectWhileConnecting()
{
QFETCH(QByteArray, data);
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
@@ -1035,7 +1090,7 @@ public:
: server(0), ok(false), quit(false)
{ }
- ~ReceiverThread() { /*delete server;*/ terminate(); wait(); }
+ ~ReceiverThread() { }
bool listen()
{
@@ -1047,6 +1102,14 @@ public:
return true;
}
+ static void cleanup(void *ptr)
+ {
+ ReceiverThread* self = reinterpret_cast<ReceiverThread*>(ptr);
+ self->quit = true;
+ self->wait(30000);
+ delete self;
+ }
+
protected:
void run()
{
@@ -1092,19 +1155,20 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop_data()
void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop()
{
QFETCH(QByteArray, data);
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
- ReceiverThread thread;
- QVERIFY(thread.listen());
- thread.start();
+ QScopedPointer<ReceiverThread, ReceiverThread> thread (new ReceiverThread);
+ QVERIFY(thread->listen());
+ thread->start();
// proceed to the connect-write-disconnect
QTcpSocket *socket = newSocket();
- socket->connectToHost("127.0.0.1", thread.serverPort);
+ socket->connectToHost("127.0.0.1", thread->serverPort);
if (!data.isEmpty())
socket->write(data);
if (socket->state() == QAbstractSocket::ConnectedState) {
- thread.quit = true;
- thread.wait();
QSKIP("localhost connections are immediate, test case is invalid", SkipSingle);
}
@@ -1130,9 +1194,9 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop()
delete socket;
// check if the other side received everything ok
- QVERIFY(thread.wait(30000));
- QVERIFY(thread.ok);
- QCOMPARE(thread.receivedData, data);
+ QVERIFY(thread->wait(30000));
+ QVERIFY(thread->ok);
+ QCOMPARE(thread->receivedData, data);
}
//----------------------------------------------------------------------------------
@@ -1194,6 +1258,7 @@ void tst_QTcpSocket::downloadBigFile()
connect(tmpSocket, SIGNAL(connected()), SLOT(exitLoopSlot()));
connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot()));
+ connect(tmpSocket, SIGNAL(disconnected()), SLOT(exitLoopSlot()));
tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80);
@@ -1380,7 +1445,7 @@ void tst_QTcpSocket::flush()
connect(socket, SIGNAL(connected()), SLOT(exitLoopSlot()));
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- enterLoop(5000);
+ enterLoop(60);
QVERIFY(socket->isOpen());
socket->write("1 LOGOUT\r\n");
@@ -1413,7 +1478,7 @@ void tst_QTcpSocket::dontCloseOnTimeout()
QVERIFY(server.listen());
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(server.serverAddress() == QHostAddress::Any))
+ if (!(server.serverAddress() == QHostAddress::Any) && !(server.serverAddress() == QHostAddress::AnyIPv6))
serverAddress = server.serverAddress();
QTcpSocket *socket = newSocket();
@@ -1633,6 +1698,9 @@ private slots:
//----------------------------------------------------------------------------------
void tst_QTcpSocket::remoteCloseError()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
RemoteCloseErrorServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
@@ -1943,6 +2011,9 @@ void tst_QTcpSocket::linuxKernelBugLocalSocket()
//----------------------------------------------------------------------------------
void tst_QTcpSocket::abortiveClose()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
connect(&server, SIGNAL(newConnection()), this, SLOT(exitLoopSlot()));
@@ -1981,6 +2052,9 @@ void tst_QTcpSocket::abortiveClose_abortSlot()
//----------------------------------------------------------------------------------
void tst_QTcpSocket::localAddressEmptyOnBSD()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
@@ -2251,6 +2325,9 @@ void tst_QTcpSocket::moveToThread0()
void tst_QTcpSocket::increaseReadBufferSize()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QTcpSocket *active = newSocket();
connect(active, SIGNAL(readyRead()), SLOT(exitLoopSlot()));
diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
index f89e0339a6..b6b0d3c9d8 100644
--- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -75,6 +75,10 @@ public:
public slots:
void init();
void cleanup();
+
+ void initTestCase();
+ void cleanupTestCase();
+
private slots:
void construction();
void fileTemplate();
@@ -97,9 +101,24 @@ private slots:
void setTemplateAfterOpen();
void autoRemoveAfterFailedRename();
+ void QTBUG_4796_data();
+ void QTBUG_4796();
+
public:
};
+void tst_QTemporaryFile::initTestCase()
+{
+ // For QTBUG_4796
+ QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX"));
+}
+
+void tst_QTemporaryFile::cleanupTestCase()
+{
+ // From QTBUG_4796
+ QVERIFY(QDir().rmdir("test-XXXXXX"));
+}
+
void tst_QTemporaryFile::construction()
{
QTemporaryFile file(0);
@@ -144,26 +163,35 @@ void tst_QTemporaryFile::cleanup()
void tst_QTemporaryFile::fileTemplate_data()
{
QTest::addColumn<QString>("constructorTemplate");
+ QTest::addColumn<QString>("prefix");
QTest::addColumn<QString>("suffix");
QTest::addColumn<QString>("fileTemplate");
- QTest::newRow("constructor default") << "" << "" << "";
- QTest::newRow("constructor with xxx sufix") << "qt_XXXXXXxxx" << "xxx" << "";
- QTest::newRow("constructor with xXx sufix") << "qt_XXXXXXxXx" << "xXx" << "";
- QTest::newRow("constructor with no sufix") << "qt_XXXXXX" << "" << "";
- QTest::newRow("constructor with >6 X's and xxx suffix") << "qt_XXXXXXXXXXxxx" << "xxx" << "";
- QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "" << "";
-
- QTest::newRow("set template, no suffix") << "" << "" << "foo";
- QTest::newRow("set template, with lowercase XXXXXX") << "" << "xxxxxx" << "qt_XXXXXXxxxxxx";
- QTest::newRow("set template, with xxx") << "" << ".xxx" << "qt_XXXXXX.xxx";
- QTest::newRow("set template, with >6 X's") << "" << ".xxx" << "qt_XXXXXXXXXXXXXX.xxx";
- QTest::newRow("set template, with >6 X's, no suffix") << "" << "" << "qt_XXXXXXXXXXXXXX";
+ QTest::newRow("constructor default") << "" << "." << "" << "";
+ QTest::newRow("constructor with xxx sufix") << "qt_XXXXXXxxx" << "qt_" << "xxx" << "";
+ QTest::newRow("constructor with xXx sufix") << "qt_XXXXXXxXx" << "qt_" << "xXx" << "";
+ QTest::newRow("constructor with no sufix") << "qt_XXXXXX" << "qt_" << "" << "";
+ QTest::newRow("constructor with >6 X's and xxx suffix") << "qt_XXXXXXXXXXxxx" << "qt_" << "xxx" << "";
+ QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "qt_" << "" << "";
+
+ QTest::newRow("constructor with XXXX suffix") << "qt_XXXXXX_XXXX" << "qt_" << "_XXXX" << "";
+ QTest::newRow("constructor with XXXXX suffix") << "qt_XXXXXX_XXXXX" << "qt_" << "_XXXXX" << "";
+ QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_XXXX." << "" << "";
+ QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_XXXXX." << "" << "";
+ QTest::newRow("constructor with XXXX prefix and suffix") << "qt_XXXX_XXXXXX_XXXX" << "qt_XXXX_" << "_XXXX" << "";
+ QTest::newRow("constructor with XXXXX prefix and suffix") << "qt_XXXXX_XXXXXX_XXXXX" << "qt_XXXXX_" << "_XXXXX" << "";
+
+ QTest::newRow("set template, no suffix") << "" << "foo" << "" << "foo";
+ QTest::newRow("set template, with lowercase XXXXXX") << "" << "qt_" << "xxxxxx" << "qt_XXXXXXxxxxxx";
+ QTest::newRow("set template, with xxx") << "" << "qt_" << ".xxx" << "qt_XXXXXX.xxx";
+ QTest::newRow("set template, with >6 X's") << "" << "qt_" << ".xxx" << "qt_XXXXXXXXXXXXXX.xxx";
+ QTest::newRow("set template, with >6 X's, no suffix") << "" << "qt_" << "" << "qt_XXXXXXXXXXXXXX";
}
void tst_QTemporaryFile::fileTemplate()
{
QFETCH(QString, constructorTemplate);
+ QFETCH(QString, prefix);
QFETCH(QString, suffix);
QFETCH(QString, fileTemplate);
@@ -173,8 +201,11 @@ void tst_QTemporaryFile::fileTemplate()
QCOMPARE(file.open(), true);
- QCOMPARE(file.fileName().right(suffix.length()), suffix);
- file.close();
+ if (prefix.length())
+ QCOMPARE(file.fileName().left(prefix.length()), prefix);
+
+ if (suffix.length())
+ QCOMPARE(file.fileName().right(suffix.length()), suffix);
}
@@ -359,10 +390,7 @@ void tst_QTemporaryFile::stressTest()
for (int i = 0; i < iterations; ++i) {
QTemporaryFile file;
file.setAutoRemove(false);
- if (!file.open()) {
- qDebug() << "Could not open File:" << file.fileName();
- continue;
- }
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QVERIFY(!names.contains(file.fileName()));
names.insert(file.fileName());
}
@@ -594,5 +622,108 @@ void tst_QTemporaryFile::autoRemoveAfterFailedRename()
cleaner.reset();
}
+void tst_QTemporaryFile::QTBUG_4796_data()
+{
+ QTest::addColumn<QString>("prefix");
+ QTest::addColumn<QString>("suffix");
+ QTest::addColumn<bool>("openResult");
+
+ QString unicode = QString::fromUtf8("\xc3\xa5\xc3\xa6\xc3\xb8");
+
+ QTest::newRow("<empty>") << QString() << QString() << true;
+ QTest::newRow("blaXXXXXX") << QString("bla") << QString() << true;
+ QTest::newRow("XXXXXXbla") << QString() << QString("bla") << true;
+ QTest::newRow("does-not-exist/qt_temp.XXXXXX") << QString("does-not-exist/qt_temp") << QString() << false;
+ QTest::newRow("XXXXXX<unicode>") << QString() << unicode << true;
+ QTest::newRow("<unicode>XXXXXX") << unicode << QString() << true;
+ QTest::newRow("<unicode>XXXXXX<unicode>") << unicode << unicode << true;
+}
+
+void tst_QTemporaryFile::QTBUG_4796()
+{
+ QVERIFY(QDir("test-XXXXXX").exists());
+
+ struct CleanOnReturn
+ {
+ ~CleanOnReturn()
+ {
+ Q_FOREACH(QString tempName, tempNames)
+ QFile::remove(tempName);
+ }
+
+ void reset()
+ {
+ tempNames.clear();
+ }
+
+ QStringList tempNames;
+ };
+
+ CleanOnReturn cleaner;
+
+ QFETCH(QString, prefix);
+ QFETCH(QString, suffix);
+ QFETCH(bool, openResult);
+
+ {
+ QString fileTemplate1 = prefix + QString("XX") + suffix;
+ QString fileTemplate2 = prefix + QString("XXXX") + suffix;
+ QString fileTemplate3 = prefix + QString("XXXXXX") + suffix;
+ QString fileTemplate4 = prefix + QString("XXXXXXXX") + suffix;
+
+ QTemporaryFile file1(fileTemplate1);
+ QTemporaryFile file2(fileTemplate2);
+ QTemporaryFile file3(fileTemplate3);
+ QTemporaryFile file4(fileTemplate4);
+ QTemporaryFile file5("test-XXXXXX/" + fileTemplate1);
+ QTemporaryFile file6("test-XXXXXX/" + fileTemplate3);
+
+ QCOMPARE(file1.open(), openResult);
+ QCOMPARE(file2.open(), openResult);
+ QCOMPARE(file3.open(), openResult);
+ QCOMPARE(file4.open(), openResult);
+ QCOMPARE(file5.open(), openResult);
+ QCOMPARE(file6.open(), openResult);
+
+ QCOMPARE(file1.exists(), openResult);
+ QCOMPARE(file2.exists(), openResult);
+ QCOMPARE(file3.exists(), openResult);
+ QCOMPARE(file4.exists(), openResult);
+ QCOMPARE(file5.exists(), openResult);
+ QCOMPARE(file6.exists(), openResult);
+
+ // make sure the file exists under the *correct* name
+ if (openResult) {
+ cleaner.tempNames << file1.fileName()
+ << file2.fileName()
+ << file3.fileName()
+ << file4.fileName()
+ << file5.fileName()
+ << file6.fileName();
+
+ QVERIFY(file1.fileName().startsWith(fileTemplate1 + QLatin1Char('.')));
+ QVERIFY(file2.fileName().startsWith(fileTemplate2 + QLatin1Char('.')));
+ QVERIFY(file5.fileName().startsWith("test-XXXXXX/" + fileTemplate1 + QLatin1Char('.')));
+ QVERIFY(file6.fileName().startsWith("test-XXXXXX/" + prefix));
+
+ if (!prefix.isEmpty()) {
+ QVERIFY(file3.fileName().startsWith(prefix));
+ QVERIFY(file4.fileName().startsWith(prefix));
+ }
+
+ if (!suffix.isEmpty()) {
+ QVERIFY(file3.fileName().endsWith(suffix));
+ QVERIFY(file4.fileName().endsWith(suffix));
+ QVERIFY(file6.fileName().endsWith(suffix));
+ }
+ }
+ }
+
+ Q_FOREACH(QString const &tempName, cleaner.tempNames)
+ QVERIFY( !QFile::exists(tempName) );
+
+ cleaner.reset();
+}
+
QTEST_MAIN(tst_QTemporaryFile)
#include "tst_qtemporaryfile.moc"
diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp
index cec3a6a251..748d9210e0 100644
--- a/tests/auto/qtextblock/tst_qtextblock.cpp
+++ b/tests/auto/qtextblock/tst_qtextblock.cpp
@@ -76,6 +76,7 @@ private slots:
void excludeParagraphSeparatorFragment();
void backwardsBlockIterator();
void previousBlock_qtbug18026();
+ void removedBlock_qtbug18500();
private:
QTextDocument *doc;
@@ -181,5 +182,16 @@ void tst_QTextBlock::previousBlock_qtbug18026()
QVERIFY(last.isValid());
}
+void tst_QTextBlock::removedBlock_qtbug18500()
+{
+ cursor.insertText("line 1\nline 2\nline 3 \nline 4\n");
+ cursor.setPosition(7);
+ QTextBlock block = cursor.block();
+ cursor.setPosition(21, QTextCursor::KeepAnchor);
+
+ cursor.removeSelectedText();
+ QVERIFY(!block.isValid());
+}
+
QTEST_MAIN(tst_QTextBlock)
#include "tst_qtextblock.moc"
diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
index 1da0bdeb6f..e885942314 100644
--- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
+++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
@@ -257,10 +257,10 @@ void tst_QTextBoundaryFinder::sentenceBoundaries()
void tst_QTextBoundaryFinder::isAtWordStart()
{
- QString txt("The quick brown fox jumped over $the lazy. dog ");
+ QString txt("The quick brown fox jumped over $the lazy. dog I win!");
QList<int> start, end;
- start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43;
- end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46;
+ start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43 << 48 << 50 << 53;
+ end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46 << 49 << 53 << 54;
QTextBoundaryFinder finder(QTextBoundaryFinder::Word, txt);
for(int i=0; i < txt.length(); ++i) {
finder.setPosition(i);
diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp
index 4a79e38ee2..41af7bf98e 100644
--- a/tests/auto/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp
@@ -42,7 +42,6 @@
#include <QtTest/QtTest>
-
#include <qtextedit.h>
#include <qtextcursor.h>
#include <qtextlist.h>
@@ -69,6 +68,7 @@ typedef QList<keyPairType> pairListType;
Q_DECLARE_METATYPE(pairListType);
Q_DECLARE_METATYPE(keyPairType);
Q_DECLARE_METATYPE(QList<bool>);
+Q_DECLARE_METATYPE(QList<int>);
#ifdef Q_WS_MAC
#include <Carbon/Carbon.h>
@@ -205,6 +205,11 @@ private slots:
#ifndef QT_NO_CONTEXTMENU
void taskQTBUG_7902_contextMenuCrash();
#endif
+ void bidiVisualMovement_data();
+ void bidiVisualMovement();
+
+ void bidiLogicalMovement_data();
+ void bidiLogicalMovement();
private:
void createSelection();
@@ -2235,5 +2240,147 @@ void tst_QTextEdit::taskQTBUG_7902_contextMenuCrash()
}
#endif
+void tst_QTextEdit::bidiVisualMovement_data()
+{
+ QTest::addColumn<QString>("logical");
+ QTest::addColumn<int>("basicDir");
+ QTest::addColumn<QList<int> >("positionList");
+
+ QTest::newRow("Latin text")
+ << QString::fromUtf8("abc")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text, one item")
+ << QString::fromUtf8("\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text after Latin text")
+ << QString::fromUtf8("abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("Latin text after Hebrew text")
+ << QString::fromUtf8("\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("LTR, 3 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("RTL, 3 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("LTR, 4 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+ QTest::newRow("RTL, 4 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+}
+
+void tst_QTextEdit::bidiVisualMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+ QFETCH(QList<int>, positionList);
+
+ ed->setText(logical);
+
+ QTextOption option = ed->document()->defaultTextOption();
+ option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
+ ed->document()->setDefaultTextOption(option);
+
+ ed->document()->setDefaultCursorMoveStyle(QTextCursor::Visual);
+ ed->moveCursor(QTextCursor::Start);
+ ed->show();
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Right);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Left);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ QVERIFY(i == positionList.size());
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Left);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Right);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
+void tst_QTextEdit::bidiLogicalMovement_data()
+{
+ bidiVisualMovement_data();
+}
+
+void tst_QTextEdit::bidiLogicalMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+
+ ed->setText(logical);
+
+ QTextOption option = ed->document()->defaultTextOption();
+ option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
+ ed->document()->setDefaultTextOption(option);
+
+ ed->document()->setDefaultCursorMoveStyle(QTextCursor::Logical);
+ ed->moveCursor(QTextCursor::Start);
+ ed->show();
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Right);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Left);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Left);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Right);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
QTEST_MAIN(tst_QTextEdit)
#include "tst_qtextedit.moc"
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp
index 4e3d67df5a..054a9957be 100644
--- a/tests/auto/qthread/tst_qthread.cpp
+++ b/tests/auto/qthread/tst_qthread.cpp
@@ -103,7 +103,9 @@ private slots:
void adoptedThreadExit();
void adoptedThreadExec();
void adoptedThreadFinished();
+ void adoptedThreadExecFinished();
void adoptMultipleThreads();
+ void adoptMultipleThreadsOverlap();
void QTBUG13810_exitAndStart();
void QTBUG15378_exitAndExec();
@@ -663,7 +665,9 @@ void tst_QThread::usleep()
typedef void (*FunctionPointer)(void *);
void noop(void*) { }
-#ifdef Q_OS_UNIX
+#ifdef Q_OS_SYMBIAN
+typedef RThread ThreadHandle;
+#elif defined Q_OS_UNIX
typedef pthread_t ThreadHandle;
#elif defined Q_OS_WIN
typedef HANDLE ThreadHandle;
@@ -694,6 +698,7 @@ public:
protected:
static void *runUnix(void *data);
static unsigned WIN_FIX_STDCALL runWin(void *data);
+ static int runSymbian(void *data);
FunctionPointer functionPointer;
void *data;
@@ -703,7 +708,10 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data)
{
this->functionPointer = functionPointer;
this->data = data;
-#ifdef Q_OS_UNIX
+#ifdef Q_OS_SYMBIAN
+ qt_symbian_throwIfError(nativeThreadHandle.Create(KNullDesC(), NativeThreadWrapper::runSymbian, 1024, &User::Allocator(), this));
+ nativeThreadHandle.Resume();
+#elif defined Q_OS_UNIX
const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this);
Q_UNUSED(state);
#elif defined(Q_OS_WINCE)
@@ -723,7 +731,12 @@ void NativeThreadWrapper::startAndWait(FunctionPointer functionPointer, void *da
void NativeThreadWrapper::join()
{
-#ifdef Q_OS_UNIX
+#ifdef Q_OS_SYMBIAN
+ TRequestStatus stat;
+ nativeThreadHandle.Logon(stat);
+ User::WaitForRequest(stat);
+ nativeThreadHandle.Close();
+#elif defined Q_OS_UNIX
pthread_join(nativeThreadHandle, 0);
#elif defined Q_OS_WIN
WaitForSingleObject(nativeThreadHandle, INFINITE);
@@ -763,6 +776,12 @@ unsigned WIN_FIX_STDCALL NativeThreadWrapper::runWin(void *data)
return 0;
}
+int NativeThreadWrapper::runSymbian(void *data)
+{
+ runUnix(data);
+ return 0;
+}
+
void NativeThreadWrapper::stop()
{
QMutexLocker lock(&mutex);
@@ -895,6 +914,21 @@ void tst_QThread::adoptedThreadFinished()
QVERIFY(!QTestEventLoop::instance().timeout());
}
+void tst_QThread::adoptedThreadExecFinished()
+{
+ NativeThreadWrapper nativeThread;
+ nativeThread.setWaitForStop();
+ nativeThread.startAndWait(adoptedThreadExecFunction);
+
+ QObject::connect(nativeThread.qthread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ nativeThread.stop();
+ nativeThread.join();
+
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+}
+
void tst_QThread::adoptMultipleThreads()
{
#if defined(Q_OS_WIN)
@@ -924,6 +958,7 @@ void tst_QThread::adoptMultipleThreads()
for (int i = 0; i < numThreads; ++i) {
nativeThreads.at(i)->stop();
nativeThreads.at(i)->join();
+ delete nativeThreads.at(i);
}
QTestEventLoop::instance().enterLoop(5);
@@ -931,6 +966,50 @@ void tst_QThread::adoptMultipleThreads()
QCOMPARE(int(recorder.activationCount), numThreads);
}
+void tst_QThread::adoptMultipleThreadsOverlap()
+{
+#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)
+ const int numThreads = 20;
+# else
+ // need to test lots of threads, so that we exceed MAXIMUM_WAIT_OBJECTS in qt_adopted_thread_watcher()
+ const int numThreads = 200;
+# endif
+#elif defined(Q_OS_SYMBIAN)
+ // stress the monitoring thread's add function
+ const int numThreads = 100;
+#else
+ const int numThreads = 5;
+#endif
+ QVector<NativeThreadWrapper*> nativeThreads;
+
+ SignalRecorder recorder;
+
+ for (int i = 0; i < numThreads; ++i) {
+ nativeThreads.append(new NativeThreadWrapper());
+ nativeThreads.at(i)->setWaitForStop();
+ nativeThreads.at(i)->mutex.lock();
+ nativeThreads.at(i)->start();
+ }
+ for (int i = 0; i < numThreads; ++i) {
+ nativeThreads.at(i)->startCondition.wait(&nativeThreads.at(i)->mutex);
+ QObject::connect(nativeThreads.at(i)->qthread, SIGNAL(finished()), &recorder, SLOT(slot()));
+ nativeThreads.at(i)->mutex.unlock();
+ }
+
+ QObject::connect(nativeThreads.at(numThreads - 1)->qthread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ for (int i = 0; i < numThreads; ++i) {
+ nativeThreads.at(i)->stop();
+ nativeThreads.at(i)->join();
+ delete nativeThreads.at(i);
+ }
+
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QCOMPARE(int(recorder.activationCount), numThreads);
+}
void tst_QThread::stressTest()
{
#if defined(Q_OS_WINCE)
diff --git a/tests/auto/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/qthreadstorage/tst_qthreadstorage.cpp
index a62bfee974..2391c81b63 100644
--- a/tests/auto/qthreadstorage/tst_qthreadstorage.cpp
+++ b/tests/auto/qthreadstorage/tst_qthreadstorage.cpp
@@ -385,19 +385,18 @@ void tst_QThreadStorage::QTBUG14579_leakInDestructor()
QCOMPARE(int(SPointer::count), c);
}
-
-class QTBUG14579_reset;
-Q_GLOBAL_STATIC(QThreadStorage<QTBUG14579_reset *>, QTBUG14579_resetTls)
-
class QTBUG14579_reset {
public:
SPointer member;
- ~QTBUG14579_reset() {
- //Quite stupid, but WTF::ThreadSpecific<T>::destroy does it.
- QTBUG14579_resetTls()->setLocalData(this);
- }
+ ~QTBUG14579_reset();
};
+Q_GLOBAL_STATIC(QThreadStorage<QTBUG14579_reset *>, QTBUG14579_resetTls)
+
+QTBUG14579_reset::~QTBUG14579_reset() {
+ //Quite stupid, but WTF::ThreadSpecific<T>::destroy does it.
+ QTBUG14579_resetTls()->setLocalData(this);
+}
void tst_QThreadStorage::QTBUG14579_resetInDestructor()
{
diff --git a/tests/auto/qudpsocket/clientserver/clientserver.pro b/tests/auto/qudpsocket/clientserver/clientserver.pro
index 5fe65b36fd..6da148659c 100644
--- a/tests/auto/qudpsocket/clientserver/clientserver.pro
+++ b/tests/auto/qudpsocket/clientserver/clientserver.pro
@@ -5,4 +5,4 @@ CONFIG -= app_bundle
TARGET = clientserver
DESTDIR = ./
-
+symbian: TARGET.CAPABILITY += NetworkServices
diff --git a/tests/auto/qudpsocket/qudpsocket.pro b/tests/auto/qudpsocket/qudpsocket.pro
index 8fd3545262..4ddb7178a4 100644
--- a/tests/auto/qudpsocket/qudpsocket.pro
+++ b/tests/auto/qudpsocket/qudpsocket.pro
@@ -1,6 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = test clientserver
-symbian: TARGET.CAPABILITY = NetworkServices
-
diff --git a/tests/auto/qudpsocket/test/test.pro b/tests/auto/qudpsocket/test/test.pro
index 7e5ffe493e..b68d30cc94 100644
--- a/tests/auto/qudpsocket/test/test.pro
+++ b/tests/auto/qudpsocket/test/test.pro
@@ -22,4 +22,4 @@ wince*|symbian: {
TARGET = tst_qudpsocket
-
+symbian: TARGET.CAPABILITY += NetworkServices
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index 6ba55b2f6d..2c8049f518 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -55,9 +55,15 @@
#include <qstringlist.h>
#include "../network-settings.h"
+#ifndef QT_NO_BEARERMANAGEMENT
+#include <QtNetwork/qnetworkconfigmanager.h>
+#include <QtNetwork/qnetworkconfiguration.h>
+#include <QtNetwork/qnetworksession.h>
+#endif
+
Q_DECLARE_METATYPE(QHostAddress)
Q_DECLARE_METATYPE(QNetworkInterface)
-
+Q_DECLARE_METATYPE(QSharedPointer<QNetworkSession>)
//TESTED_CLASS=
//TESTED_FILES=
@@ -108,10 +114,19 @@ private slots:
void setMulticastInterface();
void multicast_data();
void multicast();
+ void echo_data();
+ void echo();
protected slots:
void empty_readyReadSlot();
void empty_connectedSlot();
+
+private:
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QSharedPointer<QNetworkSession> networkSession;
+#endif
};
tst_QUdpSocket::tst_QUdpSocket()
@@ -130,6 +145,16 @@ void tst_QUdpSocket::initTestCase_data()
QTest::newRow("WithoutProxy") << false << 0;
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
+
+#ifndef QT_NO_BEARERMANAGEMENT
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
}
void tst_QUdpSocket::init()
@@ -154,6 +179,9 @@ void tst_QUdpSocket::cleanup()
void tst_QUdpSocket::constructing()
{
QUdpSocket socket;
+#ifdef FORCE_SESSION
+ socket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY(socket.isSequential());
QVERIFY(!socket.isOpen());
@@ -171,6 +199,9 @@ void tst_QUdpSocket::constructing()
void tst_QUdpSocket::unconnectedServerAndClientTest()
{
QUdpSocket serverSocket;
+#ifdef FORCE_SESSION
+ serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
@@ -181,11 +212,14 @@ void tst_QUdpSocket::unconnectedServerAndClientTest()
const char *message[] = {"Yo mista", "Yo", "Wassap"};
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(serverSocket.localAddress() == QHostAddress::Any))
+ if (!(serverSocket.localAddress() == QHostAddress::Any || serverSocket.localAddress() == QHostAddress::AnyIPv6))
serverAddress = serverSocket.localAddress();
for (int i = 0; i < 3; ++i) {
QUdpSocket clientSocket;
+#ifdef FORCE_SESSION
+ clientSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QCOMPARE(int(clientSocket.writeDatagram(message[i], strlen(message[i]),
serverAddress, serverSocket.localPort())),
int(strlen(message[i])));
@@ -216,8 +250,21 @@ void tst_QUdpSocket::broadcasting()
#endif
const char *message[] = {"Yo mista", "", "Yo", "Wassap"};
+ QList<QHostAddress> broadcastAddresses;
+ foreach (QNetworkInterface iface, QNetworkInterface::allInterfaces()) {
+ if ((iface.flags() & QNetworkInterface::CanBroadcast)
+ && iface.flags() & QNetworkInterface::IsUp) {
+ for (int i=0;i<iface.addressEntries().count();i++)
+ broadcastAddresses.append(iface.addressEntries().at(i).broadcast());
+ }
+ }
+ if (broadcastAddresses.isEmpty())
+ QSKIP("No interface can broadcast", SkipAll);
for (int i = 0; i < 4; ++i) {
QUdpSocket serverSocket;
+#ifdef FORCE_SESSION
+ serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY2(serverSocket.bind(QHostAddress::Any, 5000), serverSocket.errorString().toLatin1().constData());
QCOMPARE(serverSocket.state(), QUdpSocket::BoundState);
@@ -225,10 +272,18 @@ void tst_QUdpSocket::broadcasting()
connect(&serverSocket, SIGNAL(readyRead()), SLOT(empty_readyReadSlot()));
QUdpSocket broadcastSocket;
+#ifdef FORCE_SESSION
+ broadcastSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
+ broadcastSocket.bind();
for (int j = 0; j < 100; ++j) {
- broadcastSocket.writeDatagram(message[i], strlen(message[i]),
- QHostAddress::Broadcast, 5000);
+ for (int k = 0; k < 4; k++) {
+ broadcastSocket.writeDatagram(message[i], strlen(message[i]),
+ QHostAddress::Broadcast, 5000);
+ foreach (QHostAddress addr, broadcastAddresses)
+ broadcastSocket.writeDatagram(message[i], strlen(message[i]), addr, 5000);
+ }
QTestEventLoop::instance().enterLoop(15);
if (QTestEventLoop::instance().timeout()) {
#if defined(Q_OS_FREEBSD)
@@ -279,15 +334,19 @@ void tst_QUdpSocket::loop()
QUdpSocket peter;
QUdpSocket paul;
+#ifdef FORCE_SESSION
+ peter.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+ paul.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY2(peter.bind(), peter.errorString().toLatin1().constData());
QVERIFY2(paul.bind(), paul.errorString().toLatin1().constData());
QHostAddress peterAddress = QHostAddress::LocalHost;
- if (!(peter.localAddress() == QHostAddress::Any))
+ if (!(peter.localAddress() == QHostAddress::Any || peter.localAddress() == QHostAddress::AnyIPv6))
peterAddress = peter.localAddress();
QHostAddress pualAddress = QHostAddress::LocalHost;
- if (!(paul.localAddress() == QHostAddress::Any))
+ if (!(paul.localAddress() == QHostAddress::Any || paul.localAddress() == QHostAddress::AnyIPv6))
pualAddress = paul.localAddress();
QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(),
@@ -320,8 +379,8 @@ void tst_QUdpSocket::ipv6Loop_data()
void tst_QUdpSocket::ipv6Loop()
{
-#if defined(Q_OS_SYMBIAN)
- QSKIP("Symbian IPv6 is not yet supported", SkipAll);
+#if defined(QT_NO_IPV6)
+ QSKIP("IPv6 is not yet supported", SkipAll);
#endif
QFETCH(QByteArray, peterMessage);
QFETCH(QByteArray, paulMessage);
@@ -329,6 +388,10 @@ void tst_QUdpSocket::ipv6Loop()
QUdpSocket peter;
QUdpSocket paul;
+#ifdef FORCE_SESSION
+ peter.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+ paul.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
quint16 peterPort = 28124;
quint16 paulPort = 28123;
@@ -380,9 +443,13 @@ void tst_QUdpSocket::empty_connectedSlot()
void tst_QUdpSocket::readLine()
{
QUdpSocket socket1;
+ QUdpSocket socket2;
+#ifdef FORCE_SESSION
+ socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+ socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData());
- QUdpSocket socket2;
socket2.connectToHost("127.0.0.1", socket1.localPort());
QVERIFY(socket2.waitForConnected(5000));
}
@@ -392,13 +459,19 @@ void tst_QUdpSocket::readLine()
void tst_QUdpSocket::pendingDatagramSize()
{
QUdpSocket server;
+#ifdef FORCE_SESSION
+ server.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY2(server.bind(), server.errorString().toLatin1().constData());
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(server.localAddress() == QHostAddress::Any))
+ if (!(server.localAddress() == QHostAddress::Any || server.localAddress() == QHostAddress::AnyIPv6))
serverAddress = server.localAddress();
QUdpSocket client;
+#ifdef FORCE_SESSION
+ client.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY(client.writeDatagram("this is", 7, serverAddress, server.localPort()) == 7);
QVERIFY(client.writeDatagram(0, 0, serverAddress, server.localPort()) == 0);
QVERIFY(client.writeDatagram("3 messages", 10, serverAddress, server.localPort()) == 10);
@@ -440,13 +513,19 @@ void tst_QUdpSocket::pendingDatagramSize()
void tst_QUdpSocket::writeDatagram()
{
QUdpSocket server;
+#ifdef FORCE_SESSION
+ server.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY2(server.bind(), server.errorString().toLatin1().constData());
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(server.localAddress() == QHostAddress::Any))
+ if (!(server.localAddress() == QHostAddress::Any || server.localAddress() == QHostAddress::AnyIPv6))
serverAddress = server.localAddress();
QUdpSocket client;
+#ifdef FORCE_SESSION
+ client.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
qRegisterMetaType<qint64>("qint64");
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
@@ -473,8 +552,16 @@ void tst_QUdpSocket::writeDatagram()
QCOMPARE(*static_cast<const qint64 *>(bytesspy.at(0).at(0).constData()),
qint64(i * 1024));
QCOMPARE(errorspy.count(), 0);
- if (!server.waitForReadyRead(5000))
+ if (!server.waitForReadyRead(5000)) {
+#ifdef Q_OS_SYMBIAN
+ //symbian receive buffer for datagrams is ~30k, but it can send datagrams up to the maximum 64k...
+ if (i > 28) {
+ i = 64;
+ continue;
+ }
+#endif
QSKIP(QString("UDP packet lost at size %1, unable to complete the test.").arg(i * 1024).toLatin1().data(), SkipSingle);
+ }
QCOMPARE(server.pendingDatagramSize(), qint64(i * 1024));
QCOMPARE(server.readDatagram(0, 0), qint64(0));
}
@@ -499,14 +586,21 @@ void tst_QUdpSocket::performance()
#endif // Q_OS_SYMBIAN
QUdpSocket server;
+#ifdef FORCE_SESSION
+ server.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY2(server.bind(), server.errorString().toLatin1().constData());
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(server.localAddress() == QHostAddress::Any))
+ if (!(server.localAddress() == QHostAddress::Any || server.localAddress() == QHostAddress::AnyIPv6))
serverAddress = server.localAddress();
QUdpSocket client;
+#ifdef FORCE_SESSION
+ client.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
client.connectToHost(serverAddress, server.localPort());
+ QVERIFY(client.waitForConnected(10000));
QTime stopWatch;
stopWatch.start();
@@ -546,8 +640,14 @@ void tst_QUdpSocket::bindMode()
}
QUdpSocket socket;
+#ifdef FORCE_SESSION
+ socket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData());
QUdpSocket socket2;
+#ifdef FORCE_SESSION
+ socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY(!socket2.bind(socket.localPort()));
#if defined(Q_OS_SYMBIAN)
if(RProcess().HasCapability(ECapabilityNetworkControl)) {
@@ -617,16 +717,12 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data()
QTest::addColumn<bool>("bind");
QTest::addColumn<QHostAddress>("peerAddress");
QHostAddress localhost(QHostAddress::LocalHost);
-#if !defined(Q_OS_SYMBIAN)
QHostAddress remote = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first();
-#endif
QTest::newRow("localhost-unbound") << false << localhost;
QTest::newRow("localhost-bound") << true << localhost;
-#if !defined(Q_OS_SYMBIAN)
QTest::newRow("remote-unbound") << false << remote;
QTest::newRow("remote-bound") << true << remote;
-#endif
}
void tst_QUdpSocket::writeDatagramToNonExistingPeer()
@@ -637,6 +733,9 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer()
quint16 peerPort = 33533 + int(bind);
QUdpSocket sUdp;
+#ifdef FORCE_SESSION
+ sUdp.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QSignalSpy sReadyReadSpy(&sUdp, SIGNAL(readyRead()));
if (bind)
QVERIFY(sUdp.bind());
@@ -649,14 +748,10 @@ void tst_QUdpSocket::writeToNonExistingPeer_data()
{
QTest::addColumn<QHostAddress>("peerAddress");
QHostAddress localhost(QHostAddress::LocalHost);
-#if !defined(Q_OS_SYMBIAN)
QHostAddress remote = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first();
-#endif
// write (required to be connected)
QTest::newRow("localhost") << localhost;
-#if !defined(Q_OS_SYMBIAN)
QTest::newRow("remote") << remote;
-#endif
}
void tst_QUdpSocket::writeToNonExistingPeer()
@@ -667,9 +762,13 @@ void tst_QUdpSocket::writeToNonExistingPeer()
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
QUdpSocket sConnected;
+#ifdef FORCE_SESSION
+ sConnected.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QSignalSpy sConnectedReadyReadSpy(&sConnected, SIGNAL(readyRead()));
QSignalSpy sConnectedErrorSpy(&sConnected, SIGNAL(error(QAbstractSocket::SocketError)));
sConnected.connectToHost(peerAddress, peerPort, QIODevice::ReadWrite);
+ QVERIFY(sConnected.waitForConnected(10000));
// the first write succeeds...
QCOMPARE(sConnected.write("", 1), qint64(1));
@@ -843,12 +942,18 @@ void tst_QUdpSocket::zeroLengthDatagram()
return;
QUdpSocket receiver;
+#ifdef FORCE_SESSION
+ receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QVERIFY(receiver.bind());
QVERIFY(!receiver.waitForReadyRead(100));
QVERIFY(!receiver.hasPendingDatagrams());
QUdpSocket sender;
+#ifdef FORCE_SESSION
+ sender.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
QCOMPARE(sender.writeDatagram(QByteArray(), QHostAddress::LocalHost, receiver.localPort()), qint64(0));
QVERIFY(receiver.waitForReadyRead(1000));
@@ -890,6 +995,9 @@ void tst_QUdpSocket::multicastTtlOption()
}
QUdpSocket udpSocket;
+#ifdef FORCE_SESSION
+ udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
// bind, but ignore the result, we are only interested in initializing the socket
(void) udpSocket.bind(bindAddress, 0);
udpSocket.setSocketOption(QUdpSocket::MulticastTtlOption, ttl);
@@ -929,6 +1037,9 @@ void tst_QUdpSocket::multicastLoopbackOption()
}
QUdpSocket udpSocket;
+#ifdef FORCE_SESSION
+ udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
// bind, but ignore the result, we are only interested in initializing the socket
(void) udpSocket.bind(bindAddress, 0);
udpSocket.setSocketOption(QUdpSocket::MulticastLoopbackOption, loopback);
@@ -949,6 +1060,9 @@ void tst_QUdpSocket::multicastJoinBeforeBind()
QFETCH(QHostAddress, groupAddress);
QUdpSocket udpSocket;
+#ifdef FORCE_SESSION
+ udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
// cannot join group before binding
QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::joinMulticastGroup() called on a QUdpSocket when not in QUdpSocket::BoundState");
QVERIFY(!udpSocket.joinMulticastGroup(groupAddress));
@@ -970,8 +1084,16 @@ void tst_QUdpSocket::multicastLeaveAfterClose()
}
QUdpSocket udpSocket;
+#ifdef FORCE_SESSION
+ udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
+#ifdef Q_OS_SYMBIAN
+ QVERIFY2(udpSocket.bind(),
+ qPrintable(udpSocket.errorString()));
+#else
QVERIFY2(udpSocket.bind(groupAddress, 0),
qPrintable(udpSocket.errorString()));
+#endif
QVERIFY2(udpSocket.joinMulticastGroup(groupAddress),
qPrintable(udpSocket.errorString()));
udpSocket.close();
@@ -995,6 +1117,9 @@ void tst_QUdpSocket::setMulticastInterface_data()
void tst_QUdpSocket::setMulticastInterface()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("Symbian has no IPV6_MULTICAST_IF equivalent", SkipAll);
+#else
QFETCH_GLOBAL(bool, setProxy);
QFETCH(QNetworkInterface, iface);
QFETCH(QHostAddress, address);
@@ -1017,6 +1142,7 @@ void tst_QUdpSocket::setMulticastInterface()
} else {
QVERIFY(!iface2.isValid());
}
+#endif
}
void tst_QUdpSocket::multicast_data()
@@ -1056,8 +1182,17 @@ void tst_QUdpSocket::multicast()
}
QUdpSocket receiver;
+#ifdef FORCE_SESSION
+ receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
// bind first, then verify that we can join the multicast group
+#ifdef Q_OS_SYMBIAN
+ if (!setProxy) {
+ QEXPECT_FAIL("same bind, group ipv4 address", "bind to group address not supported on symbian", Abort);
+ QEXPECT_FAIL("same bind, group ipv6 address", "bind to group address not supported on symbian", Abort);
+ }
+#endif
QVERIFY2(receiver.bind(bindAddress, 0) == bindResult,
qPrintable(receiver.errorString()));
if (!bindResult)
@@ -1075,6 +1210,10 @@ void tst_QUdpSocket::multicast()
<< QByteArray("cdef");
QUdpSocket sender;
+#ifdef FORCE_SESSION
+ sender.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
+ sender.bind();
foreach (const QByteArray &datagram, datagrams) {
QCOMPARE(int(sender.writeDatagram(datagram, groupAddress, receiver.localPort())),
int(datagram.size()));
@@ -1090,10 +1229,68 @@ void tst_QUdpSocket::multicast()
receiver.readDatagram(datagram.data(), datagram.size(), 0, 0);
receivedDatagrams << datagram;
}
+#ifdef Q_OS_SYMBIAN
+ QEXPECT_FAIL("valid bind, group ipv4 address", "IPv4 multicast not supported on symbian", Abort);
+#endif
QCOMPARE(receivedDatagrams, datagrams);
QVERIFY2(receiver.leaveMulticastGroup(groupAddress), qPrintable(receiver.errorString()));
}
+void tst_QUdpSocket::echo_data()
+{
+ QTest::addColumn<bool>("connect");
+ QTest::newRow("writeDatagram") << false;
+ QTest::newRow("write") << true;
+}
+
+void tst_QUdpSocket::echo()
+{
+ QFETCH(bool, connect);
+ QHostInfo info = QHostInfo::fromName(QtNetworkSettings::serverName());
+ QVERIFY(info.addresses().count());
+ QHostAddress remote = info.addresses().first();
+
+ QUdpSocket sock;
+#ifdef FORCE_SESSION
+ sock.setProperty("_q_networksession", QVariant::fromValue(networkSession));
+#endif
+ if (connect) {
+ sock.connectToHost(remote, 7);
+ QVERIFY(sock.waitForConnected(10000));
+ } else {
+ sock.bind();
+ }
+ QByteArray out(30, 'x');
+ QByteArray in;
+ int successes = 0;
+ for (int i=0;i<10;i++) {
+ if (connect) {
+ sock.write(out);
+ } else {
+ sock.writeDatagram(out, remote, 7);
+ }
+ if (sock.waitForReadyRead(1000)) {
+ while (sock.hasPendingDatagrams()) {
+ QHostAddress from;
+ quint16 port;
+ if (connect) {
+ in = sock.read(sock.pendingDatagramSize());
+ } else {
+ in.resize(sock.pendingDatagramSize());
+ sock.readDatagram(in.data(), in.length(), &from, &port);
+ }
+ if (in==out)
+ successes++;
+ }
+ }
+ if (!sock.isValid())
+ QFAIL(sock.errorString().toLatin1().constData());
+ qDebug() << "packets in" << successes << "out" << i;
+ QTest::qWait(50); //choke to avoid triggering flood/DDoS protections on echo service
+ }
+ QVERIFY(successes >= 9);
+}
+
QTEST_MAIN(tst_QUdpSocket)
#include "tst_qudpsocket.moc"
diff --git a/tests/auto/qundogroup/testdata/qundogroup.ts b/tests/auto/qundogroup/testdata/qundogroup.ts
new file mode 100644
index 0000000000..a059bcb486
--- /dev/null
+++ b/tests/auto/qundogroup/testdata/qundogroup.ts
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en">
+<context>
+ <name>QUndoGroup</name>
+ <message>
+ <source>Undo %1</source>
+ <translation>undo-prefix %1 undo-suffix</translation>
+ </message>
+ <message>
+ <source>Undo</source>
+ <comment>Default text for undo action</comment>
+ <translation>Undo-default-text</translation>
+ </message>
+ <message>
+ <source>Redo %1</source>
+ <translation>redo-prefix %1 redo-suffix</translation>
+ </message>
+ <message>
+ <source>Redo</source>
+ <comment>Default text for redo action</comment>
+ <translation>Redo-default-text</translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qundogroup/tst_qundogroup.cpp b/tests/auto/qundogroup/tst_qundogroup.cpp
index 8927f859ec..d2909b733e 100644
--- a/tests/auto/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/qundogroup/tst_qundogroup.cpp
@@ -201,6 +201,7 @@ private slots:
void deleteStack();
void checkSignals();
void addStackAndDie();
+ void commandTextFormat();
};
tst_QUndoGroup::tst_QUndoGroup()
@@ -604,6 +605,42 @@ void tst_QUndoGroup::addStackAndDie()
delete stack;
}
+void tst_QUndoGroup::commandTextFormat()
+{
+ QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath);
+ QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/qundogroup.ts"));
+
+ QTranslator translator;
+ QVERIFY(translator.load("testdata/qundogroup.qm"));
+ qApp->installTranslator(&translator);
+
+ QUndoGroup group;
+ QAction *undo_action = group.createUndoAction(0);
+ QAction *redo_action = group.createRedoAction(0);
+
+ QCOMPARE(undo_action->text(), QString("Undo-default-text"));
+ QCOMPARE(redo_action->text(), QString("Redo-default-text"));
+
+ QUndoStack stack(&group);
+ stack.setActive();
+ QString str;
+
+ stack.push(new AppendCommand(&str, "foo"));
+ QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix"));
+ QCOMPARE(redo_action->text(), QString("Redo-default-text"));
+
+ stack.push(new InsertCommand(&str, 0, "bar"));
+ stack.undo();
+ QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix"));
+ QCOMPARE(redo_action->text(), QString("redo-prefix insert redo-suffix"));
+
+ stack.undo();
+ QCOMPARE(undo_action->text(), QString("Undo-default-text"));
+ QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix"));
+
+ qApp->removeTranslator(&translator);
+}
+
#else
class tst_QUndoGroup : public QObject
{
diff --git a/tests/auto/qundostack/testdata/qundostack.ts b/tests/auto/qundostack/testdata/qundostack.ts
new file mode 100644
index 0000000000..4584036af2
--- /dev/null
+++ b/tests/auto/qundostack/testdata/qundostack.ts
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en">
+<context>
+ <name>QUndoStack</name>
+ <message>
+ <source>Undo %1</source>
+ <translation>undo-prefix %1 undo-suffix</translation>
+ </message>
+ <message>
+ <source>Undo</source>
+ <comment>Default text for undo action</comment>
+ <translation>Undo-default-text</translation>
+ </message>
+ <message>
+ <source>Redo %1</source>
+ <translation>redo-prefix %1 redo-suffix</translation>
+ </message>
+ <message>
+ <source>Redo</source>
+ <comment>Default text for redo action</comment>
+ <translation>Redo-default-text</translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qundostack/tst_qundostack.cpp b/tests/auto/qundostack/tst_qundostack.cpp
index 739d3f2682..5aea0a15d3 100644
--- a/tests/auto/qundostack/tst_qundostack.cpp
+++ b/tests/auto/qundostack/tst_qundostack.cpp
@@ -101,6 +101,16 @@ private:
QString m_text;
};
+class IdleCommand : public QUndoCommand
+{
+public:
+ IdleCommand(QUndoCommand *parent = 0);
+ ~IdleCommand();
+
+ virtual void undo();
+ virtual void redo();
+};
+
InsertCommand::InsertCommand(QString *str, int idx, const QString &text,
QUndoCommand *parent)
: QUndoCommand(parent)
@@ -201,6 +211,26 @@ bool AppendCommand::mergeWith(const QUndoCommand *other)
return true;
}
+IdleCommand::IdleCommand(QUndoCommand *parent)
+ : QUndoCommand(parent)
+{
+ // "idle-item" goes to QUndoStack::{redo,undo}Text
+ // "idle-action" goes to all other places (e.g. QUndoView)
+ setText("idle-item\nidle-action");
+}
+
+IdleCommand::~IdleCommand()
+{
+}
+
+void IdleCommand::redo()
+{
+}
+
+void IdleCommand::undo()
+{
+}
+
/******************************************************************************
** tst_QUndoStack
*/
@@ -220,6 +250,8 @@ private slots:
void macroBeginEnd();
void compression();
void undoLimit();
+ void commandTextFormat();
+ void separateUndoText();
};
tst_QUndoStack::tst_QUndoStack()
@@ -2935,6 +2967,68 @@ void tst_QUndoStack::undoLimit()
true); // redoChanged
}
+void tst_QUndoStack::commandTextFormat()
+{
+ QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath);
+ QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/qundostack.ts"));
+
+ QTranslator translator;
+ QVERIFY(translator.load("testdata/qundostack.qm"));
+ qApp->installTranslator(&translator);
+
+ QUndoStack stack;
+ QAction *undo_action = stack.createUndoAction(0);
+ QAction *redo_action = stack.createRedoAction(0);
+
+ QCOMPARE(undo_action->text(), QString("Undo-default-text"));
+ QCOMPARE(redo_action->text(), QString("Redo-default-text"));
+
+ QString str;
+
+ stack.push(new AppendCommand(&str, "foo"));
+ QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix"));
+ QCOMPARE(redo_action->text(), QString("Redo-default-text"));
+
+ stack.push(new InsertCommand(&str, 0, "bar"));
+ stack.undo();
+ QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix"));
+ QCOMPARE(redo_action->text(), QString("redo-prefix insert redo-suffix"));
+
+ stack.undo();
+ QCOMPARE(undo_action->text(), QString("Undo-default-text"));
+ QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix"));
+
+ qApp->removeTranslator(&translator);
+}
+
+void tst_QUndoStack::separateUndoText()
+{
+ QUndoStack stack;
+ QAction *undo_action = stack.createUndoAction(0);
+ QAction *redo_action = stack.createRedoAction(0);
+
+ QUndoCommand *command1 = new IdleCommand();
+ QUndoCommand *command2 = new IdleCommand();
+ stack.push(command1);
+ stack.push(command2);
+ stack.undo();
+
+ QCOMPARE(undo_action->text(), QString("Undo idle-action"));
+ QCOMPARE(redo_action->text(), QString("Redo idle-action"));
+ QCOMPARE(command1->actionText(), QString("idle-action"));
+
+ QCOMPARE(command1->text(), QString("idle-item"));
+ QCOMPARE(stack.text(0), QString("idle-item"));
+
+ command1->setText("idle");
+ QCOMPARE(command1->actionText(), QString("idle"));
+ QCOMPARE(command1->text(), QString("idle"));
+
+ command1->setText("idle-item\nidle-action");
+ QCOMPARE(command1->actionText(), QString("idle-action"));
+ QCOMPARE(command1->text(), QString("idle-item"));
+}
+
QTEST_MAIN(tst_QUndoStack)
#include "tst_qundostack.moc"
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 8d4b0560dc..af70c9e070 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -275,6 +275,8 @@ private slots:
void variantInVariant();
void colorInteger();
+
+ void forwardDeclare();
};
Q_DECLARE_METATYPE(QDate)
@@ -2660,7 +2662,10 @@ void tst_QVariant::qvariant_cast_QObject_data() {
QTest::addColumn<QVariant>("data");
QTest::addColumn<bool>("success");
- QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, new QObject(this)) << true;
+ QObject *obj = new QObject(this);
+ obj->setObjectName(QString::fromLatin1("Hello"));
+ QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, &obj) << true;
+ QTest::newRow("from QObject2") << QVariant::fromValue(obj) << true;
QTest::newRow("from String") << QVariant(QLatin1String("1, 2, 3")) << false;
QTest::newRow("from int") << QVariant((int) 123) << false;
}
@@ -2672,6 +2677,9 @@ void tst_QVariant::qvariant_cast_QObject() {
QObject *o = qvariant_cast<QObject *>(data);
QCOMPARE(o != 0, success);
+ if (success) {
+ QCOMPARE(o->objectName(), QString::fromLatin1("Hello"));
+ }
}
Q_DECLARE_METATYPE(qint8);
@@ -3439,5 +3447,16 @@ void tst_QVariant::colorInteger()
QCOMPARE(v.value<QColor>(), QColor(Qt::yellow));
}
+class Forward;
+Q_DECLARE_METATYPE(Forward*);
+
+void tst_QVariant::forwardDeclare()
+{
+ Forward *f = 0;
+ QVariant v = QVariant::fromValue(f);
+ QCOMPARE(qvariant_cast<Forward*>(v), f);
+}
+
+
QTEST_MAIN(tst_QVariant)
#include "tst_qvariant.moc"
diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp
index 61eb8d4ec8..00b59a923b 100644
--- a/tests/auto/qwizard/tst_qwizard.cpp
+++ b/tests/auto/qwizard/tst_qwizard.cpp
@@ -1771,8 +1771,11 @@ public:
~TestWizard()
{
- foreach (int id, pageIds)
- delete page(id);
+ foreach (int id, pageIds) {
+ QWizardPage *page_to_delete = page(id);
+ removePage(id);
+ delete page_to_delete;
+ }
}
void applyOperations(const QList<Operation *> &operations)
@@ -2549,8 +2552,8 @@ void tst_QWizard::task177022_setFixedSize()
QWizard wiz;
QWizardPage page1;
QWizardPage page2;
- wiz.addPage(&page1);
- wiz.addPage(&page2);
+ int page1_id = wiz.addPage(&page1);
+ int page2_id = wiz.addPage(&page2);
wiz.setFixedSize(width, height);
if (wiz.wizardStyle() == QWizard::AeroStyle)
QEXPECT_FAIL("", "this probably relates to non-client area hack for AeroStyle titlebar "
@@ -2577,6 +2580,8 @@ void tst_QWizard::task177022_setFixedSize()
QCOMPARE(wiz.maximumWidth(), width);
QCOMPARE(wiz.maximumHeight(), height);
+ wiz.removePage(page1_id);
+ wiz.removePage(page2_id);
}
void tst_QWizard::task248107_backButton()
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index c002f839f2..01499d3d23 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -3305,7 +3305,7 @@ void tst_QXmlQuery::bindVariableQXmlQueryInvalidate() const
QXmlQuery query2;
query2.setQuery("'query2'");
- query.bindVariable(QLatin1String("name"), query);
+ query.bindVariable(QLatin1String("name"), query2);
QVERIFY(!query.isValid());
}
diff --git a/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro b/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro
index 3e252f68b0..48c79d5fab 100644
--- a/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro
+++ b/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro
@@ -25,3 +25,5 @@ wince*|symbian {
catalog.path = .
DEPLOYMENT += catalog
}
+
+requires(contains(QT_CONFIG,private_tests))
diff --git a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro
index f36211e13d..0fb5fefe73 100644
--- a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro
+++ b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro
@@ -25,3 +25,5 @@ INCLUDEPATH += $$QT_SOURCE_TREE/tests/auto/xmlpatternssdk/ \
$$QT_SOURCE_TREE/tests/auto/xmlpatternsxqts \
../xmlpatternsxqts \
../xmlpatternssdk
+
+requires(contains(QT_CONFIG,private_tests))
diff --git a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro
index e81888a276..0ced633071 100644
--- a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro
+++ b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro
@@ -19,3 +19,5 @@ INCLUDEPATH += $$(QTDIR)/include/QtXmlPatterns/private \
CONFIG += testlib
QT += xml
TARGET = tst_xmlpatternsxqts
+
+requires(contains(QT_CONFIG,private_tests))