summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-09-28 11:44:45 (GMT)
committerThomas Zander <t.zander@nokia.com>2010-09-28 11:44:45 (GMT)
commit5c08412285f14d89174aef1190a1de1c35fd62bd (patch)
tree2e9bef2fdf0af18db76b011cd9c4ed4b456f507c /tests/auto
parent2645784f05db7b1e631621c511e94c88fc5cd211 (diff)
parent2868302626b8a31f44df1068514485a89ec27171 (diff)
downloadQt-5c08412285f14d89174aef1190a1de1c35fd62bd.zip
Qt-5c08412285f14d89174aef1190a1de1c35fd62bd.tar.gz
Qt-5c08412285f14d89174aef1190a1de1c35fd62bd.tar.bz2
Merge commit 'origin/master' into fileEnginesOn47
Conflicts: qmake/Makefile.win32 qmake/qmake.pri src/corelib/io/qdir.cpp src/corelib/io/qfileinfo.cpp src/corelib/io/qfileinfo_p.h src/corelib/io/qfsfileengine_win.cpp src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtCoreu.def src/s60installs/eabi/QtGuiu.def src/tools/bootstrap/bootstrap.pro tests/auto/qfileinfo/tst_qfileinfo.cpp
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/collections/tst_collections.cpp129
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp17
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp31
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp23
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp16
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/in.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml19
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h35
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp76
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/data/daniel.ttfbin0 -> 51984 bytes
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp42
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart-arm.pngbin12596 -> 0 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart-mac.pngbin12621 -> 0 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart-win32.pngbin12621 -> 12457 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart.pngbin12577 -> 12424 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart200-arm.pngbin8063 -> 0 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart200-mac.pngbin8062 -> 0 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart200-win32.pngbin8062 -> 7939 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart200.pngbin8063 -> 7943 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp98
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp129
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml14
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml13
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h21
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp45
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp311
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/itemlist.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp81
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp19
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml14
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/datamodel.qml1
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml5
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp66
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp27
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml24
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp44
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml25
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/editProperties.qml34
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange6.qml30
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp172
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cb.pngbin496 -> 496 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cc.pngbin556 -> 556 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_ct.pngbin533 -> 533 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp11
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp48
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml19
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml11
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml11
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp178
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml5
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp103
-rw-r--r--tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp12
-rw-r--r--tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.0.pngbin0 -> 1265 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.qml447
-rw-r--r--tests/auto/declarative/qmlvisual/animation/qtbug13398/qtbug13398.qml68
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.0.pngbin0 -> 3692 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.1.pngbin0 -> 3697 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.2.pngbin0 -> 3696 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.qml795
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml100
-rw-r--r--tests/auto/gestures/tst_gestures.cpp31
-rw-r--r--tests/auto/headers/tst_headers.cpp3
-rw-r--r--tests/auto/linguist/lconvert/data/test-refs.po23
-rw-r--r--tests/auto/linguist/lconvert/data/test20.ts9
-rw-r--r--tests/auto/linguist/lconvert/tst_lconvert.cpp2
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt1
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp41
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result16
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs/main.js91
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs/project.pro3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result195
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs2/expectedoutput.txt29
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs2/main.js56
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs2/project.pro3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs2/project.ts.result30
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml97
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result195
-rw-r--r--tests/auto/linguist/lupdate/tst_lupdate.cpp9
-rw-r--r--tests/auto/macnativeevents/tst_macnativeevents.cpp81
-rw-r--r--tests/auto/moc/error-on-wrong-notify.h53
-rw-r--r--tests/auto/moc/tst_moc.cpp30
-rw-r--r--tests/auto/q3table/tst_q3table.cpp8
-rw-r--r--tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp6
-rw-r--r--tests/auto/qapplication/modal/base.cpp62
-rw-r--r--tests/auto/qapplication/modal/base.h64
-rw-r--r--tests/auto/qapplication/modal/main.cpp52
-rw-r--r--tests/auto/qapplication/modal/modal.pro8
-rw-r--r--tests/auto/qapplication/qapplication.pro1
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp18
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp4
-rw-r--r--tests/auto/qdatastream/tst_qdatastream.cpp2
-rw-r--r--tests/auto/qdbusthreading/tst_qdbusthreading.cpp35
-rw-r--r--tests/auto/qeasingcurve/tst_qeasingcurve.cpp21
-rw-r--r--tests/auto/qfontdatabase/tst_qfontdatabase.cpp35
-rw-r--r--tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp35
-rw-r--r--tests/auto/qgl/tst_qgl.cpp3
-rw-r--r--tests/auto/qglthreads/tst_qglthreads.cpp299
-rw-r--r--tests/auto/qglthreads/tst_qglthreads.h4
-rw-r--r--tests/auto/qglyphs/tst_qglyphs.cpp8
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp81
-rw-r--r--tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp363
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp8
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp46
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp40
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp195
-rw-r--r--tests/auto/qimage/tst_qimage.cpp4
-rw-r--r--tests/auto/qimagereader/images/qtbug13653-no_eoi.jpgbin0 -> 8250 bytes
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc1
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp5
-rw-r--r--tests/auto/qinputcontext/qinputcontext.pro4
-rw-r--r--tests/auto/qinputcontext/tst_qinputcontext.cpp802
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp26
-rw-r--r--tests/auto/qkeysequence/tst_qkeysequence.cpp28
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp19
-rw-r--r--tests/auto/qlist/tst_qlist.cpp16
-rw-r--r--tests/auto/qmainwindow/tst_qmainwindow.cpp3
-rw-r--r--tests/auto/qmake/qmake.pro1
-rw-r--r--tests/auto/qmake/testdata/substitutes/sub/test2.in1
-rw-r--r--tests/auto/qmake/testdata/substitutes/test.in2
-rw-r--r--tests/auto/qmake/testdata/substitutes/test.pro5
-rw-r--r--tests/auto/qmake/testdata/substitutes/test3.txt1
-rw-r--r--tests/auto/qmake/testdata/substitutes_build/README1
-rw-r--r--tests/auto/qmake/tst_qmake.cpp21
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp2
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp25
-rw-r--r--tests/auto/qobject/tst_qobject.cpp8
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp116
-rw-r--r--tests/auto/qpen/tst_qpen.cpp1
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp25
-rw-r--r--tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp22
-rw-r--r--tests/auto/qpluginloader/elftest/.gitattributes10
-rwxr-xr-xtests/auto/qpluginloader/elftest/corrupt1.elf64.sobin0 -> 239745 bytes
-rwxr-xr-xtests/auto/qpluginloader/elftest/corrupt2.elf64.sobin0 -> 240097 bytes
-rwxr-xr-xtests/auto/qpluginloader/elftest/corrupt3.elf64.sobin0 -> 240097 bytes
-rw-r--r--tests/auto/qpluginloader/elftest/debugobj.sobin0 -> 507232 bytes
-rw-r--r--tests/auto/qpluginloader/elftest/garbage1.so4
-rw-r--r--tests/auto/qpluginloader/elftest/garbage2.so1
-rw-r--r--tests/auto/qpluginloader/elftest/garbage3.so1
-rw-r--r--tests/auto/qpluginloader/elftest/garbage4.so1
-rw-r--r--tests/auto/qpluginloader/elftest/garbage5.so2
-rw-r--r--tests/auto/qpluginloader/tst/tst.pro2
-rw-r--r--tests/auto/qpluginloader/tst_qpluginloader.cpp52
-rw-r--r--tests/auto/qscriptengine/idtranslatable.js5
-rw-r--r--tests/auto/qscriptengine/qscriptengine.qrc1
-rw-r--r--tests/auto/qscriptengine/translations/idtranslatable_la.qmbin0 -> 342 bytes
-rw-r--r--tests/auto/qscriptengine/translations/idtranslatable_la.ts30
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp135
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp4
-rw-r--r--tests/auto/qsettings/tst_qsettings.cpp63
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp39
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp16
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp40
-rw-r--r--tests/auto/qstring/tst_qstring.cpp66
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp20
-rw-r--r--tests/auto/qtextlist/tst_qtextlist.cpp73
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp74
-rw-r--r--tests/auto/qtouchevent/tst_qtouchevent.cpp59
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp125
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp251
-rw-r--r--tests/auto/qurl/tst_qurl.cpp29
-rw-r--r--tests/auto/qvector/tst_qvector.cpp15
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp100
-rw-r--r--tests/auto/uic/baseline/icontheme.ui55
-rw-r--r--tests/auto/uic/baseline/icontheme.ui.h95
192 files changed, 8036 insertions, 497 deletions
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp
index 4ecd392..0adceee 100644
--- a/tests/auto/collections/tst_collections.cpp
+++ b/tests/auto/collections/tst_collections.cpp
@@ -165,6 +165,7 @@ private slots:
void containerTypedefs();
void forwardDeclared();
void alignment();
+ void QTBUG13079_collectionInsideCollection();
};
struct LargeStatic {
@@ -3578,5 +3579,133 @@ void tst_Collections::alignment()
}
#endif
+#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
+
+template<template<class> class C>
+struct QTBUG13079_Node {
+ C<QTBUG13079_Node> children;
+ QString s;
+
+ ~QTBUG13079_Node() {
+ children.begin(); //play with memory
+ }
+};
+template<template<class> class C> void QTBUG13079_collectionInsideCollectionImpl()
+{
+ C<QTBUG13079_Node<C> > nodeList;
+ nodeList << QTBUG13079_Node<C>();
+ nodeList.first().s = "parent";
+ nodeList.first().children << QTBUG13079_Node<C>();
+ nodeList.first().children.first().s = "child";
+
+ nodeList = nodeList.first().children;
+ QCOMPARE(nodeList.first().s, QString::fromLatin1("child"));
+
+ nodeList = nodeList.first().children;
+ QCOMPARE(nodeList.count(), 0);
+ nodeList << QTBUG13079_Node<C>();
+}
+
+template<template<class, class> class C>
+struct QTBUG13079_NodeAssoc {
+ C<int, QTBUG13079_NodeAssoc> children;
+ QString s;
+
+ ~QTBUG13079_NodeAssoc() {
+ children.begin(); //play with memory
+ }
+};
+template<template<class, class> class C> void QTBUG13079_collectionInsideCollectionAssocImpl()
+{
+ C<int, QTBUG13079_NodeAssoc<C> > nodeMap;
+ nodeMap[18] = QTBUG13079_NodeAssoc<C>();
+ nodeMap[18].s = "parent";
+ nodeMap[18].children[12] = QTBUG13079_NodeAssoc<C>();
+ nodeMap[18].children[12].s = "child";
+
+ nodeMap = nodeMap[18].children;
+ QCOMPARE(nodeMap[12].s, QString::fromLatin1("child"));
+
+ nodeMap = nodeMap[12].children;
+ QCOMPARE(nodeMap.count(), 0);
+ nodeMap[42] = QTBUG13079_NodeAssoc<C>();
+}
+
+
+static quint32 qHash(const QTBUG13079_Node<QSet> &)
+{
+ return 0;
+}
+
+bool operator==(const QTBUG13079_Node<QSet> &a, const QTBUG13079_Node<QSet> &b)
+{
+ return a.s == b.s && a.children == b.children;
+}
+
+template<template<class> class C>
+struct QTBUG13079_NodePtr : QSharedData {
+ C<QTBUG13079_NodePtr> child;
+ QTBUG13079_NodePtr *next;
+ QString s;
+
+ QTBUG13079_NodePtr() : next(0) {}
+ ~QTBUG13079_NodePtr() {
+ next = child.data(); //play with memory
+ }
+};
+template<template<class> class C> void QTBUG13079_collectionInsidePtrImpl()
+{
+ typedef C<QTBUG13079_NodePtr<C> > Ptr;
+ {
+ Ptr nodePtr;
+ nodePtr = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->s = "parent";
+ nodePtr->child = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->child->s = "child";
+ nodePtr = nodePtr->child;
+ QCOMPARE(nodePtr->s, QString::fromLatin1("child"));
+ nodePtr = nodePtr->child;
+ QVERIFY(!nodePtr);
+ }
+ {
+ Ptr nodePtr;
+ nodePtr = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->s = "parent";
+ nodePtr->next = new QTBUG13079_NodePtr<C>();
+ nodePtr->next->s = "next";
+ nodePtr = Ptr(nodePtr->next);
+ QCOMPARE(nodePtr->s, QString::fromLatin1("next"));
+ nodePtr = Ptr(nodePtr->next);
+ QVERIFY(!nodePtr);
+ }
+}
+
+#endif
+
+void tst_Collections::QTBUG13079_collectionInsideCollection()
+{
+#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
+ QTBUG13079_collectionInsideCollectionImpl<QVector>();
+ QTBUG13079_collectionInsideCollectionImpl<QStack>();
+ QTBUG13079_collectionInsideCollectionImpl<QList>();
+ QTBUG13079_collectionInsideCollectionImpl<QLinkedList>();
+ QTBUG13079_collectionInsideCollectionImpl<QQueue>();
+
+ {
+ QSet<QTBUG13079_Node<QSet> > nodeSet;
+ nodeSet << QTBUG13079_Node<QSet>();
+ nodeSet = nodeSet.begin()->children;
+ QCOMPARE(nodeSet.count(), 0);
+ }
+
+ QTBUG13079_collectionInsideCollectionAssocImpl<QMap>();
+ QTBUG13079_collectionInsideCollectionAssocImpl<QHash>();
+
+ QTBUG13079_collectionInsidePtrImpl<QSharedPointer>();
+ QTBUG13079_collectionInsidePtrImpl<QExplicitlySharedDataPointer>();
+ QTBUG13079_collectionInsidePtrImpl<QSharedDataPointer>();
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_Collections)
#include "tst_collections.moc"
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
index 1001278..da15a85 100644
--- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
@@ -47,22 +47,13 @@
#include <private/qdeclarativeanimatedimage_p.h>
#include "../shared/testhttpserver.h"
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
#define SRCDIR "."
#endif
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
class tst_qdeclarativeanimatedimage : public QObject
{
Q_OBJECT
@@ -152,14 +143,14 @@ void tst_qdeclarativeanimatedimage::remote()
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
- TRY_WAIT(component.isReady());
+ QTRY_VERIFY(component.isReady());
QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
QVERIFY(anim);
- TRY_WAIT(anim->isPlaying());
+ QTRY_VERIFY(anim->isPlaying());
if (paused) {
- TRY_WAIT(anim->isPaused());
+ QTRY_VERIFY(anim->isPaused());
QCOMPARE(anim->currentFrame(), 2);
}
QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error);
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml
new file mode 100644
index 0000000..e9dc36e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+
+Rectangle {
+ id: root
+ width: 200
+ height: 200
+
+ Rectangle {
+ id: mover
+ objectName: "mover"
+ }
+
+ states: [
+ State {
+ name: "free"
+ },
+ State {
+ name: "left"
+ PropertyChanges {
+ restoreEntryValues: false
+ target: mover
+ x: 0
+ }
+ }
+ ]
+
+ transitions: Transition {
+ PropertyAnimation { properties: "x"; duration: 50 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index ec867fe..e5943fb 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -48,6 +48,8 @@
#include <QVariantAnimation>
#include <QEasingCurve>
+#include "../../../shared/util.h"
+
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
#define SRCDIR "."
@@ -82,6 +84,7 @@ private slots:
void easingProperties();
void rotation();
void runningTrueBug();
+ void nonTransitionBug();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -762,6 +765,34 @@ void tst_qdeclarativeanimations::runningTrueBug()
QVERIFY(cloud->x() > qreal(0));
}
+//QTBUG-12805
+void tst_qdeclarativeanimations::nonTransitionBug()
+{
+ //tests that the animation values from the previous transition are properly cleared
+ //in the case where an animation in the transition doesn't match anything (but previously did)
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/nonTransitionBug.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+ QDeclarativeRectangle *mover = rect->findChild<QDeclarativeRectangle*>("mover");
+
+ mover->setX(100);
+ QCOMPARE(mover->x(), qreal(100));
+
+ rectPrivate->setState("left");
+ QTRY_COMPARE(mover->x(), qreal(0));
+
+ mover->setX(100);
+ QCOMPARE(mover->x(), qreal(100));
+
+ //make sure we don't try to animate back to 0
+ rectPrivate->setState("free");
+ QTest::qWait(300);
+ QCOMPARE(mover->x(), qreal(100));
+}
+
QTEST_MAIN(tst_qdeclarativeanimations)
#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
index 804559c..d41add3 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
@@ -11,7 +11,7 @@ Rectangle {
width: 100
height: 100
Behavior on x {
- NumberAnimation {}
+ NumberAnimation { duration: 500 }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
index 1b73cf7..c77d395 100644
--- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
+++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
@@ -53,6 +53,7 @@
#include <QtDeclarative/qdeclarativecontext.h>
#include "../shared/testhttpserver.h"
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -62,16 +63,6 @@
#define SERVER_PORT 14446
#define SERVER_ADDR "http://127.0.0.1:14446"
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 60; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
class tst_qdeclarativeborderimage : public QObject
{
@@ -154,18 +145,18 @@ void tst_qdeclarativeborderimage::imageSource()
QVERIFY(obj != 0);
if (remote)
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready);
QCOMPARE(obj->width(), 120.);
QCOMPARE(obj->height(), 120.);
QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
} else {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error);
}
delete obj;
@@ -273,14 +264,14 @@ void tst_qdeclarativeborderimage::sciSource()
QVERIFY(obj != 0);
if (remote)
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
QCOMPARE(obj->width(), 300.);
QCOMPARE(obj->height(), 300.);
if (valid) {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready);
QCOMPARE(obj->border()->left(), 10);
QCOMPARE(obj->border()->top(), 20);
QCOMPARE(obj->border()->right(), 30);
@@ -288,7 +279,7 @@ void tst_qdeclarativeborderimage::sciSource()
QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round);
QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat);
} else {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error);
}
delete obj;
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
index 4a945f3..adba190 100644
--- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -279,7 +279,7 @@ void tst_QDeclarativeDebug::initTestCase()
qRegisterMetaType<QDeclarativeDebugWatch::State>();
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768...");
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
+
m_engine = new QDeclarativeEngine(this);
QList<QByteArray> qml;
@@ -636,7 +636,7 @@ void tst_QDeclarativeDebug::queryRootContexts()
QCOMPARE(context.objects()[0].properties().count(), 0);
QCOMPARE(context.objects()[0].children().count(), 0);
- QCOMPARE(context.contexts().count(), 1);
+ QCOMPARE(context.contexts().count(), 4);
QVERIFY(context.contexts()[0].debugId() >= 0);
QCOMPARE(context.contexts()[0].name(), QString("tst_QDeclarativeDebug_childContext"));
@@ -891,6 +891,18 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
compareProperties(r, ref);
}
-QTEST_MAIN(tst_QDeclarativeDebug)
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3768";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebug tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebug.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
index a19c2c2..7db0e60 100644
--- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -76,7 +76,6 @@ void tst_QDeclarativeDebugClient::initTestCase()
{
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3770...");
- qputenv("QML_DEBUG_SERVER_PORT", "3770");
new QDeclarativeEngine(this);
m_conn = new QDeclarativeDebugConnection(this);
@@ -151,7 +150,19 @@ void tst_QDeclarativeDebugClient::sendMessage()
QCOMPARE(resp, msg);
}
-QTEST_MAIN(tst_QDeclarativeDebugClient)
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3770";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebugClient tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebugclient.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
index 9ebbbaf..4683199 100644
--- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
+++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
@@ -77,7 +77,6 @@ private slots:
void tst_QDeclarativeDebugService::initTestCase()
{
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3769...");
- qputenv("QML_DEBUG_SERVER_PORT", "3769");
new QDeclarativeEngine(this);
m_conn = new QDeclarativeDebugConnection(this);
@@ -184,6 +183,19 @@ void tst_QDeclarativeDebugService::objectToString()
delete obj;
}
-QTEST_MAIN(tst_QDeclarativeDebugService)
+
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3769";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebugService tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebugservice.moc"
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
index 5028ba1..dca5205 100644
--- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -480,7 +480,7 @@ void tst_qdeclarativedom::loadDynamicProperty()
DP_TEST(0, a, QVariant::Int, 25, 14, "int");
DP_TEST(1, b, QVariant::Bool, 44, 15, "bool");
- DP_TEST(2, c, QVariant::Double, 64, 17, "double");
+ DP_TEST(2, c, QMetaType::QReal, 64, 17, "double");
DP_TEST(3, d, QMetaType::QReal, 86, 15, "real");
DP_TEST(4, e, QVariant::String, 106, 17, "string");
DP_TEST(5, f, QVariant::Url, 128, 14, "url");
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml
new file mode 100644
index 0000000..6d23e5f7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+QtObject {
+ id: root
+ property bool test: false
+
+ Component.onCompleted: {
+ try {
+ root.deleteLater()
+ } catch(e) {
+ test = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml b/tests/auto/declarative/qdeclarativeecmascript/data/in.qml
new file mode 100644
index 0000000..0b5b0ba
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/in.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Item {
+ id: root
+ property bool test1: "x" in root
+ property bool test2: !("foo" in root)
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml
new file mode 100644
index 0000000..d5d3329
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml
@@ -0,0 +1,9 @@
+import Qt.test 1.0
+import Qt 4.7
+
+MyQmlObject {
+ id: root
+ Component.onCompleted: {
+ root.myinvokable(root);
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml
new file mode 100644
index 0000000..29d7d01
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml
@@ -0,0 +1,11 @@
+import Qt.test 1.0
+import Qt 4.7
+
+MyQmlObject {
+ id: root
+ property bool test: false
+ Component.onCompleted: {
+ test = (root.returnme() == root)
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml
new file mode 100644
index 0000000..024d82e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml
@@ -0,0 +1,19 @@
+import Qt.test 1.0
+import Qt 4.7
+
+MyQmlObject {
+ id: root
+
+ property bool readOk: false;
+ property bool writeOk: false
+
+ Component.onCompleted: {
+ readOk = (root.nonscriptable == undefined);
+
+ try {
+ root.nonscriptable = 10
+ } catch (e) {
+ writeOk = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 19bfd37..220318d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -92,9 +92,10 @@ class MyQmlObject : public QObject
Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
+ Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false);
public:
- MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
+ MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
@@ -144,6 +145,13 @@ public:
void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
int console() const { return 11; }
+
+ int nonscriptable() const { return 0; }
+ void setNonscriptable(int) {}
+
+ MyQmlObject *myinvokableObject;
+ Q_INVOKABLE MyQmlObject *returnme() { return this; }
+
signals:
void basicSignal();
void argumentSignal(int a, QString b, qreal c);
@@ -157,6 +165,7 @@ public slots:
void methodNoArgs() { m_methodCalled = true; }
void method(int a) { if(a == 163) m_methodIntCalled = true; }
void setString(const QString &s) { m_string = s; }
+ void myinvokable(MyQmlObject *o) { myinvokableObject = o; }
private:
friend class tst_qdeclarativeecmascript;
@@ -604,62 +613,62 @@ class NumberAssignment : public QObject
{
Q_OBJECT
public:
- Q_PROPERTY(qreal test1 READ test1 WRITE setTest1);
+ Q_PROPERTY(qreal test1 READ test1 WRITE setTest1)
qreal _test1;
qreal test1() const { return _test1; }
void setTest1(qreal v) { _test1 = v; }
- Q_PROPERTY(qreal test2 READ test2 WRITE setTest2);
+ Q_PROPERTY(qreal test2 READ test2 WRITE setTest2)
qreal _test2;
qreal test2() const { return _test2; }
void setTest2(qreal v) { _test2 = v; }
- Q_PROPERTY(qreal test3 READ test3 WRITE setTest3);
+ Q_PROPERTY(qreal test3 READ test3 WRITE setTest3)
qreal _test3;
qreal test3() const { return _test3; }
void setTest3(qreal v) { _test3 = v; }
- Q_PROPERTY(qreal test4 READ test4 WRITE setTest4);
+ Q_PROPERTY(qreal test4 READ test4 WRITE setTest4)
qreal _test4;
qreal test4() const { return _test4; }
void setTest4(qreal v) { _test4 = v; }
- Q_PROPERTY(int test5 READ test5 WRITE setTest5);
+ Q_PROPERTY(int test5 READ test5 WRITE setTest5)
int _test5;
int test5() const { return _test5; }
void setTest5(int v) { _test5 = v; }
- Q_PROPERTY(int test6 READ test6 WRITE setTest6);
+ Q_PROPERTY(int test6 READ test6 WRITE setTest6)
int _test6;
int test6() const { return _test6; }
void setTest6(int v) { _test6 = v; }
- Q_PROPERTY(int test7 READ test7 WRITE setTest7);
+ Q_PROPERTY(int test7 READ test7 WRITE setTest7)
int _test7;
int test7() const { return _test7; }
void setTest7(int v) { _test7 = v; }
- Q_PROPERTY(int test8 READ test8 WRITE setTest8);
+ Q_PROPERTY(int test8 READ test8 WRITE setTest8)
int _test8;
int test8() const { return _test8; }
void setTest8(int v) { _test8 = v; }
- Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9);
+ Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9)
unsigned int _test9;
unsigned int test9() const { return _test9; }
void setTest9(unsigned int v) { _test9 = v; }
- Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10);
+ Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10)
unsigned int _test10;
unsigned int test10() const { return _test10; }
void setTest10(unsigned int v) { _test10 = v; }
- Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11);
+ Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11)
unsigned int _test11;
unsigned int test11() const { return _test11; }
void setTest11(unsigned int v) { _test11 = v; }
- Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12);
+ Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12)
unsigned int _test12;
unsigned int test12() const { return _test12; }
void setTest12(unsigned int v) { _test12 = v; }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index a6d2dac..c10a110 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -52,6 +52,7 @@
#include <private/qdeclarativeglobalscriptclass_p.h>
#include "testtypes.h"
#include "testhttpserver.h"
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -157,10 +158,15 @@ private slots:
void qtbug_10696();
void qtbug_11606();
void qtbug_11600();
+ void nonscriptable();
+ void deleteLater();
+ void in();
void include();
void callQtInvokables();
+ void invokableObjectArg();
+ void invokableObjectRet();
private:
QDeclarativeEngine engine;
};
@@ -1730,6 +1736,31 @@ void tst_qdeclarativeecmascript::callQtInvokables()
QCOMPARE(o.actuals().at(0), QVariant(9));
}
+// QTBUG-13047 (check that you can pass registered object types as args)
+void tst_qdeclarativeecmascript::invokableObjectArg()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectArg.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+ MyQmlObject *qmlobject = qobject_cast<MyQmlObject *>(o);
+ QVERIFY(qmlobject);
+ QCOMPARE(qmlobject->myinvokableObject, qmlobject);
+
+ delete o;
+}
+
+// QTBUG-13047 (check that you can return registered object types from methods)
+void tst_qdeclarativeecmascript::invokableObjectRet()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectRet.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
// QTBUG-5675
void tst_qdeclarativeecmascript::listToVariant()
{
@@ -2386,15 +2417,6 @@ void tst_qdeclarativeecmascript::function()
delete o;
}
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
// Test the "Qt.include" method
void tst_qdeclarativeecmascript::include()
{
@@ -2466,8 +2488,8 @@ void tst_qdeclarativeecmascript::include()
QObject *o = component.create();
QVERIFY(o != 0);
- TRY_WAIT(o->property("done").toBool() == true);
- TRY_WAIT(o->property("done2").toBool() == true);
+ QTRY_VERIFY(o->property("done").toBool() == true);
+ QTRY_VERIFY(o->property("done2").toBool() == true);
QCOMPARE(o->property("test1").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
@@ -2494,7 +2516,7 @@ void tst_qdeclarativeecmascript::include()
QObject *o = component.create();
QVERIFY(o != 0);
- TRY_WAIT(o->property("done").toBool() == true);
+ QTRY_VERIFY(o->property("done").toBool() == true);
QCOMPARE(o->property("test1").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
@@ -2530,6 +2552,36 @@ void tst_qdeclarativeecmascript::qtbug_11600()
delete o;
}
+// Reading and writing non-scriptable properties should fail
+void tst_qdeclarativeecmascript::nonscriptable()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("nonscriptable.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("readOk").toBool(), true);
+ QCOMPARE(o->property("writeOk").toBool(), true);
+ delete o;
+}
+
+// deleteLater() should not be callable from QML
+void tst_qdeclarativeecmascript::deleteLater()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("deleteLater.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qdeclarativeecmascript::in()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("in.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ delete o;
+}
QTEST_MAIN(tst_qdeclarativeecmascript)
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml
new file mode 100644
index 0000000..8e95a94
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Flickable {
+ width: 100; height: 100
+
+ QGraphicsWidget { objectName: "widget1"; width: 200; height: 300 }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 678996b..e7ded8a 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -44,6 +44,7 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <private/qdeclarativeflickable_p.h>
#include <private/qdeclarativevaluetype_p.h>
+#include <QtGui/qgraphicswidget.h>
#include <math.h>
#ifdef Q_OS_SYMBIAN
@@ -67,9 +68,13 @@ private slots:
void flickDeceleration();
void pressDelay();
void flickableDirection();
+ void qgraphicswidget();
private:
QDeclarativeEngine engine;
+
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName);
};
tst_qdeclarativeflickable::tst_qdeclarativeflickable()
@@ -261,6 +266,38 @@ void tst_qdeclarativeflickable::flickableDirection()
QCOMPARE(spy.count(),3);
}
+void tst_qdeclarativeflickable::qgraphicswidget()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickableqgraphicswidget.qml"));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(flickable != 0);
+ QGraphicsWidget *widget = findItem<QGraphicsWidget>(flickable->contentItem(), "widget1");
+ QVERIFY(widget);
+}
+
+template<typename T>
+T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QGraphicsObject *item = qobject_cast<QGraphicsObject*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ return static_cast<T*>(item);
+ }
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
QTEST_MAIN(tst_qdeclarativeflickable)
#include "tst_qdeclarativeflickable.moc"
diff --git a/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf b/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf
new file mode 100644
index 0000000..aae50d5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
index ae23017..8765426 100644
--- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -39,8 +39,10 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativecontext.h>
#include <private/qdeclarativefontloader_p.h>
#include "../../../shared/util.h"
#include "../shared/testhttpserver.h"
@@ -67,6 +69,7 @@ private slots:
void webFont();
void redirWebFont();
void failWebFont();
+ void changeFont();
private slots:
@@ -181,6 +184,45 @@ void tst_qdeclarativefontloader::failWebFont()
QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
}
+void tst_qdeclarativefontloader::changeFont()
+{
+ QString componentStr = "import Qt 4.7\nFontLoader { source: font }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+
+ QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
+ QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
+
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 0);
+ QCOMPARE(statusSpy.count(), 0);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Loading);
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 1);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+
+ ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 2);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 3);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+}
+
QTEST_MAIN(tst_qdeclarativefontloader)
#include "tst_qdeclarativefontloader.moc"
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 1a28b71..5fd373c 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -590,7 +590,7 @@ void tst_QDeclarativeGridView::currentIndex()
QCOMPARE(gridview->currentIndex(), 35);
QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 35));
QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
- QCOMPARE(gridview->contentY(), 399.0);
+ QCOMPARE(gridview->contentY(), 400.0);
gridview->moveCurrentIndexRight();
QCOMPARE(gridview->currentIndex(), 36);
@@ -604,6 +604,8 @@ void tst_QDeclarativeGridView::currentIndex()
// no wrap
gridview->setCurrentIndex(0);
QCOMPARE(gridview->currentIndex(), 0);
+ // confirm that the velocity is updated
+ QTRY_VERIFY(gridview->verticalVelocity() != 0.0);
gridview->moveCurrentIndexUp();
QCOMPARE(gridview->currentIndex(), 0);
@@ -629,7 +631,7 @@ void tst_QDeclarativeGridView::currentIndex()
gridview->moveCurrentIndexLeft();
QCOMPARE(gridview->currentIndex(), model.count()-1);
- QTRY_COMPARE(gridview->contentY(), 879.0);
+ QTRY_COMPARE(gridview->contentY(), 880.0);
gridview->moveCurrentIndexRight();
QCOMPARE(gridview->currentIndex(), 0);
@@ -655,6 +657,15 @@ void tst_QDeclarativeGridView::currentIndex()
gridview->setFlow(QDeclarativeGridView::TopToBottom);
+ qApp->setActiveWindow(canvas);
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(canvas);
+#endif
+ QTRY_VERIFY(canvas->hasFocus());
+ QTRY_VERIFY(canvas->scene()->hasFocus());
+ qApp->processEvents();
+
QTest::keyClick(canvas, Qt::Key_Right);
QCOMPARE(gridview->currentIndex(), 5);
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png
deleted file mode 100644
index 3245027..0000000
--- a/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png b/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png
deleted file mode 100644
index d7df0e4..0000000
--- a/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png
index 351da13..5992e79 100644
--- a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart.png b/tests/auto/declarative/qdeclarativeimage/data/heart.png
index 372b224..ff93f6c 100644
--- a/tests/auto/declarative/qdeclarativeimage/data/heart.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png
deleted file mode 100644
index b16db76..0000000
--- a/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png
deleted file mode 100644
index df22325..0000000
--- a/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png
index 4976ff9..19b20a8 100644
--- a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200.png b/tests/auto/declarative/qdeclarativeimage/data/heart200.png
index 786e75d..5a31ae8 100644
--- a/tests/auto/declarative/qdeclarativeimage/data/heart200.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart200.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index b8d2828..2686127 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -52,7 +52,9 @@
#include <private/qdeclarativeloader_p.h>
#include <QtDeclarative/qdeclarativecontext.h>
#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtTest/QSignalSpy>
+#include "../../../shared/util.h"
#include "../shared/testhttpserver.h"
#ifdef Q_OS_SYMBIAN
@@ -63,18 +65,7 @@
#define SERVER_PORT 14451
#define SERVER_ADDR "http://127.0.0.1:14451"
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 60; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
class tst_qdeclarativeimage : public QObject
-
{
Q_OBJECT
public:
@@ -91,6 +82,7 @@ private slots:
void svg();
void big();
void tiling_QTBUG_6716();
+ void noLoading();
private:
template<typename T>
@@ -173,18 +165,18 @@ void tst_qdeclarativeimage::imageSource()
QVERIFY(obj->asynchronous() == true);
if (remote || async)
- TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
QCOMPARE(obj->width(), qreal(width));
QCOMPARE(obj->height(), qreal(height));
QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
QCOMPARE(obj->progress(), 1.0);
} else {
- TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Error);
}
delete obj;
@@ -272,32 +264,24 @@ void tst_qdeclarativeimage::svg()
QVERIFY(obj != 0);
QCOMPARE(obj->pixmap().width(), 300);
QCOMPARE(obj->pixmap().height(), 300);
- QCOMPARE(obj->width(), 550.0);
- QCOMPARE(obj->height(), 500.0);
-#if defined(Q_OS_MAC)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-mac.png"));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+#if defined(Q_OS_LINUX)
+ QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
#elif defined(Q_OS_WIN32)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png"));
-#elif defined(QT_ARCH_ARM)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-arm.png"));
-#else
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
#endif
obj->setSourceSize(QSize(200,200));
QCOMPARE(obj->pixmap().width(), 200);
QCOMPARE(obj->pixmap().height(), 200);
- QCOMPARE(obj->width(), 550.0);
- QCOMPARE(obj->height(), 500.0);
-#if defined(Q_OS_MAC)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-mac.png"));
+ QCOMPARE(obj->width(), 200.0);
+ QCOMPARE(obj->height(), 200.0);
+#if defined(Q_OS_LINUX)
+ QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png"));
#elif defined(Q_OS_WIN32)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png"));
-#elif defined(QT_ARCH_ARM)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-arm.png"));
-#else
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png"));
#endif
delete obj;
}
@@ -308,7 +292,7 @@ void tst_qdeclarativeimage::big()
// have to build a 400 MB image. That would be a bug in the JPEG loader.
QString src = QUrl::fromLocalFile(SRCDIR "/data/big.jpeg").toString();
- QString componentStr = "import Qt 4.7\nImage { source: \"" + src + "\"; sourceSize.width: 256; sourceSize.height: 256 }";
+ QString componentStr = "import Qt 4.7\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
@@ -316,8 +300,8 @@ void tst_qdeclarativeimage::big()
QVERIFY(obj != 0);
QCOMPARE(obj->pixmap().width(), 256);
QCOMPARE(obj->pixmap().height(), 256);
- QCOMPARE(obj->width(), 10240.0);
- QCOMPARE(obj->height(), 10240.0);
+ QCOMPARE(obj->width(), 100.0);
+ QCOMPARE(obj->height(), 256.0);
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/big256.png"));
delete obj;
@@ -363,6 +347,54 @@ void tst_qdeclarativeimage::tiling_QTBUG_6716()
}
}
+void tst_qdeclarativeimage::noLoading()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+ server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
+
+ QString componentStr = "import Qt 4.7\nImage { source: srcImage }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart.png"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QDeclarativeImage::Ready);
+
+ QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
+ QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
+ QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarativeImageBase::Status)));
+
+ // Loading local file
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 1);
+ QTRY_COMPARE(progressSpy.count(), 0);
+ QTRY_COMPARE(statusSpy.count(), 0);
+
+ // Loading remote file
+ ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/oldcolors.png");
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading);
+ QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 2);
+ QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_COMPARE(statusSpy.count(), 2);
+
+ // Loading remote file again - should not go through 'Loading' state.
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
+ ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/oldcolors.png");
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 4);
+ QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_COMPARE(statusSpy.count(), 2);
+}
+
/*
Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
index bdb6423..3bf0ea1 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
+++ b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
@@ -8,11 +8,7 @@ SOURCES += tst_qdeclarativeimageprovider.cpp
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
# LIBS += -lgcov
-symbian: {
- importFiles.sources = data
- importFiles.path = .
- DEPLOYMENT = importFiles
-} else {
+!symbian: {
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
index e0b46f0..d38160d 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -44,26 +44,16 @@
#include <QtDeclarative/qdeclarativeimageprovider.h>
#include <private/qdeclarativeimage_p.h>
#include <QImageReader>
+#include <QWaitCondition>
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
#define SRCDIR "."
#endif
-// QDeclarativeImageProvider::request() is run in an idle thread where possible
-// Be generous in our timeout.
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 10; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(100); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
Q_DECLARE_METATYPE(QDeclarativeImageProvider*);
-
class tst_qdeclarativeimageprovider : public QObject
{
Q_OBJECT
@@ -85,6 +75,8 @@ private slots:
void removeProvider_data();
void removeProvider();
+ void threadTest();
+
private:
QString newImageFileName() const;
void fillRequestTestsData(const QString &id);
@@ -95,11 +87,17 @@ private:
class TestQImageProvider : public QDeclarativeImageProvider
{
public:
- TestQImageProvider()
- : QDeclarativeImageProvider(Image)
+ TestQImageProvider(bool *deleteWatch = 0)
+ : QDeclarativeImageProvider(Image), deleteWatch(deleteWatch)
{
}
+ ~TestQImageProvider()
+ {
+ if (deleteWatch)
+ *deleteWatch = true;
+ }
+
QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
{
if (id == QLatin1String("no-such-file.png"))
@@ -114,6 +112,8 @@ public:
image = image.scaled(requestedSize);
return image;
}
+
+ bool *deleteWatch;
};
Q_DECLARE_METATYPE(TestQImageProvider*);
@@ -121,11 +121,17 @@ Q_DECLARE_METATYPE(TestQImageProvider*);
class TestQPixmapProvider : public QDeclarativeImageProvider
{
public:
- TestQPixmapProvider()
- : QDeclarativeImageProvider(Pixmap)
+ TestQPixmapProvider(bool *deleteWatch = 0)
+ : QDeclarativeImageProvider(Pixmap), deleteWatch(deleteWatch)
{
}
+ ~TestQPixmapProvider()
+ {
+ if (deleteWatch)
+ *deleteWatch = true;
+ }
+
QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
{
if (id == QLatin1String("no-such-file.png"))
@@ -140,6 +146,8 @@ public:
image = image.scaled(requestedSize);
return image;
}
+
+ bool *deleteWatch;
};
Q_DECLARE_METATYPE(TestQPixmapProvider*);
@@ -193,24 +201,24 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide
QVERIFY(obj != 0);
if (async)
- TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading);
QCOMPARE(obj->source(), QUrl(source));
if (error.isEmpty()) {
if (async)
- TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
else
QVERIFY(obj->status() == QDeclarativeImage::Ready);
- QCOMPARE(obj->width(), 100.0);
- QCOMPARE(obj->height(), 100.0);
+ QCOMPARE(obj->width(), qreal(size.width()));
+ QCOMPARE(obj->height(), qreal(size.height()));
QCOMPARE(obj->pixmap().width(), size.width());
QCOMPARE(obj->pixmap().height(), size.height());
QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
QCOMPARE(obj->progress(), 1.0);
} else {
if (async)
- TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Error);
else
QVERIFY(obj->status() == QDeclarativeImage::Error);
}
@@ -225,7 +233,9 @@ void tst_qdeclarativeimageprovider::requestImage_sync_data()
void tst_qdeclarativeimageprovider::requestImage_sync()
{
- runTest(false, new TestQImageProvider);
+ bool deleteWatch = false;
+ runTest(false, new TestQImageProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
}
void tst_qdeclarativeimageprovider::requestImage_async_data()
@@ -235,7 +245,9 @@ void tst_qdeclarativeimageprovider::requestImage_async_data()
void tst_qdeclarativeimageprovider::requestImage_async()
{
- runTest(true, new TestQImageProvider);
+ bool deleteWatch = false;
+ runTest(true, new TestQImageProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
}
void tst_qdeclarativeimageprovider::requestPixmap_sync_data()
@@ -245,13 +257,15 @@ void tst_qdeclarativeimageprovider::requestPixmap_sync_data()
void tst_qdeclarativeimageprovider::requestPixmap_sync()
{
- runTest(false, new TestQPixmapProvider);
+ bool deleteWatch = false;
+ runTest(false, new TestQPixmapProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
}
void tst_qdeclarativeimageprovider::requestPixmap_async()
{
QDeclarativeEngine engine;
- QDeclarativeImageProvider *provider = new TestQPixmapProvider;
+ QDeclarativeImageProvider *provider = new TestQPixmapProvider();
engine.addImageProvider("test", provider);
QVERIFY(engine.imageProvider("test") != 0);
@@ -305,6 +319,71 @@ void tst_qdeclarativeimageprovider::removeProvider()
delete obj;
}
+class TestThreadProvider : public QDeclarativeImageProvider
+{
+ public:
+ TestThreadProvider() : QDeclarativeImageProvider(Image), ok(false) {}
+
+ ~TestThreadProvider() {}
+
+ QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
+ {
+ mutex.lock();
+ if (!ok)
+ cond.wait(&mutex);
+ mutex.unlock();
+ QVector<int> v;
+ for (int i = 0; i < 10000; i++)
+ v.prepend(i); //do some computation
+ QImage image(50,50, QImage::Format_RGB32);
+ image.fill(QColor(id).rgb());
+ if (size)
+ *size = image.size();
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ return image;
+ }
+
+ QWaitCondition cond;
+ QMutex mutex;
+ bool ok;
+};
+
+
+void tst_qdeclarativeimageprovider::threadTest()
+{
+ QDeclarativeEngine engine;
+
+ TestThreadProvider *provider = new TestThreadProvider;
+
+ engine.addImageProvider("test_thread", provider);
+ QVERIFY(engine.imageProvider("test_thread") != 0);
+
+ QString componentStr = "import Qt 4.7\nItem { \n"
+ "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n"
+ "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n"
+ "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n"
+ "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n"
+ " }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QObject *obj = component.create();
+ //MUST not deadlock
+ QVERIFY(obj != 0);
+ QList<QDeclarativeImage *> images = obj->findChildren<QDeclarativeImage *>();
+ QCOMPARE(images.count(), 4);
+ QTest::qWait(100);
+ foreach(QDeclarativeImage *img, images) {
+ QCOMPARE(img->status(), QDeclarativeImage::Loading);
+ }
+ provider->ok = true;
+ provider->cond.wakeAll();
+ QTest::qWait(250);
+ foreach(QDeclarativeImage *img, images) {
+ QTRY_VERIFY(img->status() == QDeclarativeImage::Ready);
+ }
+}
+
QTEST_MAIN(tst_qdeclarativeimageprovider)
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml b/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml
new file mode 100644
index 0000000..1f8eac8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml
@@ -0,0 +1,4 @@
+import Test 1.0
+
+MyParserStatus {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml
new file mode 100644
index 0000000..59afe58
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+QtObject {
+ id: root
+
+ property bool test: false
+ property alias myalias: root.objectName
+ signal go
+ onGo: test = true
+
+ Component.onCompleted: {
+ root.go();
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml b/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml
new file mode 100644
index 0000000..df048cc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+Item {
+ property QtObject object: DontDoubleCallClassBeginItem {}
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt
new file mode 100644
index 0000000..93652a7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt
@@ -0,0 +1 @@
+5:23:Invalid alias location
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml
new file mode 100644
index 0000000..2a09648
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ id: root
+ property alias a: root.nonScriptable
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
index 6e11786..53e752b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
@@ -1,2 +1,2 @@
-4:5:Unable to create type NestedErrorsType
+4:5:Type NestedErrorsType unavailable
4:8:Invalid property assignment: number expected
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt
new file mode 100644
index 0000000..cdfa4b2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt
@@ -0,0 +1 @@
+4:5:Cannot assign to non-existent property "nonScriptable"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml
new file mode 100644
index 0000000..bd59bc8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml
@@ -0,0 +1,5 @@
+import Test 1.0
+
+MyQmlObject {
+ nonScriptable: 11
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml b/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml
new file mode 100644
index 0000000..e7aaf16
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml
@@ -0,0 +1,13 @@
+import Qt 4.7
+
+QtObject {
+ property int notifyCount: 0
+
+ property variant foo
+ onFooChanged: notifyCount++
+
+ Component.onCompleted: {
+ foo = 1;
+ foo = 1;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
index 5d87404..20cd976 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -50,6 +50,7 @@ void registerTypes()
qmlRegisterType<MyDotPropertyObject>("Test",1,0,"MyDotPropertyObject");
qmlRegisterType<MyNamespace::MyNamespacedType>("Test",1,0,"MyNamespacedType");
qmlRegisterType<MyNamespace::MySecondNamespacedType>("Test",1,0,"MySecondNamespacedType");
+ qmlRegisterType<MyParserStatus>("Test",1,0,"MyParserStatus");
qmlRegisterType<MyGroupedObject>();
qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser);
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index acbe219..ac55bae 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -112,6 +112,7 @@ class MyQmlObject : public QObject, public MyInterface
Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType)
Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+ Q_PROPERTY(int nonScriptable READ nonScriptable WRITE setNonScriptable SCRIPTABLE false);
Q_INTERFACES(MyInterface)
public:
@@ -150,6 +151,9 @@ public:
int propertyWithNotify() const { return m_propertyWithNotify; }
void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
+
+ int nonScriptable() const { return 0; }
+ void setNonScriptable(int) {}
public slots:
void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
@@ -170,7 +174,6 @@ private:
QML_DECLARE_TYPE(MyQmlObject)
QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-
class MyGroupedObject : public QObject
{
Q_OBJECT
@@ -576,6 +579,22 @@ public:
void setCustomData(QObject *, const QByteArray &) {}
};
+class MyParserStatus : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+public:
+ MyParserStatus() : m_cbc(0), m_ccc(0) {}
+
+ int classBeginCount() const { return m_cbc; }
+ int componentCompleteCount() const { return m_ccc; }
+
+ virtual void classBegin() { m_cbc++; }
+ virtual void componentComplete() { m_ccc++; }
+private:
+ int m_cbc;
+ int m_ccc;
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index fcdf926..1825991 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -118,6 +118,7 @@ private slots:
void valueTypes();
void cppnamespace();
void aliasProperties();
+ void aliasPropertiesAndSignals();
void componentCompositeType();
void i18n();
void i18n_data();
@@ -126,6 +127,7 @@ private slots:
void scriptString();
void defaultPropertyListOrder();
void declaredPropertyValues();
+ void dontDoubleCallClassBegin();
void basicRemote_data();
void basicRemote();
@@ -141,8 +143,8 @@ private slots:
void importsOrder();
void qmlAttachedPropertiesObjectMethod();
-
void customOnProperty();
+ void variantNotify();
// regression tests for crashes
void crash1();
@@ -342,6 +344,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidAlias.4") << "invalidAlias.4.qml" << "invalidAlias.4.errors.txt" << false;
QTest::newRow("invalidAlias.5") << "invalidAlias.5.qml" << "invalidAlias.5.errors.txt" << false;
QTest::newRow("invalidAlias.6") << "invalidAlias.6.qml" << "invalidAlias.6.errors.txt" << false;
+ QTest::newRow("invalidAlias.7") << "invalidAlias.7.qml" << "invalidAlias.7.errors.txt" << false;
QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false;
QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false;
@@ -372,6 +375,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false;
QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
+ QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false;
}
@@ -1048,6 +1052,17 @@ void tst_qdeclarativelanguage::aliasProperties()
}
}
+// QTBUG-13374 Test that alias properties and signals can coexist
+void tst_qdeclarativelanguage::aliasPropertiesAndSignals()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertiesAndSignals.qml"));
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
// Test that the root element in a composite type can be a Component
void tst_qdeclarativelanguage::componentCompositeType()
{
@@ -1192,6 +1207,20 @@ void tst_qdeclarativelanguage::declaredPropertyValues()
VERIFY_ERRORS(0);
}
+void tst_qdeclarativelanguage::dontDoubleCallClassBegin()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("dontDoubleCallClassBegin.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ MyParserStatus *o2 = qobject_cast<MyParserStatus *>(qvariant_cast<QObject *>(o->property("object")));
+ QVERIFY(o2);
+ QCOMPARE(o2->classBeginCount(), 1);
+ QCOMPARE(o2->componentCompleteCount(), 1);
+
+ delete o;
+}
+
// Check that first child of qml is of given type. Empty type insists on error.
void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
{
@@ -1668,6 +1697,20 @@ void tst_qdeclarativelanguage::customOnProperty()
delete object;
}
+// QTBUG-12601
+void tst_qdeclarativelanguage::variantNotify()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("variantNotify.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("notifyCount").toInt(), 1);
+
+ delete object;
+}
+
void tst_qdeclarativelanguage::initTestCase()
{
registerTypes();
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 10805b4..f456778 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -49,6 +49,7 @@
#include <QtCore/qtimer.h>
#include <QtCore/qdebug.h>
#include <QtCore/qtranslator.h>
+#include <QSignalSpy>
#include "../../../shared/util.h"
@@ -57,6 +58,8 @@
#define SRCDIR "."
#endif
+Q_DECLARE_METATYPE(QList<int>)
+
class tst_qdeclarativelistmodel : public QObject
{
Q_OBJECT
@@ -64,6 +67,7 @@ public:
tst_qdeclarativelistmodel() {}
private:
+ int roleFromName(const QDeclarativeListModel *model, const QString &roleName);
QScriptValue nestedListValue(QScriptEngine *eng) const;
QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model);
void waitForWorker(QDeclarativeItem *item);
@@ -78,6 +82,8 @@ private slots:
void dynamic();
void dynamic_worker_data();
void dynamic_worker();
+ void dynamic_worker_sync_data();
+ void dynamic_worker_sync();
void convertNestedToFlat_fail();
void convertNestedToFlat_fail_data();
void convertNestedToFlat_ok();
@@ -86,7 +92,23 @@ private slots:
void error_data();
void error();
void set();
+ void get();
+ void get_data();
+ void get_worker();
+ void get_worker_data();
+ void get_nested();
+ void get_nested_data();
};
+int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName)
+{
+ QList<int> roles = model->roles();
+ for (int i=0; i<roles.count(); i++) {
+ if (model->toString(roles[i]) == roleName)
+ return roles[i];
+ }
+ Q_ASSERT(false);
+ return -1;
+}
QScriptValue tst_qdeclarativelistmodel::nestedListValue(QScriptEngine *eng) const
{
@@ -196,6 +218,10 @@ void tst_qdeclarativelistmodel::dynamic_data()
QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "";
QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "";
QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "";
+ QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "";
+
+ QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "";
+ QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "";
QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
@@ -310,8 +336,12 @@ void tst_qdeclarativelistmodel::dynamic_worker()
QFETCH(int, result);
QFETCH(QString, warning);
+ if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
+ return;
+
// This is same as dynamic() except it applies the test to a ListModel called
- // from a WorkerScript (i.e. testing the internal NestedListModel class)
+ // from a WorkerScript (i.e. testing the internal FlatListModel that is created
+ // by the WorkerListModelAgent)
QDeclarativeListModel model;
QDeclarativeEngine eng;
@@ -330,27 +360,62 @@ void tst_qdeclarativelistmodel::dynamic_worker()
if (!warning.isEmpty())
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
- if (operations.count() == 1) {
- // test count(), get() return the correct default values in the worker list model
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations)));
- waitForWorker(item);
- QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result);
- } else {
- // execute a set of commands on the worker list model, then check the
- // changes are reflected in the list model in the main thread
- if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: Cannot add nested list values when modifying or after modification from a worker script");
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
- waitForWorker(item);
-
- QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString());
- if (!QByteArray(QTest::currentDataTag()).startsWith("nested"))
- QCOMPARE(e.evaluate().toInt(), result);
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations)));
+ waitForWorker(item);
+ QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result);
+
+ delete item;
+ qApp->processEvents();
+}
+
+
+
+void tst_qdeclarativelistmodel::dynamic_worker_sync_data()
+{
+ dynamic_data();
+}
+
+void tst_qdeclarativelistmodel::dynamic_worker_sync()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+
+ // This is the same as dynamic_worker() except that it executes a set of list operations
+ // from the worker script, calls sync(), and tests the changes are reflected in the
+ // list in the main thread
+
+ QDeclarativeListModel model;
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.length() - 2);
+ QVariantList operations;
+ foreach (const QString &s, script.split(';')) {
+ if (!s.isEmpty())
+ operations << s;
}
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ // execute a set of commands on the worker list model, then check the
+ // changes are reflected in the list model in the main thread
+ if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script");
+
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ waitForWorker(item);
+
+ QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString());
+ if (!QByteArray(QTest::currentDataTag()).startsWith("nested"))
+ QCOMPARE(e.evaluate().toInt(), result);
+
delete item;
qApp->processEvents();
}
@@ -374,7 +439,7 @@ void tst_qdeclarativelistmodel::convertNestedToFlat_fail()
model.append(nestedListValue(&s_eng));
QCOMPARE(model.count(), 2);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: List contains nested list values and cannot be used from a worker script");
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: List contains list-type data and cannot be used from a worker script");
QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script)));
waitForWorker(item);
@@ -426,7 +491,7 @@ void tst_qdeclarativelistmodel::convertNestedToFlat_ok()
QCOMPARE(model.count(), count+1);
QScriptValue nested = nestedListValue(&s_eng);
- const char *warning = "<Unknown File>: QML ListModel: Cannot add nested list values when modifying or after modification from a worker script";
+ const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
QTest::ignoreMessage(QtWarningMsg, warning);
model.append(nested);
@@ -595,6 +660,9 @@ void tst_qdeclarativelistmodel::error()
}
}
+/*
+ Test model changes from set() are available to the view
+*/
void tst_qdeclarativelistmodel::set()
{
QDeclarativeEngine engine;
@@ -618,6 +686,205 @@ void tst_qdeclarativelistmodel::set()
QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
}
+/*
+ Test model changes on values returned by get() are available to the view
+*/
+void tst_qdeclarativelistmodel::get()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng);
+ component.setData(
+ "import Qt 4.7\n"
+ "ListModel { \n"
+ "ListElement { roleA: 100 }\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "}", QUrl());
+ QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
+ int role = roleFromName(model, roleName);
+
+ QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
+ QDeclarativeExpression expr(eng.rootContext(), model, expression);
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ QCOMPARE(model->data(index, role), roleValue);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
+}
+
+void tst_qdeclarativelistmodel::get_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<QVariant>("roleValue");
+
+ QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500);
+ QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500);
+
+ QVariantMap map;
+ map["zzz"] = 123;
+ QTest::newRow("object value") << "get(1).roleB = {'zzz':123}" << 1 << "roleB" << QVariant::fromValue(map);
+
+ QVariantList list;
+ map.clear(); map["a"] = 50; map["b"] = 500;
+ list << map;
+ map.clear(); map["c"] = 1000;
+ list << map;
+ QTest::newRow("list of objects") << "get(2).roleB = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleB" << QVariant::fromValue(list);
+}
+
+void tst_qdeclarativelistmodel::get_worker()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+
+ QDeclarativeListModel model;
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+ QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(&eng);
+
+ // Add some values like get() test
+ QScriptValue sv = seng->newObject();
+ sv.setProperty(QLatin1String("roleA"), seng->newVariant(QVariant::fromValue(100)));
+ model.append(sv);
+ sv = seng->newObject();
+ sv.setProperty(QLatin1String("roleA"), seng->newVariant(QVariant::fromValue(200)));
+ sv.setProperty(QLatin1String("roleB"), seng->newVariant(QVariant::fromValue(400)));
+ model.append(sv);
+ model.append(sv);
+ int role = roleFromName(&model, roleName);
+
+ const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
+ if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map)
+ QTest::ignoreMessage(QtWarningMsg, warning);
+ QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
+
+ // in the worker thread, change the model data and call sync()
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, QStringList(expression))));
+ waitForWorker(item);
+
+ // see if we receive the model changes in the main thread's model
+ if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) {
+ QVERIFY(model.data(index, role) != roleValue);
+ QCOMPARE(spy.count(), 0);
+ } else {
+ QCOMPARE(model.data(index, role), roleValue);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QVERIFY(spyResult.at(2).value<QList<int> >().contains(role));
+ }
+}
+
+void tst_qdeclarativelistmodel::get_worker_data()
+{
+ get_data();
+}
+
+/*
+ Test that the tests run in get() also work for nested list data
+*/
+void tst_qdeclarativelistmodel::get_nested()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng);
+ component.setData(
+ "import Qt 4.7\n"
+ "ListModel { \n"
+ "ListElement {\n"
+ "listRoleA: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "}\n"
+ "ListElement {\n"
+ "listRoleA: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "listRoleB: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "listRoleC: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "}\n"
+ "}", QUrl());
+ QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(component.errorString().isEmpty());
+ QDeclarativeListModel *childModel;
+
+ // Test setting the inner list data for:
+ // get(0).listRoleA
+ // get(1).listRoleA
+ // get(1).listRoleB
+ // get(1).listRoleC
+
+ QList<QPair<int, QString> > testData;
+ testData << qMakePair(0, QString("listRoleA"));
+ testData << qMakePair(1, QString("listRoleA"));
+ testData << qMakePair(1, QString("listRoleB"));
+ testData << qMakePair(1, QString("listRoleC"));
+
+ for (int i=0; i<testData.count(); i++) {
+ int outerListIndex = testData[i].first;
+ QString outerListRoleName = testData[i].second;
+ int outerListRole = roleFromName(model, outerListRoleName);
+
+ childModel = qobject_cast<QDeclarativeListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
+ QVERIFY(childModel);
+
+ QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression);
+ QDeclarativeExpression expr(eng.rootContext(), model, extendedExpression);
+
+ QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>)));
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ int role = roleFromName(childModel, roleName);
+ QCOMPARE(childModel->data(index, role), roleValue);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
+ }
+}
+
+void tst_qdeclarativelistmodel::get_nested_data()
+{
+ get_data();
+}
QTEST_MAIN(tst_qdeclarativelistmodel)
diff --git a/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml
index 66728d6..9ea5953 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml
@@ -13,17 +13,17 @@ Rectangle {
objectName: "itemModel"
Rectangle {
objectName: "item1"
- height: view.height; width: view.width; color: "#FFFEF0"
+ height: ListView.view.height; width: view.width; color: "#FFFEF0"
Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
}
Rectangle {
objectName: "item2"
- height: view.height; width: view.width; color: "#F0FFF7"
+ height: ListView.view.height; width: view.width; color: "#F0FFF7"
Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
}
Rectangle {
objectName: "item3"
- height: view.height; width: view.width; color: "#F4F0FF"
+ height: ListView.view.height; width: view.width; color: "#F4F0FF"
Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
}
}
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
index 3b2db5e..d5d3365 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
@@ -4,6 +4,12 @@ Rectangle {
width: 240
height: 320
color: "#ffffff"
+
+ property real hr: list.visibleArea.heightRatio
+ function heightRatio() {
+ return list.visibleArea.heightRatio
+ }
+
function checkProperties() {
testObject.error = false;
if (list.model != testModel) {
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 9c24e03..cd17fad 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -98,6 +98,7 @@ private slots:
void manualHighlight();
void QTBUG_11105();
void footer();
+ void resizeView();
private:
template <class T> void items();
@@ -223,6 +224,13 @@ public:
emit itemsRemoved(index, 1);
}
+ void removeItems(int index, int count) {
+ int c = count;
+ while (c--)
+ list.removeAt(index);
+ emit itemsRemoved(index, count);
+ }
+
void moveItem(int from, int to) {
list.move(from, to);
emit itemsMoved(from, to, 1);
@@ -289,6 +297,13 @@ public:
emit endRemoveRows();
}
+ void removeItems(int index, int count) {
+ emit beginRemoveRows(QModelIndex(), index, index+count-1);
+ while (count--)
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
void moveItem(int from, int to) {
emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
list.move(from, to);
@@ -519,7 +534,7 @@ void tst_QDeclarativeListView::removed(bool animated)
QDeclarativeView *canvas = createView();
T model;
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 50; i++)
model.addItem("Item" + QString::number(i), "");
QDeclarativeContext *ctxt = canvas->rootContext();
@@ -642,6 +657,21 @@ void tst_QDeclarativeListView::removed(bool animated)
QTRY_COMPARE(listview->currentIndex(), 7);
QTRY_VERIFY(listview->currentItem() == oldCurrent);
+ listview->setContentY(80);
+ QTest::qWait(300);
+
+ model.removeItems(1, 17);
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i+2);
+ if (!item) qWarning() << "Item" << i+2 << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),80+i*20.0);
+ }
+
delete canvas;
}
@@ -979,13 +1009,15 @@ void tst_QDeclarativeListView::currentIndex()
// current item should be 20th item at startup
// and current item should be in view
QCOMPARE(listview->currentIndex(), 20);
- QCOMPARE(listview->contentY(), 99.0);
+ QCOMPARE(listview->contentY(), 100.0);
QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 20));
QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
// no wrap
listview->setCurrentIndex(0);
QCOMPARE(listview->currentIndex(), 0);
+ // confirm that the velocity is updated
+ QTRY_VERIFY(listview->verticalVelocity() != 0.0);
listview->incrementCurrentIndex();
QCOMPARE(listview->currentIndex(), 1);
@@ -1002,7 +1034,7 @@ void tst_QDeclarativeListView::currentIndex()
listview->decrementCurrentIndex();
QCOMPARE(listview->currentIndex(), model.count()-1);
- QTRY_COMPARE(listview->contentY(), 279.0);
+ QTRY_COMPARE(listview->contentY(), 280.0);
listview->incrementCurrentIndex();
QCOMPARE(listview->currentIndex(), 0);
@@ -1066,6 +1098,7 @@ void tst_QDeclarativeListView::itemList()
QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "item1");
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), 0.0);
+ QCOMPARE(item->height(), listview->height());
QDeclarativeText *text = findItem<QDeclarativeText>(contentItem, "text1");
QTRY_VERIFY(text);
@@ -1590,6 +1623,48 @@ void tst_QDeclarativeListView::footer()
QTRY_COMPARE(footer->y(), 0.0);
}
+void tst_QDeclarativeListView::resizeView()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; 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_COMPARE(item->y(), i*20.);
+ }
+
+ QVariant heightRatio;
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.4);
+
+ listview->setHeight(200);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.25);
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
index b0b7a3b..b62392d 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -61,15 +61,6 @@ inline QUrl TEST_FILE(const QString &filename)
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
}
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
class tst_QDeclarativeLoader : public QObject
{
@@ -146,7 +137,7 @@ void tst_QDeclarativeLoader::component()
void tst_QDeclarativeLoader::invalidUrl()
{
- QTest::ignoreMessage(QtWarningMsg, QString("<Unknown File>: File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString()).toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found").toUtf8().constData());
QDeclarativeComponent component(&engine);
component.setData(QByteArray("import Qt 4.7\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE(""));
@@ -460,7 +451,7 @@ void tst_QDeclarativeLoader::networkRequestUrl()
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
- TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+ QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
@@ -491,7 +482,7 @@ void tst_QDeclarativeLoader::networkComponent()
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
QVERIFY(loader);
- TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+ QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
@@ -508,14 +499,14 @@ void tst_QDeclarativeLoader::failNetworkRequest()
QVERIFY(server.isValid());
server.serveDirectory(SRCDIR "/data");
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Network error for URL http://127.0.0.1:14450/IDontExist.qml");
+ QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
QDeclarativeComponent component(&engine);
component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml"));
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
- TRY_WAIT(loader->status() == QDeclarativeLoader::Error);
+ QTRY_VERIFY(loader->status() == QDeclarativeLoader::Error);
QVERIFY(loader->item() == 0);
QCOMPARE(loader->progress(), 0.0);
diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
index b06ad7c..862b7d2 100644
--- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
+++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
@@ -313,7 +313,7 @@ void tst_qdeclarativemetatype::qmlParserStatusCast()
QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativeParserStatus *)&t));
QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(status, &t);
+ QCOMPARE(status, (QDeclarativeParserStatus*)&t);
}
void tst_qdeclarativemetatype::qmlPropertyValueSourceCast()
@@ -333,7 +333,7 @@ void tst_qdeclarativemetatype::qmlPropertyValueSourceCast()
QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueSource *)&t));
QDeclarativePropertyValueSource *source = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(source, &t);
+ QCOMPARE(source, (QDeclarativePropertyValueSource*)&t);
}
void tst_qdeclarativemetatype::qmlPropertyValueInterceptorCast()
@@ -353,7 +353,7 @@ void tst_qdeclarativemetatype::qmlPropertyValueInterceptorCast()
QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueInterceptor *)&t));
QDeclarativePropertyValueInterceptor *interceptor = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(interceptor, &t);
+ QCOMPARE(interceptor, (QDeclarativePropertyValueInterceptor*)&t);
}
void tst_qdeclarativemetatype::isList()
diff --git a/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml b/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml
new file mode 100644
index 0000000..9cddf1b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+Item {
+ id: root
+ property int clicked: 0
+ property int doubleClicked: 0
+
+ MouseArea {
+ width: 200; height: 200
+ onClicked: { root.clicked++ }
+ onDoubleClicked: { root.doubleClicked++ }
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
index c9bb467..e4ec01f 100644
--- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -62,6 +62,7 @@ private slots:
void updateMouseAreaPosOnResize();
void noOnClickedWithPressAndHold();
void onMousePressRejected();
+ void doubleClick();
private:
QDeclarativeView *createView();
@@ -390,6 +391,37 @@ void tst_QDeclarativeMouseArea::onMousePressRejected()
QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
}
+void tst_QDeclarativeMouseArea::doubleClick()
+{
+ QDeclarativeView *canvas = createView();
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/doubleclick.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QGraphicsScene *scene = canvas->scene();
+ QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
+ pressEvent.setScenePos(QPointF(100, 100));
+ pressEvent.setButton(Qt::LeftButton);
+ pressEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &pressEvent);
+
+ QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
+ releaseEvent.setScenePos(QPointF(100, 100));
+ releaseEvent.setButton(Qt::LeftButton);
+ releaseEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &releaseEvent);
+
+ QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick);
+ dblClickEvent.setScenePos(QPointF(100, 100));
+ dblClickEvent.setButton(Qt::LeftButton);
+ dblClickEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &dblClickEvent);
+
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1);
+}
+
QTEST_MAIN(tst_QDeclarativeMouseArea)
#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
index a5c3772..fb3c910 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
@@ -21,6 +21,7 @@ PathView {
Rectangle {
id: wrapper
objectName: "wrapper"
+ property bool onPath: PathView.onPath
width: 20; height: 20; color: name
Text {
objectName: "myText"
diff --git a/tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml b/tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml
new file mode 100644
index 0000000..177c405
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+PathView {
+ model: emptyModel
+}
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index fdbb16d..cbfbfbd 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -84,7 +84,7 @@ private slots:
void modelChanges();
void pathUpdateOnStartChanged();
void package();
-
+ void emptyModel();
private:
QDeclarativeView *createView();
@@ -152,27 +152,27 @@ public:
QString number(int index) const { return list.at(index).second; }
void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ beginInsertRows(QModelIndex(), list.count(), list.count());
list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
+ endInsertRows();
}
void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
+ beginInsertRows(QModelIndex(), index, index);
list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
+ endInsertRows();
}
void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
+ beginRemoveRows(QModelIndex(), index, index);
list.removeAt(index);
- emit endRemoveRows();
+ endRemoveRows();
}
void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
list.move(from, to);
- emit endMoveRows();
+ endMoveRows();
}
void modifyItem(int idx, const QString &name, const QString &number) {
@@ -367,9 +367,11 @@ void tst_QDeclarativePathView::dataModel()
QCOMPARE(item->y(), 10.0);
model.insertItem(4, "orange", "10");
+ QTest::qWait(100);
+
+ QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 10);
- int itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 10);
+ QVERIFY(pathview->currentIndex() == 0);
QDeclarativeText *text = findItem<QDeclarativeText>(pathview, "myText", 4);
QVERIFY(text);
@@ -384,30 +386,38 @@ void tst_QDeclarativePathView::dataModel()
QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
- itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
+ QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
QDeclarativeRectangle *testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 4);
QVERIFY(testItem != 0);
testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 5);
QVERIFY(testItem == 0);
+ pathview->setCurrentIndex(1);
+
model.insertItem(2, "pink", "2");
+ QTest::qWait(100);
- itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
+ QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
+ QVERIFY(pathview->currentIndex() == 1);
text = findItem<QDeclarativeText>(pathview, "myText", 2);
QVERIFY(text);
QCOMPARE(text->text(), model.name(2));
model.removeItem(3);
- itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
+ QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
text = findItem<QDeclarativeText>(pathview, "myText", 3);
QVERIFY(text);
QCOMPARE(text->text(), model.name(3));
+ model.moveItem(3, 5);
+ QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
+ QList<QDeclarativeItem*> items = findItems<QDeclarativeItem>(pathview, "wrapper");
+ foreach (QDeclarativeItem *item, items) {
+ QVERIFY(item->property("onPath").toBool());
+ }
+
delete canvas;
}
@@ -755,6 +765,28 @@ void tst_QDeclarativePathView::package()
delete canvas;
}
+//QTBUG-13017
+void tst_QDeclarativePathView::emptyModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringListModel model;
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("emptyModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/emptymodel.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->offset(), qreal(0.0));
+
+ delete canvas;
+}
+
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
index 6b36224..b20d8ec 100644
--- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
+++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <private/qdeclarativepixmapcache_p.h>
#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeimageprovider.h>
#include <QNetworkReply>
#include "testhttpserver.h"
#include "../../../shared/util.h"
@@ -72,6 +73,7 @@ private slots:
void parallel_data();
void massive();
void cancelcrash();
+ void shrinkcache();
private:
QDeclarativeEngine engine;
@@ -326,6 +328,31 @@ void tst_qdeclarativepixmapcache::cancelcrash()
}
}
+class MyPixmapProvider : public QDeclarativeImageProvider
+{
+public:
+ MyPixmapProvider()
+ : QDeclarativeImageProvider(Pixmap) {}
+
+ virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) {
+ QPixmap pix(800, 600);
+ pix.fill(Qt::red);
+ return pix;
+ }
+};
+
+// QTBUG-13345
+void tst_qdeclarativepixmapcache::shrinkcache()
+{
+ QDeclarativeEngine engine;
+ engine.addImageProvider(QLatin1String("mypixmaps"), new MyPixmapProvider);
+
+ for (int ii = 0; ii < 4000; ++ii) {
+ QUrl url("image://mypixmaps/" + QString::number(ii));
+ QDeclarativePixmap p(&engine, url);
+ }
+}
+
QTEST_MAIN(tst_qdeclarativepixmapcache)
#include "tst_qdeclarativepixmapcache.moc"
diff --git a/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml b/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml
new file mode 100644
index 0000000..c9c8607
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml
@@ -0,0 +1,24 @@
+import Qt 4.7
+
+Item {
+ width: 640
+ height: 480
+ Column {
+ objectName: "column"
+ QGraphicsWidget {
+ objectName: "one"
+ width: 50
+ height: 50
+ }
+ QGraphicsWidget {
+ objectName: "two"
+ width: 20
+ height: 10
+ }
+ QGraphicsWidget {
+ objectName: "three"
+ width: 40
+ height: 20
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
index 0663991..887be50 100644
--- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -46,6 +46,7 @@
#include <private/qdeclarativepositioners_p.h>
#include <private/qdeclarativetransition_p.h>
#include <qdeclarativeexpression.h>
+#include <QtGui/qgraphicswidget.h>
#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
@@ -77,6 +78,7 @@ private slots:
void test_flow_resize();
void test_flow_implicit_resize();
void test_conflictinganchors();
+ void test_vertical_qgraphicswidget();
private:
QDeclarativeView *createView(const QString &filename);
};
@@ -771,6 +773,48 @@ void tst_QDeclarativePositioners::test_conflictinganchors()
QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
}
+void tst_QDeclarativePositioners::test_vertical_qgraphicswidget()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/verticalqgraphicswidget.qml");
+
+ QGraphicsWidget *one = canvas->rootObject()->findChild<QGraphicsWidget*>("one");
+ QVERIFY(one != 0);
+
+ QGraphicsWidget *two = canvas->rootObject()->findChild<QGraphicsWidget*>("two");
+ QVERIFY(two != 0);
+
+ QGraphicsWidget *three = canvas->rootObject()->findChild<QGraphicsWidget*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
+
+ QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ two->resize(QSizeF(two->size().width(), 20.0));
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 70.0);
+
+ two->setOpacity(0.0);
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+
+ one->setVisible(false);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
index 623b3d7..360d90f 100644
--- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -309,11 +309,14 @@ void tst_QDeclarativeRepeater::dataModel()
QCOMPARE(container->childItems().count(), 4);
+ QSignalSpy repeaterSpy(repeater, SIGNAL(countChanged()));
testModel.addItem("four", "4");
QCOMPARE(container->childItems().count(), 5);
+ QCOMPARE(repeaterSpy.count(),1);
testModel.removeItem(2);
QCOMPARE(container->childItems().count(), 4);
+ QCOMPARE(repeaterSpy.count(),2);
// Check that model changes are propagated
QDeclarativeText *text = findItem<QDeclarativeText>(canvas->rootObject(), "myName", 1);
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml
new file mode 100644
index 0000000..4ed2815
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml
@@ -0,0 +1,25 @@
+import Qt 4.7
+
+Rectangle {
+ id: root
+ width:200; height:300
+
+ Rectangle {
+ id: rectangle
+ objectName: "mover"
+ color: "green"
+ width:50; height:50
+ }
+
+ states: [
+ State {
+ name: "anchored"
+ AnchorChanges {
+ target: rectangle
+ anchors.left: root.left
+ anchors.right: root.right
+ anchors.bottom: root.bottom
+ }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/editProperties.qml b/tests/auto/declarative/qdeclarativestates/data/editProperties.qml
new file mode 100644
index 0000000..4cb1ddd
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/editProperties.qml
@@ -0,0 +1,34 @@
+import Qt 4.7
+Rectangle {
+ id: myRectangle
+
+ property color sourceColor: "blue"
+ width: 400; height: 400
+ color: "red"
+
+ Rectangle {
+ id: rect2
+ objectName: "rect2"
+ width: parent.width + 2
+ height: 200
+ color: "yellow"
+ }
+
+ states: [
+ State {
+ name: "blue"
+ PropertyChanges {
+ target: rect2
+ width:50
+ height: 40
+ }
+ },
+ State {
+ name: "green"
+ PropertyChanges {
+ target: rect2
+ width: myRectangle.width / 2
+ height: myRectangle.width / 4
+ }
+ }]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml
new file mode 100644
index 0000000..be92aba
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+
+Rectangle {
+ width: 400; height: 400
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ x: 5; y: 5
+ width: 100; height: 100
+ color: "red"
+ }
+ MouseArea {
+ id: clickable
+ anchors.fill: parent
+ }
+
+ Item {
+ id: newParent
+ rotation: 180
+ }
+
+ states: State {
+ name: "reparented"
+ when: clickable.pressed
+ ParentChange {
+ target: myRect
+ parent: newParent
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 6ae2759..0d10c10 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -48,6 +48,7 @@
#include <private/qdeclarativepropertychanges_p.h>
#include <private/qdeclarativestategroup_p.h>
#include <private/qdeclarativeitem_p.h>
+#include <private/qdeclarativeproperty_p.h>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -122,6 +123,7 @@ private slots:
void anchorChanges5();
void anchorChangesCrash();
void anchorRewindBug();
+ void anchorRewindBug2();
void script();
void restoreEntryValues();
void explicitChanges();
@@ -140,6 +142,7 @@ private slots:
void unnamedWhen();
void returnToBase();
void extendsBug();
+ void editProperties();
};
void tst_qdeclarativestates::initTestCase()
@@ -581,6 +584,21 @@ void tst_qdeclarativestates::parentChange()
//do a non-qFuzzyCompare fuzzy compare
QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
}
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange6.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(180));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(-105));
+ QCOMPARE(innerRect->y(), qreal(-105));
+ }
}
void tst_qdeclarativestates::parentChangeErrors()
@@ -843,6 +861,32 @@ void tst_qdeclarativestates::anchorRewindBug()
delete rect;
}
+// QTBUG-11834
+void tst_qdeclarativestates::anchorRewindBug2()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *mover = rect->findChild<QDeclarativeRectangle*>("mover");
+
+ QVERIFY(mover != 0);
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ QDeclarativeItemPrivate::get(rect)->setState("anchored");
+ QCOMPARE(mover->y(), qreal(250.0));
+ QCOMPARE(mover->width(), qreal(200.0));
+
+ QDeclarativeItemPrivate::get(rect)->setState("");
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ delete rect;
+}
+
void tst_qdeclarativestates::script()
{
QDeclarativeEngine engine;
@@ -1203,6 +1247,134 @@ void tst_qdeclarativestates::extendsBug()
QCOMPARE(greenRect->y(), qreal(100));
}
+void tst_qdeclarativestates::editProperties()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/editProperties.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+
+ QDeclarativeStateGroup *stateGroup = rectPrivate->_states();
+ QVERIFY(stateGroup != 0);
+ qmlExecuteDeferred(stateGroup);
+
+ QDeclarativeState *blueState = stateGroup->findState("blue");
+ QVERIFY(blueState != 0);
+ qmlExecuteDeferred(blueState);
+
+ QDeclarativePropertyChanges *propertyChangesBlue = qobject_cast<QDeclarativePropertyChanges*>(blueState->operationAt(0));
+ QVERIFY(propertyChangesBlue != 0);
+
+ QDeclarativeState *greenState = stateGroup->findState("green");
+ QVERIFY(greenState != 0);
+ qmlExecuteDeferred(greenState);
+
+ QDeclarativePropertyChanges *propertyChangesGreen = qobject_cast<QDeclarativePropertyChanges*>(greenState->operationAt(0));
+ QVERIFY(propertyChangesGreen != 0);
+
+ QDeclarativeRectangle *childRect = rect->findChild<QDeclarativeRectangle*>("rect2");
+ QVERIFY(childRect != 0);
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(50));
+ QCOMPARE(childRect->height(), qreal(40));
+ QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QVERIFY(blueState->bindingInRevertList(childRect, "width"));
+
+
+ rectPrivate->setState("green");
+ QCOMPARE(childRect->width(), qreal(200));
+ QCOMPARE(childRect->height(), qreal(100));
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+
+
+ rectPrivate->setState("");
+
+
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QVERIFY(propertyChangesBlue->containsValue("width"));
+ QVERIFY(!propertyChangesBlue->containsProperty("x"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
+ QVERIFY(!propertyChangesBlue->value("x").isValid());
+
+ propertyChangesBlue->changeValue("width", 60);
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+
+ propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
+ QVERIFY(!propertyChangesBlue->containsValue("width"));
+ QVERIFY(propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+ propertyChangesBlue->changeValue("width", 50);
+ QVERIFY(propertyChangesBlue->containsValue("width"));
+ QVERIFY(!propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(50));
+ QCOMPARE(childRect->height(), qreal(40));
+
+ propertyChangesBlue->changeValue("width", 60);
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(childRect->width(), qreal(60));
+ QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+
+ propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
+ QVERIFY(!propertyChangesBlue->containsValue("width"));
+ QVERIFY(propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QCOMPARE(childRect->width(), qreal(200));
+
+ propertyChangesBlue->changeValue("width", 50);
+ QCOMPARE(childRect->width(), qreal(50));
+
+ rectPrivate->setState("");
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+ rectPrivate->setState("green");
+ QCOMPARE(childRect->width(), qreal(200));
+ QCOMPARE(childRect->height(), qreal(100));
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+
+
+ propertyChangesGreen->removeProperty("height");
+ QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "height")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QVERIFY(greenState->containsPropertyInRevertList(childRect, "width"));
+ propertyChangesGreen->removeProperty("width");
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(!greenState->bindingInRevertList(childRect, "width"));
+ QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width"));
+
+ propertyChangesBlue->removeProperty("width");
+ QCOMPARE(childRect->width(), qreal(402));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(402));
+ QCOMPARE(childRect->height(), qreal(40));
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
index 99de219..b5c6bba 100644
--- a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
index cb85251..c9ffcc1 100644
--- a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
index ddca549..eda0d25 100644
--- a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 658f381..f683d98 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -608,6 +608,17 @@ void tst_qdeclarativetext::style()
QCOMPARE((int)textObject->style(), (int)styles.at(i));
QCOMPARE(textObject->styleColor(), QColor("white"));
}
+ QString componentStr = "import Qt 4.7\nText { text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QRectF brPre = textObject->boundingRect();
+ textObject->setStyle(QDeclarativeText::Outline);
+ QRectF brPost = textObject->boundingRect();
+
+ QVERIFY(brPre.width() < brPost.width());
+ QVERIFY(brPre.height() < brPost.height());
}
void tst_qdeclarativetext::color()
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 57a5e29..84f4230 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -777,7 +777,7 @@ void tst_qdeclarativetextedit::delegateLoading_data()
// import installed
QTest::newRow("pass") << "cursorHttpTestPass.qml" << "";
- QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "<Unknown File>: Network error for URL http://localhost:42332/FailItem.qml ";
+ QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection ";
QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type ";
}
@@ -1096,7 +1096,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, true);
ic.openInputPanelReceived = false;
- QCOMPARE(view.inputContext(), &ic);
+ QCOMPARE(view.inputContext(), (QInputContext*)&ic);
QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
// input method should be disabled if focus
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 6e15a4a..7450d35 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -98,6 +98,7 @@ private slots:
void validators();
void inputMethods();
+ void passwordCharacter();
void cursorDelegate();
void navigation();
void copyAndPaste();
@@ -193,7 +194,7 @@ void tst_qdeclarativetextinput::width()
QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
QVERIFY(textinputObject != 0);
- int delta = abs(int(textinputObject->width()) - metricWidth);
+ int delta = abs(int(int(textinputObject->width()) - metricWidth));
QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform.
delete textinputObject;
@@ -450,7 +451,7 @@ void tst_qdeclarativetextinput::positionAt()
QFontMetrics fm(textinputObject->font());
int pos = textinputObject->positionAt(textinputObject->width()/2);
- int diff = abs(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2));
+ int diff = abs(int(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2)));
// some tollerance for different fonts.
#ifdef Q_OS_LINUX
@@ -462,7 +463,7 @@ void tst_qdeclarativetextinput::positionAt()
// Check without autoscroll...
textinputObject->setAutoScroll(false);
pos = textinputObject->positionAt(textinputObject->width()/2);
- diff = abs(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2);
+ diff = abs(int(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2));
// some tollerance for different fonts.
#ifdef Q_OS_LINUX
@@ -741,9 +742,48 @@ void tst_qdeclarativetextinput::copyAndPaste() {
textInput->paste();
QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
QCOMPARE(textInput->text().length(), 24);
+
+ // clear copy buffer
+ QClipboard *clipboard = QApplication::clipboard();
+ QVERIFY(clipboard);
+ clipboard->clear();
+
+ // test that copy functionality is disabled
+ // when echo mode is set to hide text/password mode
+ int index = 0;
+ while (index < 4) {
+ QDeclarativeTextInput::EchoMode echoMode = QDeclarativeTextInput::EchoMode(index);
+ textInput->setEchoMode(echoMode);
+ textInput->setText("My password");
+ textInput->select(0, textInput->text().length());;
+ textInput->copy();
+ if (echoMode == QDeclarativeTextInput::Normal) {
+ QVERIFY(!clipboard->text().isEmpty());
+ QCOMPARE(clipboard->text(), QString("My password"));
+ clipboard->clear();
+ } else {
+ QVERIFY(clipboard->text().isEmpty());
+ }
+ index++;
+ }
#endif
}
+void tst_qdeclarativetextinput::passwordCharacter()
+{
+ QString componentStr = "import Qt 4.7\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }";
+ QDeclarativeComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textInput = qobject_cast<QDeclarativeTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->setPasswordCharacter("X");
+ QSize contentsSize = textInput->contentsSize();
+ textInput->setPasswordCharacter(".");
+ // QTBUG-12383 content is updated and redrawn
+ QVERIFY(contentsSize != textInput->contentsSize());
+}
+
void tst_qdeclarativetextinput::cursorDelegate()
{
QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");
@@ -998,7 +1038,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus()
QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, true);
ic.openInputPanelReceived = false;
- QCOMPARE(view.inputContext(), &ic);
+ QCOMPARE(view.inputContext(), (QInputContext*)&ic);
QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
// input method should be disabled if focus
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
new file mode 100644
index 0000000..c5e945a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
@@ -0,0 +1,19 @@
+import Qt 4.7
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: VisualDataModel {
+ id: visualModel
+ objectName: "visualModel"
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { objectName: "display"; text: display }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml
new file mode 100644
index 0000000..7ea74f2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Text { objectName: "name"; text: name }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml
new file mode 100644
index 0000000..6654d6b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Text { objectName: "name"; text: modelData }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index e0f32ea..d73a872 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -75,6 +75,39 @@ static void initStandardTreeModel(QStandardItemModel *model)
model->insertRow(2, item);
}
+class SingleRoleModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ SingleRoleModel(QObject *parent = 0) {
+ QHash<int, QByteArray> roles;
+ roles.insert(Qt::DisplayRole , "name");
+ setRoleNames(roles);
+ list << "one" << "two" << "three" << "four";
+ }
+
+public slots:
+ void set(int idx, QString string) {
+ list[idx] = string;
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+protected:
+ int rowCount(const QModelIndex &parent = QModelIndex()) const {
+ return list.count();
+ }
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
+ if (role == Qt::DisplayRole)
+ return list.at(index.row());
+ return QVariant();
+ }
+
+private:
+ QStringList list;
+};
+
+
class tst_qdeclarativevisualdatamodel : public QObject
{
Q_OBJECT
@@ -83,7 +116,10 @@ public:
private slots:
void rootIndex();
+ void updateLayout();
+ void childChanged();
void objectListModel();
+ void singleRole();
private:
QDeclarativeEngine engine;
@@ -155,6 +191,100 @@ void tst_qdeclarativevisualdatamodel::rootIndex()
delete obj;
}
+void tst_qdeclarativevisualdatamodel::updateLayout()
+{
+ QDeclarativeView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+
+ model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+}
+
+void tst_qdeclarativevisualdatamodel::childChanged()
+{
+ QDeclarativeView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeVisualDataModel *vdm = listview->findChild<QDeclarativeVisualDataModel*>("visualModel");
+ vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Child Item"));
+
+ model.item(1,0)->child(0,0)->setText("Row 2 updated child");
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 updated child"));
+
+ model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2")));
+ QTest::qWait(300);
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
+
+ model.item(1,0)->takeRow(1);
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name == 0);
+
+ vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
+ QTest::qWait(300);
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+}
+
void tst_qdeclarativevisualdatamodel::objectListModel()
{
QDeclarativeView view;
@@ -186,6 +316,54 @@ void tst_qdeclarativevisualdatamodel::objectListModel()
QCOMPARE(name->text(), QString("Changed"));
}
+void tst_qdeclarativevisualdatamodel::singleRole()
+{
+ {
+ QDeclarativeView view;
+
+ SingleRoleModel model;
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole1.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+ {
+ QDeclarativeView view;
+
+ SingleRoleModel model;
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole2.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+}
+
template<typename T>
T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index)
{
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html
new file mode 100644
index 0000000..b640733
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html
@@ -0,0 +1 @@
+უ Σ
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml
index a54ef4a..85bff29 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml
@@ -3,13 +3,14 @@ import Qt 4.7
QtObject {
property bool dataOK: false
+ property string fileName
property string responseText
property string responseXmlRootNodeValue
- Component.onCompleted: {
+ function startRequest() {
var x = new XMLHttpRequest;
- x.open("GET", "utf16.xml");
+ x.open("GET", fileName);
// Test to the end
x.onreadystatechange = function() {
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
index 8141fcb..89252fb 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
@@ -45,6 +45,7 @@
#include <QDebug>
#include <QNetworkCookieJar>
#include "testhttpserver.h"
+#include "../../../shared/util.h"
#define SERVER_PORT 14445
@@ -104,6 +105,7 @@ private slots:
void invalidMethodUsage();
void redirects();
void nonUtf8();
+ void nonUtf8_data();
// Attributes
void document();
@@ -155,16 +157,6 @@ void tst_qdeclarativexmlhttprequest::domExceptionCodes()
delete object;
}
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
void tst_qdeclarativexmlhttprequest::callbackException_data()
{
QTest::addColumn<QString>("which");
@@ -192,7 +184,7 @@ void tst_qdeclarativexmlhttprequest::callbackException()
object->setProperty("which", which);
component.completeCreate();
- TRY_WAIT(object->property("threw").toBool() == true);
+ QTRY_VERIFY(object->property("threw").toBool() == true);
delete object;
}
@@ -288,7 +280,7 @@ void tst_qdeclarativexmlhttprequest::open()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete server;
delete object;
@@ -371,7 +363,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -441,7 +433,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -463,7 +455,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_sent()
QCOMPARE(object->property("test").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -500,7 +492,7 @@ void tst_qdeclarativexmlhttprequest::send_alreadySent()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -522,7 +514,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -541,7 +533,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -565,7 +557,7 @@ void tst_qdeclarativexmlhttprequest::send_withdata()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -600,7 +592,7 @@ void tst_qdeclarativexmlhttprequest::abort_unsent()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -621,7 +613,7 @@ void tst_qdeclarativexmlhttprequest::abort_opened()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -646,7 +638,7 @@ void tst_qdeclarativexmlhttprequest::abort()
QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
QCOMPARE(object->property("endStateUnsent").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -673,7 +665,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader()
QCOMPARE(object->property("readyState").toBool(), true);
QCOMPARE(object->property("openedState").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("headersReceivedState").toBool(), true);
QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
@@ -721,7 +713,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader_args()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
delete object;
}
@@ -747,7 +739,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders()
QCOMPARE(object->property("readyState").toBool(), true);
QCOMPARE(object->property("openedState").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("headersReceivedState").toBool(), true);
QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
@@ -789,7 +781,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
delete object;
}
@@ -812,7 +804,7 @@ void tst_qdeclarativexmlhttprequest::status()
object->setProperty("expectedStatus", status);
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("unsentException").toBool(), true);
QCOMPARE(object->property("openedException").toBool(), true);
@@ -852,7 +844,7 @@ void tst_qdeclarativexmlhttprequest::statusText()
object->setProperty("expectedStatus", statusText);
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("unsentException").toBool(), true);
QCOMPARE(object->property("openedException").toBool(), true);
@@ -893,7 +885,7 @@ void tst_qdeclarativexmlhttprequest::responseText()
object->setProperty("expectedText", responseText);
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("unsent").toBool(), true);
QCOMPARE(object->property("opened").toBool(), true);
@@ -919,26 +911,43 @@ void tst_qdeclarativexmlhttprequest::responseText_data()
void tst_qdeclarativexmlhttprequest::nonUtf8()
{
+ QFETCH(QString, fileName);
+ QFETCH(QString, responseText);
+ QFETCH(QString, xmlRootNodeValue);
+
QDeclarativeComponent component(&engine, TEST_FILE("utf16.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
+ object->setProperty("fileName", fileName);
+ QMetaObject::invokeMethod(object, "startRequest");
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("responseText").toString(), responseText);
+
+ if (!xmlRootNodeValue.isEmpty()) {
+ QString rootNodeValue = object->property("responseXmlRootNodeValue").toString();
+ QCOMPARE(rootNodeValue, xmlRootNodeValue);
+ }
+
+ delete object;
+}
+
+void tst_qdeclarativexmlhttprequest::nonUtf8_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QString>("responseText");
+ QTest::addColumn<QString>("xmlRootNodeValue");
+
QString uc;
uc.resize(3);
uc[0] = QChar(0x10e3);
uc[1] = QChar(' ');
uc[2] = QChar(0x03a3);
- QString xml = "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone='yes'?>\n<root>\n" + uc + "\n</root>\n";
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QString responseText = object->property("responseText").toString();
- QCOMPARE(responseText, xml);
-
- QString responseXmlText = object->property("responseXmlRootNodeValue").toString();
- QCOMPARE(responseXmlText, '\n' + uc + '\n');
-
- delete object;
+ QTest::newRow("responseText") << "utf16.html" << uc + '\n' << "";
+ QTest::newRow("responseXML") << "utf16.xml" << "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone='yes'?>\n<root>\n" + uc + "\n</root>\n" << QString('\n' + uc + '\n');
}
// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
@@ -982,7 +991,7 @@ void tst_qdeclarativexmlhttprequest::redirects()
object->setProperty("expectedText", "");
component.completeCreate();
- TRY_WAIT(object->property("done").toBool() == true);
+ QTRY_VERIFY(object->property("done").toBool() == true);
QCOMPARE(object->property("dataOK").toBool(), true);
delete object;
@@ -1001,7 +1010,7 @@ void tst_qdeclarativexmlhttprequest::redirects()
object->setProperty("expectedText", "");
component.completeCreate();
- TRY_WAIT(object->property("done").toBool() == true);
+ QTRY_VERIFY(object->property("done").toBool() == true);
QCOMPARE(object->property("dataOK").toBool(), true);
delete object;
@@ -1038,7 +1047,7 @@ void tst_qdeclarativexmlhttprequest::responseXML_invalid()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlNull").toBool(), true);
@@ -1052,7 +1061,7 @@ void tst_qdeclarativexmlhttprequest::document()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1066,7 +1075,7 @@ void tst_qdeclarativexmlhttprequest::element()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1080,7 +1089,7 @@ void tst_qdeclarativexmlhttprequest::attr()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1094,7 +1103,7 @@ void tst_qdeclarativexmlhttprequest::text()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1108,7 +1117,7 @@ void tst_qdeclarativexmlhttprequest::cdata()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
diff --git a/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
index 8ba9d45..0f6d531 100644
--- a/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+++ b/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
@@ -558,7 +558,7 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(prop1.isWritable());
QVERIFY(!prop1.isResettable());
QVERIFY(!prop1.isDesignable());
- QVERIFY(!prop1.isScriptable());
+ QVERIFY(prop1.isScriptable());
QVERIFY(!prop1.isStored());
QVERIFY(!prop1.isEditable());
QVERIFY(!prop1.isUser());
@@ -577,7 +577,7 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(prop2.isWritable());
QVERIFY(!prop2.isResettable());
QVERIFY(!prop2.isDesignable());
- QVERIFY(!prop2.isScriptable());
+ QVERIFY(prop2.isScriptable());
QVERIFY(!prop2.isStored());
QVERIFY(!prop2.isEditable());
QVERIFY(!prop2.isUser());
@@ -599,7 +599,7 @@ void tst_QMetaObjectBuilder::property()
prop1.setWritable(false);
prop1.setResettable(true);
prop1.setDesignable(true);
- prop1.setScriptable(true);
+ prop1.setScriptable(false);
prop1.setStored(true);
prop1.setEditable(true);
prop1.setUser(true);
@@ -614,7 +614,7 @@ void tst_QMetaObjectBuilder::property()
QVERIFY(!prop1.isWritable());
QVERIFY(prop1.isResettable());
QVERIFY(prop1.isDesignable());
- QVERIFY(prop1.isScriptable());
+ QVERIFY(!prop1.isScriptable());
QVERIFY(prop1.isStored());
QVERIFY(prop1.isEditable());
QVERIFY(prop1.isUser());
@@ -627,7 +627,7 @@ void tst_QMetaObjectBuilder::property()
QCOMPARE(prop2.type(), QByteArray("int"));
QVERIFY(!prop2.isResettable());
QVERIFY(!prop2.isDesignable());
- QVERIFY(!prop2.isScriptable());
+ QVERIFY(prop2.isScriptable());
QVERIFY(!prop2.isStored());
QVERIFY(!prop2.isEditable());
QVERIFY(!prop2.isUser());
@@ -643,7 +643,7 @@ void tst_QMetaObjectBuilder::property()
QCOMPARE(prop2.type(), QByteArray("int"));
QVERIFY(!prop2.isResettable());
QVERIFY(!prop2.isDesignable());
- QVERIFY(!prop2.isScriptable());
+ QVERIFY(prop2.isScriptable());
QVERIFY(!prop2.isStored());
QVERIFY(!prop2.isEditable());
QVERIFY(!prop2.isUser());
diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.0.png b/tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.0.png
new file mode 100644
index 0000000..16adc51
--- /dev/null
+++ b/tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.0.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.qml b/tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.qml
new file mode 100644
index 0000000..0cc98ce
--- /dev/null
+++ b/tests/auto/declarative/qmlvisual/animation/qtbug13398/data/qtbug13398.qml
@@ -0,0 +1,447 @@
+import Qt.VisualTest 4.7
+
+VisualTest {
+ Frame {
+ msec: 0
+ }
+ Frame {
+ msec: 16
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 32
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 48
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 64
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 80
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 96
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 112
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 128
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 144
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 160
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 176
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 192
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 208
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 224
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 240
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 256
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 272
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 288
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 304
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 320
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 336
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 352
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 368
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 384
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 400
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 416
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 432
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 448
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 464
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 480
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 496
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Mouse {
+ type: 2
+ button: 1
+ buttons: 1
+ x: 220; y: 270
+ modifiers: 0
+ sendToViewport: true
+ }
+ Frame {
+ msec: 512
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 528
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 544
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 560
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 576
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Mouse {
+ type: 5
+ button: 0
+ buttons: 1
+ x: 220; y: 271
+ modifiers: 0
+ sendToViewport: true
+ }
+ Mouse {
+ type: 3
+ button: 1
+ buttons: 0
+ x: 220; y: 271
+ modifiers: 0
+ sendToViewport: true
+ }
+ Frame {
+ msec: 592
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+ Frame {
+ msec: 608
+ hash: "96e8e81d61bffe02b8f41f47a4a7e8fc"
+ }
+ Frame {
+ msec: 624
+ hash: "75881a2779bd7d7f683f87c4a7393769"
+ }
+ Frame {
+ msec: 640
+ hash: "2ef628328d2a6393095e78db80b0513f"
+ }
+ Frame {
+ msec: 656
+ hash: "390926f2c2c27dfa10c9b393ee466ce6"
+ }
+ Frame {
+ msec: 672
+ hash: "ea07d93e7d8a53f56cff19d9d3b282a4"
+ }
+ Frame {
+ msec: 688
+ hash: "8aa6be919b1ef4b7e102a319a453707e"
+ }
+ Frame {
+ msec: 704
+ hash: "6ebc518fb53ffe42fca20b9f16a21b36"
+ }
+ Frame {
+ msec: 720
+ hash: "ee7a93b157e24e22efa84604e7e44fe6"
+ }
+ Frame {
+ msec: 736
+ hash: "de3bf8f67e51b036db4976fd3b4b6c3c"
+ }
+ Frame {
+ msec: 752
+ hash: "648be4298ebe3bbc7e5c4a4c9c46f193"
+ }
+ Frame {
+ msec: 768
+ hash: "1ccf3b73e22a4b98ce1df098af9466f2"
+ }
+ Frame {
+ msec: 784
+ hash: "73a2fb047728b2b8e613f0fb8dfe429d"
+ }
+ Frame {
+ msec: 800
+ hash: "bbb4cabec4b98ea8ca94dff91a0d8c99"
+ }
+ Frame {
+ msec: 816
+ hash: "3337e86bd9fcfbce939389928fb1fb72"
+ }
+ Frame {
+ msec: 832
+ hash: "cb4a2a330e8470c61de9e9b6d2dc4597"
+ }
+ Frame {
+ msec: 848
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 864
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 880
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 896
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 912
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 928
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 944
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 960
+ image: "qtbug13398.0.png"
+ }
+ Frame {
+ msec: 976
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 992
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1008
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1024
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1040
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1056
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1072
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1088
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1104
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1120
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1136
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1152
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1168
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1184
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1200
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1216
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1232
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Mouse {
+ type: 2
+ button: 1
+ buttons: 1
+ x: 220; y: 271
+ modifiers: 0
+ sendToViewport: true
+ }
+ Frame {
+ msec: 1248
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1264
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1280
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1296
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1312
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1328
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Mouse {
+ type: 3
+ button: 1
+ buttons: 0
+ x: 220; y: 271
+ modifiers: 0
+ sendToViewport: true
+ }
+ Frame {
+ msec: 1344
+ hash: "e09a359578935b988ac1cc8c40b25547"
+ }
+ Frame {
+ msec: 1360
+ hash: "697a4fd182ff90cd557f224174bad43a"
+ }
+ Frame {
+ msec: 1376
+ hash: "99e5ca9a77df1acfed628f31b9050179"
+ }
+ Frame {
+ msec: 1392
+ hash: "1f0dc00d3e3536b40a6becf775b31cee"
+ }
+ Frame {
+ msec: 1408
+ hash: "5b81ddd35d74be222bc8a40d2573884b"
+ }
+ Frame {
+ msec: 1424
+ hash: "4e236f5de69048e87add0e4380f2c3e6"
+ }
+ Frame {
+ msec: 1440
+ hash: "a901c9c0c77e03d98a2b95267cca8514"
+ }
+ Frame {
+ msec: 1456
+ hash: "78bbdf6781c2968c67982ffdb747dbbe"
+ }
+ Frame {
+ msec: 1472
+ hash: "a245ca593649f60980be982eb8fda57e"
+ }
+ Frame {
+ msec: 1488
+ hash: "c27fddc147749da24eaeb92aeaf61738"
+ }
+ Frame {
+ msec: 1504
+ hash: "b9674af46b618dc1eedabd4f18253b11"
+ }
+ Frame {
+ msec: 1520
+ hash: "8ae3c0cc0888fd0a607bc5b537a9ce0a"
+ }
+ Frame {
+ msec: 1536
+ hash: "f1981bd3fb08233622a4078e2f717011"
+ }
+ Frame {
+ msec: 1552
+ hash: "4dce834c9e3988fe535391fedc942add"
+ }
+ Frame {
+ msec: 1568
+ hash: "ca7356dee61e156d04b0b46ea033498e"
+ }
+ Frame {
+ msec: 1584
+ hash: "97499f6e04cbe690bc12458aef4b66a5"
+ }
+ Frame {
+ msec: 1600
+ hash: "2452007928bf86b9c42e666c7a7afc89"
+ }
+}
diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug13398/qtbug13398.qml b/tests/auto/declarative/qmlvisual/animation/qtbug13398/qtbug13398.qml
new file mode 100644
index 0000000..8f388bc
--- /dev/null
+++ b/tests/auto/declarative/qmlvisual/animation/qtbug13398/qtbug13398.qml
@@ -0,0 +1,68 @@
+import Qt 4.7
+
+Item {
+ width: 300
+ height: 400
+
+ Rectangle {
+ id: root
+ color: "darkkhaki"
+
+ x: 50
+ y: 50
+
+ width: 200
+ height: 300
+
+ Rectangle {
+ id: statusbar
+ color: "chocolate"
+
+ height: 30
+
+ anchors.top: root.top
+ anchors.left: root.left
+ anchors.right: root.right
+ }
+
+ Rectangle {
+ id: titlebar
+ color: "crimson"
+
+ height: 60
+
+ anchors.top: statusbar.bottom
+ anchors.left: root.left
+ anchors.right: root.right
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ root.state = root.state ? "" : "fullscreen";
+ }
+ }
+
+ states: [
+ State {
+ name: "fullscreen"
+ AnchorChanges {
+ target: statusbar
+ anchors.top: undefined
+ anchors.bottom: titlebar.top
+ }
+ AnchorChanges {
+ target: titlebar
+ anchors.top: undefined
+ anchors.bottom: root.top
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ AnchorAnimation { }
+ }
+ ]
+ }
+}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.0.png b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.0.png
new file mode 100644
index 0000000..bf02e1a
--- /dev/null
+++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.0.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.1.png b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.1.png
new file mode 100644
index 0000000..ae71dc8
--- /dev/null
+++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.2.png b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.2.png
new file mode 100644
index 0000000..6f631b0
--- /dev/null
+++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.2.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.qml b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.qml
new file mode 100644
index 0000000..3124973
--- /dev/null
+++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/data/smoothedfollow.qml
@@ -0,0 +1,795 @@
+import Qt.VisualTest 4.7
+
+VisualTest {
+ Frame {
+ msec: 0
+ }
+ Frame {
+ msec: 16
+ hash: "2c6600b50a18c415032fa95fe5089da6"
+ }
+ Frame {
+ msec: 32
+ hash: "aefd5a2570cc0252be102644ec1e49e3"
+ }
+ Frame {
+ msec: 48
+ hash: "6183d0554a8b812bee02719dc4df21d1"
+ }
+ Frame {
+ msec: 64
+ hash: "e1b3a94d033626338de0e04dba7b6df9"
+ }
+ Frame {
+ msec: 80
+ hash: "7d1a5a265fb20ac4d741d76ab7b3a41f"
+ }
+ Frame {
+ msec: 96
+ hash: "0ce7d2acda3e5ccb7b2364e2a7b409a4"
+ }
+ Frame {
+ msec: 112
+ hash: "21f3a66ee80fcb2dd4dce0d1666aa4dd"
+ }
+ Frame {
+ msec: 128
+ hash: "ea5b81ff2805210111cb388ab9be0d8f"
+ }
+ Frame {
+ msec: 144
+ hash: "a8a54a3c524dcf6777b71d99ae2d50bd"
+ }
+ Frame {
+ msec: 160
+ hash: "6b658c468af8a88e4a282d57fdcbc3b0"
+ }
+ Frame {
+ msec: 176
+ hash: "986121c9d928cc9ceb912a975f75760a"
+ }
+ Frame {
+ msec: 192
+ hash: "4bf3593d0edc4347cf77670a48ba4440"
+ }
+ Frame {
+ msec: 208
+ hash: "ea00f25295fb019f949930fb7109ceb4"
+ }
+ Frame {
+ msec: 224
+ hash: "ad6cc7563e2720c405842317d0ce731a"
+ }
+ Frame {
+ msec: 240
+ hash: "8a03a1207cdb5bd92f5227b25a7b638e"
+ }
+ Frame {
+ msec: 256
+ hash: "f355321aa47d18e8b6dde503565d0e97"
+ }
+ Frame {
+ msec: 272
+ hash: "e18f671cac8e68948f32a468bf2630cf"
+ }
+ Frame {
+ msec: 288
+ hash: "264bca92fba53f25439d240afef62880"
+ }
+ Frame {
+ msec: 304
+ hash: "a1a226c73fb97d5302ce683f901ee5c4"
+ }
+ Frame {
+ msec: 320
+ hash: "05578552476372fc58e463e84a147ddd"
+ }
+ Frame {
+ msec: 336
+ hash: "0a3e0a651f9eb3e6a44a55a6786e60ff"
+ }
+ Frame {
+ msec: 352
+ hash: "4ca362f079f96a01360ee8062fbb8238"
+ }
+ Frame {
+ msec: 368
+ hash: "ba512c117d97ce16ff92d03ce2b08056"
+ }
+ Frame {
+ msec: 384
+ hash: "8688355f0f97afe000d02f71c841d5dc"
+ }
+ Frame {
+ msec: 400
+ hash: "a2ea6ad008da95a67d3bc70e11e3811d"
+ }
+ Frame {
+ msec: 416
+ hash: "83bc9c444ab8618438dc2b8b14716f7b"
+ }
+ Frame {
+ msec: 432
+ hash: "fafbba34fc8f9d33b559e6fcd0c5f1c6"
+ }
+ Frame {
+ msec: 448
+ hash: "92d245951b759f74182602a7a337cb0f"
+ }
+ Frame {
+ msec: 464
+ hash: "e0634d25088a6855df8d86d84fe37cd7"
+ }
+ Frame {
+ msec: 480
+ hash: "7f4d05f4c3b1a365732e448f2c751740"
+ }
+ Frame {
+ msec: 496
+ hash: "fcd6f55929f753f77b1617c0984b8690"
+ }
+ Frame {
+ msec: 512
+ hash: "7e88f100a7012d739cd3c97c4e7f4b45"
+ }
+ Frame {
+ msec: 528
+ hash: "8f9d029b3850ee2f11cdf6630d100682"
+ }
+ Frame {
+ msec: 544
+ hash: "b915f712b24f187ee759b3337fb0df7a"
+ }
+ Frame {
+ msec: 560
+ hash: "eae400a0c72d38156f7ae0f16ab9ee66"
+ }
+ Frame {
+ msec: 576
+ hash: "e913a1e317cca355b06a393f44cc0243"
+ }
+ Frame {
+ msec: 592
+ hash: "abf075ea63a6f5cce43c38e20dbcdbb2"
+ }
+ Frame {
+ msec: 608
+ hash: "a6e85caa1eb933343a4605bc434e2841"
+ }
+ Frame {
+ msec: 624
+ hash: "8e33e2582dd127d3f04017bf493b0ac6"
+ }
+ Frame {
+ msec: 640
+ hash: "959e4062262bcc759abfc7b0bf3e10b6"
+ }
+ Frame {
+ msec: 656
+ hash: "9529e2241df0d90ea640fdb3752b0837"
+ }
+ Frame {
+ msec: 672
+ hash: "5595b64495996ce66b5f6892e9457456"
+ }
+ Frame {
+ msec: 688
+ hash: "532259c3577553622093eba907ae82d3"
+ }
+ Frame {
+ msec: 704
+ hash: "85c4332100b6f5256702b594c83f4eff"
+ }
+ Frame {
+ msec: 720
+ hash: "b96292d85b12fa8e68c5de3deb29b980"
+ }
+ Frame {
+ msec: 736
+ hash: "64febec9c8b58e2b93249f19c57b7aba"
+ }
+ Frame {
+ msec: 752
+ hash: "88e588af29131cf942e02b1080e564e5"
+ }
+ Frame {
+ msec: 768
+ hash: "07f911478be2f36d0c1b9cb878f4fe47"
+ }
+ Frame {
+ msec: 784
+ hash: "8ffbf2381efefcbca413f6e3455018fb"
+ }
+ Frame {
+ msec: 800
+ hash: "6e456af680e40799d3f38bdde29a85f9"
+ }
+ Frame {
+ msec: 816
+ hash: "48a8dbc64d7823164c992f55b270115d"
+ }
+ Frame {
+ msec: 832
+ hash: "a6d28eb1d0aafd387e35ca7b362bec53"
+ }
+ Frame {
+ msec: 848
+ hash: "2e9f2b2ebf1b24f01fc986ded320d7c9"
+ }
+ Frame {
+ msec: 864
+ hash: "d0cafd9be3263193c207c39eeb051bb8"
+ }
+ Frame {
+ msec: 880
+ hash: "8dee1a5365fa3ccd7036c8afa6a805cc"
+ }
+ Frame {
+ msec: 896
+ hash: "42f893afb80633f0ffb82f1725bb097f"
+ }
+ Frame {
+ msec: 912
+ hash: "f466a404940abcd4c8f3180696da1a29"
+ }
+ Frame {
+ msec: 928
+ hash: "e5746e33b3eb155a354bc5900b7593ee"
+ }
+ Frame {
+ msec: 944
+ hash: "a1c2eb7048356f4ebc803d9d5439db24"
+ }
+ Frame {
+ msec: 960
+ image: "smoothedfollow.0.png"
+ }
+ Frame {
+ msec: 976
+ hash: "338aec0e679a8f2e79f6a5503dfbd6c3"
+ }
+ Frame {
+ msec: 992
+ hash: "59321f1eb26c379e9e2a37b6890d922d"
+ }
+ Frame {
+ msec: 1008
+ hash: "f37a821b9cf9f67fd011c6790a2757f0"
+ }
+ Frame {
+ msec: 1024
+ hash: "c3f1b8722c616ecd55d8496e76a9bf06"
+ }
+ Frame {
+ msec: 1040
+ hash: "ca6aff9addda2e3ac51e5e2013393365"
+ }
+ Frame {
+ msec: 1056
+ hash: "17d1aa7821ce8169a3100a3cd3a0df2b"
+ }
+ Frame {
+ msec: 1072
+ hash: "d85dd272f35868d6832316e862db4ec1"
+ }
+ Frame {
+ msec: 1088
+ hash: "8bce5bdadfa974655dc7e020ad43edeb"
+ }
+ Frame {
+ msec: 1104
+ hash: "b97f71587a5187d5175e5d9f1409c00a"
+ }
+ Frame {
+ msec: 1120
+ hash: "53d438e601c25aebfd2ecb0064cdf5cc"
+ }
+ Frame {
+ msec: 1136
+ hash: "18c43dd35b3e0d8f9ab5c8de3e48886a"
+ }
+ Frame {
+ msec: 1152
+ hash: "e4ab585684d083de118b7862ef5cbd63"
+ }
+ Frame {
+ msec: 1168
+ hash: "48ab046a2e2ca1a1225574b94925482e"
+ }
+ Frame {
+ msec: 1184
+ hash: "c4bd06a5c329ef6975a60453f588bce7"
+ }
+ Frame {
+ msec: 1200
+ hash: "864393a984dce3e9dd2daec56ddb3fe7"
+ }
+ Frame {
+ msec: 1216
+ hash: "fcdf4cfcd8a6d8667868ba9633475fe0"
+ }
+ Frame {
+ msec: 1232
+ hash: "5ac2b96158045c9b9eb35f1cbabe5b1f"
+ }
+ Frame {
+ msec: 1248
+ hash: "83c409e5d3e6fe9e953d9ce14d731b3b"
+ }
+ Frame {
+ msec: 1264
+ hash: "01805526b04e17b89238e7b929be48dd"
+ }
+ Frame {
+ msec: 1280
+ hash: "4708345219b3732f9aaf8b40645f65d2"
+ }
+ Frame {
+ msec: 1296
+ hash: "12716f84b6f648df2cbe08cfea58764c"
+ }
+ Frame {
+ msec: 1312
+ hash: "6cce1e6354bd338f364bcca84a5fd081"
+ }
+ Frame {
+ msec: 1328
+ hash: "c5da6f6b00402e0de00490792b963cdf"
+ }
+ Frame {
+ msec: 1344
+ hash: "0eacadf69c0818e818abaf3aaf823aff"
+ }
+ Frame {
+ msec: 1360
+ hash: "c68cd79bf0d329a3c672896b9ce2044d"
+ }
+ Frame {
+ msec: 1376
+ hash: "26786f921ddddd9d2f975e1193943d2d"
+ }
+ Frame {
+ msec: 1392
+ hash: "68c7c1779bb19ee5cd9370b5c06f4ce7"
+ }
+ Frame {
+ msec: 1408
+ hash: "5e87c3e00ef7fab01c17d9e89c661aab"
+ }
+ Frame {
+ msec: 1424
+ hash: "0b459122be303c38d3564dd7fea53fc1"
+ }
+ Frame {
+ msec: 1440
+ hash: "3b13101a45b470fd04fa02f34548984b"
+ }
+ Frame {
+ msec: 1456
+ hash: "6308fa1ed015bb698251af0d1b9be084"
+ }
+ Frame {
+ msec: 1472
+ hash: "f219427d8fdf826f33351ba64db55d33"
+ }
+ Frame {
+ msec: 1488
+ hash: "0c9ad8c5224d3cdefb8ac793cac3ca79"
+ }
+ Frame {
+ msec: 1504
+ hash: "38438307162bceef76afb043c82b6a82"
+ }
+ Frame {
+ msec: 1520
+ hash: "78b367e6bab0463fe08f5e634cfbced2"
+ }
+ Frame {
+ msec: 1536
+ hash: "81e56f9d3bb9b360a07dc85697a59340"
+ }
+ Frame {
+ msec: 1552
+ hash: "cef4fdb8c12485d3590e598090312297"
+ }
+ Frame {
+ msec: 1568
+ hash: "8ea0c90a100c583558f92843030543cc"
+ }
+ Frame {
+ msec: 1584
+ hash: "0037f0f17a50bdfe3bf0de810ff837f1"
+ }
+ Frame {
+ msec: 1600
+ hash: "2b060ac0dfa045b916d3fd5ff6f84bfb"
+ }
+ Frame {
+ msec: 1616
+ hash: "b20705dcc6176efd83cff6927991ff0a"
+ }
+ Frame {
+ msec: 1632
+ hash: "0af69e490bdc54f27d3e50c1fdfd12a8"
+ }
+ Frame {
+ msec: 1648
+ hash: "8e4cceadc01de5b51082889efabcbb7e"
+ }
+ Frame {
+ msec: 1664
+ hash: "b64958786a7007686fb1734783d553f5"
+ }
+ Frame {
+ msec: 1680
+ hash: "e0b9d98bb3a596fd235d58b6a761a0e0"
+ }
+ Frame {
+ msec: 1696
+ hash: "1a5d7dc4dfd3ee86a36978d4effd299c"
+ }
+ Frame {
+ msec: 1712
+ hash: "4946561f008635599651bf24b9aa0594"
+ }
+ Frame {
+ msec: 1728
+ hash: "8427d33046af64c6e63939238c101e86"
+ }
+ Frame {
+ msec: 1744
+ hash: "cdcfab5cea86c33f276c3613d76067c4"
+ }
+ Frame {
+ msec: 1760
+ hash: "966005d62bd69b53d77459e5ab65116c"
+ }
+ Frame {
+ msec: 1776
+ hash: "8a3c4ff083a973325c4ab09e09027ef6"
+ }
+ Frame {
+ msec: 1792
+ hash: "737ffd6f52fa3d812ecaf835a30495af"
+ }
+ Frame {
+ msec: 1808
+ hash: "6731007c97ba3ba60e73ab50803868e5"
+ }
+ Frame {
+ msec: 1824
+ hash: "caa4ea08c5c330e77a7445cc1adf1666"
+ }
+ Frame {
+ msec: 1840
+ hash: "73778bfbae55a81557a128acb4a197c8"
+ }
+ Frame {
+ msec: 1856
+ hash: "7d8609f1336ddf4e25b505e54142114e"
+ }
+ Frame {
+ msec: 1872
+ hash: "d8b4514d2bd77dbe67e27d400dc1a2f3"
+ }
+ Frame {
+ msec: 1888
+ hash: "ac3e7040f1e9fc680f52f46d25eb3faa"
+ }
+ Frame {
+ msec: 1904
+ hash: "509c21774f0fca9dde0657133a1cc363"
+ }
+ Frame {
+ msec: 1920
+ image: "smoothedfollow.1.png"
+ }
+ Frame {
+ msec: 1936
+ hash: "545bcb0c362a083ee698a5c8cd225014"
+ }
+ Frame {
+ msec: 1952
+ hash: "77370c9b2880c55fecf07457dd0d455b"
+ }
+ Frame {
+ msec: 1968
+ hash: "6c44209f31f5f010f1b3e05490468821"
+ }
+ Frame {
+ msec: 1984
+ hash: "2dffac0c44e52f2984525d3d3700e6ed"
+ }
+ Frame {
+ msec: 2000
+ hash: "d70f2db1b166b2de3bef74bc4bf94a80"
+ }
+ Frame {
+ msec: 2016
+ hash: "50e4f6a82f498066fc9b6588762f59f9"
+ }
+ Frame {
+ msec: 2032
+ hash: "956a7d7db9aef1b7abefac1a69622f02"
+ }
+ Frame {
+ msec: 2048
+ hash: "13f19d5baefb6c8c9f71c16163663a27"
+ }
+ Frame {
+ msec: 2064
+ hash: "076ff84405ddb29a12ed30d27cee558b"
+ }
+ Frame {
+ msec: 2080
+ hash: "6af0261639f809da8f7e4831559596d3"
+ }
+ Frame {
+ msec: 2096
+ hash: "a0500b18e99bfe3a48d52cc62b4a946b"
+ }
+ Frame {
+ msec: 2112
+ hash: "bb0ea576c9136fb70720d4540731d2ca"
+ }
+ Frame {
+ msec: 2128
+ hash: "d9b12ad9bf54d7db0ef1b36297a6dd6c"
+ }
+ Frame {
+ msec: 2144
+ hash: "2de77e082872f072a849ba9ea93e3aec"
+ }
+ Frame {
+ msec: 2160
+ hash: "69e186c3e8e6b2c75da2ca87043129da"
+ }
+ Frame {
+ msec: 2176
+ hash: "0c2f23b0cbedb45a68f0cbe6132b4820"
+ }
+ Frame {
+ msec: 2192
+ hash: "533bad00e5624611ea8a15d5fa98f0f2"
+ }
+ Frame {
+ msec: 2208
+ hash: "d9c60bc821205aa4ea38d846e5b00f3a"
+ }
+ Frame {
+ msec: 2224
+ hash: "d4de041edf15c6b6806d7f5992146711"
+ }
+ Frame {
+ msec: 2240
+ hash: "100145df5271efaaee1d619bd50b69fc"
+ }
+ Frame {
+ msec: 2256
+ hash: "22905b794fee24f3a25e4944d5505e96"
+ }
+ Frame {
+ msec: 2272
+ hash: "aeed7adea08fe6e8b60310082cf87b6c"
+ }
+ Frame {
+ msec: 2288
+ hash: "82bf8d40b6ed8aae9d6172eae76d1859"
+ }
+ Frame {
+ msec: 2304
+ hash: "b1881778936744db3df0898638e4b0df"
+ }
+ Frame {
+ msec: 2320
+ hash: "87195016996f8786a8a2430c54f13494"
+ }
+ Frame {
+ msec: 2336
+ hash: "56f99b14320662b90eb10e77845bba30"
+ }
+ Frame {
+ msec: 2352
+ hash: "69a84022d8d2b3cdb1d7eae6ce5ccef2"
+ }
+ Frame {
+ msec: 2368
+ hash: "578ca8c66da6aa64392b253ab6cccbc0"
+ }
+ Frame {
+ msec: 2384
+ hash: "4c2058e4708001f82f3bcb8110d6a54f"
+ }
+ Frame {
+ msec: 2400
+ hash: "a838be752168bc6feb3151327147bb23"
+ }
+ Frame {
+ msec: 2416
+ hash: "bf6cde06f0ee814cd4a23f3d43e7d270"
+ }
+ Frame {
+ msec: 2432
+ hash: "9162ec43bc84261c0eb9ea2425da0b8a"
+ }
+ Frame {
+ msec: 2448
+ hash: "7be19df0ee54f9bb31ebee2d786addc8"
+ }
+ Frame {
+ msec: 2464
+ hash: "542a4c004f5b1b8efa7588b27cc2ba43"
+ }
+ Frame {
+ msec: 2480
+ hash: "f9e2edd343be212a9679f1e2ad0e73b3"
+ }
+ Frame {
+ msec: 2496
+ hash: "b6d4e9169fc4446cdbd3a36f485b943b"
+ }
+ Frame {
+ msec: 2512
+ hash: "0d3b7a652a94162b71e88ed213559af4"
+ }
+ Frame {
+ msec: 2528
+ hash: "9d4a2383a4d43ac94ff0a344f217b22d"
+ }
+ Frame {
+ msec: 2544
+ hash: "719d402379c40de5cd6d4c8fa92f5472"
+ }
+ Frame {
+ msec: 2560
+ hash: "78fb55f5b9c2033a91e41100229e4465"
+ }
+ Frame {
+ msec: 2576
+ hash: "0a9ec91eee6c7c770ce2e414fa881229"
+ }
+ Frame {
+ msec: 2592
+ hash: "5d9f81f1becf486a09f086e15a64d1f0"
+ }
+ Frame {
+ msec: 2608
+ hash: "0f5e18af1eac31e6993ea2df51a143f0"
+ }
+ Frame {
+ msec: 2624
+ hash: "08a292373756b06c3a624b8f3bf06236"
+ }
+ Frame {
+ msec: 2640
+ hash: "f3c8101429753ce8f0ee094fe0db98ac"
+ }
+ Frame {
+ msec: 2656
+ hash: "1603ad220d68ae0a2f613687533c2ebc"
+ }
+ Frame {
+ msec: 2672
+ hash: "e2b8049d18fd36fff0180bd4bc199732"
+ }
+ Frame {
+ msec: 2688
+ hash: "d1bfeadaa9046ec5013734938a8f4af1"
+ }
+ Frame {
+ msec: 2704
+ hash: "3cb3a0e9dc73e76101288395ffeb2b7b"
+ }
+ Frame {
+ msec: 2720
+ hash: "104a10e6bd48dacfedf5c98cf641ae93"
+ }
+ Frame {
+ msec: 2736
+ hash: "f04a2985e7c203dd6fce46b60fcb23fc"
+ }
+ Frame {
+ msec: 2752
+ hash: "30cb747f4604c208d7dc697d5fe2af6b"
+ }
+ Frame {
+ msec: 2768
+ hash: "b9eca6ee8fe29351cadeb9a2caf36fa6"
+ }
+ Frame {
+ msec: 2784
+ hash: "7bc56e712d713a00a684e07cf3d09907"
+ }
+ Frame {
+ msec: 2800
+ hash: "0d7a5e2ff588b71e77abb72723c763b2"
+ }
+ Frame {
+ msec: 2816
+ hash: "0d961843e54cbe5ba76c11bcd634bc39"
+ }
+ Frame {
+ msec: 2832
+ hash: "6328b52965a002944c501d9888928caa"
+ }
+ Frame {
+ msec: 2848
+ hash: "63e668a7688167b604b641929843d0cf"
+ }
+ Frame {
+ msec: 2864
+ hash: "7f5e71332268be68de9dcb25f173d2e0"
+ }
+ Frame {
+ msec: 2880
+ image: "smoothedfollow.2.png"
+ }
+ Frame {
+ msec: 2896
+ hash: "dc6e83fcc5a403913a94c498f1571098"
+ }
+ Frame {
+ msec: 2912
+ hash: "8deb275bd08df9b3abdcf3e2796a0601"
+ }
+ Frame {
+ msec: 2928
+ hash: "6c08a25a442b97a8cb359792b6a01641"
+ }
+ Frame {
+ msec: 2944
+ hash: "5f7ccd5706c77f0b0ddced41ed6352d8"
+ }
+ Frame {
+ msec: 2960
+ hash: "6668d1936524f0fdc490720a962a3698"
+ }
+ Frame {
+ msec: 2976
+ hash: "e36f901fb4b8ad754592642a7575e4ee"
+ }
+ Frame {
+ msec: 2992
+ hash: "7453182980e458d827f3ff83aa3f2c88"
+ }
+ Frame {
+ msec: 3008
+ hash: "0e15d75b2a7f2e4a39906093b930d6a8"
+ }
+ Frame {
+ msec: 3024
+ hash: "822ccc6c629eabf38fd5ac56abb638f5"
+ }
+ Frame {
+ msec: 3040
+ hash: "331ef5b3e3dd5642f8532d337fd22def"
+ }
+ Frame {
+ msec: 3056
+ hash: "3c29aae83f28239f31125ef02f523d02"
+ }
+ Frame {
+ msec: 3072
+ hash: "56ed674bf2d345861eb235a4239078e2"
+ }
+ Frame {
+ msec: 3088
+ hash: "5412b9ad01a6780b67bc59b80a274cd5"
+ }
+ Frame {
+ msec: 3104
+ hash: "a6f9ae09a7386f06a84c251083660dd6"
+ }
+ Frame {
+ msec: 3120
+ hash: "83f07277c9bec7419dd6a4d40d8accf7"
+ }
+ Frame {
+ msec: 3136
+ hash: "e6cb74961dfef68a32f255176e0ebff3"
+ }
+ Frame {
+ msec: 3152
+ hash: "9e6c3ac0190beaf30754155a5d64b81c"
+ }
+}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml
index 0df727b..63dba47 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml
@@ -1,15 +1,15 @@
import Qt 4.7
Rectangle {
- width: 800; height: 240; color: "gray"
+ width: 800; height: 720; color: "gray"
Rectangle {
id: rect
width: 50; height: 20; y: 30; color: "black"
SequentialAnimation on x {
loops: Animation.Infinite
- NumberAnimation { from: 50; to: 700; duration: 2000 }
- NumberAnimation { from: 700; to: 50; duration: 2000 }
+ NumberAnimation { from: 50; to: 700; duration: 1000 }
+ NumberAnimation { from: 700; to: 50; duration: 1000 }
}
}
@@ -25,16 +25,104 @@ Rectangle {
Rectangle {
width: 50; height: 20; x: rect.x; y: 120; color: "green"
- Behavior on x { SmoothedAnimation { reversingMode: SmoothedAnimation.Sync } }
+ Behavior on x { SmoothedAnimation { velocity: 200; reversingMode: SmoothedAnimation.Sync } }
}
Rectangle {
width: 50; height: 20; x: rect.x; y: 150; color: "purple"
- Behavior on x { SmoothedAnimation { maximumEasingTime: 200 } }
+ Behavior on x { SmoothedAnimation { velocity: 200; maximumEasingTime: 100 } }
}
Rectangle {
width: 50; height: 20; x: rect.x; y: 180; color: "blue"
- Behavior on x { SmoothedAnimation { duration: 300 } }
+ Behavior on x { SmoothedAnimation { velocity: -1; duration: 300 } }
+ }
+
+ //rect2 has jerky movement, but the rects following it should be smooth
+ Rectangle {
+ id: rect2
+ property int dir: 1
+ width: 50; height: 20; x:50; y: 240; color: "black"
+ function advance(){
+ if(x >= 700)
+ dir = -1;
+ if(x <= 50)
+ dir = 1;
+ x += 130.0 * dir;
+ }
+ }
+ Timer{
+ interval: 200
+ running: true
+ repeat: true
+ onTriggered: rect2.advance();
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect2.x; y: 270; color: "red"
+ Behavior on x { SmoothedAnimation { velocity: 400 } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect2.x; y: 300; color: "yellow"
+ Behavior on x { SmoothedAnimation { velocity: 300; reversingMode: SmoothedAnimation.Immediate } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect2.x; y: 330; color: "green"
+ Behavior on x { SmoothedAnimation { velocity: 200; reversingMode: SmoothedAnimation.Sync } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect2.x; y: 360; color: "purple"
+ Behavior on x { SmoothedAnimation { velocity: 200; maximumEasingTime: 100 } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect2.x; y: 390; color: "blue"
+ Behavior on x { SmoothedAnimation { velocity: -1; duration: 300 } }
+ }
+
+ //rect3 just jumps , but the rects following it should be smooth
+ Rectangle {
+ id: rect3
+ width: 50; height: 20; x:50; y: 480; color: "black"
+ function advance(){
+ if(x == 50)
+ x = 700;
+ else
+ x = 50;
+ }
+ }
+ Timer{
+ interval: 1000
+ running: true
+ repeat: true
+ onTriggered: rect3.advance();
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect3.x; y: 510; color: "red"
+ Behavior on x { SmoothedAnimation { velocity: 400 } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect3.x; y: 540; color: "yellow"
+ Behavior on x { SmoothedAnimation { velocity: 300; reversingMode: SmoothedAnimation.Immediate } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect3.x; y: 570; color: "green"
+ Behavior on x { SmoothedAnimation { velocity: 200; reversingMode: SmoothedAnimation.Sync } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect3.x; y: 600; color: "purple"
+ Behavior on x { SmoothedAnimation { velocity: 200; maximumEasingTime: 100 } }
+ }
+
+ Rectangle {
+ width: 50; height: 20; x: rect3.x; y: 630; color: "blue"
+ Behavior on x { SmoothedAnimation { velocity: -1; duration: 300 } }
}
}
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index a968520..667cdd3 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
+#include <QtTest/qtesttouch.h>
#include "../../shared/util.h"
#include <qevent.h>
@@ -361,6 +362,7 @@ private slots:
void partialGesturePropagation();
void testQGestureRecognizerCleanup();
void testReuseCanceledGestures();
+ void bug_13501_gesture_not_accepted();
};
tst_Gestures::tst_Gestures()
@@ -395,7 +397,12 @@ void tst_Gestures::customGesture()
{
GestureWidget widget;
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+
CustomEvent event;
+ event.hotSpot = widget.mapToGlobal(QPoint(5,5));
+ event.hasHotSpot = true;
sendCustomGesture(&event, &widget);
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@@ -2301,5 +2308,29 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
}
+class NoConsumeWidgetBug13501 :public QWidget
+{
+ Q_OBJECT
+protected:
+ bool event(QEvent *e) {
+ if(e->type() == QEvent::Gesture) {
+ return false;
+ }
+ return QWidget::event(e);
+ }
+};
+
+void tst_Gestures::bug_13501_gesture_not_accepted()
+{
+ // Create a gesture event that is not accepted by any widget
+ // make sure this does not lead to an assert in QGestureManager
+ NoConsumeWidgetBug13501 w;
+ w.grabGesture(Qt::TapGesture);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ //QTest::mousePress(&ignoreEvent, Qt::LeftButton);
+ QTest::touchEvent(&w).press(0, QPoint(10, 10), &w);
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index 06c70f9..7ccf058 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -213,7 +213,8 @@ void tst_Headers::licenseCheck()
return;
if (content.first().contains("generated")) {
- content.takeFirst();
+ // don't scan generated files
+ return;
}
if (sourceFile.endsWith("/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp")
diff --git a/tests/auto/linguist/lconvert/data/test-refs.po b/tests/auto/linguist/lconvert/data/test-refs.po
new file mode 100644
index 0000000..e149a38
--- /dev/null
+++ b/tests/auto/linguist/lconvert/data/test-refs.po
@@ -0,0 +1,23 @@
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Language: de_DE\n"
+
+#: themer/kdmlabel.cpp:285
+#, no-c-format
+msgctxt "date format"
+msgid "%a %d %B"
+msgstr "%a %d %B"
+
+#: foo.bar.baz
+#, no-c-format
+msgid "full java class name"
+msgstr ""
+
+#: foo.car:123 monks:here file/gar.c:17:19 no:monks:here
+#, no-c-format
+msgid "some excessive locations"
+msgstr ""
diff --git a/tests/auto/linguist/lconvert/data/test20.ts b/tests/auto/linguist/lconvert/data/test20.ts
index f042edf..0e38b4b 100644
--- a/tests/auto/linguist/lconvert/data/test20.ts
+++ b/tests/auto/linguist/lconvert/data/test20.ts
@@ -158,5 +158,14 @@
<comment>comment with | and ~ and so~</comment>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>just something obsolete</source>
+ <translation type="obsolete">translated obsoletion</translation>
+ </message>
+ <message>
+ <source>something else obsolete</source>
+ <comment>comment with | and ~ and so~</comment>
+ <translation type="obsolete">another translated obsoletion</translation>
+ </message>
</context>
</TS>
diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp
index 998f588..a3c29d8 100644
--- a/tests/auto/linguist/lconvert/tst_lconvert.cpp
+++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp
@@ -317,6 +317,8 @@ void tst_lconvert::roundtrips_data()
QTest::newRow("po-xliff-po (plural-2)") << "plural-2.po" << poXlfPo << noArgs;
QTest::newRow("po-xliff-po (plural-3)") << "plural-3.po" << poXlfPo << noArgs;
+ QTest::newRow("po-ts-po (references)") << "test-refs.po" << poTsPo << noArgs;
+
QTest::newRow("ts20-ts11-ts20 (utf8)") << "codec-utf8.ts" << tsTs11Ts << noArgs;
QTest::newRow("ts20-ts11-ts20 (cp1252)") << "codec-cp1252.ts" << tsTs11Ts << noArgs;
QTest::newRow("ts20-ts11-ts20 (dual-encoding)") << "dual-encoding.ts" << tsTs11Ts << noArgs;
diff --git a/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt
index 093610d..1eed403 100644
--- a/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt
+++ b/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt
@@ -1,4 +1,3 @@
-*.*Function 'eval' is not implemented
Updating 'project\.ts'\.\.\.
Found 3 source text\(s\) \(3 new and 0 already existing\)
Removed 5 obsolete entries
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
index f58f932..706e8d0 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
@@ -302,3 +302,44 @@ static inline QString message2()
}
}
+
+
+
+// QTBUG-11426: operator overloads
+class LotsaFun : public QObject
+{
+ Q_OBJECT
+public:
+ int operator<<(int left, int right);
+};
+
+int LotsaFun::operator<<(int left, int right)
+{
+ tr("this is inside operator<<");
+ return left << right;
+}
+
+
+
+// QTBUG-12683: define in re-opened namespace
+namespace NameSchpace {
+
+class YetMoreFun : public QObject
+{
+ Q_OBJECT
+public:
+ void funStuff();
+};
+
+}
+
+namespace NameSchpace {
+
+#define somevar 1
+
+void YetMoreFun::funStuff()
+{
+ tr("funStuff!");
+}
+
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
index 7ac318e..f73fc64 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
@@ -141,6 +141,22 @@ backslashed \ stuff.</source>
</message>
</context>
<context>
+ <name>LotsaFun</name>
+ <message>
+ <location filename="main.cpp" line="318"/>
+ <source>this is inside operator&lt;&lt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>NameSchpace::YetMoreFun</name>
+ <message>
+ <location filename="main.cpp" line="342"/>
+ <source>funStuff!</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>Plurals, QCoreApplication</name>
<message numerus="yes">
<location filename="main.cpp" line="81"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs/main.js b/tests/auto/linguist/lupdate/testdata/good/parsejs/main.js
new file mode 100644
index 0000000..9f61cea
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs/main.js
@@ -0,0 +1,91 @@
+qsTr("One");
+qsTranslate("FooContext", "Two");
+
+var greeting_strings = [
+ QT_TR_NOOP("Hello"),
+ QT_TRANSLATE_NOOP("FooContext", "Goodbye")
+];
+
+qsTr("One", "not the same one");
+
+//: My first comment.
+qsTr("See comment");
+
+//: My second comment.
+qsTranslate("BarContext", "See other comment");
+
+//: My third comment
+//: spans two lines.
+qsTr("The comment explains it all");
+
+//: My fourth comment
+//: spans a whopping
+//: three lines.
+qsTranslate("BazContext", "It should be clear by now");
+
+/*: C-style comment. */
+qsTr("I love C++");
+
+/*: Another C-style comment. */
+qsTranslate("FooContext", "I really love C++");
+
+/*: C-style comment, followed by */
+/*: another one. */
+qsTr("Qt is the best");
+
+/*: Another C-style comment, followed by */
+/*: yet another one. */
+qsTranslate("BarContext", "Qt is the very best");
+
+// This comment doesn't have any effect.
+qsTr("The comment had no effect");
+
+// This comment doesn't have any effect either.
+qsTranslate("BazContext", "The comment had no effect, really");
+
+/* This C-style comment doesn't have any effect. */
+qsTr("No comment to your comment");
+
+/* This C-style comment doesn't have any effect either. */
+qsTranslate("FooContext", "I refuse to comment on that");
+
+//= id_foo
+qsTr("This string has an identifier");
+
+//= id_bar
+qsTranslate("BarContext", "This string also has an identifier");
+
+//~ loc-blank False
+qsTr("This string has meta-data");
+
+//~ loc-layout_id foo_dialog
+qsTranslate("BazContext", "This string also has meta-data");
+
+// This comment is to be ignored.
+//: This is a comment for the translator.
+//= id_baz
+//~ foo 123
+//~ magic-stuff This means something special.
+qsTr("This string has a lot of information");
+
+// This comment is also to be ignored.
+//: This is another comment for the translator.
+//= id_babar
+//~ foo-bar Important stuff
+//~ needle-in-haystack Found
+//~ overflow True
+qsTranslate("FooContext", "This string has even more information");
+
+qsTr("This string has disambiguation", "Disambiguation");
+
+qsTranslate("BarContext", "This string also has disambiguation", "Another disambiguation");
+
+qsTr("This string contains plurals", "", 10);
+
+qsTrId("qtn_foo_bar");
+
+var more_greeting_strings = [ QT_TRID_NOOP("qtn_needle"), QT_TRID_NOOP("qtn_haystack") ];
+
+//: qsTrId() with comment, meta-data and plurals.
+//~ well-tested True
+qsTrId("qtn_bar_baz", 10);
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsejs/project.pro
new file mode 100644
index 0000000..d549039
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs/project.pro
@@ -0,0 +1,3 @@
+SOURCES += main.js
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result
new file mode 100644
index 0000000..d03c713
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs/project.ts.result
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name></name>
+ <message id="qtn_foo_bar">
+ <location filename="main.js" line="85"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_needle">
+ <location filename="main.js" line="87"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_haystack">
+ <location filename="main.js" line="87"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_bar_baz" numerus="yes">
+ <location filename="main.js" line="91"/>
+ <source></source>
+ <extracomment>qsTrId() with comment, meta-data and plurals.</extracomment>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ <extra-well-tested>True</extra-well-tested>
+ </message>
+</context>
+<context>
+ <name>BarContext</name>
+ <message>
+ <location filename="main.js" line="15"/>
+ <source>See other comment</source>
+ <extracomment>My second comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="38"/>
+ <source>Qt is the very best</source>
+ <extracomment>Another C-style comment, followed by yet another one.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_bar">
+ <location filename="main.js" line="56"/>
+ <source>This string also has an identifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="81"/>
+ <source>This string also has disambiguation</source>
+ <comment>Another disambiguation</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>BazContext</name>
+ <message>
+ <location filename="main.js" line="24"/>
+ <source>It should be clear by now</source>
+ <extracomment>My fourth comment spans a whopping three lines.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="44"/>
+ <source>The comment had no effect, really</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="62"/>
+ <source>This string also has meta-data</source>
+ <translation type="unfinished"></translation>
+ <extra-loc-layout_id>foo_dialog</extra-loc-layout_id>
+ </message>
+</context>
+<context>
+ <name>FooContext</name>
+ <message>
+ <location filename="main.js" line="2"/>
+ <source>Two</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="6"/>
+ <source>Goodbye</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="30"/>
+ <source>I really love C++</source>
+ <extracomment>Another C-style comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="50"/>
+ <source>I refuse to comment on that</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_babar">
+ <location filename="main.js" line="77"/>
+ <source>This string has even more information</source>
+ <extracomment>This is another comment for the translator.</extracomment>
+ <translation type="unfinished"></translation>
+ <extra-needle-in-haystack>Found</extra-needle-in-haystack>
+ <extra-overflow>True</extra-overflow>
+ <extra-foo-bar>Important stuff</extra-foo-bar>
+ </message>
+</context>
+<context>
+ <name>main</name>
+ <message>
+ <location filename="main.js" line="1"/>
+ <source>One</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="5"/>
+ <source>Hello</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="9"/>
+ <source>One</source>
+ <comment>not the same one</comment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="12"/>
+ <source>See comment</source>
+ <extracomment>My first comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="19"/>
+ <source>The comment explains it all</source>
+ <extracomment>My third comment spans two lines.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="27"/>
+ <source>I love C++</source>
+ <extracomment>C-style comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="34"/>
+ <source>Qt is the best</source>
+ <extracomment>C-style comment, followed by another one.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="41"/>
+ <source>The comment had no effect</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="47"/>
+ <source>No comment to your comment</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_foo">
+ <location filename="main.js" line="53"/>
+ <source>This string has an identifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="59"/>
+ <source>This string has meta-data</source>
+ <translation type="unfinished"></translation>
+ <extra-loc-blank>False</extra-loc-blank>
+ </message>
+ <message id="id_baz">
+ <location filename="main.js" line="69"/>
+ <source>This string has a lot of information</source>
+ <extracomment>This is a comment for the translator.</extracomment>
+ <translation type="unfinished"></translation>
+ <extra-foo>123</extra-foo>
+ <extra-magic-stuff>This means something special.</extra-magic-stuff>
+ </message>
+ <message>
+ <location filename="main.js" line="79"/>
+ <source>This string has disambiguation</source>
+ <comment>Disambiguation</comment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message numerus="yes">
+ <location filename="main.js" line="83"/>
+ <source>This string contains plurals</source>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs2/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/parsejs2/expectedoutput.txt
new file mode 100644
index 0000000..d6c977f
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs2/expectedoutput.txt
@@ -0,0 +1,29 @@
+.*/lupdate/testdata/good/parsejs2/main.js:3: qsTranslate\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs2/main.js:4: qsTranslate\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs2/main.js:5: qsTranslate\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs2/main.js:6: qsTranslate\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs2/main.js:7: qsTranslate\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs2/main.js:9: QT_TRANSLATE_NOOP\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs2/main.js:10: QT_TRANSLATE_NOOP\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs2/main.js:11: QT_TRANSLATE_NOOP\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs2/main.js:12: QT_TRANSLATE_NOOP\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs2/main.js:13: QT_TRANSLATE_NOOP\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs2/main.js:15: qsTr\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs2/main.js:16: qsTr\(\): text to translate must be a literal string.
+.*/lupdate/testdata/good/parsejs2/main.js:18: QT_TR_NOOP\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs2/main.js:19: QT_TR_NOOP\(\): text to translate must be a literal string.
+.*/lupdate/testdata/good/parsejs2/main.js:21: qsTrId\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs2/main.js:22: qsTrId\(\): identifier must be a literal string.
+.*/lupdate/testdata/good/parsejs2/main.js:24: QT_TRID_NOOP\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs2/main.js:25: QT_TRID_NOOP\(\): identifier must be a literal string.
+.*/lupdate/testdata/good/parsejs2/main.js:27: Unexpected character in meta string
+.*/lupdate/testdata/good/parsejs2/main.js:28: Unexpected character in meta string
+.*/lupdate/testdata/good/parsejs2/main.js:29: Unterminated meta string
+.*/lupdate/testdata/good/parsejs2/main.js:30: Unterminated meta string
+.*/lupdate/testdata/good/parsejs2/main.js:33: //% cannot be used with qsTranslate\(\). Ignoring
+.*/lupdate/testdata/good/parsejs2/main.js:35: //% cannot be used with QT_TRANSLATE_NOOP\(\). Ignoring
+.*/lupdate/testdata/good/parsejs2/main.js:37: //% cannot be used with qsTr\(\). Ignoring
+.*/lupdate/testdata/good/parsejs2/main.js:39: //% cannot be used with QT_TR_NOOP\(\). Ignoring
+.*/lupdate/testdata/good/parsejs2/main.js:42: Discarding unconsumed meta data
+.*/lupdate/testdata/good/parsejs2/main.js:44: Discarding unconsumed meta data
+.*/lupdate/testdata/good/parsejs2/main.js:46: Discarding unconsumed meta data
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs2/main.js b/tests/auto/linguist/lupdate/testdata/good/parsejs2/main.js
new file mode 100644
index 0000000..ea02957
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs2/main.js
@@ -0,0 +1,56 @@
+// This script exercises lupdate errors and warnings.
+
+qsTranslate();
+qsTranslate(10);
+qsTranslate(10, 20);
+qsTranslate("10", 20);
+qsTranslate(10, "20");
+
+QT_TRANSLATE_NOOP();
+QT_TRANSLATE_NOOP(10);
+QT_TRANSLATE_NOOP(10, 20);
+QT_TRANSLATE_NOOP("10", 20);
+QT_TRANSLATE_NOOP(10, "20");
+
+qsTr();
+qsTr(10);
+
+QT_TR_NOOP();
+QT_TR_NOOP(10);
+
+qsTrId();
+qsTrId(10);
+
+QT_TRID_NOOP();
+QT_TRID_NOOP(10);
+
+//% This is wrong
+//% "This is not wrong" This is wrong
+//% "I forgot to close the meta string
+//% "Being evil \
+
+//% "Should cause a warning"
+qsTranslate("FooContext", "Hello");
+//% "Should cause a warning"
+QT_TRANSLATE_NOOP("FooContext", "World");
+//% "Should cause a warning"
+qsTr("Hello");
+//% "Should cause a warning"
+QT_TR_NOOP("World");
+
+//: This comment will be discarded.
+Math.sin(1);
+//= id_foobar
+Math.cos(2);
+//~ underflow False
+Math.tan(3);
+
+/*
+Not tested for now, because these should perhaps not cause
+translation entries to be generated at all; see QTBUG-11843.
+
+//= qtn_foo
+qsTrId("qtn_foo");
+//= qtn_bar
+QT_TRID_NOOP("qtn_bar");
+*/
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs2/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsejs2/project.pro
new file mode 100644
index 0000000..d549039
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs2/project.pro
@@ -0,0 +1,3 @@
+SOURCES += main.js
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsejs2/project.ts.result
new file mode 100644
index 0000000..bfa1b3d
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs2/project.ts.result
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>FooContext</name>
+ <message>
+ <location filename="main.js" line="33"/>
+ <source>Hello</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="35"/>
+ <source>World</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>main</name>
+ <message>
+ <location filename="main.js" line="37"/>
+ <source>Hello</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="39"/>
+ <source>World</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml b/tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml
new file mode 100644
index 0000000..172bd65
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseqml/main.qml
@@ -0,0 +1,97 @@
+import Qt 4.7
+
+QtObject {
+ function translate() {
+ qsTr("One");
+ qsTranslate("FooContext", "Two");
+
+ var greeting_strings = [
+ QT_TR_NOOP("Hello"),
+ QT_TRANSLATE_NOOP("FooContext", "Goodbye")
+ ];
+
+ qsTr("One", "not the same one");
+
+ //: My first comment.
+ qsTr("See comment");
+
+ //: My second comment.
+ qsTranslate("BarContext", "See other comment");
+
+ //: My third comment
+ //: spans two lines.
+ qsTr("The comment explains it all");
+
+ //: My fourth comment
+ //: spans a whopping
+ //: three lines.
+ qsTranslate("BazContext", "It should be clear by now");
+
+ /*: C-style comment. */
+ qsTr("I love C++");
+
+ /*: Another C-style comment. */
+ qsTranslate("FooContext", "I really love C++");
+
+ /*: C-style comment, followed by */
+ /*: another one. */
+ qsTr("Qt is the best");
+
+ /*: Another C-style comment, followed by */
+ /*: yet another one. */
+ qsTranslate("BarContext", "Qt is the very best");
+
+ // This comment doesn't have any effect.
+ qsTr("The comment had no effect");
+
+ // This comment doesn't have any effect either.
+ qsTranslate("BazContext", "The comment had no effect, really");
+
+ /* This C-style comment doesn't have any effect. */
+ qsTr("No comment to your comment");
+
+ /* This C-style comment doesn't have any effect either. */
+ qsTranslate("FooContext", "I refuse to comment on that");
+
+ //= id_foo
+ qsTr("This string has an identifier");
+
+ //= id_bar
+ qsTranslate("BarContext", "This string also has an identifier");
+
+ //~ loc-blank False
+ qsTr("This string has meta-data");
+
+ //~ loc-layout_id foo_dialog
+ qsTranslate("BazContext", "This string also has meta-data");
+
+ // This comment is to be ignored.
+ //: This is a comment for the translator.
+ //= id_baz
+ //~ foo 123
+ //~ magic-stuff This means something special.
+ qsTr("This string has a lot of information");
+
+ // This comment is also to be ignored.
+ //: This is another comment for the translator.
+ //= id_babar
+ //~ foo-bar Important stuff
+ //~ needle-in-haystack Found
+ //~ overflow True
+ qsTranslate("FooContext", "This string has even more information");
+
+ qsTr("This string has disambiguation", "Disambiguation");
+
+ qsTranslate("BarContext", "This string also has disambiguation", "Another disambiguation");
+
+ qsTr("This string contains plurals", "", 10);
+
+ qsTrId("qtn_foo_bar");
+
+ var more_greeting_strings = [ QT_TRID_NOOP("qtn_needle"), QT_TRID_NOOP("qtn_haystack") ];
+
+ //: qsTrId() with comment, meta-data and plurals.
+ //~ well-tested True
+ qsTrId("qtn_bar_baz", 10);
+ }
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro
new file mode 100644
index 0000000..1040e22
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.pro
@@ -0,0 +1,3 @@
+SOURCES += main.qml
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result
new file mode 100644
index 0000000..7dac8cb
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseqml/project.ts.result
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name></name>
+ <message id="qtn_foo_bar">
+ <location filename="main.qml" line="89"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_needle">
+ <location filename="main.qml" line="91"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_haystack">
+ <location filename="main.qml" line="91"/>
+ <source></source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="qtn_bar_baz" numerus="yes">
+ <location filename="main.qml" line="95"/>
+ <source></source>
+ <extracomment>qsTrId() with comment, meta-data and plurals.</extracomment>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ <extra-well-tested>True</extra-well-tested>
+ </message>
+</context>
+<context>
+ <name>BarContext</name>
+ <message>
+ <location filename="main.qml" line="19"/>
+ <source>See other comment</source>
+ <extracomment>My second comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="42"/>
+ <source>Qt is the very best</source>
+ <extracomment>Another C-style comment, followed by yet another one.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_bar">
+ <location filename="main.qml" line="60"/>
+ <source>This string also has an identifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="85"/>
+ <source>This string also has disambiguation</source>
+ <comment>Another disambiguation</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>BazContext</name>
+ <message>
+ <location filename="main.qml" line="28"/>
+ <source>It should be clear by now</source>
+ <extracomment>My fourth comment spans a whopping three lines.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="48"/>
+ <source>The comment had no effect, really</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="66"/>
+ <source>This string also has meta-data</source>
+ <translation type="unfinished"></translation>
+ <extra-loc-layout_id>foo_dialog</extra-loc-layout_id>
+ </message>
+</context>
+<context>
+ <name>FooContext</name>
+ <message>
+ <location filename="main.qml" line="6"/>
+ <source>Two</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="10"/>
+ <source>Goodbye</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="34"/>
+ <source>I really love C++</source>
+ <extracomment>Another C-style comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="54"/>
+ <source>I refuse to comment on that</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_babar">
+ <location filename="main.qml" line="81"/>
+ <source>This string has even more information</source>
+ <extracomment>This is another comment for the translator.</extracomment>
+ <translation type="unfinished"></translation>
+ <extra-needle-in-haystack>Found</extra-needle-in-haystack>
+ <extra-overflow>True</extra-overflow>
+ <extra-foo-bar>Important stuff</extra-foo-bar>
+ </message>
+</context>
+<context>
+ <name>main</name>
+ <message>
+ <location filename="main.qml" line="5"/>
+ <source>One</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="9"/>
+ <source>Hello</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="13"/>
+ <source>One</source>
+ <comment>not the same one</comment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="16"/>
+ <source>See comment</source>
+ <extracomment>My first comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="23"/>
+ <source>The comment explains it all</source>
+ <extracomment>My third comment spans two lines.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="31"/>
+ <source>I love C++</source>
+ <extracomment>C-style comment.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="38"/>
+ <source>Qt is the best</source>
+ <extracomment>C-style comment, followed by another one.</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="45"/>
+ <source>The comment had no effect</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="51"/>
+ <source>No comment to your comment</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="id_foo">
+ <location filename="main.qml" line="57"/>
+ <source>This string has an identifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.qml" line="63"/>
+ <source>This string has meta-data</source>
+ <translation type="unfinished"></translation>
+ <extra-loc-blank>False</extra-loc-blank>
+ </message>
+ <message id="id_baz">
+ <location filename="main.qml" line="73"/>
+ <source>This string has a lot of information</source>
+ <extracomment>This is a comment for the translator.</extracomment>
+ <translation type="unfinished"></translation>
+ <extra-foo>123</extra-foo>
+ <extra-magic-stuff>This means something special.</extra-magic-stuff>
+ </message>
+ <message>
+ <location filename="main.qml" line="83"/>
+ <source>This string has disambiguation</source>
+ <comment>Disambiguation</comment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message numerus="yes">
+ <location filename="main.qml" line="87"/>
+ <source>This string contains plurals</source>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp
index 5ba6c52..e6d2135 100644
--- a/tests/auto/linguist/lupdate/tst_lupdate.cpp
+++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp
@@ -122,12 +122,19 @@ static bool prepareMatch(const QString &expect, QString *tmpl, int *require, int
return true;
}
-void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn, bool err)
+void tst_lupdate::doCompare(const QStringList &_actual, const QString &expectedFn, bool err)
{
QFile file(expectedFn);
QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(expectedFn));
QStringList expected = QString(file.readAll()).split('\n');
+ QStringList actual;
+ actual.reserve(_actual.size());
+ QRegExp niRx(".*:Function '\\w+' is not implemented");
+ foreach (const QString &a, _actual)
+ if (!niRx.exactMatch(a))
+ actual << a;
+
int ei = 0, ai = 0, em = expected.size(), am = actual.size();
int oei = 0, oai = 0, oem = em, oam = am;
int require = 0, accept = 0;
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp
index 16638ce..742267f 100644
--- a/tests/auto/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp
@@ -68,6 +68,11 @@ private slots:
void testDragWindow();
void testMouseEnter();
void testChildDialogInFrontOfModalParent();
+#ifdef QT_MAC_USE_COCOA
+ void testChildWindowInFrontOfParentWindow();
+// void testChildToolWindowInFrontOfChildNormalWindow();
+ void testChildWindowInFrontOfStaysOnTopParentWindow();
+#endif
void testKeyPressOnToplevel();
void testModifierShift();
void testModifierAlt();
@@ -313,6 +318,82 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent()
QVERIFY(!child.isVisible());
}
+#ifdef QT_MAC_USE_COCOA
+void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow()
+{
+ // Test that a child window always stacks in front of its parent window.
+ // Do this by first click on the parent, then on the child window button.
+ QWidget parent;
+ QPushButton child("a button", &parent);
+ child.setWindowFlags(Qt::Window);
+ connect(&child, SIGNAL(clicked()), &child, SLOT(close()));
+ parent.show();
+ child.show();
+
+ QPoint parent_p = parent.geometry().bottomLeft() + QPoint(20, -20);
+ QPoint child_p = child.geometry().center();
+
+ NativeEventList native;
+ native.append(new QNativeMouseButtonEvent(parent_p, Qt::LeftButton, 1, Qt::NoModifier));
+ native.append(new QNativeMouseButtonEvent(parent_p, Qt::LeftButton, 0, Qt::NoModifier));
+ native.append(new QNativeMouseButtonEvent(child_p, Qt::LeftButton, 1, Qt::NoModifier));
+ native.append(new QNativeMouseButtonEvent(child_p, Qt::LeftButton, 0, Qt::NoModifier));
+
+ native.play();
+ QTest::qWait(100);
+ QVERIFY(!child.isVisible());
+}
+
+/* This test can be enabled once setStackingOrder has been fixed in qwidget_mac.mm
+void tst_MacNativeEvents::testChildToolWindowInFrontOfChildNormalWindow()
+{
+ // Test that a child tool window always stacks in front of normal sibling windows.
+ // Do this by first click on the sibling, then on the tool window button.
+ QWidget parent;
+ QWidget normalChild(&parent, Qt::Window);
+ QPushButton toolChild("a button", &parent);
+ toolChild.setWindowFlags(Qt::Tool);
+ connect(&toolChild, SIGNAL(clicked()), &toolChild, SLOT(close()));
+ parent.show();
+ normalChild.show();
+ toolChild.show();
+
+ QPoint normalChild_p = normalChild.geometry().bottomLeft() + QPoint(20, -20);
+ QPoint toolChild_p = toolChild.geometry().center();
+
+ NativeEventList native;
+ native.append(new QNativeMouseButtonEvent(normalChild_p, Qt::LeftButton, 1, Qt::NoModifier));
+ native.append(new QNativeMouseButtonEvent(normalChild_p, Qt::LeftButton, 0, Qt::NoModifier));
+ native.append(new QNativeMouseButtonEvent(toolChild_p, Qt::LeftButton, 1, Qt::NoModifier));
+ native.append(new QNativeMouseButtonEvent(toolChild_p, Qt::LeftButton, 0, Qt::NoModifier));
+
+ native.play();
+ QTest::qWait(100);
+ QVERIFY(!toolChild.isVisible());
+}
+*/
+void tst_MacNativeEvents::testChildWindowInFrontOfStaysOnTopParentWindow()
+{
+ // Test that a child window stacks on top of a stays-on-top parent.
+ QWidget parent(0, Qt::WindowStaysOnTopHint);
+ QPushButton button("close", &parent);
+ button.setWindowFlags(Qt::Window);
+ connect(&button, SIGNAL(clicked()), &button, SLOT(close()));
+ parent.show();
+ button.show();
+ QPoint inside = button.geometry().center();
+
+ // Post a click on the button to close the child dialog:
+ NativeEventList native;
+ native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 1, Qt::NoModifier));
+ native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 0, Qt::NoModifier));
+
+ native.play();
+ QTest::qWait(100);
+ QVERIFY(!button.isVisible());
+}
+#endif
+
void tst_MacNativeEvents::testKeyPressOnToplevel()
{
// Check that we receive keyevents for
diff --git a/tests/auto/moc/error-on-wrong-notify.h b/tests/auto/moc/error-on-wrong-notify.h
new file mode 100644
index 0000000..4b6284a
--- /dev/null
+++ b/tests/auto/moc/error-on-wrong-notify.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 <QObject>
+
+class ClassWithWrongNOTIFY : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged)
+
+ int m_foo;
+public:
+ void setFoo(int i) { m_foo = i; }
+ int foo() { return m_foo; }
+};
+
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index d3a7e03..bb23f49 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -492,6 +492,7 @@ private slots:
void warnOnVirtualSignal();
void QTBUG5590_dummyProperty();
void QTBUG12260_defaultTemplate();
+ void notifyError();
signals:
void sigWithUnsignedArg(unsigned foo);
void sigWithSignedArg(signed foo);
@@ -1076,10 +1077,10 @@ void tst_Moc::qprivateslots()
class PrivatePropertyTest : public QObject
{
Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo);
- Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar);
- Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop);
- Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz);
+ Q_PROPERTY(int foo READ foo WRITE setFoo)
+ Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar)
+ Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop)
+ Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz)
class MyDPointer {
public:
MyDPointer() : mBar(0), mPlop(0) {}
@@ -1362,6 +1363,27 @@ void tst_Moc::QTBUG12260_defaultTemplate()
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1);
}
+void tst_Moc::notifyError()
+{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled", SkipAll);
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ QProcess proc;
+ proc.start("moc", QStringList(srcify("error-on-wrong-notify.h")));
+ QVERIFY(proc.waitForFinished());
+ QCOMPARE(proc.exitCode(), 1);
+ QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
+ QByteArray mocOut = proc.readAllStandardOutput();
+ QVERIFY(mocOut.isEmpty());
+ QString mocError = QString::fromLocal8Bit(proc.readAllStandardError());
+ QCOMPARE(mocError, QString(SRCDIR) +
+ QString("/error-on-wrong-notify.h:52: Error: NOTIFY signal 'fooChanged' of property 'foo' does not exist in class ClassWithWrongNOTIFY.\n"));
+#else
+ QSKIP("Only tested on linux/gcc", SkipAll);
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_Moc)
#include "tst_moc.moc"
diff --git a/tests/auto/q3table/tst_q3table.cpp b/tests/auto/q3table/tst_q3table.cpp
index 90bf806..93de251 100644
--- a/tests/auto/q3table/tst_q3table.cpp
+++ b/tests/auto/q3table/tst_q3table.cpp
@@ -502,7 +502,7 @@ void tst_Q3Table::pageUpDownNavigation()
void tst_Q3Table::simpleKeyboardNavigation()
{
QApplication::setActiveWindow(testWidget);
- QTRY_COMPARE(QApplication::activeWindow(), testWidget);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(testWidget));
QWidget *w;
// Test for task #24726
@@ -1208,7 +1208,7 @@ void tst_Q3Table::editCheck()
table.show();
QApplication::setActiveWindow(&table);
QTest::qWaitForWindowShown(&table);
- QTRY_COMPARE(QApplication::activeWindow(), &table);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&table));
table.setCurrentCell(0, 0);
#ifdef WAITS
QTest::qWait(50);
@@ -1345,7 +1345,7 @@ void tst_Q3Table::valueChanged()
testWidget->show();
QApplication::setActiveWindow(testWidget);
QTest::qWaitForWindowShown(testWidget);
- QTRY_COMPARE(QApplication::activeWindow(), testWidget);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(testWidget));
#ifdef WAITS
QTest::qWait(50);
#endif
@@ -1395,7 +1395,7 @@ void tst_Q3Table::dateTimeEdit()
testWidget->show();
QApplication::setActiveWindow(testWidget);
QTest::qWaitForWindowShown(testWidget);
- QTRY_COMPARE(QApplication::activeWindow(), testWidget);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(testWidget));
#ifdef WAITS
QTest::qWait(50);
#endif
diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 6f158f0..dbcccc9 100644
--- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -1208,6 +1208,7 @@ void tst_QAbstractItemModel::testMoveToGrandParent()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QPersistentModelIndex persistentSource = sourceIndex;
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setAncestorRowNumbers(QList<int>() << 5);
@@ -1228,7 +1229,7 @@ void tst_QAbstractItemModel::testMoveToGrandParent()
QCOMPARE(beforeSignal.at(4).toInt(), destRow);
QCOMPARE(afterSignal.size(), 5);
- QCOMPARE(afterSignal.at(0).value<QModelIndex>(), sourceIndex);
+ QCOMPARE(afterSignal.at(0).value<QModelIndex>(), static_cast<QModelIndex>(persistentSource));
QCOMPARE(afterSignal.at(1).toInt(), startRow);
QCOMPARE(afterSignal.at(2).toInt(), endRow);
QCOMPARE(afterSignal.at(3).value<QModelIndex>(), QModelIndex());
@@ -1351,6 +1352,7 @@ void tst_QAbstractItemModel::testMoveToSibling()
QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ QPersistentModelIndex persistentDest = destIndex;
ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
moveCommand->setNumCols(4);
@@ -1374,7 +1376,7 @@ void tst_QAbstractItemModel::testMoveToSibling()
QCOMPARE(afterSignal.at(0).value<QModelIndex>(), sourceIndex);
QCOMPARE(afterSignal.at(1).toInt(), startRow);
QCOMPARE(afterSignal.at(2).toInt(), endRow);
- QCOMPARE(afterSignal.at(3).value<QModelIndex>(), destIndex);
+ QCOMPARE(afterSignal.at(3).value<QModelIndex>(), static_cast<QModelIndex>(persistentDest));
QCOMPARE(afterSignal.at(4).toInt(), destRow);
for (int i = 0; i < indexList.size(); i++)
diff --git a/tests/auto/qapplication/modal/base.cpp b/tests/auto/qapplication/modal/base.cpp
new file mode 100644
index 0000000..9022c36
--- /dev/null
+++ b/tests/auto/qapplication/modal/base.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 "base.h"
+
+base::base(QWidget *parent) :
+ QWidget(parent)
+{
+ m_timer = new QTimer(this);
+ m_modalStarted = false;
+ m_timer->setSingleShot(false);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(periodicTimer()));
+ m_timer->start(5000);
+}
+
+void base::periodicTimer()
+{
+ if(m_modalStarted)
+ exit(0);
+ m_modalDialog = new QDialog(this);
+ m_modalDialog->setModal(true);
+ m_modalDialog->show();
+ m_modalStarted = true;
+}
diff --git a/tests/auto/qapplication/modal/base.h b/tests/auto/qapplication/modal/base.h
new file mode 100644
index 0000000..faa1765
--- /dev/null
+++ b/tests/auto/qapplication/modal/base.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 BASE_H
+#define BASE_H
+
+#include <QWidget>
+#include <QTimer>
+#include <QDialog>
+
+class base : public QWidget
+{
+Q_OBJECT
+ QTimer *m_timer;
+ bool m_modalStarted;
+ QDialog *m_modalDialog;
+public:
+ explicit base(QWidget *parent = 0);
+
+signals:
+
+public slots:
+ void periodicTimer();
+};
+
+#endif // BASE_H
diff --git a/tests/auto/qapplication/modal/main.cpp b/tests/auto/qapplication/modal/main.cpp
new file mode 100644
index 0000000..f9d8fb4
--- /dev/null
+++ b/tests/auto/qapplication/modal/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 <QtGui>
+
+#include <QApplication>
+#include "base.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ base *b = new base();
+ return app.exec();
+}
diff --git a/tests/auto/qapplication/modal/modal.pro b/tests/auto/qapplication/modal/modal.pro
new file mode 100644
index 0000000..836f6ff
--- /dev/null
+++ b/tests/auto/qapplication/modal/modal.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+SOURCES += main.cpp \
+ base.cpp
+DESTDIR = ./
+HEADERS += base.h
diff --git a/tests/auto/qapplication/qapplication.pro b/tests/auto/qapplication/qapplication.pro
index 7814ad3..becc6c6 100644
--- a/tests/auto/qapplication/qapplication.pro
+++ b/tests/auto/qapplication/qapplication.pro
@@ -1,6 +1,7 @@
TEMPLATE = subdirs
SUBDIRS = test \
desktopsettingsaware \
+ modal \
wincmdline
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index 1a38070..91ae921 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -146,6 +146,7 @@ private slots:
void symbianNeedForTraps();
void symbianLeaveThroughMain();
+ void qtbug_12673();
};
class EventSpy : public QObject
@@ -2239,6 +2240,23 @@ void tst_QApplication::symbianLeaveThroughMain()
#endif
}
+void tst_QApplication::qtbug_12673()
+{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("This might not make sense in Symbian, but since I do not know how to test it I'll just skip it for now.", SkipAll);
+#else
+ QProcess testProcess;
+ QStringList arguments;
+#ifdef Q_OS_MAC
+ testProcess.start("modal/modal.app", arguments);
+#else
+ testProcess.start("modal/modal", arguments);
+#endif
+ QVERIFY(testProcess.waitForFinished(20000));
+ QCOMPARE(testProcess.exitStatus(), QProcess::NormalExit);
+#endif // Q_OS_SYMBIAN
+}
+
//QTEST_APPLESS_MAIN(tst_QApplication)
int main(int argc, char *argv[])
{
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index a62720b..1590528 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -1324,7 +1324,7 @@ void tst_QCompleter::task253125_lineEditCompletion()
#endif
QTest::qWait(10);
QApplication::setActiveWindow(&edit);
- QTRY_COMPARE(QApplication::activeWindow(), &edit);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&edit));
QTest::keyClick(&edit, 'i');
QCOMPARE(edit.completer()->currentCompletion(), QString("iota"));
@@ -1362,7 +1362,7 @@ void tst_QCompleter::task247560_keyboardNavigation()
QTest::qWait(10);
QApplication::setActiveWindow(&edit);
- QTRY_COMPARE(QApplication::activeWindow(), &edit);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&edit));
QTest::keyClick(&edit, 'r');
QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp
index 31e12fe..c03bc71 100644
--- a/tests/auto/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/qdatastream/tst_qdatastream.cpp
@@ -1820,7 +1820,7 @@ void tst_QDataStream::stream_QPixmap()
#ifdef Q_OS_WINCE
QSKIP("Test depends on more memory than available on Qt/CE", SkipAll);
#endif
- STREAM_IMPL(QIcon);
+ STREAM_IMPL(QPixmap);
}
void tst_QDataStream::stream_QIcon_data()
diff --git a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
index 94771a8..9d96ad8 100644
--- a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
+++ b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
@@ -70,7 +70,12 @@ public:
QSemaphore sem1, sem2;
volatile bool success;
QEventLoop *loop;
- const char *functionSpy;
+ enum FunctionSpy {
+ NoMethod = 0,
+ Adaptor_method,
+ Object_method
+ } functionSpy;
+
QThread *threadSpy;
int signalSpy;
@@ -127,7 +132,7 @@ public:
public Q_SLOTS:
void method()
{
- tst_QDBusThreading::self()->functionSpy = Q_FUNC_INFO;
+ tst_QDBusThreading::self()->functionSpy = tst_QDBusThreading::Adaptor_method;
tst_QDBusThreading::self()->threadSpy = QThread::currentThread();
emit signal();
}
@@ -155,7 +160,7 @@ public:
public Q_SLOTS:
void method()
{
- tst_QDBusThreading::self()->functionSpy = Q_FUNC_INFO;
+ tst_QDBusThreading::self()->functionSpy = tst_QDBusThreading::Object_method;
tst_QDBusThreading::self()->threadSpy = QThread::currentThread();
emit signal();
deleteLater();
@@ -198,7 +203,7 @@ void Thread::run()
static const char myConnectionName[] = "connection";
tst_QDBusThreading::tst_QDBusThreading()
- : loop(0), functionSpy(0), threadSpy(0)
+ : loop(0), functionSpy(NoMethod), threadSpy(0)
{
_self = this;
QCoreApplication::instance()->thread()->setObjectName("Main thread");
@@ -420,22 +425,22 @@ void tst_QDBusThreading::registerObjectInOtherThread()
QTest::qWait(100);
QCOMPARE(signalSpy, 0);
- functionSpy = 0;
+ functionSpy = NoMethod;
threadSpy = 0;
QDBusReply<void> reply = iface.call("method");
QVERIFY(reply.isValid());
- QCOMPARE(functionSpy, "void Object::method()");
+ QCOMPARE(functionSpy, Object_method);
QCOMPARE(threadSpy, th);
QTest::qWait(100);
QCOMPARE(signalSpy, 1);
sem2.acquire(); // the object is gone
- functionSpy = 0;
+ functionSpy = NoMethod;
threadSpy = 0;
reply = iface.call("method");
QVERIFY(!reply.isValid());
- QCOMPARE(functionSpy, (const char*)0);
+ QCOMPARE(functionSpy, NoMethod);
QCOMPARE(threadSpy, (QThread*)0);
}
@@ -468,36 +473,36 @@ void tst_QDBusThreading::registerAdaptorInOtherThread()
connect(&adaptor, SIGNAL(signal()), SLOT(signalSpySlot()));
QCOMPARE(signalSpy, 0);
- functionSpy = 0;
+ functionSpy = NoMethod;
threadSpy = 0;
QDBusReply<void> reply = adaptor.call("method");
QVERIFY(reply.isValid());
- QCOMPARE(functionSpy, "void Adaptor::method()");
+ QCOMPARE(functionSpy, Adaptor_method);
QCOMPARE(threadSpy, th);
QTest::qWait(100);
QCOMPARE(signalSpy, 1);
- functionSpy = 0;
+ functionSpy = NoMethod;
threadSpy = 0;
reply = object.call("method");
QVERIFY(reply.isValid());
- QCOMPARE(functionSpy, "void Object::method()");
+ QCOMPARE(functionSpy, Object_method);
QCOMPARE(threadSpy, th);
QTest::qWait(100);
QCOMPARE(signalSpy, 1);
sem2.acquire(); // the object is gone
- functionSpy = 0;
+ functionSpy = NoMethod;
threadSpy = 0;
reply = adaptor.call("method");
QVERIFY(!reply.isValid());
- QCOMPARE(functionSpy, (const char*)0);
+ QCOMPARE(functionSpy, NoMethod);
QCOMPARE(threadSpy, (QThread*)0);
reply = object.call("method");
QVERIFY(!reply.isValid());
- QCOMPARE(functionSpy, (const char*)0);
+ QCOMPARE(functionSpy, NoMethod);
QCOMPARE(threadSpy, (QThread*)0);
}
diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
index 124f900..2411ab6 100644
--- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
@@ -153,19 +153,19 @@ void tst_QEasingCurve::propertyDefaults()
QEasingCurve curve(QEasingCurve::InElastic);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setType(QEasingCurve::InBounce);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setType(QEasingCurve::Linear);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setType(QEasingCurve::InElastic);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setPeriod(0.4);
curve.setAmplitude(0.6);
curve.setOvershoot(1.0);
@@ -490,7 +490,7 @@ void tst_QEasingCurve::operators()
// operator==
curve.setType(QEasingCurve::InBack);
curve2 = curve;
- curve2.setOvershoot(qreal(1.70158f));
+ curve2.setOvershoot(qreal(1.70158));
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
@@ -505,6 +505,15 @@ void tst_QEasingCurve::operators()
curve2.setType(QEasingCurve::InBack);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
+
+ QEasingCurve curve3;
+ QEasingCurve curve4;
+ curve4.setAmplitude(curve4.amplitude());
+ QEasingCurve curve5;
+ curve5.setAmplitude(0.12345);
+ QVERIFY(curve3 == curve4); // default value and not assigned
+ QVERIFY(curve3 != curve5); // unassinged and other value
+ QVERIFY(curve4 != curve5);
}
class tst_QEasingProperties : public QObject
@@ -527,7 +536,7 @@ void tst_QEasingCurve::properties()
tst_QEasingProperties obj;
QEasingCurve inOutBack(QEasingCurve::InOutBack);
- qreal overshoot = 1.5f;
+ qreal overshoot = 1.5;
inOutBack.setOvershoot(overshoot);
qreal amplitude = inOutBack.amplitude();
qreal period = inOutBack.period();
diff --git a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
index 357b82e..bddd92a 100644
--- a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
@@ -70,6 +70,11 @@ private slots:
void fixedPitch_data();
void fixedPitch();
+#ifdef Q_WS_MAC
+ void trickyFonts_data();
+ void trickyFonts();
+#endif
+
void widthTwoTimes_data();
void widthTwoTimes();
@@ -131,10 +136,16 @@ void tst_QFontDatabase::fixedPitch_data()
QTest::newRow( "Times New Roman" ) << QString( "Times New Roman" ) << false;
QTest::newRow( "Arial" ) << QString( "Arial" ) << false;
- QTest::newRow( "Script" ) << QString( "Script" ) << false;
+ QTest::newRow( "Andale Mono" ) << QString( "Andale Mono" ) << true;
QTest::newRow( "Courier" ) << QString( "Courier" ) << true;
QTest::newRow( "Courier New" ) << QString( "Courier New" ) << true;
+#ifndef Q_WS_MAC
+ QTest::newRow( "Script" ) << QString( "Script" ) << false;
QTest::newRow( "Lucida Console" ) << QString( "Lucida Console" ) << true;
+#else
+ QTest::newRow( "Menlo" ) << QString( "Menlo" ) << true;
+ QTest::newRow( "Monaco" ) << QString( "Monaco" ) << true;
+#endif
}
void tst_QFontDatabase::fixedPitch()
@@ -156,6 +167,28 @@ void tst_QFontDatabase::fixedPitch()
QCOMPARE(fi.fixedPitch(), fixedPitch);
}
+#ifdef Q_WS_MAC
+void tst_QFontDatabase::trickyFonts_data()
+{
+ QTest::addColumn<QString>("font");
+
+ QTest::newRow( "Geeza Pro" ) << QString( "Geeza Pro" );
+}
+
+void tst_QFontDatabase::trickyFonts()
+{
+ QFETCH(QString, font);
+
+ QFontDatabase fdb;
+ if (!fdb.families().contains(font))
+ QSKIP( "Font not installed", SkipSingle);
+
+ QFont qfont(font);
+ QFontInfo fi(qfont);
+ QCOMPARE(fi.family(), font);
+}
+#endif
+
void tst_QFontDatabase::widthTwoTimes_data()
{
QTest::addColumn<QString>("font");
diff --git a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp
index c53c67a..54463c9 100644
--- a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -47,6 +47,7 @@
#include <qfuturewatcher.h>
#include <qtconcurrentrun.h>
#include <qtconcurrentmap.h>
+#include "../../shared/util.h"
#ifndef QT_NO_CONCURRENT_TEST
#include <private/qfutureinterface_p.h>
@@ -81,6 +82,7 @@ private slots:
void incrementalMapResults();
void incrementalFilterResults();
void qfutureSynchornizer();
+ void warnRace();
};
QTEST_MAIN(tst_QFutureWatcher)
@@ -466,12 +468,12 @@ void tst_QFutureWatcher::toMuchProgress()
ProgressObject o;
QFutureWatcher<void> f;
- f.setFuture((new ProgressEmitterTask())->start());
QObject::connect(&f, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
#ifdef PRINT
QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(printProgress(int)));
#endif
QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(registerProgress(int)));
+ f.setFuture((new ProgressEmitterTask())->start());
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
@@ -886,6 +888,37 @@ void tst_QFutureWatcher::qfutureSynchornizer()
QVERIFY(t.elapsed() < taskCount * 10);
}
+class DummyObject : public QObject {
+ Q_OBJECT
+public slots:
+ void dummySlot() {}
+public:
+ static void function(QMutex *m)
+ {
+ QMutexLocker lock(m);
+ }
+};
+
+void tst_QFutureWatcher::warnRace()
+{
+#ifndef Q_OS_MAC //I don't know why it is not working on mac
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(QtWarningMsg, "QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race");
+#endif
+#endif
+ QFutureWatcher<void> watcher;
+ DummyObject object;
+ QMutex mutex;
+ mutex.lock();
+
+ QFuture<void> future = QtConcurrent::run(DummyObject::function, &mutex);
+ watcher.setFuture(future);
+ QTRY_VERIFY(future.isStarted());
+ connect(&watcher, SIGNAL(finished()), &object, SLOT(dummySlot()));
+ mutex.unlock();
+ future.waitForFinished();
+}
+
#include "tst_qfuturewatcher.moc"
#else
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 5fe453b..dfcfb47 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -847,6 +847,7 @@ void tst_QGL::graphicsViewClipping()
scene.addWidget(widget)->setPos(0, 0);
QGraphicsView view(&scene);
+ view.setBackgroundBrush(Qt::white);
#ifdef Q_WS_QWS
view.setWindowFlags(Qt::FramelessWindowHint);
#endif
@@ -1835,7 +1836,7 @@ void tst_QGL::clipTest()
// Sample pixels in a grid pattern which avoids false failures due to
// off-by-one pixel errors on some buggy GL implementations
for (int x = 2; x < reference.width(); x += 5) {
- for (int y = 2; y < reference.width(); y += 5) {
+ for (int y = 2; y < reference.height(); y += 5) {
QFUZZY_COMPARE_PIXELS(widgetFB.pixel(x, y), reference.pixel(x, y));
}
}
diff --git a/tests/auto/qglthreads/tst_qglthreads.cpp b/tests/auto/qglthreads/tst_qglthreads.cpp
index cce3161..38b0dab 100644
--- a/tests/auto/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/qglthreads/tst_qglthreads.cpp
@@ -45,10 +45,6 @@
#include <QtOpenGL/QtOpenGL>
#include "tst_qglthreads.h"
-#ifdef Q_WS_X11
-#include <private/qt_x11_p.h>
-#endif
-
#define RUNNING_TIME 5000
tst_QGLThreads::tst_QGLThreads(QObject *parent)
@@ -56,8 +52,6 @@ tst_QGLThreads::tst_QGLThreads(QObject *parent)
{
}
-
-
/*
swapInThread
@@ -339,6 +333,7 @@ void renderAScene(int w, int h)
class ThreadSafeGLWidget : public QGLWidget
{
public:
+ ThreadSafeGLWidget(QWidget *parent = 0) : QGLWidget(parent) {}
void paintEvent(QPaintEvent *)
{
// ignored as we're anyway swapping as fast as we can
@@ -426,7 +421,7 @@ void tst_QGLThreads::renderInThread_data()
void tst_QGLThreads::renderInThread()
{
#ifdef Q_OS_MAC
- QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll);
+ QSKIP("OpenGL threading tests are currently disabled on Mac as they were causing reboots", SkipAll);
#endif
QFETCH(bool, resize);
@@ -461,15 +456,301 @@ void tst_QGLThreads::renderInThread()
QVERIFY(!thread.failure);
}
+class Device
+{
+public:
+ virtual ~Device() {}
+ virtual QPaintDevice *realPaintDevice() = 0;
+ virtual void prepareDevice() {}
+};
+
+class GLWidgetWrapper : public Device
+{
+public:
+ GLWidgetWrapper() {
+ widget.resize(150, 150);
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+ widget.doneCurrent();
+ }
+ QPaintDevice *realPaintDevice() { return &widget; }
+ ThreadSafeGLWidget widget;
+};
+class PixmapWrapper : public Device
+{
+public:
+ PixmapWrapper() { pixmap = new QPixmap(512, 512); }
+ ~PixmapWrapper() { delete pixmap; }
+ QPaintDevice *realPaintDevice() { return pixmap; }
-int main(int argc, char **argv)
+ QPixmap *pixmap;
+};
+
+class PixelBufferWrapper : public Device
+{
+public:
+ PixelBufferWrapper() { pbuffer = new QGLPixelBuffer(512, 512); }
+ ~PixelBufferWrapper() { delete pbuffer; }
+ QPaintDevice *realPaintDevice() { return pbuffer; }
+
+ QGLPixelBuffer *pbuffer;
+};
+
+
+class FrameBufferObjectWrapper : public Device
+{
+public:
+ FrameBufferObjectWrapper() {
+ widget.makeCurrent();
+ fbo = new QGLFramebufferObject(512, 512);
+ widget.doneCurrent();
+ }
+ ~FrameBufferObjectWrapper() { delete fbo; }
+ QPaintDevice *realPaintDevice() { return fbo; }
+ void prepareDevice() { widget.makeCurrent(); }
+
+ ThreadSafeGLWidget widget;
+ QGLFramebufferObject *fbo;
+};
+
+
+class ThreadPainter : public QObject
+{
+ Q_OBJECT
+public:
+ ThreadPainter(Device *pd) : device(pd), fail(true) {
+ pixmap = QPixmap(40, 40);
+ pixmap.fill(Qt::green);
+ QPainter p(&pixmap);
+ p.drawLine(0, 0, 40, 40);
+ p.drawLine(0, 40, 40, 0);
+ }
+
+public slots:
+ void draw() {
+ bool beginFailed = false;
+ QTime time;
+ time.start();
+ int rotAngle = 10;
+ device->prepareDevice();
+ QPaintDevice *paintDevice = device->realPaintDevice();
+ QSize s(paintDevice->width(), paintDevice->height());
+ while (time.elapsed() < RUNNING_TIME) {
+ QPainter p;
+ if (!p.begin(paintDevice)) {
+ beginFailed = true;
+ break;
+ }
+ p.translate(s.width()/2, s.height()/2);
+ p.rotate(rotAngle);
+ p.translate(-s.width()/2, -s.height()/2);
+ p.fillRect(0, 0, s.width(), s.height(), Qt::red);
+ QRect rect(QPoint(0, 0), s);
+ p.drawPixmap(10, 10, pixmap);
+ p.drawTiledPixmap(50, 50, 100, 100, pixmap);
+ p.drawText(rect.center(), "This is a piece of text");
+ p.end();
+ rotAngle += 2;
+#ifdef Q_WS_WIN
+ Sleep(20);
+#else
+ usleep(20 * 1000);
+#endif
+ }
+
+ fail = beginFailed;
+ QThread::currentThread()->quit();
+ }
+
+ bool failed() { return fail; }
+
+private:
+ QPixmap pixmap;
+ Device *device;
+ bool fail;
+};
+
+template <class T>
+class PaintThreadManager
+{
+public:
+ PaintThreadManager(int count) : numThreads(count)
+ {
+ for (int i=0; i<numThreads; ++i) {
+ devices.append(new T);
+ threads.append(new QThread);
+ painters.append(new ThreadPainter(devices.at(i)));
+ painters.at(i)->moveToThread(threads.at(i));
+ painters.at(i)->connect(threads.at(i), SIGNAL(started()), painters.at(i), SLOT(draw()));
+ }
+ }
+
+ ~PaintThreadManager() {
+ qDeleteAll(threads);
+ qDeleteAll(painters);
+ qDeleteAll(devices);
+ }
+
+
+ void start() {
+ for (int i=0; i<numThreads; ++i)
+ threads.at(i)->start();
+ }
+
+ bool areRunning() {
+ bool running = false;
+ for (int i=0; i<numThreads; ++i){
+ if (threads.at(i)->isRunning())
+ running = true;
+ }
+
+ return running;
+ }
+
+ bool failed() {
+ for (int i=0; i<numThreads; ++i) {
+ if (painters.at(i)->failed())
+ return true;
+ }
+
+ return false;
+ }
+
+private:
+ QList<QThread *> threads;
+ QList<Device *> devices;
+ QList<ThreadPainter *> painters;
+ int numThreads;
+};
+
+/*
+ This test uses QPainter to draw onto different QGLWidgets in
+ different threads at the same time. The ThreadSafeGLWidget is
+ necessary to handle paint and resize events that might come from
+ the main thread at any time while the test is running. The resize
+ and paint events would cause makeCurrent() calls to be issued from
+ within the QGLWidget while the widget's context was current in
+ another thread, which would cause errors.
+*/
+void tst_QGLThreads::painterOnGLWidgetInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on Mac as they were causing reboots", SkipAll);
+#endif
+ if (!((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) ||
+ (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) {
+ QSKIP("The OpenGL based threaded QPainter tests requires OpenGL/ES 2.0.", SkipAll);
+ }
+
+ PaintThreadManager<GLWidgetWrapper> painterThreads(5);
+ painterThreads.start();
+
+ while (painterThreads.areRunning()) {
+ qApp->processEvents();
+#ifdef Q_WS_WIN
+ Sleep(100);
+#else
+ usleep(100 * 1000);
+#endif
+ }
+ QVERIFY(!painterThreads.failed());
+}
+
+/*
+ This test uses QPainter to draw onto different QPixmaps in
+ different threads at the same time.
+*/
+void tst_QGLThreads::painterOnPixmapInThread()
{
#ifdef Q_WS_X11
- XInitThreads();
+ QSKIP("Drawing text in threads onto X11 drawables currently crashes on some X11 servers.", SkipAll);
+#endif
+ PaintThreadManager<PixmapWrapper> painterThreads(5);
+ painterThreads.start();
+
+ while (painterThreads.areRunning()) {
+ qApp->processEvents();
+#ifdef Q_WS_WIN
+ Sleep(100);
+#else
+ usleep(100 * 1000);
+#endif
+ }
+ QVERIFY(!painterThreads.failed());
+}
+
+/* This test uses QPainter to draw onto different QGLPixelBuffer
+ objects in different threads at the same time.
+*/
+void tst_QGLThreads::painterOnPboInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on Mac as they were causing reboots", SkipAll);
+#endif
+ if (!((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) ||
+ (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) {
+ QSKIP("The OpenGL based threaded QPainter tests requires OpenGL/ES 2.0.", SkipAll);
+ return;
+ }
+
+ if (!QGLPixelBuffer::hasOpenGLPbuffers()) {
+ QSKIP("This system doesn't support pbuffers.", SkipAll);
+ return;
+ }
+
+ PaintThreadManager<PixelBufferWrapper> painterThreads(5);
+ painterThreads.start();
+
+ while (painterThreads.areRunning()) {
+ qApp->processEvents();
+#ifdef Q_WS_WIN
+ Sleep(100);
+#else
+ usleep(100 * 1000);
#endif
+ }
+ QVERIFY(!painterThreads.failed());
+}
+/* This test uses QPainter to draw onto different
+ QGLFramebufferObjects (bound in a QGLWidget's context) in different
+ threads at the same time.
+*/
+void tst_QGLThreads::painterOnFboInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on Mac as they were causing reboots", SkipAll);
+#endif
+ if (!((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) ||
+ (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) {
+ QSKIP("The OpenGL based threaded QPainter tests requires OpenGL/ES 2.0.", SkipAll);
+ return;
+ }
+
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
+ QSKIP("This system doesn't support framebuffer objects.", SkipAll);
+ return;
+ }
+
+ PaintThreadManager<FrameBufferObjectWrapper> painterThreads(5);
+ painterThreads.start();
+
+ while (painterThreads.areRunning()) {
+ qApp->processEvents();
+#ifdef Q_WS_WIN
+ Sleep(100);
+#else
+ usleep(100 * 1000);
+#endif
+ }
+ QVERIFY(!painterThreads.failed());
+}
+
+int main(int argc, char **argv)
+{
+ QApplication::setAttribute(Qt::AA_X11InitThreads);
QApplication app(argc, argv);
QTEST_DISABLE_KEYPAD_NAVIGATION \
diff --git a/tests/auto/qglthreads/tst_qglthreads.h b/tests/auto/qglthreads/tst_qglthreads.h
index 9e97909..a8c2963 100644
--- a/tests/auto/qglthreads/tst_qglthreads.h
+++ b/tests/auto/qglthreads/tst_qglthreads.h
@@ -56,6 +56,10 @@ private slots:
void renderInThread_data();
void renderInThread();
+ void painterOnGLWidgetInThread();
+ void painterOnPixmapInThread();
+ void painterOnPboInThread();
+ void painterOnFboInThread();
};
#endif // TST_QGLTHREADS_H
diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp
index b75e801..da91063 100644
--- a/tests/auto/qglyphs/tst_qglyphs.cpp
+++ b/tests/auto/qglyphs/tst_qglyphs.cpp
@@ -347,10 +347,6 @@ void tst_QGlyphs::drawMultiScriptText1()
void tst_QGlyphs::drawMultiScriptText2()
{
-#if defined(Q_WS_MAC)
- QSKIP("Unstable because of QTBUG-11145", SkipAll);
-#endif
-
QString text;
text += QChar(0x0621); // Arabic, Hamza
text += QChar(0x03D0); // Greek, beta
@@ -530,10 +526,6 @@ void tst_QGlyphs::drawUnderlinedText()
void tst_QGlyphs::drawRightToLeft()
{
-#if defined(Q_WS_MAC)
- QSKIP("Unstable because of QTBUG-11145", SkipAll);
-#endif
-
QString s;
s.append(QChar(1575));
s.append(QChar(1578));
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index fa6a5ec..07fa630 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -66,6 +66,7 @@ private slots:
void source();
void boundingRectFor();
void boundingRect();
+ void boundingRect2();
void draw();
void opacity();
void grayscale();
@@ -76,6 +77,7 @@ private slots:
void dropShadowClipping();
void childrenVisibilityShouldInvalidateCache();
void prepareGeometryChangeInvalidateCache();
+ void itemHasNoContents();
};
void tst_QGraphicsEffect::initTestCase()
@@ -263,6 +265,57 @@ void tst_QGraphicsEffect::boundingRect()
delete item;
}
+void tst_QGraphicsEffect::boundingRect2()
+{
+ CustomEffect *effect = new CustomEffect;
+ QGraphicsRectItem *root = new QGraphicsRectItem;
+ root->setGraphicsEffect(effect);
+
+ QGraphicsRectItem *child = new QGraphicsRectItem;
+ QRectF childRect(0, 0, 100, 100);
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ child->setRect(childRect);
+ child->setParentItem(root);
+
+ QGraphicsRectItem *grandChild = new QGraphicsRectItem;
+ QRectF grandChildRect(0, 0, 200, 200);
+ grandChild->setRect(grandChildRect);
+ grandChild->setParentItem(child);
+
+ // Make sure the effect's bounding rect is clipped to the child's bounding rect.
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect));
+
+ // Disable ItemClipsChildrenToShape; effect's bounding rect is no longer clipped.
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+
+ // Add root item to a scene, do the same tests as above. Results should be the same.
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect));
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+
+ // Now add the scene to a view, results should be the same.
+ QGraphicsView view(&scene);
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect));
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+
+ CustomEffect *childEffect = new CustomEffect;
+ child->setGraphicsEffect(childEffect);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childEffect->boundingRectFor(childRect | grandChildRect)));
+
+ child->setGraphicsEffect(0);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+}
+
void tst_QGraphicsEffect::draw()
{
QGraphicsScene scene;
@@ -675,6 +728,34 @@ void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache()
QCOMPARE(item->nbPaint, 0);
}
+void tst_QGraphicsEffect::itemHasNoContents()
+{
+ QGraphicsRectItem *parent = new QGraphicsRectItem;
+ parent->setFlag(QGraphicsItem::ItemHasNoContents);
+
+ MyGraphicsItem *child = new MyGraphicsItem;
+ child->setParentItem(parent);
+ child->resize(200, 200);
+
+ QGraphicsScene scene;
+ scene.addItem(parent);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(child->nbPaint, 1);
+
+ CustomEffect *effect = new CustomEffect;
+ parent->setGraphicsEffect(effect);
+ QTRY_COMPARE(effect->numRepaints, 1);
+
+ for (int i = 0; i < 3; ++i) {
+ effect->reset();
+ effect->update();
+ QTRY_COMPARE(effect->numRepaints, 1);
+ }
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 7346f07..82af71f 100644
--- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -109,6 +109,7 @@ private slots:
void styleInfoLeak();
void task236367_maxSizeHint();
void heightForWidth();
+ void widthForHeight();
};
class RectWidget : public QGraphicsWidget
@@ -225,9 +226,10 @@ struct ItemDesc
return (*this);
}
- ItemDesc &heightForWidth(QSizeF (*fnConstraint)(Qt::SizeHint, const QSizeF &)) {
+ ItemDesc &dynamicConstraint(QSizeF (*fnConstraint)(Qt::SizeHint, const QSizeF &),
+ Qt::Orientation orientation) {
m_fnConstraint = fnConstraint;
- m_constraintOrientation = Qt::Vertical;
+ m_constraintOrientation = orientation;
return (*this);
}
@@ -235,7 +237,7 @@ struct ItemDesc
QSizePolicy sp = m_sizePolicy;
if (m_fnConstraint) {
sp.setHeightForWidth(m_constraintOrientation == Qt::Vertical);
- //sp.setWidthForHeight(m_constraintOrientation == Qt::Horizontal);
+ sp.setWidthForHeight(m_constraintOrientation == Qt::Horizontal);
}
item->setSizePolicy(sp);
@@ -2174,10 +2176,50 @@ void tst_QGraphicsGridLayout::alignment2()
static QSizeF hfw1(Qt::SizeHint, const QSizeF &constraint)
{
QSizeF result(constraint);
- if (constraint.width() < 0 && constraint.height() < 0) {
+ const qreal ch = constraint.height();
+ const qreal cw = constraint.width();
+ if (cw < 0 && ch < 0) {
return QSizeF(50, 400);
- } else if (constraint.width() >= 0) {
- result.setHeight(20000./constraint.width());
+ } else if (cw > 0) {
+ result.setHeight(20000./cw);
+ }
+ return result;
+}
+
+static QSizeF wfh1(Qt::SizeHint, const QSizeF &constraint)
+{
+ QSizeF result(constraint);
+ const qreal ch = constraint.height();
+ const qreal cw = constraint.width();
+ if (cw < 0 && ch < 0) {
+ return QSizeF(400, 50);
+ } else if (ch > 0) {
+ result.setWidth(20000./ch);
+ }
+ return result;
+}
+
+static QSizeF wfh2(Qt::SizeHint, const QSizeF &constraint)
+{
+ QSizeF result(constraint);
+ const qreal ch = constraint.height();
+ const qreal cw = constraint.width();
+ if (ch < 0 && cw < 0)
+ return QSizeF(50, 50);
+ if (ch >= 0)
+ result.setWidth(ch);
+ return result;
+}
+
+static QSizeF hfw3(Qt::SizeHint, const QSizeF &constraint)
+{
+ QSizeF result(constraint);
+ const qreal ch = constraint.height();
+ const qreal cw = constraint.width();
+ if (cw < 0 && ch < 0) {
+ return QSizeF(10, 10);
+ } else if (cw > 0) {
+ result.setHeight(100./cw);
}
return result;
}
@@ -2212,7 +2254,7 @@ void tst_QGraphicsGridLayout::geometries_data()
);
// change layout height and verify
- QTest::newRow("hfw-h401") << (ItemList()
+ QTest::newRow("hfw-100x401") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,10))
@@ -2229,7 +2271,7 @@ void tst_QGraphicsGridLayout::geometries_data()
.minSize(QSizeF(40,40))
.preferredSize(QSizeF(50,400))
.maxSize(QSizeF(500, 500))
- .heightForWidth(hfw1)
+ .dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(100, 401)
<< (RectList()
@@ -2238,7 +2280,7 @@ void tst_QGraphicsGridLayout::geometries_data()
);
- QTest::newRow("hfw-h408") << (ItemList()
+ QTest::newRow("hfw-100x408") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,10))
@@ -2255,7 +2297,7 @@ void tst_QGraphicsGridLayout::geometries_data()
.minSize(QSizeF(40,40))
.preferredSize(QSizeF(50,400))
.maxSize(QSizeF(500, 500))
- .heightForWidth(hfw1)
+ .dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(100, 408)
<< (RectList()
@@ -2280,7 +2322,7 @@ void tst_QGraphicsGridLayout::geometries_data()
.minSize(QSizeF(40,40))
.preferredSize(QSizeF(50,400))
.maxSize(QSizeF(500, 500))
- .heightForWidth(hfw1)
+ .dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(100, 410)
<< (RectList()
@@ -2288,7 +2330,7 @@ void tst_QGraphicsGridLayout::geometries_data()
<< QRectF(0, 10, 50,100) << QRectF(50, 10, 50,400)
);
- QTest::newRow("hfw-h470") << (ItemList()
+ QTest::newRow("hfw-100x470") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,10))
@@ -2305,7 +2347,7 @@ void tst_QGraphicsGridLayout::geometries_data()
.minSize(QSizeF(40,40))
.preferredSize(QSizeF(50,400))
.maxSize(QSizeF(500, 500))
- .heightForWidth(hfw1)
+ .dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(100, 470)
<< (RectList()
@@ -2315,7 +2357,7 @@ void tst_QGraphicsGridLayout::geometries_data()
// change layout width and verify
- QTest::newRow("hfw-w100") << (ItemList()
+ QTest::newRow("hfw-100x401") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,10))
@@ -2332,7 +2374,7 @@ void tst_QGraphicsGridLayout::geometries_data()
.minSize(QSizeF(40,40))
.preferredSize(QSizeF(50,400))
.maxSize(QSizeF(5000, 5000))
- .heightForWidth(hfw1)
+ .dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(100, 401)
<< (RectList()
@@ -2340,7 +2382,7 @@ void tst_QGraphicsGridLayout::geometries_data()
<< QRectF( 0, 1, 50, 100) << QRectF( 50, 1, 50, 400)
);
- QTest::newRow("hfw-w160") << (ItemList()
+ QTest::newRow("hfw-160x400") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,10))
@@ -2357,16 +2399,16 @@ void tst_QGraphicsGridLayout::geometries_data()
.minSize(QSizeF(40,40))
.preferredSize(QSizeF(50,400))
.maxSize(QSizeF(5000, 5000))
- .heightForWidth(hfw1)
+ .dynamicConstraint(hfw1, Qt::Vertical)
)
- << QSizeF(160, 401)
+ << QSizeF(160, 400)
<< (RectList()
<< QRectF( 0, 0, 80, 100) << QRectF( 80, 0, 80, 100)
<< QRectF( 0, 100, 80, 100) << QRectF( 80, 100, 80, 250)
);
- QTest::newRow("hfw-w500") << (ItemList()
+ QTest::newRow("hfw-160x300") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,10))
@@ -2383,12 +2425,145 @@ void tst_QGraphicsGridLayout::geometries_data()
.minSize(QSizeF(40,40))
.preferredSize(QSizeF(50,400))
.maxSize(QSizeF(5000, 5000))
- .heightForWidth(hfw1)
+ .dynamicConstraint(hfw1, Qt::Vertical)
+ )
+ << QSizeF(160, 300)
+ << (RectList()
+ << QRectF( 0, 0, 80, 50) << QRectF( 80, 0, 80, 50)
+ << QRectF( 0, 50, 80, 100) << QRectF( 80, 50, 80, 250)
+ );
+
+ QTest::newRow("hfw-20x40") << (ItemList()
+ << ItemDesc(0,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(0,1)
+ .minSize(QSizeF(1,10))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ .dynamicConstraint(hfw3, Qt::Vertical)
+ )
+ << QSizeF(20, 40)
+ << (RectList()
+ << QRectF(0, 0, 10, 20) << QRectF(10, 0, 10, 20)
+ << QRectF(0, 20, 10, 20) << QRectF(10, 20, 10, 10)
+ );
+
+ QTest::newRow("wfh-300x160") << (ItemList()
+ << ItemDesc(0,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(10,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(0,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(10,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(10,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,1)
+ .minSize(QSizeF(10,10))
+ .preferredSize(QSizeF(400,50))
+ .maxSize(QSizeF(5000, 5000))
+ .dynamicConstraint(wfh1, Qt::Horizontal)
+ )
+ << QSizeF(300, 160)
+ << (RectList()
+ << QRectF( 0, 0, 50, 80) << QRectF( 50, 0, 100, 80)
+ << QRectF( 0, 80, 50, 80) << QRectF( 50, 80, 250, 80)
+ );
+
+ QTest::newRow("wfh-40x20") << (ItemList()
+ << ItemDesc(0,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(0,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,0)
+ // Note, must be 10 in order to match stretching of wfh item
+ // below (the same stretch makes it easier to test)
+ .minSize(QSizeF(10,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ .dynamicConstraint(wfh2, Qt::Horizontal)
)
- << QSizeF(500, 401)
+ << QSizeF(40, 20)
<< (RectList()
- << QRectF( 0, 0, 100, 100) << QRectF(100, 0, 100, 100)
- << QRectF( 0, 100, 100, 100) << QRectF(100, 100, 400, 50)
+ << QRectF(0, 0, 20, 10) << QRectF(20, 0, 20, 10)
+ << QRectF(0, 10, 20, 10) << QRectF(20, 10, 10, 10)
+ );
+
+ QTest::newRow("wfh-400x160") << (ItemList()
+ << ItemDesc(0,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(0,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ .dynamicConstraint(wfh2, Qt::Horizontal)
+ )
+
+ << QSizeF(400, 160)
+ << (RectList()
+ << QRectF(0, 0, 100, 80) << QRectF(100, 0, 100, 80)
+ << QRectF(0, 80, 100, 80) << QRectF(100, 80, 80, 80)
+ );
+
+ QTest::newRow("wfh-160x100") << (ItemList()
+ << ItemDesc(0,0)
+ .minSize(QSizeF(1,1))
+ // Note, preferred width must be 50 in order to match
+ // preferred width of wfh item below.
+ // (The same preferred size makes the stretch the same, and
+ // makes it easier to test) (The stretch algorithm is a
+ // blackbox)
+ .preferredSize(QSizeF(50,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(0,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(10,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,0)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(10,50))
+ .maxSize(QSizeF(100, 100))
+ << ItemDesc(1,1)
+ .minSize(QSizeF(1,1))
+ .preferredSize(QSizeF(10,50))
+ .maxSize(QSizeF(500, 500))
+ .dynamicConstraint(wfh2, Qt::Horizontal)
+ )
+ << QSizeF(160, 100)
+ << (RectList()
+ << QRectF(0, 0, 80, 50) << QRectF( 80, 0, 80, 50)
+ << QRectF(0, 50, 80, 50) << QRectF( 80, 50, 50, 50)
);
}
@@ -2461,14 +2636,6 @@ void tst_QGraphicsGridLayout::task236367_maxSizeHint()
QCOMPARE(widget->size(), QSizeF(w, h));
}
-/*
-static qreal hfw(qreal w)
-{
- if (w == 0)
- return 20000;
- return 20000/w;
-}
-*/
static QSizeF hfw(Qt::SizeHint /*which*/, const QSizeF &constraint)
{
QSizeF result(constraint);
@@ -2485,7 +2652,16 @@ static QSizeF hfw(Qt::SizeHint /*which*/, const QSizeF &constraint)
} else if (ch == 0) {
result.setWidth(20000);
}
+ return result;
+}
+static QSizeF wfh(Qt::SizeHint /*which*/, const QSizeF &constraint)
+{
+ QSizeF result(constraint);
+ const qreal ch = constraint.height();
+ if (ch >= 0) {
+ result.setWidth(ch);
+ }
return result;
}
@@ -2536,24 +2712,25 @@ void tst_QGraphicsGridLayout::heightForWidth()
layout->setSpacing(0);
RectWidget *w00 = new RectWidget;
w00->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
- w00->setSizeHint(Qt::PreferredSize, QSizeF(10,10));
+ w00->setSizeHint(Qt::PreferredSize, QSizeF(50,50));
w00->setSizeHint(Qt::MaximumSize, QSizeF(100,100));
layout->addItem(w00, 0, 0);
RectWidget *w01 = new RectWidget;
w01->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
- w01->setSizeHint(Qt::PreferredSize, QSizeF(10,10));
+ w01->setSizeHint(Qt::PreferredSize, QSizeF(50,50));
w01->setSizeHint(Qt::MaximumSize, QSizeF(100,100));
layout->addItem(w01, 0, 1);
RectWidget *w10 = new RectWidget;
w10->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
- w10->setSizeHint(Qt::PreferredSize, QSizeF(10,10));
+ w10->setSizeHint(Qt::PreferredSize, QSizeF(50,50));
w10->setSizeHint(Qt::MaximumSize, QSizeF(100,100));
layout->addItem(w10, 1, 0);
RectWidget *w11 = new RectWidget;
w11->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
+ w11->setSizeHint(Qt::PreferredSize, QSizeF(50,400));
w11->setSizeHint(Qt::MaximumSize, QSizeF(30000,30000));
w11->setConstraintFunction(hfw);
QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -2562,42 +2739,104 @@ void tst_QGraphicsGridLayout::heightForWidth()
layout->addItem(w11, 1, 1);
QSizeF prefSize = layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1));
- QCOMPARE(prefSize, QSizeF(10+200, 10+100));
+ QCOMPARE(prefSize, QSizeF(50+50, 50+400));
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 20001));
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 20010));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 20050));
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, 20100));
- qreal width1;
- qreal width2;
- expectedWidth(1, 10, 1, 200, 20, &width1, &width2);
- QSizeF expectedSize = hfw(Qt::MinimumSize, QSizeF(width2, -1)) + QSizeF(width1, 1);
- QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(20, -1)), expectedSize);
- expectedSize.rheight()+=9;
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(20, -1)), expectedSize);
- expectedSize.rheight()+=90;
- QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(20, -1)), expectedSize);
-
- expectedWidth(1, 10, 1, 200, 300, &width1, &width2);
- expectedSize = hfw(Qt::MinimumSize, QSizeF(width2, -1)) + QSizeF(width1, 1);
- QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(300, -1)), expectedSize);
- expectedSize.rheight()+=9;
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(300, -1)), expectedSize);
- // the height of the hfw widget is shorter than the one to the left, which is 100, so
- // the total height of the last row is 100 (which leaves the layout height to be 200)
- QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(300, -1)), QSizeF(300, 200));
-
- // the hfw item is shorter than the item to the left
- expectedWidth(1, 10, 1, 200, 500, &width1, &width2);
- expectedSize = hfw(Qt::MinimumSize, QSizeF(width2, -1)) + QSizeF(width1, 1);
- QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(500, -1)), expectedSize);
- expectedSize.rheight()+=9;
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(500, -1)), expectedSize);
+
+ QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(20, -1)), QSizeF(20, 1 + 2000));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(20, -1)), QSizeF(20, 50 + 2000));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(20, -1)), QSizeF(20, 100 + 2000));
+
+ QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(300, -1)), QSizeF(300, 1 + 100));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(300, -1)), QSizeF(300, 50 + 100));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(300, -1)), QSizeF(300, 100 + 100));
+
// the height of the hfw widget is shorter than the one to the left, which is 100, so
// the total height of the last row is 100 (which leaves the layout height to be 200)
- QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(500, -1)), QSizeF(500, 200));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(500, -1)), QSizeF(500, 100 + 100));
+
+ // hfw item size: (500, 40) -> preferred size is maxed up to preferred size of item w10 (50)
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(600, -1)), QSizeF(600, 50 + 50));
}
+void tst_QGraphicsGridLayout::widthForHeight()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsGridLayout *layout = new QGraphicsGridLayout;
+ widget->setLayout(layout);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+ RectWidget *w00 = new RectWidget;
+ w00->setMinimumSize(1, 1);
+ w00->setPreferredSize(50, 50);
+ w00->setMaximumSize(100, 100);
+
+ layout->addItem(w00, 0, 0);
+
+ RectWidget *w01 = new RectWidget;
+ w01->setMinimumSize(1,1);
+ w01->setPreferredSize(50,50);
+ w01->setMaximumSize(100,100);
+ layout->addItem(w01, 0, 1);
+
+ RectWidget *w10 = new RectWidget;
+ w10->setMinimumSize(1,1);
+ w10->setPreferredSize(50,50);
+ w10->setMaximumSize(100,100);
+ layout->addItem(w10, 1, 0);
+
+ RectWidget *w11 = new RectWidget;
+ w11->setMinimumSize(1,1);
+ w11->setPreferredSize(50, 50);
+ w11->setMaximumSize(30000,30000);
+ // This will make sure its always square.
+ w11->setConstraintFunction(wfh);
+ QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ sp.setWidthForHeight(true);
+ w11->setSizePolicy(sp);
+ layout->addItem(w11, 1, 1);
+
+ /*
+ | 1, 50, 100 | 1, 50, 100 |
+ -----+--------------+--------------+
+ 1| | |
+ 50| | |
+ 100| | |
+ -----|--------------+--------------+
+ 1| | |
+ 50| | WFH |
+ 100| | |
+ -----------------------------------+
+ */
+
+
+ QSizeF prefSize = layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1));
+ QCOMPARE(prefSize, QSizeF(50+50, 50+50));
+
+ // wfh(1): = 1
+ QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, 2)), QSizeF(1 + 1, 2));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, 2)), QSizeF(50 + 50, 2));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, 2)), QSizeF(100 + 100, 2));
+
+ // wfh(40) = 40
+ QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, 80)), QSizeF(1 + 40, 80));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, 80)), QSizeF(50 + 50, 80));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, 80)), QSizeF(100 + 100, 80));
+
+ // wfh(80) = 80
+ QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, 160)), QSizeF(1 + 80, 160));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, 160)), QSizeF(50 + 80, 160));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, 160)), QSizeF(100 + 100, 160));
+
+ // wfh(200) = 200
+ QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, 300)), QSizeF(1 + 200, 300));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, 300)), QSizeF(50 + 200, 300));
+ QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, 300)), QSizeF(100 + 200, 300));
+
+}
QTEST_MAIN(tst_QGraphicsGridLayout)
#include "tst_qgraphicsgridlayout.moc"
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 3634ce9..4476084 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -4578,7 +4578,7 @@ void tst_QGraphicsItem::itemChange()
QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemFlagsHaveChanged);
QVariant expectedFlags = qVariantFromValue<quint32>(QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges));
QCOMPARE(tester.values.at(tester.values.size() - 2), expectedFlags);
- QCOMPARE(tester.values.at(tester.values.size() - 1), qVariantFromValue<quint32>(QGraphicsItem::ItemIsSelectable));
+ QCOMPARE(tester.values.at(tester.values.size() - 1), qVariantFromValue<quint32>((quint32)QGraphicsItem::ItemIsSelectable));
}
{
// ItemSelectedChange
diff --git a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
index 879e12b..dbffa6e 100644
--- a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
+++ b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
@@ -75,6 +75,7 @@ private slots:
void setPreferredSize_data();
void setPreferredSize();
void setSizePolicy_data();
+ void setPreferredSize2();
void setSizePolicy();
};
@@ -343,6 +344,13 @@ void tst_QGraphicsLayoutItem::setPreferredSize()
}
}
+void tst_QGraphicsLayoutItem::setPreferredSize2()
+{
+ SubQGraphicsLayoutItem layoutItem;
+ layoutItem.setPreferredSize(QSizeF(30, -1));
+ QCOMPARE(layoutItem.preferredWidth(), qreal(30));
+}
+
void tst_QGraphicsLayoutItem::setSizePolicy_data()
{
QTest::addColumn<QSizePolicy>("policy");
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 903977c..b8e729e 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -276,6 +276,7 @@ private slots:
void isActive();
void siblingIndexAlwaysValid();
void removeFullyTransparentItem();
+ void zeroScale();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -286,6 +287,7 @@ private slots:
void taskQTBUG_5904_crashWithDeviceCoordinateCache();
void taskQT657_paintIntoCacheWithTransparentParts();
void taskQTBUG_7863_paintIntoCacheWithTransparentParts();
+ void taskQT_3674_doNotCrash();
};
void tst_QGraphicsScene::initTestCase()
@@ -4564,5 +4566,49 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
}
}
+void tst_QGraphicsScene::taskQT_3674_doNotCrash()
+{
+ QGraphicsScene scene;
+
+ QGraphicsView view(&scene);
+ view.resize(200, 200);
+
+ QPixmap pixmap(view.size());
+ QPainter painter(&pixmap);
+ view.render(&painter);
+ painter.end();
+
+ scene.addItem(new QGraphicsWidget);
+ scene.setBackgroundBrush(Qt::green);
+
+ QApplication::processEvents();
+ QApplication::processEvents();
+}
+
+void tst_QGraphicsScene::zeroScale()
+{
+ //should not crash
+ QGraphicsScene scene;
+ scene.setSceneRect(-100, -100, 100, 100);
+ QGraphicsView view(&scene);
+
+ ChangedListener cl;
+ connect(&scene, SIGNAL(changed(const QList<QRectF> &)), &cl, SLOT(changed(const QList<QRectF> &)));
+
+ QGraphicsRectItem *rect1 = new QGraphicsRectItem(0, 0, 0.0000001, 0.00000001);
+ scene.addItem(rect1);
+ rect1->setRotation(82);
+ rect1->setScale(0.00000001);
+
+ QApplication::processEvents();
+ QTRY_COMPARE(cl.changes.count(), 1);
+ QGraphicsRectItem *rect2 = new QGraphicsRectItem(-0.0000001, -0.0000001, 0.0000001, 0.0000001);
+ rect2->setScale(0.00000001);
+ scene.addItem(rect2);
+ rect1->setPos(20,20);
+ QApplication::processEvents();
+ QTRY_COMPARE(cl.changes.count(), 2);
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 1cce687..7b5ac7a 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -244,6 +244,9 @@ private slots:
void QTBUG_4151_clipAndIgnore();
void QTBUG_5859_exposedRect();
void QTBUG_7438_cursor();
+
+public slots:
+ void dummySlot() {}
};
void tst_QGraphicsView::initTestCase()
@@ -3202,14 +3205,18 @@ void tst_QGraphicsView::scrollAfterResize()
void tst_QGraphicsView::moveItemWhileScrolling_data()
{
QTest::addColumn<bool>("adjustForAntialiasing");
+ QTest::addColumn<bool>("changedConnected");
- QTest::newRow("no adjust") << false;
- QTest::newRow("adjust") << true;
+ QTest::newRow("no adjust") << false << false;
+ QTest::newRow("adjust") << true << false;
+ QTest::newRow("no adjust changedConnected") << false << true;
+ QTest::newRow("adjust changedConnected") << true << true;
}
void tst_QGraphicsView::moveItemWhileScrolling()
{
QFETCH(bool, adjustForAntialiasing);
+ QFETCH(bool, changedConnected);
class MoveItemScrollView : public QGraphicsView
{
@@ -3253,6 +3260,8 @@ void tst_QGraphicsView::moveItemWhileScrolling()
view.resize(200, 200);
view.painted = false;
view.show();
+ if (changedConnected)
+ QObject::connect(view.scene(), SIGNAL(changed(QList<QRectF>)), this, SLOT(dummySlot()));
QTest::qWaitForWindowShown(&view);
QApplication::processEvents();
QTRY_VERIFY(view.painted);
@@ -3691,24 +3700,32 @@ void tst_QGraphicsView::update2_data()
{
QTest::addColumn<qreal>("penWidth");
QTest::addColumn<bool>("antialiasing");
+ QTest::addColumn<bool>("changedConnected");
// Anti-aliased.
- QTest::newRow("pen width: 0.0, antialiasing: true") << 0.0 << true;
- QTest::newRow("pen width: 1.5, antialiasing: true") << 1.5 << true;
- QTest::newRow("pen width: 2.0, antialiasing: true") << 2.0 << true;
- QTest::newRow("pen width: 3.0, antialiasing: true") << 3.0 << true;
+ QTest::newRow("pen width: 0.0, antialiasing: true") << 0.0 << true << false;
+ QTest::newRow("pen width: 1.5, antialiasing: true") << 1.5 << true << false;
+ QTest::newRow("pen width: 2.0, antialiasing: true") << 2.0 << true << false;
+ QTest::newRow("pen width: 3.0, antialiasing: true") << 3.0 << true << false;
// Aliased.
- QTest::newRow("pen width: 0.0, antialiasing: false") << 0.0 << false;
- QTest::newRow("pen width: 1.5, antialiasing: false") << 1.5 << false;
- QTest::newRow("pen width: 2.0, antialiasing: false") << 2.0 << false;
- QTest::newRow("pen width: 3.0, antialiasing: false") << 3.0 << false;
+ QTest::newRow("pen width: 0.0, antialiasing: false") << 0.0 << false << false;
+ QTest::newRow("pen width: 1.5, antialiasing: false") << 1.5 << false << false;
+ QTest::newRow("pen width: 2.0, antialiasing: false") << 2.0 << false << false;
+ QTest::newRow("pen width: 3.0, antialiasing: false") << 3.0 << false << false;
+
+ // changed() connected
+ QTest::newRow("pen width: 0.0, antialiasing: false, changed") << 0.0 << false << true;
+ QTest::newRow("pen width: 1.5, antialiasing: true, changed") << 1.5 << true << true;
+ QTest::newRow("pen width: 2.0, antialiasing: false, changed") << 2.0 << false << true;
+ QTest::newRow("pen width: 3.0, antialiasing: true, changed") << 3.0 << true << true;
}
void tst_QGraphicsView::update2()
{
QFETCH(qreal, penWidth);
QFETCH(bool, antialiasing);
+ QFETCH(bool, changedConnected);
// Create a rect item.
const QRectF rawItemRect(-50.4, -50.3, 100.2, 100.1);
@@ -3719,6 +3736,9 @@ void tst_QGraphicsView::update2()
// Add item to a scene.
QGraphicsScene scene(-100, -100, 200, 200);
+ if (changedConnected)
+ QObject::connect(&scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(dummySlot()));
+
scene.addItem(rect);
// Create a view on the scene.
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index e5628d1..ddc4f73 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -172,6 +172,12 @@ private slots:
void itemChangeEvents();
void itemSendGeometryPosChangesDeactivated();
+ void fontPropagatesResolveToChildren();
+ void fontPropagatesResolveToGrandChildren();
+ void fontPropagatesResolveInParentChange();
+ void fontPropagatesResolveViaNonWidget();
+ void fontPropagatesResolveFromScene();
+
// Task fixes
void task236127_bspTreeIndexFails();
void task243004_setStyleCrash();
@@ -622,6 +628,192 @@ void tst_QGraphicsWidget::font()
QCOMPARE(widget.font().family(), font.family());
}
+void tst_QGraphicsWidget::fontPropagatesResolveToChildren()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ root->setFont(font);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *child3 = new QGraphicsWidget();
+ child3->setParentItem(root);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(root->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child3->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveToGrandChildren()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ root->setFont(font);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+ QGraphicsWidget *grandChild3 = new QGraphicsWidget(child2);
+
+ QGraphicsWidget *child3 = new QGraphicsWidget();
+ QGraphicsWidget *grandChild4 = new QGraphicsWidget(child3);
+ QGraphicsWidget *grandChild5 = new QGraphicsWidget(child3);
+ child3->setParentItem(root);
+ grandChild5->setParentItem(child3);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveViaNonWidget()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsPixmapItem *child1 = new QGraphicsPixmapItem(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ root->setFont(font);
+
+ QGraphicsPixmapItem *child2 = new QGraphicsPixmapItem(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+ QGraphicsWidget *grandChild3 = new QGraphicsWidget(child2);
+
+ QGraphicsPixmapItem *child3 = new QGraphicsPixmapItem();
+ QGraphicsWidget *grandChild4 = new QGraphicsWidget(child3);
+ QGraphicsWidget *grandChild5 = new QGraphicsWidget(child3);
+ child3->setParentItem(root);
+ grandChild5->setParentItem(child3);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveFromScene()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont font;
+ font.setItalic(true);
+ scene.setFont(font);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+ QGraphicsWidget *grandChild3 = new QGraphicsWidget(child2);
+
+ QGraphicsWidget *child3 = new QGraphicsWidget();
+ QGraphicsWidget *grandChild4 = new QGraphicsWidget(child3);
+ QGraphicsWidget *grandChild5 = new QGraphicsWidget(child3);
+ child3->setParentItem(root);
+ grandChild5->setParentItem(child3);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(root->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(child3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+}
+
+void tst_QGraphicsWidget::fontPropagatesResolveInParentChange()
+{
+ QGraphicsWidget *root = new QGraphicsWidget();
+
+ QGraphicsWidget *child1 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild1 = new QGraphicsWidget(child1);
+
+ QGraphicsWidget *child2 = new QGraphicsWidget(root);
+ QGraphicsWidget *grandChild2 = new QGraphicsWidget(child2);
+
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ QFont italicFont;
+ italicFont.setItalic(true);
+ child1->setFont(italicFont);
+
+ QFont boldFont;
+ boldFont.setBold(true);
+ child2->setFont(boldFont);
+
+ QVERIFY(grandChild1->font().italic());
+ QVERIFY(!grandChild1->font().bold());
+ QVERIFY(!grandChild2->font().italic());
+ QVERIFY(grandChild2->font().bold());
+
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::WeightResolved));
+
+ grandChild2->setParentItem(child1);
+
+ QGraphicsView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QVERIFY(grandChild1->font().italic());
+ QVERIFY(!grandChild1->font().bold());
+ QVERIFY(grandChild2->font().italic());
+ QVERIFY(!grandChild2->font().bold());
+
+ QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+
+}
+
void tst_QGraphicsWidget::fontPropagation()
{
QGraphicsWidget *root = new QGraphicsWidget;
@@ -728,11 +920,12 @@ void tst_QGraphicsWidget::fontPropagationWidgetItemWidget()
widget->setFont(font);
QCOMPARE(widget2->font().pointSize(), 43);
- QCOMPARE(widget2->font().resolve(), QFont().resolve());
+ QCOMPARE(widget2->font().resolve(), uint(QFont::SizeResolved));
widget->setFont(QFont());
QCOMPARE(widget2->font().pointSize(), qApp->font().pointSize());
+ QCOMPARE(widget2->font().resolve(), QFont().resolve());
}
void tst_QGraphicsWidget::fontPropagationSceneChange()
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index 46bc6e7..6b8028c 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -162,14 +162,14 @@ void tst_QImage::create()
{
bool cr = true;
#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE)
- try {
+ QT_TRY {
#endif
//QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian);
QImage image(7000000, 7000000, QImage::Format_Indexed8);
image.setColorCount(256);
cr = !image.isNull();
#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE)
- } catch (...) {
+ } QT_CATCH (...) {
}
#endif
QVERIFY( !cr );
diff --git a/tests/auto/qimagereader/images/qtbug13653-no_eoi.jpg b/tests/auto/qimagereader/images/qtbug13653-no_eoi.jpg
new file mode 100644
index 0000000..605e8a8
--- /dev/null
+++ b/tests/auto/qimagereader/images/qtbug13653-no_eoi.jpg
Binary files differ
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index 1acc82f..5536b38 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -63,5 +63,6 @@
<file>images/rect.svgz</file>
<file>images/corrupt.svg</file>
<file>images/corrupt.svgz</file>
+ <file>images/qtbug13653-no_eoi.jpg</file>
</qresource>
</RCC>
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 5b30b04..3bee5d9 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -239,6 +239,7 @@ void tst_QImageReader::readImage_data()
#if defined QTEST_HAVE_JPEG
QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg");
+ QTest::newRow("JPEG: qtbug13653") << QString("qtbug13653-no_eoi.jpg") << true << QByteArray("jpeg");
#endif
#if defined QTEST_HAVE_GIF
QTest::newRow("GIF: earth") << QString("earth.gif") << true << QByteArray("gif");
@@ -1039,6 +1040,7 @@ void tst_QImageReader::readFromDevice_data()
QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg");
QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg");
QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-4") << QString("qtbug13653-no_eoi.jpg") << QByteArray("jpeg");
#endif // QTEST_HAVE_JPEG
#ifdef QTEST_HAVE_GIF
QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif");
@@ -1314,6 +1316,9 @@ void tst_QImageReader::readFromResources_data()
QTest::newRow("YCbCr_rgb.jpg") << QString("YCbCr_rgb.jpg")
<< QByteArray("jpg") << QSize(75, 50)
<< QString("");
+ QTest::newRow("qtbug13653-no_eoi.jpg") << QString("qtbug13653-no_eoi.jpg")
+ << QByteArray("jpg") << QSize(240, 180)
+ << QString("");
#endif
#ifdef QTEST_HAVE_MNG
QTest::newRow("corrupt.mng") << QString("corrupt.mng")
diff --git a/tests/auto/qinputcontext/qinputcontext.pro b/tests/auto/qinputcontext/qinputcontext.pro
index b3ea8c2..ec6831e 100644
--- a/tests/auto/qinputcontext/qinputcontext.pro
+++ b/tests/auto/qinputcontext/qinputcontext.pro
@@ -1,2 +1,6 @@
load(qttest_p4)
SOURCES += tst_qinputcontext.cpp
+
+symbian {
+ LIBS += -lws32 -lcone
+}
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp
index 644b463..d077bc1 100644
--- a/tests/auto/qinputcontext/tst_qinputcontext.cpp
+++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp
@@ -48,17 +48,27 @@
#include <qlayout.h>
#include <qradiobutton.h>
#include <qwindowsstyle.h>
+#include <qdesktopwidget.h>
+#include <qpushbutton.h>
+
+#ifdef Q_OS_SYMBIAN
+#include <private/qt_s60_p.h>
+#include <private/qcoefepinputcontext_p.h>
+
+#include <w32std.h>
+#include <coecntrl.h>
+#endif
class tst_QInputContext : public QObject
{
Q_OBJECT
public:
- tst_QInputContext() {}
+ tst_QInputContext() : m_phoneIsQwerty(false) {}
virtual ~tst_QInputContext() {}
public slots:
- void initTestCase() {}
+ void initTestCase();
void cleanupTestCase() {}
void init() {}
void cleanup() {}
@@ -69,8 +79,178 @@ private slots:
void closeSoftwareInputPanel();
void selections();
void focusProxy();
+ void symbianTestCoeFepInputContext_data();
+ void symbianTestCoeFepInputContext();
+ void symbianTestCoeFepAutoCommit_data();
+ void symbianTestCoeFepAutoCommit();
+
+private:
+ bool m_phoneIsQwerty;
+};
+
+#ifdef Q_OS_SYMBIAN
+class KeyEvent : public TWsEvent
+{
+public:
+ KeyEvent(QWidget *w, TInt type, TInt scanCode, TUint code, TUint modifiers, TInt repeats) {
+ iHandle = w->effectiveWinId()->DrawableWindow()->WindowGroupId();
+ iType = type;
+ SetTimeNow();
+ TKeyEvent *keyEvent = reinterpret_cast<TKeyEvent *>(iEventData);
+ keyEvent->iScanCode = scanCode;
+ keyEvent->iCode = code;
+ keyEvent->iModifiers = modifiers;
+ keyEvent->iRepeats = repeats;
+ }
+};
+
+class FepReplayEvent
+{
+public:
+ enum Type {
+ Pause,
+ Key,
+ CompleteKey
+ };
+
+ FepReplayEvent(int msecsToPause)
+ : m_type(Pause)
+ , m_msecsToPause(msecsToPause)
+ {
+ }
+
+ FepReplayEvent(TInt keyType, TInt scanCode, TUint code, TUint modifiers, TInt repeats)
+ : m_type(Key)
+ , m_keyType(keyType)
+ , m_scanCode(scanCode)
+ , m_code(code)
+ , m_modifiers(modifiers)
+ , m_repeats(repeats)
+ {
+ }
+
+ FepReplayEvent(TInt scanCode, TUint code, TUint modifiers, TInt repeats)
+ : m_type(CompleteKey)
+ , m_scanCode(scanCode)
+ , m_code(code)
+ , m_modifiers(modifiers)
+ , m_repeats(repeats)
+ {
+ }
+
+ void sendEvent(QWidget *w, TInt type, TInt scanCode, TUint code, TUint modifiers, TInt repeats)
+ {
+ KeyEvent event(w, type, scanCode, code, modifiers, repeats);
+ S60->wsSession().SendEventToWindowGroup(w->effectiveWinId()->DrawableWindow()->WindowGroupId(), event);
+ }
+
+ void pause(int msecs)
+ {
+ // Don't use qWait here. The polling nature of that function screws up the test.
+ QTimer timer;
+ QEventLoop loop;
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(msecs);
+ loop.exec();
+ }
+
+ // For some reason, the test fails if using processEvents instead of an event loop
+ // with a zero timer to quit it, so use the timer.
+#define KEY_WAIT 0
+
+ void replay(QWidget *w)
+ {
+ if (m_type == Pause) {
+ pause(m_msecsToPause);
+ } else if (m_type == Key) {
+ sendEvent(w, m_keyType, m_scanCode, m_code, m_modifiers, m_repeats);
+ if (m_keyType != EEventKeyDown)
+ // EEventKeyDown events should have no pause before the EEventKey event.
+ pause(KEY_WAIT);
+ } else if (m_type == CompleteKey) {
+ sendEvent(w, EEventKeyDown, m_scanCode, 0, m_modifiers, m_repeats);
+ // EEventKeyDown events should have no pause before the EEventKey event.
+ sendEvent(w, EEventKey, m_scanCode, m_code, m_modifiers, m_repeats);
+ pause(KEY_WAIT);
+ sendEvent(w, EEventKeyUp, m_scanCode, 0, m_modifiers, m_repeats);
+ pause(KEY_WAIT);
+ }
+ }
+
+private:
+ Type m_type;
+ int m_msecsToPause;
+ TInt m_keyType;
+ TInt m_scanCode;
+ TUint m_code;
+ TUint m_modifiers;
+ TInt m_repeats;
};
+Q_DECLARE_METATYPE(QList<FepReplayEvent>)
+Q_DECLARE_METATYPE(Qt::InputMethodHints)
+Q_DECLARE_METATYPE(QLineEdit::EchoMode);
+
+#endif // Q_OS_SYMBIAN
+
+void tst_QInputContext::initTestCase()
+{
+#ifdef Q_OS_SYMBIAN
+ // Sanity test. Checks FEP for:
+ // - T9 mode is default (it will attempt to fix this)
+ // - Language is English (it cannot fix this; bail out if not correct)
+ QWidget w;
+ QLayout *layout = new QVBoxLayout;
+ w.setLayout(layout);
+ QLineEdit *lineedit = new QLineEdit;
+ layout->addWidget(lineedit);
+ lineedit->setFocus();
+#ifdef QT_KEYPAD_NAVIGATION
+ lineedit->setEditFocus(true);
+#endif
+ w.show();
+
+ QDesktopWidget desktop;
+ QRect screenSize = desktop.screenGeometry(&w);
+ if (screenSize.width() > screenSize.height()) {
+ // Crude way of finding out we are running on a qwerty phone.
+ m_phoneIsQwerty = true;
+ return;
+ }
+
+ for (int iterations = 0; iterations < 16; iterations++) {
+ QTest::qWait(500);
+
+ QList<FepReplayEvent> keyEvents;
+
+ keyEvents << FepReplayEvent('9', '9', 0, 0);
+ keyEvents << FepReplayEvent('6', '6', 0, 0);
+ keyEvents << FepReplayEvent('8', '8', 0, 0);
+ keyEvents << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+
+ foreach(FepReplayEvent event, keyEvents) {
+ event.replay(lineedit);
+ }
+
+ QApplication::processEvents();
+
+ if (lineedit->text().endsWith("you", Qt::CaseInsensitive)) {
+ // Success!
+ return;
+ }
+
+ // Try changing modes.
+ // After 8 iterations, try to press the mode switch twice before typing.
+ for (int c = 0; c <= iterations / 8; c++) {
+ FepReplayEvent(EStdKeyHash, '#', 0, 0).replay(lineedit);
+ }
+ }
+
+ QFAIL("FEP sanity test failed. Either the phone is not set to English, or the test was unable to enable T9");
+#endif
+}
+
void tst_QInputContext::maximumTextLength()
{
QLineEdit le;
@@ -271,7 +451,6 @@ void tst_QInputContext::focusProxy()
QInputContext *gic = qApp->inputContext();
QVERIFY(gic);
- qDebug() << gic->focusWidget() << &proxy;
QCOMPARE(gic->focusWidget(), &proxy);
// then change the focus proxy and check that input context is valid
@@ -285,5 +464,622 @@ void tst_QInputContext::focusProxy()
QCOMPARE(gic->focusWidget(), &proxy);
}
+void tst_QInputContext::symbianTestCoeFepInputContext_data()
+{
+#ifdef Q_OS_SYMBIAN
+ QTest::addColumn<bool> ("inputMethodEnabled");
+ QTest::addColumn<Qt::InputMethodHints> ("inputMethodHints");
+ QTest::addColumn<int> ("maxLength"); // Zero for no limit
+ QTest::addColumn<QLineEdit::EchoMode> ("echoMode");
+ QTest::addColumn<QList<FepReplayEvent> > ("keyEvents");
+ QTest::addColumn<QString> ("finalString");
+ QTest::addColumn<QString> ("preeditString");
+ QList<FepReplayEvent> events;
+
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('6', '6', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('1', '1', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('1', '1', 0, 0);
+ QTest::newRow("Numbers (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("521")
+ << QString("");
+ QTest::newRow("Numbers and password mode (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("521")
+ << QString("");
+ QTest::newRow("Numbers")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("521")
+ << QString("");
+ QTest::newRow("Numbers max length (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("21")
+ << QString("");
+ QTest::newRow("Numbers max length")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("21")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent(EEventKeyDown, '5', 0, 0, 0);
+ events << FepReplayEvent(EEventKey, '5', '5', 0, 0);
+ events << FepReplayEvent(EEventKey, '5', '5', 0, 1);
+ events << FepReplayEvent(EEventKey, '5', '5', 0, 1);
+ events << FepReplayEvent(EEventKeyUp, '5', 0, 0, 0);
+ QTest::newRow("Numbers and autorepeat (no FEP)")
+ << false
+ << Qt::InputMethodHints(Qt::ImhNone)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("555")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('3', '3', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ QTest::newRow("Multitap")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("Adh")
+ << QString("");
+ QTest::newRow("Multitap with no auto uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("adh")
+ << QString("");
+ QTest::newRow("Multitap with uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferUppercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("ADH")
+ << QString("");
+ QTest::newRow("Multitap with lowercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("adh")
+ << QString("");
+ QTest::newRow("Multitap with forced uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhUppercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("ADH")
+ << QString("");
+ QTest::newRow("Multitap with forced lowercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhLowercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("adh")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent(EStdKeyHash, '#', 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('2', '2', 0, 0);
+ events << FepReplayEvent('3', '3', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent('5', '5', 0, 0);
+ events << FepReplayEvent(EStdKeyBackspace, EKeyBackspace, 0, 0);
+ QTest::newRow("Multitap with mode switch")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("bdh")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ QTest::newRow("Multitap with unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("Qt")
+ << QString("x");
+ events << FepReplayEvent(2000);
+ QTest::newRow("Multitap with committed text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("Qtx")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ // Simulate holding down hash key.
+ events << FepReplayEvent(EEventKeyDown, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 0);
+ events << FepReplayEvent(500);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKeyUp, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('7', '7', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ // QTBUG-9867: Switch back as well to make sure we don't get extra symbols
+ events << FepReplayEvent(EEventKeyDown, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 0);
+ events << FepReplayEvent(500);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKey, EStdKeyHash, '#', 0, 1);
+ events << FepReplayEvent(EEventKeyUp, EStdKeyHash, 0, 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ events << FepReplayEvent('6', '6', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent(2000);
+ events << FepReplayEvent(EStdKeyDevice3, EKeyDevice3, 0, 0); // Select key
+ QTest::newRow("Multitap and numbers")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("H778wmt")
+ << QString("");
+ QTest::newRow("T9 and numbers")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("hi778you")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent(EStdKeyDevice3, EKeyDevice3, 0, 0); // Select key
+ QTest::newRow("T9")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("hi")
+ << QString("");
+ QTest::newRow("T9 with uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferUppercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("HI")
+ << QString("");
+ QTest::newRow("T9 with forced lowercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhLowercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("hi")
+ << QString("");
+ QTest::newRow("T9 with forced uppercase")
+ << true
+ << Qt::InputMethodHints(Qt::ImhUppercaseOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("HI")
+ << QString("");
+ QTest::newRow("T9 with maxlength")
+ << true
+ << Qt::InputMethodHints(Qt::ImhLowercaseOnly)
+ << 1
+ << QLineEdit::Normal
+ << events
+ << QString("i")
+ << QString("");
+ events.clear();
+
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent(EStdKeyLeftArrow, EKeyLeftArrow, 0, 0);
+ events << FepReplayEvent(EStdKeyLeftArrow, EKeyLeftArrow, 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ events << FepReplayEvent('6', '6', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent('0', '0', 0, 0);
+ events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+ events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ QTest::newRow("T9 with movement and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("you hi")
+ << QString("tv");
+ QTest::newRow("T9 with movement, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("wmt h")
+ << QString("u");
+ QTest::newRow("T9 with movement, maxlength, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("T9 with movement, maxlength and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("hi")
+ << QString("");
+ QTest::newRow("Multitap with movement and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("wmt h")
+ << QString("u");
+ QTest::newRow("Multitap with movement, maxlength and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("Numbers with movement")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("96804488")
+ << QString("");
+ QTest::newRow("Numbers with movement and maxlength")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("44")
+ << QString("");
+ QTest::newRow("Numbers with movement, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("9680448")
+ << QString("8");
+ QTest::newRow("Numbers with movement, maxlength, password and unfinished text")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("44")
+ << QString("");
+ events << FepReplayEvent(EStdKeyRightArrow, EKeyRightArrow, 0, 0);
+ QTest::newRow("T9 with movement")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("you htvi")
+ << QString("");
+ QTest::newRow("T9 with movement and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("wmt hu")
+ << QString("");
+ QTest::newRow("T9 with movement, maxlength and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("Multitap with movement")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("wmt hu")
+ << QString("");
+ QTest::newRow("Multitap with movement and maxlength")
+ << true
+ << Qt::InputMethodHints(Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase)
+ << 2
+ << QLineEdit::Normal
+ << events
+ << QString("wh")
+ << QString("");
+ QTest::newRow("Numbers with movement and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("96804488")
+ << QString("");
+ QTest::newRow("Numbers with movement, maxlength and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 2
+ << QLineEdit::Password
+ << events
+ << QString("44")
+ << QString("");
+ events.clear();
+
+ // Test that the symbol key successfully does nothing when in number-only mode.
+ events << FepReplayEvent(EEventKeyDown, EStdKeyLeftFunc, 0, 0, 0);
+ events << FepReplayEvent(EEventKeyUp, EStdKeyLeftFunc, 0, 0, 0);
+ QTest::newRow("Dead symbols key")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Normal
+ << events
+ << QString("")
+ << QString("");
+ QTest::newRow("Dead symbols key and password")
+ << true
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << 0
+ << QLineEdit::Password
+ << events
+ << QString("")
+ << QString("");
+ events.clear();
+#endif
+}
+
+void tst_QInputContext::symbianTestCoeFepInputContext()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("This is a Symbian-only test", SkipAll);
+#else
+ QCoeFepInputContext *ic = qobject_cast<QCoeFepInputContext *>(qApp->inputContext());
+ if (!ic) {
+ QSKIP("coefep is not the active input context; skipping test", SkipAll);
+ }
+
+ QFETCH(bool, inputMethodEnabled);
+ QFETCH(Qt::InputMethodHints, inputMethodHints);
+ QFETCH(int, maxLength);
+ QFETCH(QLineEdit::EchoMode, echoMode);
+ QFETCH(QList<FepReplayEvent>, keyEvents);
+ QFETCH(QString, finalString);
+ QFETCH(QString, preeditString);
+
+ if (inputMethodEnabled && m_phoneIsQwerty) {
+ QSKIP("Skipping advanced input method tests on QWERTY phones", SkipSingle);
+ }
+
+ QWidget w;
+ QLayout *layout = new QVBoxLayout;
+ w.setLayout(layout);
+ QLineEdit *lineedit = new QLineEdit;
+ layout->addWidget(lineedit);
+ lineedit->setFocus();
+#ifdef QT_KEYPAD_NAVIGATION
+ lineedit->setEditFocus(true);
+#endif
+ w.show();
+
+ lineedit->setAttribute(Qt::WA_InputMethodEnabled, inputMethodEnabled);
+ lineedit->setInputMethodHints(inputMethodHints);
+ if (maxLength > 0)
+ lineedit->setMaxLength(maxLength);
+ lineedit->setEchoMode(echoMode);
+
+ QTest::qWait(200);
+
+ foreach(FepReplayEvent event, keyEvents) {
+ event.replay(lineedit);
+ }
+
+ QApplication::processEvents();
+
+ QCOMPARE(lineedit->text(), finalString);
+ QCOMPARE(ic->m_preeditString, preeditString);
+#endif
+}
+
+void tst_QInputContext::symbianTestCoeFepAutoCommit_data()
+{
+#ifdef Q_OS_SYMBIAN
+ QTest::addColumn<Qt::InputMethodHints> ("inputMethodHints");
+ QTest::addColumn<QLineEdit::EchoMode> ("echoMode");
+ QTest::addColumn<QList<FepReplayEvent> > ("keyEvents");
+ QTest::addColumn<QString> ("finalString");
+
+ QList<FepReplayEvent> events;
+
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('4', '4', 0, 0);
+ events << FepReplayEvent('0', '0', 0, 0);
+ events << FepReplayEvent('9', '9', 0, 0);
+ events << FepReplayEvent('6', '6', 0, 0);
+ events << FepReplayEvent('8', '8', 0, 0);
+ QTest::newRow("Numbers")
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << QLineEdit::Normal
+ << events
+ << QString("440968");
+ QTest::newRow("Numbers and password")
+ << Qt::InputMethodHints(Qt::ImhDigitsOnly)
+ << QLineEdit::Password
+ << events
+ << QString("440968");
+ QTest::newRow("Multitap")
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase | Qt::ImhNoPredictiveText)
+ << QLineEdit::Normal
+ << events
+ << QString("h wmt");
+ QTest::newRow("T9")
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << QLineEdit::Normal
+ << events
+ << QString("hi you");
+ QTest::newRow("Multitap with password")
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase | Qt::ImhNoPredictiveText)
+ << QLineEdit::Password
+ << events
+ << QString("h wmt");
+ QTest::newRow("T9 with password")
+ << Qt::InputMethodHints(Qt::ImhPreferLowercase)
+ << QLineEdit::Password
+ << events
+ << QString("h wmt");
+#endif
+}
+
+void tst_QInputContext::symbianTestCoeFepAutoCommit()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("This is a Symbian-only test", SkipAll);
+#else
+ QCoeFepInputContext *ic = qobject_cast<QCoeFepInputContext *>(qApp->inputContext());
+ if (!ic) {
+ QSKIP("coefep is not the active input context; skipping test", SkipAll);
+ }
+
+ QFETCH(Qt::InputMethodHints, inputMethodHints);
+ QFETCH(QLineEdit::EchoMode, echoMode);
+ QFETCH(QList<FepReplayEvent>, keyEvents);
+ QFETCH(QString, finalString);
+
+ if (m_phoneIsQwerty) {
+ QSKIP("Skipping advanced input method tests on QWERTY phones", SkipSingle);
+ }
+
+ QWidget w;
+ QLayout *layout = new QVBoxLayout;
+ w.setLayout(layout);
+ QLineEdit *lineedit = new QLineEdit;
+ layout->addWidget(lineedit);
+ lineedit->setFocus();
+#ifdef QT_KEYPAD_NAVIGATION
+ lineedit->setEditFocus(true);
+#endif
+ QPushButton *pushButton = new QPushButton("Done");
+ layout->addWidget(pushButton);
+ QAction softkey("Done", &w);
+ softkey.setSoftKeyRole(QAction::PositiveSoftKey);
+ w.addAction(&softkey);
+ w.show();
+
+ lineedit->setInputMethodHints(inputMethodHints);
+ lineedit->setEchoMode(echoMode);
+
+ QTest::qWait(200);
+ foreach(FepReplayEvent event, keyEvents) {
+ event.replay(lineedit);
+ }
+ QApplication::processEvents();
+
+ QTest::mouseClick(pushButton, Qt::LeftButton);
+
+ QCOMPARE(lineedit->text(), finalString);
+ QVERIFY(ic->m_preeditString.isEmpty());
+
+#ifdef Q_WS_S60
+ lineedit->inputContext()->reset();
+ lineedit->clear();
+ lineedit->setFocus();
+#ifdef QT_KEYPAD_NAVIGATION
+ lineedit->setEditFocus(true);
+#endif
+
+ QTest::qWait(200);
+ foreach(FepReplayEvent event, keyEvents) {
+ event.replay(lineedit);
+ }
+ QApplication::processEvents();
+
+ FepReplayEvent(EStdKeyDevice0, EKeyDevice0, 0, 0).replay(lineedit); // Left softkey
+
+ QCOMPARE(lineedit->text(), finalString);
+ QVERIFY(ic->m_preeditString.isEmpty());
+
+#endif // Q_WS_S60
+#endif // Q_OS_SYMBIAN
+}
+
QTEST_MAIN(tst_QInputContext)
#include "tst_qinputcontext.moc"
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 2a378fe..97a9b82 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -235,6 +235,7 @@ private slots:
void enterKey();
void task257859_finalizeEdit();
+ void QTBUG4435_keepSelectionOnCheck();
};
@@ -1168,6 +1169,31 @@ void tst_QItemDelegate::task257859_finalizeEdit()
QTRY_VERIFY(!editor);
}
+void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
+{
+ QStandardItemModel model(3, 1);
+ for (int i = 0; i < 3; ++i) {
+ QStandardItem *item = new QStandardItem(QLatin1String("Item ") + QString::number(i));
+ item->setCheckable(true);
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ model.setItem(i, item);
+ }
+ QTableView view;
+ view.setModel(&model);
+ view.setItemDelegate(new TestItemDelegate);
+ view.show();
+ view.selectAll();
+ QTest::qWaitForWindowShown(&view);
+ QStyleOptionViewItem option;
+ option.rect = view.visualRect(model.index(0, 0));
+ const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
+ QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center()
+ + QPoint(checkMargin, 0);
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos);
+ QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
+ QCOMPARE(model.item(0)->checkState(), Qt::Checked);
+}
+
// ### _not_ covered:
diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp
index 1faae6a..60f022f 100644
--- a/tests/auto/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp
@@ -532,20 +532,20 @@ void tst_QKeySequence::translated_data()
QTest::addColumn<QString>("transKey");
QTest::addColumn<QString>("compKey");
- QTest::newRow("Shift++") << QString(tr("Shift++")) << QString("Umschalt++");
- QTest::newRow("Ctrl++") << QString(tr("Ctrl++")) << QString("Strg++");
- QTest::newRow("Alt++") << QString(tr("Alt++")) << QString("Alt++");
- QTest::newRow("Meta++") << QString(tr("Meta++")) << QString("Meta++");
-
- QTest::newRow("Shift+,, Shift++") << QString(tr("Shift+,, Shift++")) << QString("Umschalt+,, Umschalt++");
- QTest::newRow("Shift+,, Ctrl++") << QString(tr("Shift+,, Ctrl++")) << QString("Umschalt+,, Strg++");
- QTest::newRow("Shift+,, Alt++") << QString(tr("Shift+,, Alt++")) << QString("Umschalt+,, Alt++");
- QTest::newRow("Shift+,, Meta++") << QString(tr("Shift+,, Meta++")) << QString("Umschalt+,, Meta++");
-
- QTest::newRow("Ctrl+,, Shift++") << QString(tr("Ctrl+,, Shift++")) << QString("Strg+,, Umschalt++");
- QTest::newRow("Ctrl+,, Ctrl++") << QString(tr("Ctrl+,, Ctrl++")) << QString("Strg+,, Strg++");
- QTest::newRow("Ctrl+,, Alt++") << QString(tr("Ctrl+,, Alt++")) << QString("Strg+,, Alt++");
- QTest::newRow("Ctrl+,, Meta++") << QString(tr("Ctrl+,, Meta++")) << QString("Strg+,, Meta++");
+ QTest::newRow("Shift++") << tr("Shift++") << QString("Umschalt++");
+ QTest::newRow("Ctrl++") << tr("Ctrl++") << QString("Strg++");
+ QTest::newRow("Alt++") << tr("Alt++") << QString("Alt++");
+ QTest::newRow("Meta++") << tr("Meta++") << QString("Meta++");
+
+ QTest::newRow("Shift+,, Shift++") << tr("Shift+,, Shift++") << QString("Umschalt+,, Umschalt++");
+ QTest::newRow("Shift+,, Ctrl++") << tr("Shift+,, Ctrl++") << QString("Umschalt+,, Strg++");
+ QTest::newRow("Shift+,, Alt++") << tr("Shift+,, Alt++") << QString("Umschalt+,, Alt++");
+ QTest::newRow("Shift+,, Meta++") << tr("Shift+,, Meta++") << QString("Umschalt+,, Meta++");
+
+ QTest::newRow("Ctrl+,, Shift++") << tr("Ctrl+,, Shift++") << QString("Strg+,, Umschalt++");
+ QTest::newRow("Ctrl+,, Ctrl++") << tr("Ctrl+,, Ctrl++") << QString("Strg+,, Strg++");
+ QTest::newRow("Ctrl+,, Alt++") << tr("Ctrl+,, Alt++") << QString("Strg+,, Alt++");
+ QTest::newRow("Ctrl+,, Meta++") << tr("Ctrl+,, Meta++") << QString("Strg+,, Meta++");
qApp->removeTranslator(ourTranslator);
qApp->removeTranslator(qtTranslator);
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 717b32d..93bd447 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -275,6 +275,7 @@ private slots:
#endif
void taskQTBUG_7395_readOnlyShortcut();
void QTBUG697_paletteCurrentColorGroup();
+ void QTBUG13520_textNotVisible();
#ifdef QT3_SUPPORT
void validateAndSet_data();
@@ -3034,6 +3035,8 @@ public:
};
State state;
+
+ friend class tst_QLineEdit;
};
Q_DECLARE_METATYPE(LineEdit::State);
@@ -3741,5 +3744,21 @@ void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::red).rgb());
}
+void tst_QLineEdit::QTBUG13520_textNotVisible()
+{
+ LineEdit le;
+ le.setAlignment( Qt::AlignRight | Qt::AlignVCenter);
+ le.show();
+ QTest::qWaitForWindowShown(&le);
+ le.setText("01-ST16-01SIL-MPL001wfgsdfgsdgsdfgsdfgsdfgsdfgsdfg");
+ le.setCursorPosition(0);
+ QTest::qWait(100); //just make sure we get he lineedit correcly painted
+
+ QVERIFY(le.cursorRect().center().x() < le.width() / 2);
+
+
+}
+
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"
diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp
index ba8aefa..14b8057 100644
--- a/tests/auto/qlist/tst_qlist.cpp
+++ b/tests/auto/qlist/tst_qlist.cpp
@@ -89,6 +89,8 @@ private slots:
void testSTLIterators() const;
void testOperators() const;
+
+ void initializeList() const;
};
void tst_QList::length() const
@@ -662,5 +664,19 @@ void tst_QList::testSTLIterators() const
QCOMPARE(*it, QLatin1String("foo"));
}
+void tst_QList::initializeList() const
+{
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ QList<int> v1{2,3,4};
+ QCOMPARE(v1, QList<int>() << 2 << 3 << 4);
+ QCOMPARE(v1, (QList<int>{2,3,4}));
+
+ QList<QList<int>> v2{ v1, {1}, QList<int>(), {2,3,4} };
+ QList<QList<int>> v3;
+ v3 << v1 << (QList<int>() << 1) << QList<int>() << v1;
+ QCOMPARE(v3, v2);
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_QList)
#include "tst_qlist.moc"
diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp
index 1273e85..5a69d9c 100644
--- a/tests/auto/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp
@@ -1449,8 +1449,7 @@ Q_DECLARE_METATYPE(MoveList)
void MoveSeparator::apply(QMainWindow *mw) const
{
-
- QMainWindowLayout *l = qobject_cast<QMainWindowLayout*>(mw->layout());
+ QMainWindowLayout *l = qFindChild<QMainWindowLayout *>(mw);
QVERIFY(l);
QList<int> path;
diff --git a/tests/auto/qmake/qmake.pro b/tests/auto/qmake/qmake.pro
index 8cae6be..d0faa87 100644
--- a/tests/auto/qmake/qmake.pro
+++ b/tests/auto/qmake/qmake.pro
@@ -1,6 +1,7 @@
load(qttest_p4)
HEADERS += testcompiler.h
SOURCES += tst_qmake.cpp testcompiler.cpp
+QT -= gui
cross_compile: DEFINES += QMAKE_CROSS_COMPILED
diff --git a/tests/auto/qmake/testdata/substitutes/sub/test2.in b/tests/auto/qmake/testdata/substitutes/sub/test2.in
new file mode 100644
index 0000000..78a6069
--- /dev/null
+++ b/tests/auto/qmake/testdata/substitutes/sub/test2.in
@@ -0,0 +1 @@
+heya
diff --git a/tests/auto/qmake/testdata/substitutes/test.in b/tests/auto/qmake/testdata/substitutes/test.in
new file mode 100644
index 0000000..2fa05e0
--- /dev/null
+++ b/tests/auto/qmake/testdata/substitutes/test.in
@@ -0,0 +1,2 @@
+test
+tst
diff --git a/tests/auto/qmake/testdata/substitutes/test.pro b/tests/auto/qmake/testdata/substitutes/test.pro
new file mode 100644
index 0000000..26b0272
--- /dev/null
+++ b/tests/auto/qmake/testdata/substitutes/test.pro
@@ -0,0 +1,5 @@
+QMAKE_SUBSTITUTES += test.in sub/test2.in indirect
+
+indirect.input = $$PWD/test3.txt
+indirect.output = $$OUT_PWD/sub/indirect_test.txt
+
diff --git a/tests/auto/qmake/testdata/substitutes/test3.txt b/tests/auto/qmake/testdata/substitutes/test3.txt
new file mode 100644
index 0000000..ce01362
--- /dev/null
+++ b/tests/auto/qmake/testdata/substitutes/test3.txt
@@ -0,0 +1 @@
+hello
diff --git a/tests/auto/qmake/testdata/substitutes_build/README b/tests/auto/qmake/testdata/substitutes_build/README
new file mode 100644
index 0000000..81dc596
--- /dev/null
+++ b/tests/auto/qmake/testdata/substitutes_build/README
@@ -0,0 +1 @@
+Placeholder file to ensure this directory exists
diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp
index 5efe714..1d3e128 100644
--- a/tests/auto/qmake/tst_qmake.cpp
+++ b/tests/auto/qmake/tst_qmake.cpp
@@ -90,6 +90,7 @@ private slots:
void bundle_spaces();
#endif
void includefunction();
+ void substitutes();
private:
TestCompiler test_compiler;
@@ -98,7 +99,8 @@ private:
tst_qmake::tst_qmake()
{
- QString cmd = QString("qmake \"QT_VERSION=%1\"").arg(QT_VERSION);
+ QString binpath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
+ QString cmd = QString("%2/qmake \"QT_VERSION=%1\"").arg(QT_VERSION).arg(binpath);
#ifdef Q_CC_MSVC
test_compiler.setBaseCommands( "nmake", cmd );
#elif defined(Q_CC_MINGW)
@@ -477,6 +479,23 @@ void tst_qmake::includefunction()
QVERIFY(test_compiler.commandOutput().contains(warningMsg));
}
+void tst_qmake::substitutes()
+{
+ QString workDir = base_path + "/testdata/substitutes";
+ QVERIFY( test_compiler.qmake( workDir, "test" ));
+ QVERIFY( test_compiler.exists( workDir, "test", Plain, "" ));
+ QVERIFY( test_compiler.exists( workDir, "sub/test2", Plain, "" ));
+ QVERIFY( test_compiler.exists( workDir, "sub/indirect_test.txt", Plain, "" ));
+ QVERIFY( test_compiler.makeDistClean( workDir ));
+
+ QString buildDir = base_path + "/testdata/substitutes_build";
+ QVERIFY( test_compiler.qmake( workDir, "test", buildDir ));
+ QVERIFY( test_compiler.exists( buildDir, "test", Plain, "" ));
+ QVERIFY( test_compiler.exists( buildDir, "sub/test2", Plain, "" ));
+ QVERIFY( test_compiler.exists( buildDir, "sub/indirect_test.txt", Plain, "" ));
+ QVERIFY( test_compiler.makeDistClean( buildDir ));
+}
+
QTEST_MAIN(tst_qmake)
#include "tst_qmake.moc"
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index ff39842..1d0980e 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -107,7 +107,7 @@ class tst_QMetaObject : public QObject
Q_PROPERTY(QVariantList value5 WRITE setVal5 READ val5)
Q_PROPERTY(int value6 READ value6 NOTIFY value6Changed)
Q_PROPERTY(MyStruct value7 READ value7 WRITE setVal7 NOTIFY value7Changed)
- Q_PROPERTY(int value8 READ value8 NOTIFY value8Changed)
+ Q_PROPERTY(int value8 READ value8)
Q_PROPERTY(int value9 READ value9 CONSTANT)
Q_PROPERTY(int value10 READ value10 FINAL)
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index bb91965..2ad4060 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -296,6 +296,7 @@ private Q_SLOTS:
void ioGetFromHttpWithoutContentLength();
void ioGetFromHttpBrokenChunkedEncoding();
+ void qtbug12908compressedHttpReply();
// NOTE: This test must be last!
void parentingRepliesToTheApp();
@@ -4375,6 +4376,30 @@ void tst_QNetworkReply::ioGetFromHttpBrokenChunkedEncoding()
QCOMPARE(reply->error(), QNetworkReply::NoError);
}
+// TODO:
+// Prepare a gzip that has one chunk that expands to the size mentioned in the bugreport.
+// Then have a custom HTTP server that waits after this chunk so the returning gets
+// triggered.
+void tst_QNetworkReply::qtbug12908compressedHttpReply()
+{
+ QString header("HTTP/1.0 200 OK\r\nContent-Encoding: gzip\r\nContent-Length: 63\r\n\r\n");
+
+ // dd if=/dev/zero of=qtbug-12908 bs=16384 count=1 && gzip qtbug-12908 && base64 -w 0 qtbug-12908.gz
+ QString encodedFile("H4sICDdDaUwAA3F0YnVnLTEyOTA4AO3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAIC3AYbSVKsAQAAA");
+ QByteArray decodedFile = QByteArray::fromBase64(encodedFile.toAscii());
+
+ MiniHttpServer server(header.toAscii() + decodedFile);
+ 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());
+
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+}
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index abfe24b..24cd5a3 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -3285,16 +3285,16 @@ void tst_QObject::overloads()
QCOMPARE(obj2.s_num, 101);
emit obj1.sig(&obj2, &obj3); //this signal is connected
QCOMPARE(obj1.s_num, 11);
- QCOMPARE(obj1.o1_obj, &obj2);
+ QCOMPARE(obj1.o1_obj, (QObject *)&obj2);
QCOMPARE(obj1.o2_obj, &obj3);
QCOMPARE(obj1.o3_obj, (QObject *)0); //default arg of the signal
- QCOMPARE(obj1.o4_obj, qApp); //default arg of the slot
+ QCOMPARE(obj1.o4_obj, (QObject *)qApp); //default arg of the slot
QCOMPARE(obj2.s_num, 111);
- QCOMPARE(obj2.o1_obj, &obj2);
+ QCOMPARE(obj2.o1_obj, (QObject *)&obj2);
QCOMPARE(obj2.o2_obj, &obj3);
QCOMPARE(obj2.o3_obj, (QObject *)0); //default arg of the signal
- QCOMPARE(obj2.o4_obj, qApp); //default arg of the slot
+ QCOMPARE(obj2.o4_obj, (QObject *)qApp); //default arg of the slot
}
class ManySignals : public QObject
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 5003950..ae97285 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -118,12 +118,10 @@ private slots:
void drawLine_task190634();
void drawLine_task229459();
void drawLine_task234891();
- void drawHorizontalLineF();
void drawRect_data() { fillData(); }
void drawRect();
void drawRect2();
- void drawRectFHorizontalLine();
void fillRect();
void fillRect2();
@@ -223,6 +221,8 @@ private slots:
void drawRect_task215378();
void drawRect_task247505();
+ void drawText_subPixelPositionsInRaster_qtbug5053();
+
void drawImage_data();
void drawImage();
@@ -255,7 +255,6 @@ private slots:
void setPenColorOnPixmap();
void QTBUG5939_attachPainterPrivate();
- void drawHorizontalLine();
private:
void fillData();
@@ -1223,26 +1222,6 @@ void tst_QPainter::drawLine_task234891()
QCOMPARE(expected, img);
}
-void tst_QPainter::drawHorizontalLineF()
-{
- QPixmap pixmap(100, 3);
- pixmap.fill();
-
- {
- QPainter painter(&pixmap);
- painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f));
- }
-
- QImage refImage(100, 3, QImage::Format_ARGB32);
- refImage.fill(0xFFFFFFFF);
- {
- QPainter painter(&refImage);
- painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f));
- }
-
- QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
-}
-
void tst_QPainter::drawLine_task216948()
{
QImage img(1, 10, QImage::Format_ARGB32_Premultiplied);
@@ -1327,26 +1306,6 @@ void tst_QPainter::drawRect2()
}
}
-void tst_QPainter::drawRectFHorizontalLine()
-{
- QPixmap pixmap(100, 3);
- pixmap.fill();
-
- {
- QPainter painter(&pixmap);
- painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f));
- }
-
- QImage refImage(100, 3, QImage::Format_ARGB32);
- refImage.fill(0xFFFFFFFF);
- {
- QPainter painter(&refImage);
- painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f));
- }
-
- QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
-}
-
void tst_QPainter::fillRect()
{
QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
@@ -4584,6 +4543,14 @@ void tst_QPainter::clipBoundingRect()
QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20)));
QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+ // Test a basic float rectangle
+ p.setClipRect(QRectF(100, 100, 200, 100));
+ QVERIFY(p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(50, 50, 300, 200)));
+ p.setClipRect(QRectF(120, 120, 20, 20), Qt::IntersectClip);
+ QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+
// Test a basic path + region
QPainterPath path;
path.addRect(100, 100, 200, 100);
@@ -4605,26 +4572,63 @@ void tst_QPainter::clipBoundingRect()
}
-void tst_QPainter::drawHorizontalLine()
+void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
{
- QPixmap pixmap(100, 3);
- pixmap.fill();
+#if !defined(Q_WS_MAC) || !defined(QT_MAC_USE_COCOA)
+ QSKIP("Only Mac/Cocoa supports sub pixel positions in raster engine currently", SkipAll);
+#endif
- {
- QPainter painter(&pixmap);
- painter.translate(0.3, 0.3);
- painter.drawLine(QLine(1, 1, 99, 1));
+ int w = 10, h = 10;
+ QImage image(w, h, QImage::Format_RGB32);
+ image.fill(0xffffffff);
+ QPainter p(&image);
+ p.drawText(0, h, "X\\");
+ p.end();
+
+ bool foundNonGrayPixel = false;
+ const int *bits = (const int *) ((const QImage &) image).bits();
+ int bpl = image.bytesPerLine() / 4;
+ for (int y=0; y<w; ++y) {
+ for (int x=0; x<h; ++x) {
+ int r = qRed(bits[x]);
+ int g = qGreen(bits[x]);
+ int b = qBlue(bits[x]);
+ if (r != g || r != b) {
+ foundNonGrayPixel = true;
+ break;
+ }
+ }
+ bits += bpl;
}
+ if (!foundNonGrayPixel)
+ QSKIP("Font smoothing must be turned on for this test", SkipAll);
+
+ QFontMetricsF fm(qApp->font());
- QImage refImage(100, 3, QImage::Format_ARGB32);
- refImage.fill(0xFFFFFFFF);
+ QImage baseLine(fm.width(QChar::fromLatin1('e')), fm.height(), QImage::Format_RGB32);
+ baseLine.fill(Qt::white);
{
- QPainter painter(&refImage);
- painter.translate(0.3, 0.3);
- painter.drawLine(QLine(1, 1, 99, 1));
+ QPainter p(&baseLine);
+ p.drawText(0, fm.ascent(), QString::fromLatin1("e"));
+ }
+
+ bool foundDifferentRasterization = false;
+ for (int i=1; i<12; ++i) {
+ QImage comparison(baseLine.size(), QImage::Format_RGB32);
+ comparison.fill(Qt::white);
+
+ {
+ QPainter p(&comparison);
+ p.drawText(QPointF(i / 12.0, fm.ascent()), QString::fromLatin1("e"));
+ }
+
+ if (comparison != baseLine) {
+ foundDifferentRasterization = true;
+ break;
+ }
}
- QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
+ QVERIFY(foundDifferentRasterization);
}
QTEST_MAIN(tst_QPainter)
diff --git a/tests/auto/qpen/tst_qpen.cpp b/tests/auto/qpen/tst_qpen.cpp
index 149f462..b0c2cad 100644
--- a/tests/auto/qpen/tst_qpen.cpp
+++ b/tests/auto/qpen/tst_qpen.cpp
@@ -213,6 +213,5 @@ void tst_QPen::stream()
QCOMPARE(pen, cmp);
}
-
QTEST_APPLESS_MAIN(tst_QPen)
#include "tst_qpen.moc"
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index f22edf6..8005ec5 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -742,6 +742,11 @@ void tst_QPixmap::testMetrics()
QCOMPARE(bitmap.width(), 100);
QCOMPARE(bitmap.height(), 100);
QCOMPARE(bitmap.depth(), 1);
+
+ QPixmap null;
+
+ QCOMPARE(null.size().width(), null.width());
+ QCOMPARE(null.size().height(), null.height());
}
void tst_QPixmap::createMaskFromColor()
@@ -1558,6 +1563,8 @@ void tst_QPixmap::loadFromDataImage_data()
const QString prefix = QLatin1String(SRCDIR) + "/loadFromData";
#endif
QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png";
+ // When no extension is provided we try all extensions that has been registered by image providers
+ QTest::newRow("designer_argb32") << prefix + "/designer_argb32.png";
QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png";
QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png";
QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png";
@@ -1673,31 +1680,39 @@ void tst_QPixmap::preserveDepth()
void tst_QPixmap::loadAsBitmapOrPixmap()
{
QImage tmp(10, 10, QImage::Format_RGB32);
- tmp.save("tmp.png");
+ tmp.save("temp_image.png");
bool ok;
// Check that we can load the pixmap as a pixmap and that it then turns into a pixmap
- QPixmap pixmap("tmp.png");
+ QPixmap pixmap("temp_image.png");
+ QVERIFY(!pixmap.isNull());
+ QVERIFY(pixmap.depth() > 1);
+ QVERIFY(!pixmap.isQBitmap());
+
+ pixmap = QPixmap();
+ ok = pixmap.load("temp_image.png");
+ QVERIFY(ok);
QVERIFY(!pixmap.isNull());
QVERIFY(pixmap.depth() > 1);
QVERIFY(!pixmap.isQBitmap());
+ //now we can try to load it without an extension
pixmap = QPixmap();
- ok = pixmap.load("tmp.png");
+ ok = pixmap.load("temp_image");
QVERIFY(ok);
QVERIFY(!pixmap.isNull());
QVERIFY(pixmap.depth() > 1);
QVERIFY(!pixmap.isQBitmap());
// The do the same check for bitmaps..
- QBitmap bitmap("tmp.png");
+ QBitmap bitmap("temp_image.png");
QVERIFY(!bitmap.isNull());
QVERIFY(bitmap.depth() == 1);
QVERIFY(bitmap.isQBitmap());
bitmap = QBitmap();
- ok = bitmap.load("tmp.png");
+ ok = bitmap.load("temp_image.png");
QVERIFY(ok);
QVERIFY(!bitmap.isNull());
QVERIFY(bitmap.depth() == 1);
diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
index f0f087d..12d2c57 100644
--- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
+++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
@@ -72,6 +72,7 @@ private slots:
void convolutionBoundingRectFor();
void convolutionDrawSubRect();
void dropShadowBoundingRectFor();
+ void blurIndexed8();
void testDefaultImplementations();
};
@@ -423,6 +424,27 @@ void tst_QPixmapFilter::dropShadowBoundingRectFor()
QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta - 10, -delta - 10, 0, 0));
}
+QT_BEGIN_NAMESPACE
+void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
+QT_END_NAMESPACE
+
+void tst_QPixmapFilter::blurIndexed8()
+{
+ QImage img(16, 32, QImage::Format_Indexed8);
+ img.setColorCount(256);
+ for (int i = 0; i < 256; ++i)
+ img.setColor(i, qRgb(i, i, i));
+
+ img.fill(255);
+
+ QImage original = img;
+ qt_blurImage(img, 10, true, false);
+ QCOMPARE(original.size(), img.size());
+
+ original = img;
+ qt_blurImage(img, 10, true, true);
+ QCOMPARE(original.size(), QSize(img.height(), img.width()));
+}
QTEST_MAIN(tst_QPixmapFilter)
#include "tst_qpixmapfilter.moc"
diff --git a/tests/auto/qpluginloader/elftest/.gitattributes b/tests/auto/qpluginloader/elftest/.gitattributes
new file mode 100644
index 0000000..891192c
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/.gitattributes
@@ -0,0 +1,10 @@
+corrupt1.elf64.so set -crlf -diff
+corrupt2.elf64.so set -crlf -diff
+corrupt3.elf64.so set -crlf -diff
+debugobj.so set -crlf -diff
+garbage1.so set -crlf -diff
+garbage2.so set -crlf -diff
+garbage3.so set -crlf -diff
+garbage4.so set -crlf -diff
+garbage5.so set -crlf -diff
+
diff --git a/tests/auto/qpluginloader/elftest/corrupt1.elf64.so b/tests/auto/qpluginloader/elftest/corrupt1.elf64.so
new file mode 100755
index 0000000..12ce736
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/corrupt1.elf64.so
Binary files differ
diff --git a/tests/auto/qpluginloader/elftest/corrupt2.elf64.so b/tests/auto/qpluginloader/elftest/corrupt2.elf64.so
new file mode 100755
index 0000000..11fdc2c
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/corrupt2.elf64.so
Binary files differ
diff --git a/tests/auto/qpluginloader/elftest/corrupt3.elf64.so b/tests/auto/qpluginloader/elftest/corrupt3.elf64.so
new file mode 100755
index 0000000..94a2bc3
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/corrupt3.elf64.so
Binary files differ
diff --git a/tests/auto/qpluginloader/elftest/debugobj.so b/tests/auto/qpluginloader/elftest/debugobj.so
new file mode 100644
index 0000000..f0ee056
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/debugobj.so
Binary files differ
diff --git a/tests/auto/qpluginloader/elftest/garbage1.so b/tests/auto/qpluginloader/elftest/garbage1.so
new file mode 100644
index 0000000..0c74530
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/garbage1.so
@@ -0,0 +1,4 @@
+p¶¤Ðã¨ø±ÕÛcdL+ôúæî&‘¿&÷ýeü¥=კ²
+•o°Ã’ÊŽI› §ÙÏmgƒ]!ÀZ
+L'Ž)t±
+ÙN»¸(e©× P)Y8öG ˆ6ß-yÈÏÀ ñŸ§÷—“"ô–ZÖÿ›kõ4â?Ë^náÁÇß5$ž’ôY=£ð#y \ No newline at end of file
diff --git a/tests/auto/qpluginloader/elftest/garbage2.so b/tests/auto/qpluginloader/elftest/garbage2.so
new file mode 100644
index 0000000..c06338e
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/garbage2.so
@@ -0,0 +1 @@
+£Çv.³Y‹¨tKëW3 \ No newline at end of file
diff --git a/tests/auto/qpluginloader/elftest/garbage3.so b/tests/auto/qpluginloader/elftest/garbage3.so
new file mode 100644
index 0000000..a24c523
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/garbage3.so
@@ -0,0 +1 @@
+£ÝÈÈ‚åžT-õ«´ÊôÚ¥ Àä¸ï¨ì¾œÀi8¼_ñxÓõª¾I±Ð×®ÝxÎ=úØ4@þñ[¨—úBàKS$ú \ No newline at end of file
diff --git a/tests/auto/qpluginloader/elftest/garbage4.so b/tests/auto/qpluginloader/elftest/garbage4.so
new file mode 100644
index 0000000..4f45cf5
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/garbage4.so
@@ -0,0 +1 @@
+¶ !¦\~çU­u³†:9©ˆ œ§T+91ˆQ¬EøåÇšx¨ng5Óã—zhŒ–…ÿÆ^t™ŠµŽ¦'ÆÎmm*ˈdXH;vw+ªG“²ÃàØ ¨9Lƒ0! \ No newline at end of file
diff --git a/tests/auto/qpluginloader/elftest/garbage5.so b/tests/auto/qpluginloader/elftest/garbage5.so
new file mode 100644
index 0000000..f8c0a1d
--- /dev/null
+++ b/tests/auto/qpluginloader/elftest/garbage5.so
@@ -0,0 +1,2 @@
+ïÌô’Q²
+ãµ-¢9Ò \ No newline at end of file
diff --git a/tests/auto/qpluginloader/tst/tst.pro b/tests/auto/qpluginloader/tst/tst.pro
index 2d757e7..e270120 100644
--- a/tests/auto/qpluginloader/tst/tst.pro
+++ b/tests/auto/qpluginloader/tst/tst.pro
@@ -27,3 +27,5 @@ symbian: {
DEPLOYMENT += libDep pluginDep
}
+
+DEFINES += SRCDIR=\\\"$$PWD/../\\\"
diff --git a/tests/auto/qpluginloader/tst_qpluginloader.cpp b/tests/auto/qpluginloader/tst_qpluginloader.cpp
index 1e382b8..46fce5e 100644
--- a/tests/auto/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/qpluginloader/tst_qpluginloader.cpp
@@ -123,6 +123,9 @@ private slots:
void loadHints();
void deleteinstanceOnUnload();
void checkingStubsFromDifferentDrives();
+ void loadDebugObj();
+ void loadCorruptElf();
+ void loadGarbage();
};
tst_QPluginLoader::tst_QPluginLoader()
@@ -350,5 +353,54 @@ void tst_QPluginLoader::checkingStubsFromDifferentDrives()
#endif//Q_OS_SYMBIAN
}
+void tst_QPluginLoader::loadDebugObj()
+{
+#if defined (__ELF__)
+ QVERIFY(QFile::exists(SRCDIR "elftest/debugobj.so"));
+ QPluginLoader lib1(SRCDIR "elftest/debugobj.so");
+ QCOMPARE(lib1.load(), false);
+#endif
+}
+
+void tst_QPluginLoader::loadCorruptElf()
+{
+#if defined (__ELF__)
+if (sizeof(void*) == 8) {
+ QVERIFY(QFile::exists(SRCDIR "elftest/corrupt1.elf64.so"));
+
+ QPluginLoader lib1(SRCDIR "elftest/corrupt1.elf64.so");
+ QCOMPARE(lib1.load(), false);
+ QVERIFY(lib1.errorString().contains("not an ELF object"));
+
+ QPluginLoader lib2(SRCDIR "elftest/corrupt2.elf64.so");
+ QCOMPARE(lib2.load(), false);
+ QVERIFY(lib2.errorString().contains("invalid"));
+
+ QPluginLoader lib3(SRCDIR "elftest/corrupt3.elf64.so");
+ QCOMPARE(lib3.load(), false);
+ QVERIFY(lib3.errorString().contains("invalid"));
+} else if (sizeof(void*) == 4) {
+ QPluginLoader libW(SRCDIR "elftest/corrupt3.elf64.so");
+ QCOMPARE(libW.load(), false);
+ QVERIFY(libW.errorString().contains("architecture"));
+} else {
+ QFAIL("Please port QElfParser to this platform or blacklist this test.");
+}
+#endif
+}
+
+void tst_QPluginLoader::loadGarbage()
+{
+#if defined (Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+ for (int i=0; i<5; i++) {
+ QPluginLoader lib(QString(SRCDIR "elftest/garbage%1.so").arg(i));
+ QCOMPARE(lib.load(), false);
+#ifdef SHOW_ERRORS
+ qDebug() << lib.errorString();
+#endif
+ }
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_QPluginLoader)
#include "tst_qpluginloader.moc"
diff --git a/tests/auto/qscriptengine/idtranslatable.js b/tests/auto/qscriptengine/idtranslatable.js
new file mode 100644
index 0000000..554ca88
--- /dev/null
+++ b/tests/auto/qscriptengine/idtranslatable.js
@@ -0,0 +1,5 @@
+qsTrId("qtn_foo_bar");
+
+var more_greeting_strings = [ QT_TRID_NOOP("qtn_needle"), QT_TRID_NOOP("qtn_haystack") ];
+
+qsTrId("qtn_bar_baz", 10);
diff --git a/tests/auto/qscriptengine/qscriptengine.qrc b/tests/auto/qscriptengine/qscriptengine.qrc
index b87f985..fa55a5b 100644
--- a/tests/auto/qscriptengine/qscriptengine.qrc
+++ b/tests/auto/qscriptengine/qscriptengine.qrc
@@ -1,5 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>translations/translatable_la.qm</file>
+ <file>translations/idtranslatable_la.qm</file>
</qresource>
</RCC>
diff --git a/tests/auto/qscriptengine/translations/idtranslatable_la.qm b/tests/auto/qscriptengine/translations/idtranslatable_la.qm
new file mode 100644
index 0000000..c8c0b72
--- /dev/null
+++ b/tests/auto/qscriptengine/translations/idtranslatable_la.qm
Binary files differ
diff --git a/tests/auto/qscriptengine/translations/idtranslatable_la.ts b/tests/auto/qscriptengine/translations/idtranslatable_la.ts
new file mode 100644
index 0000000..b6d7053
--- /dev/null
+++ b/tests/auto/qscriptengine/translations/idtranslatable_la.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="nb_NO">
+<context>
+ <name></name>
+ <message id="qtn_foo_bar">
+ <location filename="idtranslatable.js" line="1"/>
+ <source></source>
+ <translation>First string</translation>
+ </message>
+ <message id="qtn_needle">
+ <location filename="idtranslatable.js" line="3"/>
+ <source></source>
+ <translation>Second string</translation>
+ </message>
+ <message id="qtn_haystack">
+ <location filename="idtranslatable.js" line="3"/>
+ <source></source>
+ <translation>Third string</translation>
+ </message>
+ <message id="qtn_bar_baz" numerus="yes">
+ <location filename="idtranslatable.js" line="5"/>
+ <source></source>
+ <translation>
+ <numerusform>Fourth string</numerusform>
+ <numerusform>%n fooish bar(s) found</numerusform>
+ </translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 04b2627..b035492 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -162,6 +162,7 @@ private slots:
void translateWithInvalidArgs();
void translationContext_data();
void translationContext();
+ void translateScriptIdBased();
void functionScopes();
void nativeFunctionScopes();
void evaluateProgram();
@@ -173,6 +174,10 @@ private slots:
void reentrency();
void newFixedStaticScopeObject();
void newGrowingStaticScopeObject();
+ void dateRoundtripJSQtJS();
+ void dateRoundtripQtJSQt();
+ void dateConversionJSQt();
+ void dateConversionQtJS();
};
tst_QScriptEngine::tst_QScriptEngine()
@@ -4416,6 +4421,8 @@ void tst_QScriptEngine::installTranslatorFunctions()
QVERIFY(!global.property("QT_TRANSLATE_NOOP").isValid());
QVERIFY(!global.property("qsTr").isValid());
QVERIFY(!global.property("QT_TR_NOOP").isValid());
+ QVERIFY(!global.property("qsTrId").isValid());
+ QVERIFY(!global.property("QT_TRID_NOOP").isValid());
QVERIFY(!globalOrig.property("String").property("prototype").property("arg").isValid());
eng.installTranslatorFunctions();
@@ -4423,6 +4430,8 @@ void tst_QScriptEngine::installTranslatorFunctions()
QVERIFY(global.property("QT_TRANSLATE_NOOP").isFunction());
QVERIFY(global.property("qsTr").isFunction());
QVERIFY(global.property("QT_TR_NOOP").isFunction());
+ QVERIFY(global.property("qsTrId").isFunction());
+ QVERIFY(global.property("QT_TRID_NOOP").isFunction());
QVERIFY(globalOrig.property("String").property("prototype").property("arg").isFunction());
if (useCustomGlobalObject) {
@@ -4430,6 +4439,8 @@ void tst_QScriptEngine::installTranslatorFunctions()
QVERIFY(!globalOrig.property("QT_TRANSLATE_NOOP").isValid());
QVERIFY(!globalOrig.property("qsTr").isValid());
QVERIFY(!globalOrig.property("QT_TR_NOOP").isValid());
+ QVERIFY(!globalOrig.property("qsTrId").isValid());
+ QVERIFY(!globalOrig.property("QT_TRID_NOOP").isValid());
}
{
@@ -4457,6 +4468,17 @@ void tst_QScriptEngine::installTranslatorFunctions()
QVERIFY(ret.isString());
QCOMPARE(ret.toString(), QString::fromLatin1("foobar"));
}
+
+ {
+ QScriptValue ret = eng.evaluate("qsTrId('foo')");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString::fromLatin1("foo"));
+ }
+ {
+ QScriptValue ret = eng.evaluate("QT_TRID_NOOP('foo')");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString::fromLatin1("foo"));
+ }
}
static QScriptValue callQsTr(QScriptContext *ctx, QScriptEngine *eng)
@@ -4567,6 +4589,10 @@ void tst_QScriptEngine::translateWithInvalidArgs_data()
QTest::newRow("qsTranslate('foo', 'bar', 'baz', 123)") << "qsTranslate('foo', 'bar', 'baz', 123)" << "Error: qsTranslate(): fourth argument (encoding) must be a string";
QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')") << "qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')" << "Error: qsTranslate(): fifth argument (n) must be a number";
QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 123)") << "qsTranslate('foo', 'bar', 'baz', 'zab', 123)" << "Error: qsTranslate(): invalid encoding 'zab'";
+
+ QTest::newRow("qsTrId()") << "qsTrId()" << "Error: qsTrId() requires at least one argument";
+ QTest::newRow("qsTrId(123)") << "qsTrId(123)" << "TypeError: qsTrId(): first argument (id) must be a string";
+ QTest::newRow("qsTrId('foo', 'bar')") << "qsTrId('foo', 'bar')" << "TypeError: qsTrId(): second argument (n) must be a number";
}
void tst_QScriptEngine::translateWithInvalidArgs()
@@ -4628,6 +4654,53 @@ void tst_QScriptEngine::translationContext()
QCoreApplication::instance()->removeTranslator(&translator);
}
+void tst_QScriptEngine::translateScriptIdBased()
+{
+ QScriptEngine engine;
+
+ QTranslator translator;
+ translator.load(":/translations/idtranslatable_la");
+ QCoreApplication::instance()->installTranslator(&translator);
+ engine.installTranslatorFunctions();
+
+ QString fileName = QString::fromLatin1("idtranslatable.js");
+
+ QHash<QString, QString> expectedTranslations;
+ expectedTranslations["qtn_foo_bar"] = "First string";
+ expectedTranslations["qtn_needle"] = "Second string";
+ expectedTranslations["qtn_haystack"] = "Third string";
+ expectedTranslations["qtn_bar_baz"] = "Fourth string";
+
+ QHash<QString, QString>::const_iterator it;
+ for (it = expectedTranslations.constBegin(); it != expectedTranslations.constEnd(); ++it) {
+ for (int x = 0; x < 2; ++x) {
+ QString fn;
+ if (x)
+ fn = fileName;
+ // Top-level
+ QCOMPARE(engine.evaluate(QString::fromLatin1("qsTrId('%0')")
+ .arg(it.key()), fn).toString(),
+ it.value());
+ QCOMPARE(engine.evaluate(QString::fromLatin1("QT_TRID_NOOP('%0')")
+ .arg(it.key()), fn).toString(),
+ it.key());
+ // From function
+ QCOMPARE(engine.evaluate(QString::fromLatin1("(function() { return qsTrId('%0'); })()")
+ .arg(it.key()), fn).toString(),
+ it.value());
+ QCOMPARE(engine.evaluate(QString::fromLatin1("(function() { return QT_TRID_NOOP('%0'); })()")
+ .arg(it.key()), fn).toString(),
+ it.key());
+ }
+ }
+
+ // Plural form
+ QCOMPARE(engine.evaluate("qsTrId('qtn_bar_baz', 10)").toString(),
+ QString::fromLatin1("10 fooish bar(s) found"));
+ QCOMPARE(engine.evaluate("qsTrId('qtn_foo_bar', 10)").toString(),
+ QString::fromLatin1("qtn_foo_bar")); // Doesn't have plural
+}
+
void tst_QScriptEngine::functionScopes()
{
QScriptEngine eng;
@@ -4998,6 +5071,68 @@ void tst_QScriptEngine::qRegExpInport()
}
}
+// QScriptValue::toDateTime() returns a local time, whereas JS dates
+// are always stored as UTC. QtScript must respect the current time
+// zone, and correctly adjust for daylight saving time that may be in
+// effect at a given date (QTBUG-9770).
+void tst_QScriptEngine::dateRoundtripJSQtJS()
+{
+ uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
+ QDateTime qtDate = jsDate.toDateTime();
+ QScriptValue jsDate2 = eng.newDate(qtDate);
+ if (jsDate2.toNumber() != jsDate.toNumber())
+ QFAIL(qPrintable(jsDate.toString()));
+ secs += 2*60*60;
+ }
+}
+
+void tst_QScriptEngine::dateRoundtripQtJSQt()
+{
+ QDateTime qtDate = QDateTime(QDate(2009, 1, 1));
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.newDate(qtDate);
+ QDateTime qtDate2 = jsDate.toDateTime();
+ if (qtDate2 != qtDate)
+ QFAIL(qPrintable(qtDate.toString()));
+ qtDate = qtDate.addSecs(2*60*60);
+ }
+}
+
+void tst_QScriptEngine::dateConversionJSQt()
+{
+ uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
+ QDateTime qtDate = jsDate.toDateTime();
+ QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate);
+ QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString();
+ jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z")
+ if (qtUTCDateStr != jsUTCDateStr)
+ QFAIL(qPrintable(jsDate.toString()));
+ secs += 2*60*60;
+ }
+}
+
+void tst_QScriptEngine::dateConversionQtJS()
+{
+ QDateTime qtDate = QDateTime(QDate(2009, 1, 1));
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.newDate(qtDate);
+ QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString();
+ jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z")
+ QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate);
+ if (jsUTCDateStr != qtUTCDateStr)
+ QFAIL(qPrintable(qtDate.toString()));
+ qtDate = qtDate.addSecs(2*60*60);
+ }
+}
+
static QScriptValue createAnotherEngine(QScriptContext *, QScriptEngine *)
{
QScriptEngine eng;
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index e154528..e16be8b 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -381,7 +381,7 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
QCOMPARE(a1_s_o2->currentLoopTime(), 250);
QCOMPARE(notTimeDriven->currentLoopTime(), 0);
QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), notTimeDriven);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation *>(notTimeDriven));
// Current time = 505
group.setCurrentTime(505);
@@ -391,7 +391,7 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
QCOMPARE(a1_s_o2->currentLoopTime(), 250);
QCOMPARE(notTimeDriven->currentLoopTime(), 5);
QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), notTimeDriven);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation *>(notTimeDriven));
QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp
index 48c5fd1..0813e28 100644
--- a/tests/auto/qsettings/tst_qsettings.cpp
+++ b/tests/auto/qsettings/tst_qsettings.cpp
@@ -61,6 +61,10 @@
#include <io.h>
#endif
+#if defined(Q_OS_WIN)
+#include <QtCore/qt_windows.h>
+#endif
+
#ifndef QSETTINGS_P_H_VERSION
#define QSETTINGS_P_H_VERSION 1
#endif
@@ -128,6 +132,9 @@ private slots:
#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN)
void dontReorderIniKeysNeedlessly();
#endif
+#if defined(Q_OS_WIN)
+ void qtbug_13249();
+#endif
/*
These tests were developed for the Qt 3 QSettings class.
@@ -3798,6 +3805,62 @@ void tst_QSettings::setPathBug()
}
#endif
+#if defined(Q_OS_WIN)
+
+static DWORD readKeyType(HKEY handle, const QString &rSubKey)
+{
+ DWORD dataType;
+ DWORD dataSize;
+ LONG res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), 0, &dataType, 0, &dataSize);
+
+ if (res == ERROR_SUCCESS)
+ return dataType;
+
+ return 0;
+}
+
+void tst_QSettings::qtbug_13249()
+{
+ QSettings settings1(QSettings::UserScope, "software.org", "KillerAPP");
+
+ qint32 x = 1024;
+ settings1.setValue("qtbug_13249_a", (qint32)x);
+ QCOMPARE(settings1.value("qtbug_13249_a").toInt(), (qint32)1024);
+ settings1.setValue("qtbug_13249_b", (quint32)x);
+ QCOMPARE(settings1.value("qtbug_13249_b").toUInt(), (quint32)1024);
+ settings1.setValue("qtbug_13249_c", (qint64)x);
+ QCOMPARE(settings1.value("qtbug_13249_c").toLongLong(), (qint64)1024);
+ settings1.setValue("qtbug_13249_d", (quint64)x);
+ QCOMPARE(settings1.value("qtbug_13249_d").toULongLong(), (quint64)1024);
+ settings1.sync();
+
+ HKEY handle;
+ LONG res;
+ QString keyName = "Software\\software.org\\KillerAPP";
+ res = RegOpenKeyEx(HKEY_CURRENT_USER, reinterpret_cast<const wchar_t *>(keyName.utf16()), 0, KEY_READ, &handle);
+ if (res == ERROR_SUCCESS)
+ {
+ DWORD dataType;
+ dataType = readKeyType(handle, QString("qtbug_13249_a"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_DWORD, (int)dataType);
+ }
+ dataType = readKeyType(handle, QString("qtbug_13249_b"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_DWORD, (int)dataType);
+ }
+ dataType = readKeyType(handle, QString("qtbug_13249_c"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_QWORD, (int)dataType);
+ }
+ dataType = readKeyType(handle, QString("qtbug_13249_d"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_QWORD, (int)dataType);
+ }
+ RegCloseKey(handle);
+ }
+}
+#endif
/*
// Not tested at the moment.
void tst_QSettings::oldSubkeyList()
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 53fefee..66caf4a 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -143,6 +143,7 @@ private slots:
void taskQTBUG_10287_unnecessaryMapCreation();
void testMultipleProxiesWithSelection();
+ void mapSelectionFromSource();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -3075,6 +3076,44 @@ void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection()
}
+static bool isValid(const QItemSelection &selection) {
+ foreach(const QItemSelectionRange &range, selection)
+ if (!range.isValid())
+ return false;
+ return true;
+}
+
+void tst_QSortFilterProxyModel::mapSelectionFromSource()
+{
+ QStringListModel model;
+ const QStringList initial = QString("bravo charlie delta echo").split(" ");
+ model.setStringList(initial);
+
+ QSortFilterProxyModel proxy;
+ proxy.setDynamicSortFilter(true);
+ proxy.setFilterRegExp("d.*");
+ proxy.setSourceModel(&model);
+
+ // Only "delta" remains.
+ QVERIFY(proxy.rowCount() == 1);
+
+ QItemSelection selection;
+ QModelIndex charlie = model.index(1, 0);
+ selection.append(QItemSelectionRange(charlie, charlie));
+ QModelIndex delta = model.index(2, 0);
+ selection.append(QItemSelectionRange(delta, delta));
+ QModelIndex echo = model.index(3, 0);
+ selection.append(QItemSelectionRange(echo, echo));
+
+ QVERIFY(isValid(selection));
+
+ QItemSelection proxiedSelection = proxy.mapSelectionFromSource(selection);
+
+ // Only "delta" is in the mapped result.
+ QVERIFY(proxiedSelection.size() == 1);
+ QVERIFY(isValid(proxiedSelection));
+}
+
class Model10287 : public QStandardItemModel
{
Q_OBJECT
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 6c1dd8f..d6a7a01 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -183,6 +183,7 @@ private slots:
void ignoreSslErrorsListWithSlot();
void readFromClosedSocket();
void writeBigChunk();
+ void setEmptyDefaultConfiguration();
static void exitLoop()
{
@@ -1835,6 +1836,21 @@ void tst_QSslSocket::writeBigChunk()
socket->close();
}
+void tst_QSslSocket::setEmptyDefaultConfiguration()
+{
+ // used to produce a crash in QSslConfigurationPrivate::deepCopyDefaultConfiguration, QTBUG-13265
+
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslConfiguration emptyConf;
+ QSslConfiguration::setDefaultConfiguration(emptyConf);
+
+ QSslSocketPtr socket = newSocket();
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+
+}
+
#endif // QT_NO_OPENSSL
QTEST_MAIN(tst_QSslSocket)
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 6498ae4..daf0fa3 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -73,6 +73,8 @@ private slots:
void prepareToCorrectData();
void prepareToWrongData();
+ void copyConstructor();
+
void translatedPainter();
void rotatedPainter();
void scaledPainter();
@@ -92,6 +94,8 @@ private slots:
void drawStruckOutText();
void drawOverlinedText();
void drawUnderlinedText();
+
+ void unprintableCharacter_qtbug12614();
};
void tst_QStaticText::init()
@@ -107,6 +111,31 @@ void tst_QStaticText::constructionAndDestruction()
QStaticText text("My text");
}
+void tst_QStaticText::copyConstructor()
+{
+ QStaticText text(QLatin1String("My text"));
+
+ QTextOption textOption(Qt::AlignRight);
+ text.setTextOption(textOption);
+
+ text.setPerformanceHint(QStaticText::AggressiveCaching);
+ text.setTextWidth(123.456);
+ text.setTextFormat(Qt::PlainText);
+
+ QStaticText copiedText(text);
+ copiedText.setText(QLatin1String("Other text"));
+
+ QCOMPARE(copiedText.textOption().alignment(), Qt::AlignRight);
+ QCOMPARE(copiedText.performanceHint(), QStaticText::AggressiveCaching);
+ QCOMPARE(copiedText.textWidth(), 123.456);
+ QCOMPARE(copiedText.textFormat(), Qt::PlainText);
+
+ QStaticText otherCopiedText(copiedText);
+ otherCopiedText.setTextWidth(789);
+
+ QCOMPARE(otherCopiedText.text(), QString::fromLatin1("Other text"));
+}
+
Q_DECLARE_METATYPE(QStaticText::PerformanceHint)
void tst_QStaticText::drawToPoint_data()
{
@@ -332,7 +361,7 @@ bool tst_QStaticText::supportsTransformations() const
QPaintEngine::Type type = engine->type();
if (type == QPaintEngine::OpenGL
-#if !defined Q_WS_WIN
+#if !defined(Q_WS_WIN) && !defined(Q_WS_X11)
|| type == QPaintEngine::Raster
#endif
)
@@ -745,5 +774,14 @@ void tst_QStaticText::drawUnderlinedText()
QCOMPARE(imageDrawText, imageDrawStaticText);
}
+void tst_QStaticText::unprintableCharacter_qtbug12614()
+{
+ QString s(QChar(0x200B)); // U+200B, ZERO WIDTH SPACE
+
+ QStaticText staticText(s);
+
+ QVERIFY(staticText.size().isValid()); // Force layout. Should not crash.
+}
+
QTEST_MAIN(tst_QStaticText)
#include "tst_qstatictext.moc"
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index a3f7f15..af6b371 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -174,6 +174,12 @@ private slots:
void fromLatin1Roundtrip();
void toLatin1Roundtrip_data();
void toLatin1Roundtrip();
+ void stringRef_toLatin1Roundtrip_data();
+ void stringRef_toLatin1Roundtrip();
+ void stringRef_utf8_data();
+ void stringRef_utf8();
+ void stringRef_local8Bit_data();
+ void stringRef_local8Bit();
void fromLatin1();
void fromAscii();
void arg();
@@ -3128,6 +3134,20 @@ void tst_QString::utf8()
QCOMPARE( utf8, QByteArray(res.toUtf8()) );
}
+void tst_QString::stringRef_utf8_data()
+{
+ utf8_data();
+}
+
+void tst_QString::stringRef_utf8()
+{
+ QFETCH( QByteArray, utf8 );
+ QFETCH( QString, res );
+
+ QStringRef ref(&res, 0, res.length());
+ QCOMPARE( utf8, QByteArray(ref.toUtf8()) );
+}
+
// copied to tst_QTextCodec::utf8Codec_data()
void tst_QString::fromUtf8_data()
{
@@ -3307,6 +3327,20 @@ void tst_QString::local8Bit()
QCOMPARE(local8Bit.toLocal8Bit(), QByteArray(result));
}
+void tst_QString::stringRef_local8Bit_data()
+{
+ local8Bit_data();
+}
+
+void tst_QString::stringRef_local8Bit()
+{
+ QFETCH(QString, local8Bit);
+ QFETCH(QByteArray, result);
+
+ QStringRef ref(&local8Bit, 0, local8Bit.length());
+ QCOMPARE(ref.toLocal8Bit(), QByteArray(result));
+}
+
void tst_QString::fromLatin1Roundtrip_data()
{
QTest::addColumn<QByteArray>("latin1");
@@ -3410,6 +3444,38 @@ void tst_QString::toLatin1Roundtrip()
QCOMPARE(QString::fromLatin1(latin1, latin1.length()), unicodedst);
}
+void tst_QString::stringRef_toLatin1Roundtrip_data()
+{
+ toLatin1Roundtrip_data();
+}
+
+void tst_QString::stringRef_toLatin1Roundtrip()
+{
+ QFETCH(QByteArray, latin1);
+ QFETCH(QString, unicodesrc);
+ QFETCH(QString, unicodedst);
+
+ // QtTest safety check:
+ Q_ASSERT(latin1.isNull() == unicodesrc.isNull());
+ Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty());
+ Q_ASSERT(latin1.length() == unicodesrc.length());
+ Q_ASSERT(latin1.isNull() == unicodedst.isNull());
+ Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty());
+ Q_ASSERT(latin1.length() == unicodedst.length());
+
+ if (!latin1.isEmpty())
+ while (latin1.length() < 128) {
+ latin1 += latin1;
+ unicodesrc += unicodesrc;
+ unicodedst += unicodedst;
+ }
+
+ // toLatin1
+ QStringRef src(&unicodesrc, 0, unicodesrc.length());
+ QCOMPARE(src.toLatin1().length(), latin1.length());
+ QCOMPARE(src.toLatin1(), latin1);
+}
+
void tst_QString::fromLatin1()
{
QString a;
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index e370309..04b1e79 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -698,20 +698,25 @@ void tst_QStyleSheetStyle::fontPrecedence()
QCOMPARE(FONTSIZE(edit2), 26);
}
-static bool testForColors(const QImage& image, const QColor& color)
+// Ensure primary will only return true if the color covers more than 50% of pixels
+static bool testForColors(const QImage& image, const QColor& color, bool ensurePrimary=false)
{
int count = 0;
QRgb rgb = color.rgba();
+ int totalCount = image.height()*image.width();
for (int y = 0; y < image.height(); ++y) {
for (int x = 0; x < image.width(); ++x) {
// Because of antialiasing we allow a certain range of errors here.
QRgb pixel = image.pixel(x, y);
+
if (qAbs((int)(pixel & 0xff) - (int)(rgb & 0xff)) +
qAbs((int)((pixel & 0xff00) >> 8) - (int)((rgb & 0xff00) >> 8)) +
qAbs((int)((pixel & 0xff0000) >> 16) - (int)((rgb & 0xff0000) >> 16)) <= 50) {
- if (++count >= 10) {
+ count++;
+ if (!ensurePrimary && count >=10 )
+ return true;
+ else if (count > totalCount/2)
return true;
- }
}
}
}
@@ -1528,6 +1533,15 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
tree.render(&image);
QVERIFY(testForColors(image, tree.palette().base().color()));
QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51)));
+
+ QTableWidget table(12, 12);
+ table.setItem(0, 0, new QTableWidgetItem());
+ table.setStyleSheet( "QTableView {background-color: #ff0000}" );
+ table.show();
+ QTest::qWait(20);
+ image = QImage(table.width(), table.height(), QImage::Format_ARGB32);
+ table.render(&image);
+ QVERIFY(testForColors(image, Qt::red, true));
}
void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()
diff --git a/tests/auto/qtextlist/tst_qtextlist.cpp b/tests/auto/qtextlist/tst_qtextlist.cpp
index 3e92836..8ad0898 100644
--- a/tests/auto/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/qtextlist/tst_qtextlist.cpp
@@ -67,6 +67,9 @@ private slots:
void item();
void autoNumbering();
void autoNumberingRTL();
+ void autoNumberingPrefixAndSuffix();
+ void autoNumberingPrefixAndSuffixRTL();
+ void autoNumberingPrefixAndSuffixHtmlExportImport();
void romanNumbering();
void romanNumberingLimit();
void formatChange();
@@ -128,6 +131,76 @@ void tst_QTextList::autoNumbering()
QVERIFY(cursor.currentList()->itemText(cursor.block()) == "ab.");
}
+void tst_QTextList::autoNumberingPrefixAndSuffix()
+{
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListLowerAlpha);
+ fmt.setNumberPrefix("-");
+ fmt.setNumberSuffix(")");
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 0; i < 27; ++i)
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 28);
+
+ QVERIFY(cursor.currentList());
+ QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 27);
+ QVERIFY(cursor.currentList()->itemText(cursor.block()) == "-ab)");
+}
+
+void tst_QTextList::autoNumberingPrefixAndSuffixRTL()
+{
+ QTextBlockFormat bfmt;
+ bfmt.setLayoutDirection(Qt::RightToLeft);
+ cursor.setBlockFormat(bfmt);
+
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListUpperAlpha);
+ fmt.setNumberPrefix("-");
+ fmt.setNumberSuffix("*");
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 2);
+
+ QVERIFY(cursor.currentList()->itemText(cursor.block()) == "*B-");
+}
+
+void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport()
+{
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListLowerAlpha);
+ fmt.setNumberPrefix("\"");
+ fmt.setNumberSuffix("#");
+ fmt.setIndent(10);
+ // FIXME: Would like to test "'" but there's a problem in the css parser (Scanner::preprocess
+ // is called before the values are being parsed), so the quoting does not work.
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 0; i < 27; ++i)
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 28);
+
+ QString htmlExport = doc->toHtml();
+ QTextDocument importDoc;
+ importDoc.setHtml(htmlExport);
+
+ QTextCursor importCursor(&importDoc);
+ for (int i = 0; i < 27; ++i)
+ importCursor.movePosition(QTextCursor::NextBlock);
+
+ QVERIFY(importCursor.currentList());
+ QVERIFY(importCursor.currentList()->itemNumber(importCursor.block()) == 27);
+ QVERIFY(importCursor.currentList()->itemText(importCursor.block()) == "\"ab#");
+ QVERIFY(importCursor.currentList()->format().indent() == 10);
+}
+
void tst_QTextList::autoNumberingRTL()
{
QTextBlockFormat bfmt;
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index 8d213ed..f23d065 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -87,6 +87,8 @@ private slots:
void cancelLongTimer();
void singleShotStaticFunctionZeroTimeout();
void recurseOnTimeoutAndStopTimer();
+
+ void QTBUG13633_dontBlockEvents();
};
class TimerHelper : public QObject
@@ -161,8 +163,9 @@ void tst_QTimer::singleShotTimeout()
QCOMPARE(helper.count, 1);
}
-#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
-// Increase wait as emulator startup can cause unexpected delays
+#if defined(Q_OS_SYMBIAN)
+// Increase wait as emulator startup can cause unexpected delays, and
+// on hardware there are sometimes spikes right after process startup.
#define TIMEOUT_TIMEOUT 2000
#else
#define TIMEOUT_TIMEOUT 200
@@ -268,13 +271,7 @@ void tst_QTimer::livelock()
QCOMPARE(tester.timeoutsForFirst, 1);
QCOMPARE(tester.timeoutsForExtra, 0);
QCOMPARE(tester.timeoutsForSecond, 1);
-#if defined(Q_OS_MAC)
- QEXPECT_FAIL("zero timer", "Posted events source are handled AFTER timers", Continue);
- QEXPECT_FAIL("non-zero timer", "Posted events source are handled AFTER timers", Continue);
-#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
- QEXPECT_FAIL("zero timer", "", Continue);
- QEXPECT_FAIL("non-zero timer", "", Continue);
-#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
#elif defined(Q_OS_WINCE)
@@ -667,5 +664,64 @@ void tst_QTimer::recurseOnTimeoutAndStopTimer()
QVERIFY(!t.two->isActive());
}
+
+
+class DontBlockEvents : public QObject
+{
+ Q_OBJECT
+public:
+ DontBlockEvents();
+ void timerEvent(QTimerEvent*);
+
+ int count;
+ int total;
+ QBasicTimer m_timer;
+
+public slots:
+ void paintEvent();
+
+};
+
+DontBlockEvents::DontBlockEvents()
+{
+ count = 0;
+ total = 0;
+
+ //QTBUG-13633 need few unrelated timer running to reproduce the bug.
+ (new QTimer(this))->start(2000);
+ (new QTimer(this))->start(2500);
+ (new QTimer(this))->start(3000);
+ (new QTimer(this))->start(5000);
+ (new QTimer(this))->start(1000);
+ (new QTimer(this))->start(2000);
+
+ m_timer.start(1, this);
+}
+
+void DontBlockEvents::timerEvent(QTimerEvent* event)
+{
+ if (event->timerId() == m_timer.timerId()) {
+ QMetaObject::invokeMethod(this, "paintEvent", Qt::QueuedConnection);
+ m_timer.start(0, this);
+ count++;
+ QCOMPARE(count, 1);
+ total++;
+ }
+}
+
+void DontBlockEvents::paintEvent()
+{
+ count--;
+ QCOMPARE(count, 0);
+}
+
+
+void tst_QTimer::QTBUG13633_dontBlockEvents()
+{
+ DontBlockEvents t;
+ QTest::qWait(60);
+ QVERIFY(t.total > 2);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"
diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp
index bb80fde..4219ef4 100644
--- a/tests/auto/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp
@@ -109,6 +109,7 @@ class tst_QTouchEventGraphicsItem : public QGraphicsItem
public:
QList<QTouchEvent::TouchPoint> touchBeginPoints, touchUpdatePoints, touchEndPoints;
bool seenTouchBegin, seenTouchUpdate, seenTouchEnd;
+ int touchBeginCounter, touchUpdateCounter, touchEndCounter;
bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd;
bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd;
tst_QTouchEventGraphicsItem **weakpointer;
@@ -131,6 +132,7 @@ public:
touchUpdatePoints.clear();
touchEndPoints.clear();
seenTouchBegin = seenTouchUpdate = seenTouchEnd = false;
+ touchBeginCounter = touchUpdateCounter = touchEndCounter = 0;
acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true;
deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false;
}
@@ -146,6 +148,7 @@ public:
if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin");
if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin");
seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd;
+ ++touchBeginCounter;
touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchBegin);
if (deleteInTouchBegin)
@@ -155,6 +158,7 @@ public:
if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin");
if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate");
seenTouchUpdate = seenTouchBegin && !seenTouchEnd;
+ ++touchUpdateCounter;
touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchUpdate);
if (deleteInTouchUpdate)
@@ -164,6 +168,7 @@ public:
if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin");
if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd");
seenTouchEnd = seenTouchBegin && !seenTouchEnd;
+ ++touchEndCounter;
touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchEnd);
if (deleteInTouchEnd)
@@ -194,6 +199,7 @@ private slots:
void deleteInEventHandler();
void deleteInRawEventTranslation();
void crashInQGraphicsSceneAfterNotHandlingTouchBegin();
+ void touchBeginWithGraphicsWidget();
};
void tst_QTouchEvent::touchDisabledByDefault()
@@ -1334,6 +1340,59 @@ void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin()
QTest::touchEvent(view.viewport()).release(0, view.mapFromScene(QPoint(10, 10)));
}
+void tst_QTouchEvent::touchBeginWithGraphicsWidget()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ tst_QTouchEventGraphicsItem *root;
+ root = new tst_QTouchEventGraphicsItem;
+ root->setAcceptTouchEvents(true);
+ scene.addItem(root);
+
+ QGraphicsWidget *glassWidget = new QGraphicsWidget;
+ glassWidget->setMinimumSize(100, 100);
+ scene.addItem(glassWidget);
+
+ view.resize(200, 200);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.fitInView(scene.sceneRect());
+
+ QTest::touchEvent()
+ .press(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport());
+ QTest::touchEvent()
+ .stationary(0)
+ .press(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport());
+ QTest::touchEvent()
+ .release(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport())
+ .release(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport());
+
+ QCOMPARE(root->touchBeginCounter, 1);
+ QCOMPARE(root->touchUpdateCounter, 1);
+ QCOMPARE(root->touchEndCounter, 1);
+ QCOMPARE(root->touchUpdatePoints.size(), 2);
+
+ root->reset();
+ glassWidget->setWindowFlags(Qt::Window); // make the glassWidget a panel
+
+ QTest::touchEvent()
+ .press(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport());
+ QTest::touchEvent()
+ .stationary(0)
+ .press(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport());
+ QTest::touchEvent()
+ .release(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport())
+ .release(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport());
+
+ QCOMPARE(root->touchBeginCounter, 0);
+ QCOMPARE(root->touchUpdateCounter, 0);
+ QCOMPARE(root->touchEndCounter, 0);
+
+
+ delete root;
+ delete glassWidget;
+}
+
QTEST_MAIN(tst_QTouchEvent)
#include "tst_qtouchevent.moc"
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 75a4c62..7e2e800 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -239,6 +239,7 @@ private slots:
void doubleClickedWithSpans();
void taskQTBUG_6450_selectAllWith1stColumnHidden();
void taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint();
+ void taskQTBUG_11466_keyboardNavigationRegression();
};
class QtTestModel: public QAbstractItemModel
@@ -3785,5 +3786,129 @@ void tst_QTreeView::keyboardNavigationWithDisabled()
QCOMPARE(view.currentIndex(), model.index(6, 0));
}
+class Model_11466 : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ Model_11466(QObject *parent) :
+ m_block(false)
+ {
+ // set up the model to have two top level items and a few others
+ m_selectionModel = new QItemSelectionModel(this, this); // owned by this
+
+ connect(m_selectionModel, SIGNAL(currentChanged(const QModelIndex &,const QModelIndex &)),
+ this, SLOT(slotCurrentChanged(const QModelIndex &,const QModelIndex &)));
+ };
+
+ int rowCount(const QModelIndex &parent) const
+ {
+ if (parent.isValid())
+ return (parent.internalId() == 0) ? 4 : 0;
+ return 2; // two top level items
+ }
+
+ int columnCount(const QModelIndex &parent) const
+ {
+ return 2;
+ }
+
+ QVariant data(const QModelIndex &index, int role) const
+ {
+ if (role == Qt::DisplayRole && index.isValid()) {
+ qint64 parentRowPlusOne = index.internalId();
+ QString str;
+ QTextStream stream(&str);
+ if (parentRowPlusOne > 0)
+ stream << parentRowPlusOne << " -> " << index.row() << " : " << index.column();
+ else
+ stream << index.row() << " : " << index.column();
+ return QVariant(str);
+ }
+ return QVariant();
+ }
+
+ QModelIndex parent(const QModelIndex &index) const
+ {
+ if (index.isValid()) {
+ qint64 parentRowPlusOne = index.internalId();
+ if (parentRowPlusOne > 0) {
+ int row = static_cast<int>(parentRowPlusOne - 1);
+ return createIndex(row, 0, (quint32)0);
+ }
+ }
+ return QModelIndex();
+ }
+
+ void bindView(QTreeView *view)
+ {
+ // sets the view to this model with a shared selection model
+ QItemSelectionModel *oldModel = view->selectionModel();
+ if (oldModel != m_selectionModel)
+ delete oldModel;
+ view->setModel(this); // this creates a new selection model for the view, but we dont want it either ...
+ oldModel = view->selectionModel();
+ view->setSelectionModel(m_selectionModel);
+ delete oldModel;
+ }
+
+ QModelIndex index(int row, int column, const QModelIndex &parent) const
+ {
+ return createIndex(row, column, parent.isValid() ? (quint32)(parent.row() + 1) : (quint32)0);
+ }
+
+public slots:
+ void slotCurrentChanged(const QModelIndex &current,const QModelIndex &)
+ {
+ if (m_block)
+ return;
+
+ if (current.isValid()) {
+ int selectedRow = current.row();
+ quint32 parentRowPlusOne = static_cast<quint32>(current.internalId());
+
+ for (int i = 0; i < 2; ++i) {
+ // announce the removal of all non top level items
+ beginRemoveRows(createIndex(i, 0, 0), 0, 3);
+ // nothing to actually do for the removal
+ endRemoveRows();
+
+ // put them back in again
+ beginInsertRows(createIndex(i, 0, 0), 0, 3);
+ // nothing to actually do for the insertion
+ endInsertRows();
+ }
+ // reselect the current item ...
+ QModelIndex selectedIndex = createIndex(selectedRow, 0, parentRowPlusOne);
+
+ m_block = true; // recursion block
+ m_selectionModel->select(selectedIndex, QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Current|QItemSelectionModel::Rows);
+ m_selectionModel->setCurrentIndex(selectedIndex, QItemSelectionModel::NoUpdate);
+ m_block = false;
+ } else {
+ m_selectionModel->clear();
+ }
+ }
+
+private:
+ bool m_block;
+ QItemSelectionModel *m_selectionModel;
+};
+
+void tst_QTreeView::taskQTBUG_11466_keyboardNavigationRegression()
+{
+ QTreeView treeView;
+ treeView.setSelectionBehavior(QAbstractItemView::SelectRows);
+ treeView.setSelectionMode(QAbstractItemView::SingleSelection);
+ Model_11466 model(&treeView);
+ model.bindView(&treeView);
+ treeView.expandAll();
+ treeView.show();
+ QTest::qWaitForWindowShown(&treeView);
+
+ QTest::keyPress(treeView.viewport(), Qt::Key_Down);
+ QTest::qWait(10);
+ QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first());
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index abed55c..32fab6b 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -50,11 +50,13 @@
#include <qhostinfo.h>
#include <qmap.h>
#include <QNetworkProxy>
+#include <QNetworkInterface>
#include <qstringlist.h>
#include "../network-settings.h"
Q_DECLARE_METATYPE(QHostAddress)
+Q_DECLARE_METATYPE(QNetworkInterface)
//TESTED_CLASS=
//TESTED_FILES=
@@ -94,6 +96,18 @@ private slots:
void outOfProcessConnectedClientServerTest();
void outOfProcessUnconnectedClientServerTest();
void zeroLengthDatagram();
+ void multicastTtlOption_data();
+ void multicastTtlOption();
+ void multicastLoopbackOption_data();
+ void multicastLoopbackOption();
+ void multicastJoinBeforeBind_data();
+ void multicastJoinBeforeBind();
+ void multicastLeaveAfterClose_data();
+ void multicastLeaveAfterClose();
+ void setMulticastInterface_data();
+ void setMulticastInterface();
+ void multicast_data();
+ void multicast();
protected slots:
void empty_readyReadSlot();
@@ -844,5 +858,242 @@ void tst_QUdpSocket::zeroLengthDatagram()
QCOMPARE(receiver.readDatagram(&buf, 1), qint64(0));
}
+void tst_QUdpSocket::multicastTtlOption_data()
+{
+ QTest::addColumn<QHostAddress>("bindAddress");
+ QTest::addColumn<int>("ttl");
+ QTest::addColumn<int>("expected");
+
+ QList<QHostAddress> addresses;
+ addresses += QHostAddress(QHostAddress::Any);
+ addresses += QHostAddress(QHostAddress::AnyIPv6);
+
+ foreach (const QHostAddress &address, addresses) {
+ QTest::newRow(QString("%1 0").arg(address.toString()).toAscii()) << address << 0 << 0;
+ QTest::newRow(QString("%1 1").arg(address.toString()).toAscii()) << address << 1 << 1;
+ QTest::newRow(QString("%1 2").arg(address.toString()).toAscii()) << address << 2 << 2;
+ QTest::newRow(QString("%1 128").arg(address.toString()).toAscii()) << address << 128 << 128;
+ QTest::newRow(QString("%1 255").arg(address.toString()).toAscii()) << address << 255 << 255;
+ QTest::newRow(QString("%1 1024").arg(address.toString()).toAscii()) << address << 1024 << 1;
+ }
+}
+
+void tst_QUdpSocket::multicastTtlOption()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ QFETCH(QHostAddress, bindAddress);
+ QFETCH(int, ttl);
+ QFETCH(int, expected);
+ if (setProxy) {
+ // UDP multicast does not work with proxies
+ expected = 0;
+ }
+
+ QUdpSocket udpSocket;
+ // bind, but ignore the result, we are only interested in initializing the socket
+ (void) udpSocket.bind(bindAddress, 0);
+ udpSocket.setSocketOption(QUdpSocket::MulticastTtlOption, ttl);
+ QCOMPARE(udpSocket.socketOption(QUdpSocket::MulticastTtlOption).toInt(), expected);
+}
+
+void tst_QUdpSocket::multicastLoopbackOption_data()
+{
+ QTest::addColumn<QHostAddress>("bindAddress");
+ QTest::addColumn<int>("loopback");
+ QTest::addColumn<int>("expected");
+
+ QList<QHostAddress> addresses;
+ addresses += QHostAddress(QHostAddress::Any);
+ addresses += QHostAddress(QHostAddress::AnyIPv6);
+
+ foreach (const QHostAddress &address, addresses) {
+ QTest::newRow(QString("%1 0").arg(address.toString()).toAscii()) << address << 0 << 0;
+ QTest::newRow(QString("%1 1").arg(address.toString()).toAscii()) << address << 1 << 1;
+ QTest::newRow(QString("%1 2").arg(address.toString()).toAscii()) << address << 2 << 1;
+ QTest::newRow(QString("%1 0 again").arg(address.toString()).toAscii()) << address << 0 << 0;
+ QTest::newRow(QString("%1 2 again").arg(address.toString()).toAscii()) << address << 2 << 1;
+ QTest::newRow(QString("%1 0 last time").arg(address.toString()).toAscii()) << address << 0 << 0;
+ QTest::newRow(QString("%1 1 again").arg(address.toString()).toAscii()) << address << 1 << 1;
+ }
+}
+
+void tst_QUdpSocket::multicastLoopbackOption()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ QFETCH(QHostAddress, bindAddress);
+ QFETCH(int, loopback);
+ QFETCH(int, expected);
+ if (setProxy) {
+ // UDP multicast does not work with proxies
+ expected = 0;
+ }
+
+ QUdpSocket udpSocket;
+ // bind, but ignore the result, we are only interested in initializing the socket
+ (void) udpSocket.bind(bindAddress, 0);
+ udpSocket.setSocketOption(QUdpSocket::MulticastLoopbackOption, loopback);
+ QCOMPARE(udpSocket.socketOption(QUdpSocket::MulticastLoopbackOption).toInt(), expected);
+}
+
+void tst_QUdpSocket::multicastJoinBeforeBind_data()
+{
+ QTest::addColumn<QHostAddress>("groupAddress");
+ QTest::newRow("valid ipv4 group address") << QHostAddress("239.255.118.62");
+ QTest::newRow("invalid ipv4 group address") << QHostAddress(QHostAddress::Broadcast);
+ QTest::newRow("valid ipv6 group address") << QHostAddress("FF01::114");
+ QTest::newRow("invalid ipv6 group address") << QHostAddress(QHostAddress::AnyIPv6);
+}
+
+void tst_QUdpSocket::multicastJoinBeforeBind()
+{
+ QFETCH(QHostAddress, groupAddress);
+
+ QUdpSocket udpSocket;
+ // cannot join group before binding
+ QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::joinMulticastGroup() called on a QUdpSocket when not in QUdpSocket::BoundState");
+ QVERIFY(!udpSocket.joinMulticastGroup(groupAddress));
+}
+
+void tst_QUdpSocket::multicastLeaveAfterClose_data()
+{
+ QTest::addColumn<QHostAddress>("groupAddress");
+ QTest::newRow("valid ipv4 group address") << QHostAddress("239.255.118.62");
+ QTest::newRow("valid ipv6 group address") << QHostAddress("FF01::114");
+}
+
+void tst_QUdpSocket::multicastLeaveAfterClose()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ QFETCH(QHostAddress, groupAddress);
+ if (setProxy) {
+ QSKIP("UDP Multicast does not work with proxies", SkipAll);
+ }
+
+ QUdpSocket udpSocket;
+ QVERIFY2(udpSocket.bind(groupAddress, 0),
+ qPrintable(udpSocket.errorString()));
+ QVERIFY2(udpSocket.joinMulticastGroup(groupAddress),
+ qPrintable(udpSocket.errorString()));
+ udpSocket.close();
+ QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::leaveMulticastGroup() called on a QUdpSocket when not in QUdpSocket::BoundState");
+ QVERIFY(!udpSocket.leaveMulticastGroup(groupAddress));
+}
+
+void tst_QUdpSocket::setMulticastInterface_data()
+{
+ QTest::addColumn<QNetworkInterface>("iface");
+ QTest::addColumn<QHostAddress>("address");
+ QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
+ foreach (const QNetworkInterface &iface, interfaces) {
+ foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) {
+ QTest::newRow(QString("%1:%2").arg(iface.name()).arg(entry.ip().toString()).toAscii())
+ << iface
+ << entry.ip();
+ }
+ }
+}
+
+void tst_QUdpSocket::setMulticastInterface()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ QFETCH(QNetworkInterface, iface);
+ QFETCH(QHostAddress, address);
+
+ QUdpSocket udpSocket;
+ // bind initializes the socket
+ bool bound = udpSocket.bind((address.protocol() == QAbstractSocket::IPv6Protocol
+ ? QHostAddress(QHostAddress::AnyIPv6)
+ : QHostAddress(QHostAddress::Any)),
+ 0);
+ if (!bound)
+ QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::setMulticastInterface() called on a QUdpSocket when not in QUdpSocket::BoundState");
+ udpSocket.setMulticastInterface(iface);
+ if (!bound)
+ QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::multicastInterface() called on a QUdpSocket when not in QUdpSocket::BoundState");
+ QNetworkInterface iface2 = udpSocket.multicastInterface();
+ if (!setProxy) {
+ QVERIFY(iface2.isValid());
+ QCOMPARE(iface.name(), iface2.name());
+ } else {
+ QVERIFY(!iface2.isValid());
+ }
+}
+
+void tst_QUdpSocket::multicast_data()
+{
+ QHostAddress anyAddress = QHostAddress(QHostAddress::Any);
+ QHostAddress groupAddress = QHostAddress("239.255.118.62");
+ QHostAddress any6Address = QHostAddress(QHostAddress::AnyIPv6);
+ QHostAddress group6Address = QHostAddress("FF01::114");
+
+ QTest::addColumn<QHostAddress>("bindAddress");
+ QTest::addColumn<bool>("bindResult");
+ QTest::addColumn<QHostAddress>("groupAddress");
+ QTest::addColumn<bool>("joinResult");
+ QTest::newRow("valid bind, group ipv4 address") << anyAddress << true << groupAddress << true;
+ QTest::newRow("valid bind, invalid group ipv4 address") << anyAddress << true << anyAddress << false;
+ QTest::newRow("same bind, group ipv4 address") << groupAddress << true << groupAddress << true;
+ QTest::newRow("valid bind, group ipv6 address") << any6Address << true << group6Address << true;
+ QTest::newRow("valid bind, invalid group ipv6 address") << any6Address << true << any6Address << false;
+ QTest::newRow("same bind, group ipv6 address") << group6Address << true << group6Address << true;
+}
+
+void tst_QUdpSocket::multicast()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ QFETCH(QHostAddress, bindAddress);
+ QFETCH(bool, bindResult);
+ QFETCH(QHostAddress, groupAddress);
+ QFETCH(bool, joinResult);
+ if (setProxy) {
+ // UDP multicast does not work with proxies
+ if ((bindAddress.protocol() == QAbstractSocket::IPv4Protocol && (bindAddress.toIPv4Address() & 0xffff0000) == 0xefff0000)
+ || bindAddress.protocol() == QAbstractSocket::IPv6Protocol) {
+ // proxy cannot bind to IPv6 or multicast addresses
+ bindResult = false;
+ }
+ joinResult = false;
+ }
+
+ QUdpSocket receiver;
+
+ // bind first, then verify that we can join the multicast group
+ QVERIFY2(receiver.bind(bindAddress, 0) == bindResult,
+ qPrintable(receiver.errorString()));
+ if (!bindResult)
+ return;
+
+ QVERIFY2(receiver.joinMulticastGroup(groupAddress) == joinResult,
+ qPrintable(receiver.errorString()));
+ if (!joinResult)
+ return;
+
+ QList<QByteArray> datagrams = QList<QByteArray>()
+ << QByteArray("0123")
+ << QByteArray("4567")
+ << QByteArray("89ab")
+ << QByteArray("cdef");
+
+ QUdpSocket sender;
+ foreach (const QByteArray &datagram, datagrams) {
+ QCOMPARE(int(sender.writeDatagram(datagram, groupAddress, receiver.localPort())),
+ int(datagram.size()));
+ }
+
+ QVERIFY2(receiver.waitForReadyRead(),
+ qPrintable(receiver.errorString()));
+ QVERIFY(receiver.hasPendingDatagrams());
+ QList<QByteArray> receivedDatagrams;
+ while (receiver.hasPendingDatagrams()) {
+ QByteArray datagram;
+ datagram.resize(receiver.pendingDatagramSize());
+ receiver.readDatagram(datagram.data(), datagram.size(), 0, 0);
+ receivedDatagrams << datagram;
+ }
+ QCOMPARE(receivedDatagrams, datagrams);
+
+ QVERIFY2(receiver.leaveMulticastGroup(groupAddress), qPrintable(receiver.errorString()));
+}
+
QTEST_MAIN(tst_QUdpSocket)
#include "tst_qudpsocket.moc"
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index b2b28bd..eff4658 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -196,6 +196,7 @@ private slots:
void task_199967();
void task_240612();
void taskQTBUG_6962();
+ void taskQTBUG_8701();
#ifdef QT3_SUPPORT
void dirPath();
@@ -2276,7 +2277,9 @@ void tst_QUrl::ipv6()
QCOMPARE(url.isValid(), isValid);
if (url.isValid()) {
- QCOMPARE(url.toString(), ipv6Auth);
+ QCOMPARE(url.toString(), ipv6Auth);
+ url.setHost(url.host());
+ QCOMPARE(url.toString(), ipv6Auth);
}
};
@@ -2300,6 +2303,8 @@ void tst_QUrl::ipv6_2()
QUrl url(input);
QCOMPARE(url.toString(), output);
+ url.setHost(url.host());
+ QCOMPARE(url.toString(), output);
}
void tst_QUrl::moreIpv6()
@@ -2484,16 +2489,26 @@ void tst_QUrl::isValid()
QUrl url = QUrl::fromEncoded("http://strange;hostname/here");
QVERIFY(!url.isValid());
QCOMPARE(url.path(), QString("/here"));
+ url.setAuthority("strange;hostname");
+ QVERIFY(!url.isValid());
url.setAuthority("foobar@bar");
QVERIFY(url.isValid());
+ url.setAuthority("strange;hostname");
+ QVERIFY(!url.isValid());
+ QVERIFY(url.errorString().contains("invalid hostname"));
}
{
QUrl url = QUrl::fromEncoded("foo://stuff;1/g");
QVERIFY(!url.isValid());
QCOMPARE(url.path(), QString("/g"));
+ url.setHost("stuff;1");
+ QVERIFY(!url.isValid());
url.setHost("stuff-1");
QVERIFY(url.isValid());
+ url.setHost("stuff;1");
+ QVERIFY(!url.isValid());
+ QVERIFY(url.errorString().contains("invalid hostname"));
}
}
@@ -3961,5 +3976,17 @@ void tst_QUrl::taskQTBUG_6962()
QCOMPARE(url.authority(), QString());
}
+void tst_QUrl::taskQTBUG_8701()
+{
+ //bug 8701: foo:///bar mangled to foo:/bar
+ QString foo_triple_bar("foo:///bar"), foo_uni_bar("foo:/bar");
+
+ QCOMPARE(foo_triple_bar, QUrl(foo_triple_bar).toString());
+ QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar).toString());
+
+ QCOMPARE(foo_triple_bar, QUrl(foo_triple_bar, QUrl::StrictMode).toString()); // fails
+ QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar, QUrl::StrictMode).toString());
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"
diff --git a/tests/auto/qvector/tst_qvector.cpp b/tests/auto/qvector/tst_qvector.cpp
index 2bc8d15..a04ce60 100644
--- a/tests/auto/qvector/tst_qvector.cpp
+++ b/tests/auto/qvector/tst_qvector.cpp
@@ -88,6 +88,7 @@ private slots:
void outOfMemory();
void QTBUG6416_reserve();
+ void initializeList();
};
void tst_QVector::constructors() const
@@ -834,5 +835,19 @@ void tst_QVector::QTBUG6416_reserve()
QCOMPARE(fooCtor, fooDtor);
}
+void tst_QVector::initializeList()
+{
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ QVector<int> v1{2,3,4};
+ QCOMPARE(v1, QVector<int>() << 2 << 3 << 4);
+ QCOMPARE(v1, (QVector<int>{2,3,4}));
+
+ QVector<QVector<int>> v2{ v1, {1}, QVector<int>(), {2,3,4} };
+ QVector<QVector<int>> v3;
+ v3 << v1 << (QVector<int>() << 1) << QVector<int>() << v1;
+ QCOMPARE(v3, v2);
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_QVector)
#include "tst_qvector.moc"
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 2413888..902c8ff 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -402,6 +402,8 @@ private slots:
#endif // QT_MAC_USE_COCOA
#endif
+ void nativeChildFocus();
+
private:
bool ensureScreenSize(int width, int height);
QWidget *testWidget;
@@ -9716,7 +9718,6 @@ void tst_QWidget::destroyBackingStoreWhenHidden()
QVERIFY(0 != backingStore(child));
// Parent is obscured, therefore its backing store should be destroyed
- QEXPECT_FAIL("", "QTBUG-12406", Continue);
QVERIFY(0 == backingStore(parent));
// Disable full screen
@@ -9732,6 +9733,80 @@ void tst_QWidget::destroyBackingStoreWhenHidden()
QVERIFY(0 != backingStore(parent));
QVERIFY(0 == backingStore(child));
}
+
+ // 6. Partial reveal followed by full reveal
+ {
+ QWidget upper;
+ upper.setAutoFillBackground(true);
+ upper.setPalette(Qt::red);
+ upper.setGeometry(50, 50, 100, 100);
+
+ QWidget lower;
+ lower.setAutoFillBackground(true);
+ lower.setPalette(Qt::green);
+ lower.setGeometry(50, 50, 100, 100);
+
+ lower.show();
+ QTest::qWaitForWindowShown(&lower);
+ upper.show();
+ QTest::qWaitForWindowShown(&upper);
+ upper.raise();
+
+ QVERIFY(0 != backingStore(upper));
+ QVERIFY(0 == backingStore(lower));
+
+ // Check that upper obscures lower
+ QVERIFY(lower.visibleRegion().subtracted(upper.visibleRegion()).isEmpty());
+
+ // Partially reveal lower
+ upper.move(100, 100);
+
+ // Completely reveal lower
+ upper.hide();
+
+ // Hide lower widget - this should cause its backing store to be deleted
+ lower.hide();
+
+ // Check that backing store was deleted
+ WAIT_AND_VERIFY(0 == backingStore(lower));
+ }
+
+ // 7. Reparenting of visible native child widget
+ {
+ QWidget parent1;
+ parent1.setAutoFillBackground(true);
+ parent1.setPalette(Qt::green);
+ parent1.setGeometry(50, 50, 100, 100);
+
+ QWidget *child = new QWidget(&parent1);
+ child->winId();
+ child->setAutoFillBackground(true);
+ child->setPalette(Qt::red);
+ child->setGeometry(10, 10, 30, 30);
+
+ QWidget parent2;
+ parent2.setAutoFillBackground(true);
+ parent2.setPalette(Qt::blue);
+ parent2.setGeometry(150, 150, 100, 100);
+
+ parent1.show();
+ QTest::qWaitForWindowShown(&parent1);
+ QVERIFY(0 != backingStore(parent1));
+
+ parent2.show();
+ QTest::qWaitForWindowShown(&parent2);
+ QVERIFY(0 != backingStore(parent2));
+
+ child->setParent(&parent2);
+ child->setGeometry(10, 10, 30, 30);
+ child->show();
+
+ parent1.hide();
+ WAIT_AND_VERIFY(0 == backingStore(parent1));
+
+ parent2.hide();
+ WAIT_AND_VERIFY(0 == backingStore(parent2));
+ }
}
#undef WAIT_AND_VERIFY
@@ -10432,5 +10507,28 @@ void tst_QWidget::taskQTBUG_11373()
#endif // QT_MAC_USE_COCOA
#endif
+void tst_QWidget::nativeChildFocus()
+{
+ QWidget w;
+ QLayout *layout = new QVBoxLayout;
+ w.setLayout(layout);
+ QLineEdit *p1 = new QLineEdit;
+ QLineEdit *p2 = new QLineEdit;
+ layout->addWidget(p1);
+ layout->addWidget(p2);
+ p1->setObjectName("p1");
+ p2->setObjectName("p2");
+ w.show();
+ w.activateWindow();
+ p1->setFocus();
+ p1->setAttribute(Qt::WA_NativeWindow);
+ p2->setAttribute(Qt::WA_NativeWindow);
+ QApplication::processEvents();
+ QTest::qWaitForWindowShown(&w);
+
+ QCOMPARE(QApplication::activeWindow(), &w);
+ QCOMPARE(QApplication::focusWidget(), p1);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/uic/baseline/icontheme.ui b/tests/auto/uic/baseline/icontheme.ui
new file mode 100644
index 0000000..a214635
--- /dev/null
+++ b/tests/auto/uic/baseline/icontheme.ui
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>122</width>
+ <height>117</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="fileicon">
+ <property name="text">
+ <string>fileicon</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>image1.png</normaloff>image1.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="fileandthemeicon">
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ <property name="icon">
+ <iconset theme="edit-copy">
+ <normaloff>image7.png</normaloff>image7.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="themeicon">
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ <property name="icon">
+ <iconset theme="edit-copy">
+ <normaloff/>
+ </iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/uic/baseline/icontheme.ui.h b/tests/auto/uic/baseline/icontheme.ui.h
new file mode 100644
index 0000000..946fff9
--- /dev/null
+++ b/tests/auto/uic/baseline/icontheme.ui.h
@@ -0,0 +1,95 @@
+/********************************************************************************
+** Form generated from reading UI file 'icontheme.ui'
+**
+** Created: Thu Sep 2 10:28:19 2010
+** by: Qt User Interface Compiler version 4.8.0
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef ICONTHEME_H
+#define ICONTHEME_H
+
+#include <QtCore/QVariant>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QButtonGroup>
+#include <QtGui/QHeaderView>
+#include <QtGui/QPushButton>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QWidget>
+
+QT_BEGIN_NAMESPACE
+
+class Ui_Form
+{
+public:
+ QVBoxLayout *verticalLayout;
+ QPushButton *fileicon;
+ QPushButton *fileandthemeicon;
+ QPushButton *themeicon;
+
+ void setupUi(QWidget *Form)
+ {
+ if (Form->objectName().isEmpty())
+ Form->setObjectName(QString::fromUtf8("Form"));
+ Form->resize(122, 117);
+ verticalLayout = new QVBoxLayout(Form);
+ verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
+ fileicon = new QPushButton(Form);
+ fileicon->setObjectName(QString::fromUtf8("fileicon"));
+ QIcon icon;
+ icon.addFile(QString::fromUtf8("image1.png"), QSize(), QIcon::Normal, QIcon::Off);
+ fileicon->setIcon(icon);
+
+ verticalLayout->addWidget(fileicon);
+
+ fileandthemeicon = new QPushButton(Form);
+ fileandthemeicon->setObjectName(QString::fromUtf8("fileandthemeicon"));
+ QIcon icon1;
+ QString iconThemeName = QString::fromUtf8("edit-copy");
+ if (QIcon::hasThemeIcon(iconThemeName)) {
+ icon1 = QIcon::fromTheme(iconThemeName);
+ } else {
+ icon1.addFile(QString::fromUtf8("image7.png"), QSize(), QIcon::Normal, QIcon::Off);
+ }
+ fileandthemeicon->setIcon(icon1);
+
+ verticalLayout->addWidget(fileandthemeicon);
+
+ themeicon = new QPushButton(Form);
+ themeicon->setObjectName(QString::fromUtf8("themeicon"));
+ QIcon icon2;
+ iconThemeName = QString::fromUtf8("edit-copy");
+ if (QIcon::hasThemeIcon(iconThemeName)) {
+ icon2 = QIcon::fromTheme(iconThemeName);
+ } else {
+ icon2.addFile(QString::fromUtf8(""), QSize(), QIcon::Normal, QIcon::Off);
+ }
+ themeicon->setIcon(icon2);
+
+ verticalLayout->addWidget(themeicon);
+
+
+ retranslateUi(Form);
+
+ QMetaObject::connectSlotsByName(Form);
+ } // setupUi
+
+ void retranslateUi(QWidget *Form)
+ {
+ Form->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8));
+ fileicon->setText(QApplication::translate("Form", "fileicon", 0, QApplication::UnicodeUTF8));
+ fileandthemeicon->setText(QApplication::translate("Form", "PushButton", 0, QApplication::UnicodeUTF8));
+ themeicon->setText(QApplication::translate("Form", "PushButton", 0, QApplication::UnicodeUTF8));
+ } // retranslateUi
+
+};
+
+namespace Ui {
+ class Form: public Ui_Form {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // ICONTHEME_H